Annotation of loncom/interface/londocs.pm, revision 1.535
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.535 ! raeburn 4: # $Id: londocs.pm,v 1.534 2013/03/11 22:16:11 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.329 droeschl 44: use HTML::Entities;
1.488 raeburn 45: use HTML::TokeParser;
1.329 droeschl 46: use GDBM_File;
47: use Apache::lonlocal;
48: use Cwd;
49: use LONCAPA qw(:DEFAULT :match);
50:
51: my $iconpath;
52:
53: my %hash;
54:
55: my $hashtied;
56: my %alreadyseen=();
57:
58: my $hadchanges;
59:
60:
61: my %help=();
62:
63:
64: sub mapread {
65: my ($coursenum,$coursedom,$map)=@_;
66: return
67: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
68: $map);
69: }
70:
71: sub storemap {
1.492 raeburn 72: my ($coursenum,$coursedom,$map,$contentchg)=@_;
73: my $report;
74: if (($contentchg) && ($map =~ /^default/)) {
75: $report = 1;
76: }
1.329 droeschl 77: my ($outtext,$errtext)=
78: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
1.492 raeburn 79: $map,1,$report);
1.329 droeschl 80: if ($errtext) { return ($errtext,2); }
1.364 bisitz 81:
1.329 droeschl 82: $hadchanges=1;
83: return ($errtext,0);
84: }
85:
86:
87:
88: sub authorhosts {
89: my %outhash=();
90: my $home=0;
91: my $other=0;
92: foreach my $key (keys(%env)) {
93: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
94: my $role=$1;
95: my $realm=$2;
96: my ($start,$end)=split(/\./,$env{$key});
97: if (($start) && ($start>time)) { next; }
98: if (($end) && (time>$end)) { next; }
99: my ($ca,$cd);
100: if ($1 eq 'au') {
101: $ca=$env{'user.name'};
102: $cd=$env{'user.domain'};
103: } else {
104: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
105: }
106: my $allowed=0;
107: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
108: my @ids=&Apache::lonnet::current_machine_ids();
1.484 raeburn 109: foreach my $id (@ids) {
110: if ($id eq $myhome) {
111: $allowed=1;
112: last;
113: }
114: }
1.329 droeschl 115: if ($allowed) {
116: $home++;
1.484 raeburn 117: $outhash{'home_'.$ca.':'.$cd}=1;
1.329 droeschl 118: } else {
1.484 raeburn 119: $outhash{'otherhome_'.$ca.':'.$cd}=$myhome;
1.329 droeschl 120: $other++;
121: }
122: }
123: }
124: return ($home,$other,%outhash);
125: }
126:
127:
128: sub clean {
129: my ($title)=@_;
130: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 131: return $title;
1.329 droeschl 132: }
133:
134:
135:
136: sub dumpcourse {
137: my ($r) = @_;
1.408 raeburn 138: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 139: $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Content to Authoring Space')."\n".
140: &Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Content to Authoring Space')."\n");
141: $r->print(&startContentScreen('tools'));
1.329 droeschl 142: my ($home,$other,%outhash)=&authorhosts();
1.484 raeburn 143: unless ($home) {
144: $r->print(&endContentScreen());
145: return '';
146: }
1.329 droeschl 147: my $origcrsid=$env{'request.course.id'};
148: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
149: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
150: # Do the dumping
1.484 raeburn 151: unless ($outhash{'home_'.$env{'form.authorspace'}}) {
152: $r->print(&endContentScreen());
153: return '';
154: }
1.531 raeburn 155: my ($ca,$cd)=split(/\:/,$env{'form.authorspace'});
1.329 droeschl 156: $r->print('<h3>'.&mt('Copying Files').'</h3>');
157: my $title=$env{'form.authorfolder'};
158: $title=&clean($title);
159: my %replacehash=();
160: foreach my $key (keys(%env)) {
161: if ($key=~/^form\.namefor\_(.+)/) {
162: $replacehash{$1}=$env{$key};
163: }
164: }
165: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
166: $crs=~s/\_/\//g;
167: foreach my $item (keys(%replacehash)) {
168: my $newfilename=$title.'/'.$replacehash{$item};
169: $newfilename=~s/\.(\w+)$//;
170: my $ext=$1;
171: $newfilename=&clean($newfilename);
172: $newfilename.='.'.$ext;
173: my @dirs=split(/\//,$newfilename);
1.462 raeburn 174: my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
1.329 droeschl 175: my $makepath=$path;
176: my $fail=0;
177: for (my $i=0;$i<$#dirs;$i++) {
178: $makepath.='/'.$dirs[$i];
1.344 bisitz 179: unless (-e $makepath) {
180: unless(mkdir($makepath,0777)) { $fail=1; }
1.329 droeschl 181: }
182: }
183: $r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
184: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
185: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
186: print $fh &Apache::lonclonecourse::rewritefile(
187: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
188: (%replacehash,$crs => '')
189: );
190: } else {
191: print $fh
192: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
193: }
194: $fh->close();
195: } else {
196: $fail=1;
197: }
198: if ($fail) {
199: $r->print('<span class="LC_error">'.&mt('fail').'</span>');
200: } else {
201: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
202: }
203: }
204: } else {
1.484 raeburn 205: $r->print(&mt('Searching ...').'<br />');
206: $r->rflush();
1.329 droeschl 207: # Input form
1.484 raeburn 208: $r->print('<form name="dumpdoc" action="" method="post">'."\n");
1.329 droeschl 209: unless ($home==1) {
1.484 raeburn 210: $r->print('<div class="LC_left_float">'.
211: '<fieldset><legend>'.
212: &mt('Select the Authoring Space').
213: '</legend><select name="authorspace">');
1.329 droeschl 214: }
215: foreach my $key (sort(keys(%outhash))) {
216: if ($key=~/^home_(.+)$/) {
217: if ($home==1) {
218: $r->print(
219: '<input type="hidden" name="authorspace" value="'.$1.'" />');
220: } else {
221: $r->print('<option value="'.$1.'">'.$1.' - '.
1.484 raeburn 222: &Apache::loncommon::plainname(split(/\:/,$1)).'</option>');
1.329 droeschl 223: }
224: }
225: }
226: unless ($home==1) {
1.484 raeburn 227: $r->print('</select></fieldset></div>'."\n");
1.329 droeschl 228: }
229: my $title=$origcrsdata{'description'};
230: $title=~s/[\/\s]+/\_/gs;
231: $title=&clean($title);
1.484 raeburn 232: $r->print('<div class="LC_left_float">'.
233: '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
234: '<input type="text" size="50" name="authorfolder" value="'.
235: $title.'" />'.
236: '</fieldset></div><br clear="all" />'."\n");
1.329 droeschl 237: &tiehash();
1.484 raeburn 238: $r->print('<h4>'.&mt('Filenames in Authoring Space').'</h4>'
1.329 droeschl 239: .&Apache::loncommon::start_data_table()
240: .&Apache::loncommon::start_data_table_header_row()
241: .'<th>'.&mt('Internal Filename').'</th>'
242: .'<th>'.&mt('Title').'</th>'
243: .'<th>'.&mt('Save as ...').'</th>'
244: .&Apache::loncommon::end_data_table_header_row());
245: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
246: $r->print(&Apache::loncommon::start_data_table_row()
247: .'<td>'.$file.'</td>');
248: my ($ext)=($file=~/\.(\w+)$/);
249: my $title=$hash{'title_'.$hash{
250: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
251: $r->print('<td>'.($title?$title:' ').'</td>');
252: if (!$title) {
253: $title=$file;
254: } else {
255: $title=~s|/|_|g;
256: }
257: $title=~s/\.(\w+)$//;
258: $title=&clean($title);
259: $title.='.'.$ext;
260: $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
261: .&Apache::loncommon::end_data_table_row());
262: }
263: $r->print(&Apache::loncommon::end_data_table());
264: &untiehash();
265: $r->print(
1.484 raeburn 266: '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype Content").'" /></p></form>');
1.329 droeschl 267: }
1.484 raeburn 268: $r->print(&endContentScreen());
1.329 droeschl 269: }
270:
271: sub group_import {
272: my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
1.529 raeburn 273: my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
274: %removeparam,$importuploaded,$fixuperrors);
275: $allmaps = {};
1.329 droeschl 276: while (@files) {
277: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 278: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 279: && ($caller eq 'londocs')
280: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 281:
1.329 droeschl 282: my $errtext = '';
283: my $fatal = 0;
284: my $newmapstr = '<map>'."\n".
285: '<resource id="1" src="" type="start"></resource>'."\n".
286: '<link from="1" to="2" index="1"></link>'."\n".
287: '<resource id="2" src="" type="finish"></resource>'."\n".
288: '</map>';
289: $env{'form.output'}=$newmapstr;
290: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
291: 'output',$1.$2);
1.534 raeburn 292: if ($result !~ m{^/uploaded/}) {
1.329 droeschl 293: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
294: $fatal = 2;
295: }
296: if ($fatal) {
297: return ($errtext,$fatal);
298: }
299: }
300: if ($url) {
1.529 raeburn 301: if (($caller eq 'londocs') &&
302: ($folder =~ /^default/)) {
1.534 raeburn 303: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.529 raeburn 304: my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
305: my $cid = $coursedom.'_'.$coursenum;
306: $allmaps =
307: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
308: $chome,$cid);
309: $donechk = 1;
310: }
311: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) {
312: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
313: \%addedmaps,\%hierarchy,\%titles,$allmaps);
314: $importuploaded = 1;
315: } elsif ($url =~ m{^/res/.+\.(page|sequence)$}) {
316: next if ($allmaps->{$url});
317: }
318: }
1.344 bisitz 319: if (!$residx
1.329 droeschl 320: || defined($LONCAPA::map::zombies[$residx])) {
321: $residx = &LONCAPA::map::getresidx($url,$residx);
322: push(@LONCAPA::map::order, $residx);
323: }
324: my $ext = 'false';
325: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
326: $url = &LONCAPA::map::qtunescape($url);
327: $name = &LONCAPA::map::qtunescape($name);
1.534 raeburn 328: if ($name eq '') {
329: $name = &mt('Web Page');
330: }
331: if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
332: my $filepath = $1;
333: my $fname = $name;
334: if ($fname =~ /^\W+$/) {
335: $fname = 'web';
336: } else {
337: $fname =~ s/\W/_/g;
338: }
339: if (length($fname > 15)) {
340: $fname = substr($fname,0,14);
341: }
342: my $initialtext = &mt('Replace with your own content.');
343: my $newhtml = <<END;
344: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
345: <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
346: <head>
347: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
348: <title>$name</title>
349: </head>
350: <body bgcolor="#ffffff">
351: $initialtext
352: </body>
353: </html>
354: END
355: $env{'form.output'}=$newhtml;
356: my $result =
357: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
358: 'output',
359: "$filepath/$residx/$fname.html");
360: if ($result =~ m{^/uploaded/}) {
361: $url = $result;
362: if ($filepath =~ /^supplemental/) {
363: $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
364: $env{'user.domain'}.'___&&&___'.$name;
365: }
366: } else {
367: return (&mt('Failed to save new web page.'),1);
368: }
369: }
1.344 bisitz 370: $LONCAPA::map::resources[$residx] =
1.329 droeschl 371: join(':', ($name, $url, $ext, 'normal', 'res'));
372: }
373: }
1.529 raeburn 374: if ($importuploaded) {
375: my %import_errors;
376: my %updated = (
377: removefrommap => \%removefrommap,
378: removeparam => \%removeparam,
379: );
1.533 raeburn 380: my ($result,$msgsarray,$lockerror) =
381: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.529 raeburn 382: if (keys(%import_errors) > 0) {
1.530 raeburn 383: $fixuperrors =
1.529 raeburn 384: '<p span class="LC_warning">'."\n".
385: &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".
386: '<ul>'."\n";
387: foreach my $key (sort(keys(%import_errors))) {
388: $fixuperrors .= '<li>'.$key.'</li>'."\n";
389: }
390: $fixuperrors .= '</ul></p>'."\n";
391: }
1.533 raeburn 392: if (ref($msgsarray) eq 'ARRAY') {
393: if (@{$msgsarray} > 0) {
394: $fixuperrors .= '<p class="LC_info">'.
395: join('<br />',@{$msgsarray}).
396: '</p>';
397: }
398: }
399: if ($lockerror) {
400: $fixuperrors .= '<p class="LC_error">'.
401: $lockerror.
402: '</p>';
403: }
1.529 raeburn 404: }
405: my ($errtext,$fatal) =
406: &storemap($coursenum, $coursedom, $folder.'.'.$container,1);
407: return ($errtext,$fatal,$fixuperrors);
1.329 droeschl 408: }
409:
410: sub log_docs {
1.494 raeburn 411: return &Apache::lonnet::write_log('course','docslog',@_);
1.329 droeschl 412: }
413:
414: {
415: my @oldresources=();
416: my @oldorder=();
417: my $parmidx;
418: my %parmaction=();
419: my %parmvalue=();
420: my $changedflag;
421:
422: sub snapshotbefore {
423: @oldresources=@LONCAPA::map::resources;
424: @oldorder=@LONCAPA::map::order;
425: $parmidx=undef;
426: %parmaction=();
427: %parmvalue=();
428: $changedflag=0;
429: }
430:
431: sub remember_parms {
432: my ($idx,$parameter,$action,$value)=@_;
433: $parmidx=$idx;
434: $parmaction{$parameter}=$action;
435: $parmvalue{$parameter}=$value;
436: $changedflag=1;
437: }
438:
439: sub log_differences {
440: my ($plain)=@_;
441: my %storehash=('folder' => $plain,
442: 'currentfolder' => $env{'form.folder'});
443: if ($parmidx) {
444: $storehash{'parameter_res'}=$oldresources[$parmidx];
445: foreach my $parm (keys(%parmaction)) {
446: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
447: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
448: }
449: }
450: my $maxidx=$#oldresources;
451: if ($#LONCAPA::map::resources>$#oldresources) {
452: $maxidx=$#LONCAPA::map::resources;
453: }
454: for (my $idx=0; $idx<=$maxidx; $idx++) {
455: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
456: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
457: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
458: $changedflag=1;
459: }
460: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
461: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
462: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
463: $changedflag=1;
464: }
465: }
466: $storehash{'maxidx'}=$maxidx;
467: if ($changedflag) { &log_docs(\%storehash); }
468: }
469: }
470:
471: sub docs_change_log {
1.484 raeburn 472: my ($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath)=@_;
1.486 raeburn 473: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.483 raeburn 474: my $js = '<script type="text/javascript">'."\n".
475: '// <![CDATA['."\n".
476: &Apache::loncommon::display_filter_js('docslog')."\n".
1.486 raeburn 477: &editing_js($env{'user.domain'},$env{'user.name'},$supplementalflag)."\n".
1.483 raeburn 478: &history_tab_js()."\n".
1.484 raeburn 479: &Apache::lonratedt::editscript('simple')."\n".
1.483 raeburn 480: '// ]]>'."\n".
481: '</script>'."\n";
1.484 raeburn 482: $r->print(&Apache::loncommon::start_page('Content Change Log',$js));
483: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Change Log'));
1.489 raeburn 484: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 485: my %orderhash;
486: my $container='sequence';
487: my $pathitem;
1.519 raeburn 488: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 489: $container='page';
490: }
1.519 raeburn 491: my $folderpath=$env{'form.folderpath'};
492: if ($folderpath eq '') {
493: $folderpath = 'default&'.&escape(&mt('Main '.$crstype.' Documents').':::::');
494: }
495: $pathitem = '<input type="hidden" name="folderpath" value="'.
496: &HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 497: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
498: my $jumpto = $readfile;
499: $jumpto =~ s{^/}{};
500: my $tid = 1;
1.489 raeburn 501: if ($supplementalflag) {
502: $tid = 2;
503: }
1.509 raeburn 504: my ($breadcrumbtrail) =
505: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1.484 raeburn 506: $r->print($breadcrumbtrail.
507: &generate_edit_table($tid,\%orderhash,undef,$iconpath,$jumpto,
508: $readfile));
1.329 droeschl 509: my %docslog=&Apache::lonnet::dump('nohist_docslog',
510: $env{'course.'.$env{'request.course.id'}.'.domain'},
511: $env{'course.'.$env{'request.course.id'}.'.num'});
512:
513: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
514:
515: my %saveable_parameters = ('show' => 'scalar',);
516: &Apache::loncommon::store_course_settings('docs_log',
517: \%saveable_parameters);
518: &Apache::loncommon::restore_course_settings('docs_log',
519: \%saveable_parameters);
520: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1.452 www 521: # FIXME: internationalization seems wrong here
1.329 droeschl 522: my %lt=('hiddenresource' => 'Resources hidden',
523: 'encrypturl' => 'URL hidden',
524: 'randompick' => 'Randomly pick',
525: 'randomorder' => 'Randomly ordered',
526: 'set' => 'set to',
527: 'del' => 'deleted');
1.484 raeburn 528: my $filter = &Apache::loncommon::display_filter('docslog')."\n".
529: $pathitem."\n".
530: '<input type="hidden" name="folder" value="'.$env{'form.folder'}.'" />'.
531: (' 'x2).'<input type="submit" value="'.&mt('Display').'" />';
532: $r->print('<div class="LC_left_float">'.
533: '<fieldset><legend>'.&mt('Display of Content Changes').'</legend>'."\n".
534: &makedocslogform($filter,1).
535: '</fieldset></div><br clear="all" />');
1.329 droeschl 536: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
537: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
538: &mt('After').'</th>'.
539: &Apache::loncommon::end_data_table_header_row());
540: my $shown=0;
541: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
542: if ($env{'form.displayfilter'} eq 'currentfolder') {
543: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
544: }
545: my @changes=keys(%{$docslog{$id}{'logentry'}});
546: if ($env{'form.displayfilter'} eq 'containing') {
547: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
548: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
549: foreach my $key (@changes) {
550: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
551: }
1.344 bisitz 552: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 553: }
554: my $count = 0;
555: my $time =
556: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
557: my $plainname =
558: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
559: $docslog{$id}{'exe_udom'});
560: my $about_me_link =
561: &Apache::loncommon::aboutmewrapper($plainname,
562: $docslog{$id}{'exe_uname'},
563: $docslog{$id}{'exe_udom'});
564: my $send_msg_link='';
565: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
566: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
567: $send_msg_link ='<br />'.
568: &Apache::loncommon::messagewrapper(&mt('Send message'),
569: $docslog{$id}{'exe_uname'},
570: $docslog{$id}{'exe_udom'});
571: }
572: $r->print(&Apache::loncommon::start_data_table_row());
573: $r->print('<td>'.$time.'</td>
574: <td>'.$about_me_link.
575: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
576: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
577: $send_msg_link.'</td><td>'.
578: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1.488 raeburn 579: my $is_supp = 0;
580: if ($docslog{$id}{'logentry'}{'currentfolder'} =~ /^supplemental/) {
581: $is_supp = 1;
582: }
1.329 droeschl 583: # Before
584: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
585: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
586: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
587: if ($oldname ne $newname) {
1.488 raeburn 588: my $shown = &LONCAPA::map::qtescape($oldname);
589: if ($is_supp) {
590: $shown = &Apache::loncommon::parse_supplemental_title($shown);
591: }
592: $r->print($shown);
1.329 droeschl 593: }
594: }
595: $r->print('<ul>');
596: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
597: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1.488 raeburn 598: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]);
599: if ($is_supp) {
600: $shown = &Apache::loncommon::parse_supplemental_title($shown);
601: }
602: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 603: }
604: }
605: $r->print('</ul>');
606: # After
607: $r->print('</td><td>');
608:
609: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
610: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
611: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
612: if ($oldname ne '' && $oldname ne $newname) {
1.488 raeburn 613: my $shown = &LONCAPA::map::qtescape($newname);
614: if ($is_supp) {
615: $shown = &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($newname));
616: }
617: $r->print($shown);
1.329 droeschl 618: }
1.364 bisitz 619: }
1.329 droeschl 620: $r->print('<ul>');
621: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
622: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1.488 raeburn 623: my $shown = &LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]);
624: if ($is_supp) {
625: $shown = &Apache::loncommon::parse_supplemental_title($shown);
626: }
627: $r->print('<li>'.$shown.'</li>');
1.329 droeschl 628: }
629: }
630: $r->print('</ul>');
631: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
632: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
633: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
634: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1.452 www 635: # FIXME: internationalization seems wrong here
1.329 droeschl 636: $r->print('<li>'.
637: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
638: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
639: .'</li>');
640: }
641: }
642: $r->print('</ul>');
643: }
644: # End
645: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
646: $shown++;
647: if (!($env{'form.show'} eq &mt('all')
648: || $shown<=$env{'form.show'})) { last; }
649: }
1.484 raeburn 650: $r->print(&Apache::loncommon::end_data_table()."\n".
651: &makesimpleeditform($pathitem)."\n".
652: '</div></div>');
653: $r->print(&endContentScreen());
1.329 droeschl 654: }
655:
656: sub update_paste_buffer {
1.492 raeburn 657: my ($coursenum,$coursedom,$folder) = @_;
1.329 droeschl 658:
659: return if (!defined($env{'form.markcopy'}));
660: return if (!defined($env{'form.copyfolder'}));
661: return if ($env{'form.markcopy'} < 0);
662:
663: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
664: $env{'form.copyfolder'});
1.364 bisitz 665:
1.329 droeschl 666: return if ($fatal);
667:
668: # Mark for copying
669: my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
670: if (&is_supplemental_title($title)) {
671: &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
1.488 raeburn 672: ($title) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 673: } elsif ($env{'docs.markedcopy_supplemental'}) {
1.346 raeburn 674: &Apache::lonnet::delenv('docs.markedcopy_supplemental');
1.329 droeschl 675: }
676: $url=~s{http(:|:)//https(:|:)//}{https$2//};
677:
1.492 raeburn 678: (my $cmd,undef)=split('_',$env{'form.cmd'});
679:
680: my %addtoenv = (
681: 'docs.markedcopy_title' => $title,
682: 'docs.markedcopy_url' => $url,
683: 'docs.markedcopy_cmd' => $cmd,
684: );
685: &Apache::lonnet::delenv('docs.markedcopy_nested');
686: &Apache::lonnet::delenv('docs.markedcopy_nestednames');
687: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(default|supplemental)_?(\d*)\.(page|sequence)$}) {
688: my $prefix = $1;
689: my $subdir =$2;
690: if ($subdir eq '') {
691: $subdir = $prefix;
692: }
693: my (%addedmaps,%removefrommap,%removeparam,%hierarchy,%titles,%allmaps);
694: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,\%addedmaps,
695: \%hierarchy,\%titles,\%allmaps);
696: if (ref($hierarchy{$url}) eq 'HASH') {
697: my ($nested,$nestednames);
698: &recurse_uploaded_maps($url,$subdir,\%hierarchy,\%titles,\$nested,\$nestednames);
699: $nested =~ s/\&$//;
700: $nestednames =~ s/\Q___&&&___\E$//;
701: if ($nested ne '') {
702: $addtoenv{'docs.markedcopy_nested'} = $nested;
703: }
704: if ($nestednames ne '') {
705: $addtoenv{'docs.markedcopy_nestednames'} = $nestednames;
706: }
707: }
708: }
709: &Apache::lonnet::appenv(\%addtoenv);
1.329 droeschl 710: delete($env{'form.markcopy'});
711: }
712:
1.492 raeburn 713: sub recurse_uploaded_maps {
714: my ($url,$dir,$hierarchy,$titlesref,$nestref,$namesref) = @_;
715: if (ref($hierarchy->{$url}) eq 'HASH') {
716: my @maps = map { $hierarchy->{$url}{$_}; } sort { $a <=> $b } (keys(%{$hierarchy->{$url}}));
717: my @titles = map { $titlesref->{$url}{$_}; } sort { $a <=> $b } (keys(%{$titlesref->{$url}}));
718: my (@uploaded,@names,%shorter);
719: for (my $i=0; $i<@maps; $i++) {
720: my ($inner) = ($maps[$i] =~ m{^/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_(\d+)\.(?:page|sequence)$});
721: if ($inner ne '') {
722: push(@uploaded,$inner);
723: push(@names,&escape($titles[$i]));
724: $shorter{$maps[$i]} = $inner;
725: }
726: }
727: $$nestref .= "$dir:".join(',',@uploaded).'&';
728: $$namesref .= "$dir:".(join(',',@names)).'___&&&___';
729: foreach my $map (@maps) {
730: if ($shorter{$map} ne '') {
731: &recurse_uploaded_maps($map,$shorter{$map},$hierarchy,$titlesref,$nestref,$namesref);
732: }
733: }
734: }
735: return;
736: }
737:
1.329 droeschl 738: sub print_paste_buffer {
1.492 raeburn 739: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.329 droeschl 740: return if (!defined($env{'docs.markedcopy_url'}));
741:
1.492 raeburn 742: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent);
1.488 raeburn 743: my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
744: if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
745: $is_external = 1;
746: }
747:
1.527 raeburn 748: my ($canpaste,$nopaste,$othercrs,$areachange);
1.488 raeburn 749: if ($folder =~ /^supplemental/) {
1.492 raeburn 750: $canpaste = &supp_pasteable($env{'docs.markedcopy_url'});
751: unless ($canpaste) {
752: $nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.');
753: }
1.488 raeburn 754: } else {
755: $canpaste = 1;
756: }
757:
758: if ($canpaste) {
1.492 raeburn 759: if ($env{'docs.markedcopy_url'} =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
760: my $srcdom = $1;
761: my $srcnum = $2;
762: my $rem = $3;
763: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
764: $othercourse = 1;
765: if ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
766: if ($canpaste) {
767: $othercrs = '<br />'.&mt('(from another course).');
768: }
769: } else {
770: $canpaste = 0;
771: $nopaste = &mt('Paste from another course unavailable.')
772: }
773: }
774: if ($rem =~ m{^(default|supplemental)_?(\d*)\.(?:page|sequence)$}) {
775: my $prefix = $1;
776: $parent = $2;
777: if ($folder !~ /^\Q$prefix\E/) {
778: $areachange = 1;
779: }
780: $is_uploaded_map = 1;
781: }
782: }
1.488 raeburn 783: }
784:
1.381 bisitz 785: $r->print('<fieldset>'
1.492 raeburn 786: .'<legend>'.&mt('Clipboard').'</legend>');
787: my ($type,$buffer);
1.488 raeburn 788: if ($is_external) {
1.492 raeburn 789: $type = &mt('External Resource');
790: $buffer = $type.': '.
791: &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
792: &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')';
1.533 raeburn 793: } else {
1.492 raeburn 794: my $icon = &Apache::loncommon::icon($extension);
795: if ($extension eq 'sequence' &&
796: $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
797: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
798: $icon .= '/navmap.folder.closed.gif';
799: }
800: $icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
801: $buffer = $icon.$type.': '. &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}));
1.329 droeschl 802: }
1.488 raeburn 803: if ($canpaste) {
1.492 raeburn 804: $r->print('<form name="pasteform" action="/adm/coursedocs" method="post">'.$buffer);
1.533 raeburn 805: if ((!$areachange) && (!$othercourse) &&
806: ($env{'docs.markedcopy_cmd'} eq 'cut')) {
807: if (($is_uploaded_map) ||
808: ($env{'docs.markedcopy_url'} =~ /(bulletinboard|smppg)$/) ||
809: ($env{'docs.markedcopy_url'} =~ m{^/uploaded/$coursedom/$coursenum/(?:docs|supplemental)/(.+)$})) {
810: my ($copytext,$movetext);
811: if ($is_uploaded_map) {
812: $copytext = &mt('Copy to new folder');
813: $movetext = &mt('Move old folder');
814: } elsif ($env{'docs.markedcopy_url'} =~ /bulletinboard$/) {
815: $copytext = &mt('Copy to new bulletin board (not posts)');
816: $movetext = &mt('Move old bulletin board (not posts)');
817: } elsif ($env{'docs.markedcopy_url'} =~ /smppg$/) {
818: $copytext = &mt('Copy to new simple page');
819: $movetext = &mt('Move old simple page');
820: } else {
821: $copytext = &mt('Copy to new uploaded document');
822: $movetext = &mt('Move old uploaded document');
823: }
1.492 raeburn 824: $r->print((' 'x 4).'<span id="pasteoptionstext">'.
825: '<a href="javascript:showPasteOptions();" class="LC_menubuttons_link">'.
826: &mt('Show Paste Options').'</a></span><br />'.
827: '<div id="pasteoptions" class="LC_dccid">'.(' 'x 4).
828: '<label>'.
829: '<input type="radio" name="docs.markedcopy_options" value="new" checked="checked" />'.
1.533 raeburn 830: $copytext.'</label>'.(' ' x2).
1.492 raeburn 831: '<label>'.
832: '<input type="radio" name="docs.markedcopy_options" value="move" />'.
1.533 raeburn 833: $movetext.'</label><br />');
834: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested'})) {
1.492 raeburn 835: $r->print('<br />'.&mt('Folder to paste contains sub-folders').
836: '<br /><table border="0">');
837: my @pastemaps = split(/\&/,$env{'docs.markedcopy_nested'});
838: my @titles = split(/\Q___&&&___\E/,$env{'docs.markedcopy_nestednames'});
839: my $lastdir = $parent;
840: my %depths = (
841: $lastdir => 0,
842: );
843: my (%display,%deps);
844: for (my $i=0; $i<@pastemaps; $i++) {
845: ($lastdir,my $subfolderstr) = split(/\:/,$pastemaps[$i]);
846: my ($namedir,$esctitlestr) = split(/\:/,$titles[$i]);
847: my @subfolders = split(/,/,$subfolderstr);
848: $deps{$lastdir} = \@subfolders;
849: my @subfoldertitles = map { &unescape($_); } split(/,/,$esctitlestr);
850: my $depth = $depths{$lastdir} + 1;
851: my $offset = int($depth * 4);
852: my $indent = (' ' x $offset);
853: for (my $j=0; $j<@subfolders; $j++) {
854: $depths{$subfolders[$j]} = $depth;
855: $display{$subfolders[$j]} =
856: '<tr><td>'.$indent.$subfoldertitles[$j].' </td>'.
857: '<td><label>'.
858: '<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="new" checked="checked" />'.&mt('Copy to new').'</label>'.(' ' x2).
859: '<label>'.
860: '<input type="radio" name="docs.markedcopy_'.$subfolders[$j].'" value="move" />'.
861: &mt('Move old').'</label>'.
862: '</td></tr>';
863: }
864: }
865: &recurse_print($r,$parent,\%deps,\%display);
866: $r->print('</table>');
867: }
868: $r->print('</div>');
869: }
870: }
871: $r->print('<br /><input type="submit" name="pastemarked" value="'.&mt('Paste').'" />'.$othercrs);
1.519 raeburn 872: $r->print('
1.329 droeschl 873: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
874: ');
1.488 raeburn 875: $r->print('</form>');
876: } else {
1.492 raeburn 877: $r->print(&mt('Paste buffer contains:').' '.$buffer.
878: '<br /><p class="LC_info">'.$nopaste.'</p>');
1.329 droeschl 879: }
1.488 raeburn 880: $r->print('</fieldset>');
881: }
882:
1.492 raeburn 883: sub recurse_print {
884: my ($r,$dir,$deps,$display) = @_;
885: $r->print($display->{$dir}."\n");
886: if (ref($deps->{$dir}) eq 'ARRAY') {
887: foreach my $subdir (@{$deps->{$dir}}) {
888: &recurse_print($r,$subdir,$deps,$display);
889: }
890: }
891: }
892:
1.488 raeburn 893: sub supp_pasteable {
894: my ($url) = @_;
895: if (($url =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//}) ||
896: (($url =~ /\.sequence$/) && ($url =~ m{^/uploaded/})) ||
897: ($url =~ m{^/uploaded/$match_domain/$match_courseid/(docs|supplemental)/(default|\d+)/\d+/}) ||
898: ($url =~ m{^/adm/$match_domain/$match_username/aboutme}) ||
899: ($url =~ m{^/public/$match_domain/$match_courseid/syllabus})) {
900: return 1;
901: }
902: return;
1.329 droeschl 903: }
904:
1.492 raeburn 905: sub paste_popup_js {
906: my %lt = &Apache::lonlocal::texthash(
907: show => 'Show Paste Options',
908: hide => 'Hide Paste Options',
909: );
910: return <<"END";
911:
912: function showPasteOptions() {
913: document.getElementById('pasteoptions').style.display='block';
914: document.getElementById('pasteoptions').style.textAlign='left';
915: document.getElementById('pasteoptions').style.textFace='normal';
916: document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:hidePasteOptions();" class="LC_menubuttons_link">$lt{'hide'}</a><br />';
917: return;
918: }
919:
920: function hidePasteOptions() {
921: document.getElementById('pasteoptions').style.display='none';
922: document.getElementById('pasteoptionstext').innerHTML ='<a href="javascript:showPasteOptions()" class="LC_menubuttons_link">$lt{'show'}</a>';
923: return;
924: }
925:
926: END
927:
928: }
929:
930:
1.329 droeschl 931: sub do_paste_from_buffer {
1.492 raeburn 932: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 933:
1.492 raeburn 934: # Early out if paste buffer is empty
1.329 droeschl 935: if (!$env{'form.pastemarked'}) {
1.492 raeburn 936: return ();
1.329 droeschl 937: }
938:
1.492 raeburn 939: # Supplemental content may only include certain types of content
940: # Early out if pasted content is not supported in Supplemental area
941: if ($folder =~ /^supplemental/) {
942: unless (&supp_pasteable($env{'docs.markedcopy_url'})) {
943: return (&mt('Paste failed: content type is not supported within Supplemental Content'));
944: }
945: }
946:
947: # Prepare to paste resource at end of list
1.491 raeburn 948: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
949: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
950:
1.492 raeburn 951: my ($is_map,$srcdom,$srcnum,$prefixchg,%before,%after,%mapchanges,%tomove);
1.491 raeburn 952: if ($url=~/\.(page|sequence)$/) {
953: $is_map = 1;
954: }
955: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/([^/]+)}) {
956: $srcdom = $1;
957: $srcnum = $2;
958: my $oldprefix = $3;
1.492 raeburn 959: # When paste buffer was populated using an active role in a different course
960: # check for mdc privilege in the course from which the resource was pasted
1.491 raeburn 961: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
962: unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
1.492 raeburn 963: return (&mt('Paste failed: Item is from a different course which you do not have rights to edit.'));
1.491 raeburn 964: }
965: }
1.492 raeburn 966: # When pasting content from Main Content to Supplemental Content and vice versa
967: # URLs will contain different paths (which depend on whether pasted item is
968: # a folder/page or a document.
1.491 raeburn 969: if (($folder =~ /^supplemental/) && (($oldprefix =~ /^default/) || ($oldprefix eq 'docs'))) {
970: $prefixchg = 1;
971: %before = ( map => 'default',
972: doc => 'docs');
973: %after = ( map => 'supplemental',
974: doc => 'supplemental' );
975: } elsif (($folder =~ /^default/) && ($oldprefix =~ /^supplemental/)) {
976: $prefixchg = 1;
977: %before = ( map => 'supplemental',
978: doc => 'supplemental');
979: %after = ( map => 'default',
980: doc => 'docs');
981: }
982:
1.492 raeburn 983: # If pasting an uploaded map, get list of contained uploaded maps.
984: my @nested;
985: if ($env{'docs.markedcopy_nested'}) {
986: my ($type) = ($oldprefix =~ /^(default|supplemental)/);
987: my @items = split(/\&/,$env{'docs.markedcopy_nested'});
988: my @deps = map { /\d+:([\d,]+$)/ } @items;
989: foreach my $dep (@deps) {
990: if ($dep =~ /,/) {
991: push(@nested,split(/,/,$dep));
992: } else {
993: push(@nested,$dep);
994: }
995: }
996: foreach my $item (@nested) {
997: if ($env{'form.docs.markedcopy_'.$item} eq 'move') {
998: $tomove{$type.'_'.$item} = 1;
999: }
1000: }
1.488 raeburn 1001: }
1002: }
1003:
1.329 droeschl 1004: # Maps need to be copied first
1.492 raeburn 1005: my ($oldurl,%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1006: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls);
1.489 raeburn 1007: $oldurl = $url;
1.491 raeburn 1008: if ($is_map) {
1009: # If pasting a map, check if map contains other maps
1.529 raeburn 1010: my ($allmaps,%hierarchy,%titles);
1011: $allmaps = {};
1.491 raeburn 1012: if ($folder =~ /^default/) {
1.529 raeburn 1013: $allmaps =
1014: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1015: $env{"course.$env{'request.course.id'}.home"},
1016: $env{'request.course.id'});
1.488 raeburn 1017: }
1.492 raeburn 1018: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
1.529 raeburn 1019: \%addedmaps,\%hierarchy,\%titles,$allmaps);
1.488 raeburn 1020: if ($url=~ m{^/uploaded/}) {
1.492 raeburn 1021: my $newurl;
1022: unless ($env{'form.docs.markedcopy_options'} eq 'move') {
1023: ($newurl,my $error) =
1024: &get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum,
1.529 raeburn 1025: $srcdom,$srcnum,\$title,$allmaps,\%newurls);
1.492 raeburn 1026: if ($error) {
1027: return ($error);
1028: }
1029: if ($newurl ne '') {
1030: if ($newurl ne $url) {
1031: if ($newurl =~ /(?:default|supplemental)_(\d+).(?:sequence|page)$/) {
1032: $newsubdir{$url} = $1;
1033: }
1034: $mapchanges{$url} = 1;
1035: }
1.491 raeburn 1036: }
1037: }
1.492 raeburn 1038: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) ||
1039: (($newurl ne '') && ($newurl ne $url))) {
1.533 raeburn 1040: unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,
1041: $coursenum,$srcdom,$srcnum,$allmaps,
1042: \%rewrites,\%retitles,\%copies,\%dbcopies,
1.492 raeburn 1043: \%zombies,\%params,\%mapmoves,\%mapchanges,\%tomove,
1044: \%newsubdir,\%newurls)) {
1045: $mapmoves{$url} = 1;
1046: }
1047: $url = $newurl;
1048: } elsif ($env{'docs.markedcopy_nested'}) {
1.533 raeburn 1049: &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,
1050: $srcdom,$srcnum,$allmaps,\%rewrites,
1.492 raeburn 1051: \%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves,
1052: \%mapchanges,\%tomove,\%newsubdir,\%newurls);
1.329 droeschl 1053: }
1.488 raeburn 1054: } elsif ($url=~m {^/res/}) {
1055: # published maps can only exists once, so remove it from paste buffer when done
1056: &Apache::lonnet::delenv('docs.markedcopy');
1.492 raeburn 1057: # if pasting published map (main content are only) check map is not already in course
1058: if ($folder =~ /^default/) {
1.529 raeburn 1059: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1.492 raeburn 1060: return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'));
1.491 raeburn 1061: }
1.489 raeburn 1062: }
1063: }
1.329 droeschl 1064: }
1.533 raeburn 1065: my $lockerrors;
1066: if ($url=~ m{/(bulletinboard|smppg)$}) {
1067: my $prefix = $1;
1068: #need to copy the db contents to a new one, unless this is a move.
1069: my %info = (
1070: src => $url,
1071: cdom => $coursedom,
1072: cnum => $coursenum,
1073: );
1074: my (%lockerr,$msg);
1075: unless ($env{'form.docs.markedcopy_options'} eq 'move') {
1076: my ($newurl,$result,$errtext) =
1077: &dbcopy(\%info,$coursedom,$coursenum,\%lockerr);
1078: if ($result eq 'ok') {
1079: $url = $newurl;
1.491 raeburn 1080: $title=&mt('Copy of').' '.$title;
1081: } else {
1.533 raeburn 1082: if ($prefix eq 'smppg') {
1083: $msg = &mt('Paste failed: An error occurred when copying the simple page.').' '.$errtext;
1084: } elsif ($prefix eq 'bulletinboard') {
1085: $msg = &mt('Paste failed: An error occurred when copying the bulletin board.').' '.$errtext;
1086: }
1087: return ($result,undef,[$msg],$lockerr{$prefix});
1088: }
1089: if ($lockerr{$prefix}) {
1090: $lockerrors = $lockerr{$prefix};
1.491 raeburn 1091: }
1.533 raeburn 1092: }
1.329 droeschl 1093: }
1094: $title = &LONCAPA::map::qtunescape($title);
1095: my $ext='false';
1096: if ($url=~m{^http(|s)://}) { $ext='true'; }
1097: $url = &LONCAPA::map::qtunescape($url);
1.491 raeburn 1098:
1099: # For uploaded files (excluding pages/sequences) path in copied file is changed
1100: # if paste is from Main to Supplemental (or vice versa), or if pasting between
1101: # courses.
1102:
1.492 raeburn 1103: my $newidx;
1.491 raeburn 1104: unless ($is_map) {
1.492 raeburn 1105: # Now insert the URL at the bottom
1106: $newidx = &LONCAPA::map::getresidx($url);
1.491 raeburn 1107: if ($url =~ m{^/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(.+)$}) {
1108: my $relpath = $1;
1109: if ($relpath ne '') {
1110: my ($prefix,$subdir,$rem) = ($relpath =~ m{^(default|\d+)/(\d+)/(.+)$});
1.492 raeburn 1111: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1.491 raeburn 1112: my $newprefix = $newloc;
1113: if ($newloc eq 'default') {
1114: $newprefix = 'docs';
1115: }
1.492 raeburn 1116: if ($newdocsdir eq '') {
1117: $newdocsdir = 'default';
1.491 raeburn 1118: }
1.533 raeburn 1119: if (($prefixchg) ||
1120: ($srcdom ne $coursedom) || ($srcnum ne $coursenum) ||
1121: ($env{'form.docs.markedcopy_options'} ne 'move')) {
1.492 raeburn 1122: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1.491 raeburn 1123: $url =
1124: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1125: &Apache::lonnet::getfile($oldurl));
1126: if ($url eq '/adm/notfound.html') {
1.492 raeburn 1127: return (&mt('Paste failed: an error occurred saving the file.'));
1.491 raeburn 1128: } else {
1129: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1130: $newsubpath =~ s{/+$}{/};
1131: $docmoves{$oldurl} = $newsubpath;
1132: }
1133: }
1134: }
1.488 raeburn 1135: }
1.491 raeburn 1136: }
1.492 raeburn 1137: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1138: my ($result,$save_err);
1.529 raeburn 1139: my %updated = (
1140: rewrites => \%rewrites,
1141: zombies => \%zombies,
1142: removefrommap => \%removefrommap,
1143: removeparam => \%removeparam,
1144: dbcopies => \%dbcopies,
1145: retitles => \%retitles,
1146: );
1147: my %info = (
1148: newsubdir => \%newsubdir,
1149: params => \%params,
1150: before => \%before,
1151: after => \%after,
1152: );
1153: my %moves = (
1154: copies => \%copies,
1155: docmoves => \%docmoves,
1156: mapmoves => \%mapmoves,
1.530 raeburn 1157: );
1.533 raeburn 1158: ($result,my $msgsarray,my $lockerror) =
1.529 raeburn 1159: &apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors,
1160: \%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste');
1.533 raeburn 1161: $lockerrors .= $lockerror;
1.491 raeburn 1162: if ($result eq 'ok') {
1.492 raeburn 1163: if ($is_map) {
1164: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1165: $folder.'.'.$container);
1.533 raeburn 1166: return ($errtext,$save_err,$msgsarray,$lockerrors) if ($fatal);
1.492 raeburn 1167:
1168: if ($#LONCAPA::map::order<1) {
1169: my $idx=&LONCAPA::map::getresidx();
1170: if ($idx<=0) { $idx=1; }
1171: $LONCAPA::map::order[0]=$idx;
1172: $LONCAPA::map::resources[$idx]='';
1173: }
1174: $newidx = &LONCAPA::map::getresidx($url);
1175: }
1.491 raeburn 1176: if ($env{'docs.markedcopy_supplemental'}) {
1.492 raeburn 1177: if ($folder !~ /^supplemental/) {
1.491 raeburn 1178: (undef,undef,$title) =
1179: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental'});
1.489 raeburn 1180: }
1.329 droeschl 1181: } else {
1.491 raeburn 1182: if ($folder=~/^supplemental/) {
1183: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1184: $env{'user.domain'}.'___&&&___'.$title;
1185: }
1.329 droeschl 1186: }
1.491 raeburn 1187: $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
1188: push(@LONCAPA::map::order, $newidx);
1.492 raeburn 1189:
1190: # Store the result
1191: my ($errtext,$fatal) =
1192: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1193: if ($fatal) {
1194: $save_err = $errtext;
1195: }
1196: }
1.533 raeburn 1197:
1.492 raeburn 1198: if ($env{'form.docs.markedcopy_options'} eq 'move') {
1199: &Apache::lonnet::delenv('docs.markedcopy');
1200: &Apache::lonnet::delenv('docs.markedcopy_nested');
1201: &Apache::lonnet::delenv('docs.markedcopy_nestednames');
1202: }
1.533 raeburn 1203: return ($result,$save_err,$msgsarray,$lockerrors);
1.492 raeburn 1204: }
1205:
1206: sub get_newmap_url {
1207: my ($url,$folder,$prefixchg,$coursedom,$coursenum,$srcdom,$srcnum,
1208: $titleref,$allmaps,$newurls) = @_;
1209: my $newurl;
1210: if ($url=~ m{^/uploaded/}) {
1211: $$titleref=&mt('Copy of').' '.$$titleref;
1212: }
1213: my $now = time;
1214: my $suffix=$$.int(rand(100)).$now;
1215: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
1216: if ($oldid =~ m{^(/uploaded/$match_domain/$match_courseid/)(\D+)(\d+)$}) {
1217: my $path = $1;
1218: my $prefix = $2;
1219: my $ancestor = $3;
1220: if (length($ancestor) > 10) {
1221: $ancestor = substr($ancestor,-10,10);
1222: }
1223: my $newid;
1224: if ($prefixchg) {
1225: if ($folder =~ /^supplemental/) {
1226: $prefix =~ s/^default/supplemental/;
1227: } else {
1228: $prefix =~ s/^supplemental/default/;
1229: }
1230: }
1231: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1232: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1233: } else {
1234: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$now.'.'.$ext;
1235: }
1236: my $counter = 0;
1237: my $is_unique = &uniqueness_check($newurl);
1238: if ($folder =~ /^default/) {
1239: if ($allmaps->{$newurl}) {
1240: $is_unique = 0;
1241: }
1242: }
1243: while ((!$is_unique || $allmaps->{$newurl} || $newurls->{$newurl}) && ($counter < 100)) {
1244: $counter ++;
1245: $suffix ++;
1246: if (($srcdom eq $coursedom) && ($srcnum eq $coursenum)) {
1247: $newurl = $path.$prefix.$ancestor.$suffix.'.'.$ext;
1248: } else {
1249: $newurl = "/uploaded/$coursedom/$coursenum/$prefix".$ancestor.$suffix.'.'.$ext;
1250: }
1251: $is_unique = &uniqueness_check($newurl);
1252: }
1253: if ($is_unique) {
1254: $newurls->{$newurl} = 1;
1255: } else {
1256: if ($url=~/\.page$/) {
1257: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the composite page'));
1258: } else {
1259: return (undef,&mt('Paste failed: an error occurred creating a unique URL for the folder'));
1260: }
1261: }
1.329 droeschl 1262: }
1.492 raeburn 1263: return ($newurl);
1.329 droeschl 1264: }
1265:
1.488 raeburn 1266: sub dbcopy {
1.533 raeburn 1267: my ($dbref,$coursedom,$coursenum,$lockerrorsref) = @_;
1268: my ($url,$result,$errtext);
1269: my $url = $dbref->{'src'};
1270: if (ref($dbref) eq 'HASH') {
1271: if ($url =~ m{/(smppg|bulletinboard)$}) {
1272: my $prefix = $1;
1273: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
1274: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
1275: my $db_name;
1276: my $marker = (split(m{/},$url))[4];
1277: $marker=~s/\D//g;
1278: if ($dbref->{'src'} =~ m{/smppg$}) {
1279: $db_name =
1280: &Apache::lonsimplepage::get_db_name($url,$marker,
1281: $dbref->{'cdom'},
1282: $dbref->{'cnum'});
1283: } else {
1284: $db_name = 'bulletinpage_'.$marker;
1285: }
1286: my ($suffix,$freedlock,$error) =
1287: &Apache::lonnet::get_timebased_id($prefix,'num','templated',
1288: $coursedom,$coursenum,
1289: 'concat');
1290: if (!$suffix) {
1291: if ($prefix eq 'smppg') {
1292: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a simple page [_1].',$url);
1293: } else {
1294: $errtext = &mt('Failed to acquire a unique timestamp-based suffix when copying a bulletin board [_1].',$url);
1295: }
1296: if ($error) {
1297: $errtext .= '<br />'.$error;
1298: }
1299: } else {
1300: #need to copy the db contents to a new one.
1301: my %contents=&Apache::lonnet::dump($db_name,
1302: $dbref->{'cdom'},
1303: $dbref->{'cnum'});
1304: if (exists($contents{'uploaded.photourl'})) {
1305: my $photo = $contents{'uploaded.photourl'};
1306: my ($subdir,$fname) =
1307: ($photo =~ m{^/uploaded/$match_domain/$match_courseid/+(bulletin|simplepage)/(?:|\d+/)([^/]+)$});
1308: my $newphoto;
1309: if ($fname ne '') {
1310: my $content = &Apache::lonnet::getfile($photo);
1311: unless ($content eq '-1') {
1312: $env{'form.'.$suffix.'.photourl'} = $content;
1313: $newphoto =
1314: &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,$suffix.'.photourl',"$subdir/$suffix/$fname");
1315: delete($env{'form.'.$suffix.'.photourl'});
1316: }
1317: }
1318: if ($newphoto =~ m{^/uploaded/}) {
1319: $contents{'uploaded.photourl'} = $newphoto;
1320: }
1321: }
1322: $db_name =~ s{_\d*$ }{_$suffix}x;
1323: $result=&Apache::lonnet::put($db_name,\%contents,
1324: $coursedom,$coursenum);
1325: if ($result eq 'ok') {
1326: $url =~ s{/(\d*)/(smppg|bulletinboard)$}{/$suffix/$2}x;
1327: }
1328: }
1329: if (($freedlock ne 'ok') && (ref($lockerrorsref) eq 'HASH')) {
1330: $lockerrorsref->{$prefix} =
1331: '<div class="LC_error">'.
1332: &mt('There was a problem removing a lockfile.');
1333: if ($prefix eq 'smppg') {
1334: $lockerrorsref->{$prefix} .=
1335: &mt('This will prevent creation of additional simple pages in this course.');
1336: } else {
1337: $lockerrorsref->{$prefix} .= &mt('This will prevent creation of additional bulletin boards in this course.');
1338: }
1339: $lockerrorsref->{$prefix} .= &mt('Please contact the domain coordinator for your LON-CAPA domain.').'</div>';
1340: }
1341: }
1342: } elsif ($url =~ m{/syllabus$}) {
1343: if (($dbref->{'cdom'} =~ /^$match_domain$/) &&
1344: ($dbref->{'cnum'} =~ /^$match_courseid$/)) {
1345: if (($dbref->{'cdom'} ne $coursedom) ||
1346: ($dbref->{'cnum'} ne $coursenum)) {
1347: my %contents=&Apache::lonnet::dump('syllabus',
1348: $dbref->{'cdom'},
1349: $dbref->{'cnum'});
1350: $result=&Apache::lonnet::put('syllabus',\%contents,
1351: $coursedom,$coursenum);
1352: }
1353: }
1.488 raeburn 1354: }
1355: }
1.533 raeburn 1356: return ($url,$result,$errtext);
1.488 raeburn 1357: }
1358:
1.329 droeschl 1359: sub uniqueness_check {
1360: my ($newurl) = @_;
1361: my $unique = 1;
1362: foreach my $res (@LONCAPA::map::order) {
1363: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
1364: $url=&LONCAPA::map::qtescape($url);
1365: if ($newurl eq $url) {
1366: $unique = 0;
1.344 bisitz 1367: last;
1.329 droeschl 1368: }
1369: }
1370: return $unique;
1371: }
1372:
1.488 raeburn 1373: sub contained_map_check {
1.492 raeburn 1374: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
1375: $allmaps) = @_;
1.488 raeburn 1376: my $content = &Apache::lonnet::getfile($url);
1377: unless ($content eq '-1') {
1378: my $parser = HTML::TokeParser->new(\$content);
1379: $parser->attr_encoded(1);
1380: while (my $token = $parser->get_token) {
1381: next if ($token->[0] ne 'S');
1382: if ($token->[1] eq 'resource') {
1383: next if ($token->[2]->{'type'} eq 'zombie');
1384: my $ressrc = $token->[2]->{'src'};
1385: if ($folder =~ /^supplemental/) {
1386: unless (&supp_pasteable($ressrc)) {
1.492 raeburn 1387: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.488 raeburn 1388: next;
1389: }
1390: }
1.492 raeburn 1391: if ($ressrc =~ m{^/(res|uploaded)/.+\.(sequence|page)$}) {
1392: if ($1 eq 'uploaded') {
1393: $hierarchy->{$url}{$token->[2]->{'id'}} = $ressrc;
1394: $titles->{$url}{$token->[2]->{'id'}} = $token->[2]->{'title'};
1.488 raeburn 1395: } else {
1.492 raeburn 1396: if ($allmaps->{$ressrc}) {
1.529 raeburn 1397: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.492 raeburn 1398: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
1399: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1400: } else {
1401: $addedmaps->{$ressrc} = [$url];
1402: }
1.488 raeburn 1403: }
1.492 raeburn 1404: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
1405: $addedmaps,$hierarchy,$titles,$allmaps);
1.488 raeburn 1406: }
1.492 raeburn 1407: } elsif ($token->[1] eq 'param') {
1.488 raeburn 1408: if ($folder =~ /^supplemental/) {
1.492 raeburn 1409: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
1410: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
1411: } else {
1412: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1413: }
1.488 raeburn 1414: }
1415: }
1416: }
1417: }
1418: return;
1419: }
1420:
1421: sub url_paste_fixups {
1.533 raeburn 1422: my ($oldurl,$folder,$prefixchg,$cdom,$cnum,$fromcdom,$fromcnum,$allmaps,
1423: $rewrites,$retitles,$copies,$dbcopies,$zombies,$params,$mapmoves,
1424: $mapchanges,$tomove,$newsubdir,$newurls) = @_;
1.491 raeburn 1425: my $checktitle;
1426: if (($prefixchg) &&
1.492 raeburn 1427: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1.491 raeburn 1428: $checktitle = 1;
1429: }
1.492 raeburn 1430: my $skip;
1431: if ($oldurl =~ m{^\Q/uploaded/$cdom/$cnum/\E(default|supplemental)(_?\d*)\.(?:page|sequence)$}) {
1432: my $mapid = $1.$2;
1433: if ($tomove->{$mapid}) {
1434: $skip = 1;
1435: }
1436: }
1.491 raeburn 1437: my $file = &Apache::lonnet::getfile($oldurl);
1.488 raeburn 1438: return if ($file eq '-1');
1439: my $parser = HTML::TokeParser->new(\$file);
1440: $parser->attr_encoded(1);
1.491 raeburn 1441: my $changed = 0;
1.488 raeburn 1442: while (my $token = $parser->get_token) {
1443: next if ($token->[0] ne 'S');
1444: if ($token->[1] eq 'resource') {
1445: my $ressrc = $token->[2]->{'src'};
1446: next if ($ressrc eq '');
1.491 raeburn 1447: my $id = $token->[2]->{'id'};
1.492 raeburn 1448: my $title = $token->[2]->{'title'};
1.491 raeburn 1449: if ($checktitle) {
1450: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.532 raeburn 1451: $retitles->{$oldurl}{$id} = $ressrc;
1.491 raeburn 1452: }
1453: }
1.488 raeburn 1454: next if ($token->[2]->{'type'} eq 'external');
1455: if ($token->[2]->{'type'} eq 'zombie') {
1.492 raeburn 1456: next if ($skip);
1.532 raeburn 1457: $zombies->{$oldurl}{$id} = $ressrc;
1.491 raeburn 1458: $changed = 1;
1459: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 1460: my $srcdom = $1;
1461: my $srcnum = $2;
1.488 raeburn 1462: my $rem = $3;
1.492 raeburn 1463: my $newurl;
1464: my $mapname;
1465: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1466: my $prefix = $1;
1467: $mapname = $prefix.$2;
1468: if ($tomove->{$mapname}) {
1.533 raeburn 1469: &url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,$cnum,
1470: $srcdom,$srcnum,$allmaps,$rewrites,
1471: $retitles,$copies,$dbcopies,$zombies,
1472: $params,$mapmoves,$mapchanges,$tomove,
1473: $newsubdir,$newurls);
1.492 raeburn 1474: next;
1475: } else {
1476: ($newurl,my $error) =
1477: &get_newmap_url($ressrc,$folder,$prefixchg,$cdom,$cnum,
1478: $srcdom,$srcnum,\$title,$allmaps,$newurls);
1479: if ($newurl =~ /(?:default|supplemental)_(\d+)\.(?:sequence|page)$/) {
1480: $newsubdir->{$ressrc} = $1;
1481: }
1482: if ($error) {
1483: next;
1484: }
1485: }
1486: }
1487: if (($srcdom ne $cdom) || ($srcnum ne $cnum) || ($prefixchg) ||
1488: ($mapchanges->{$oldurl}) || (($newurl ne '') && ($newurl ne $oldurl))) {
1489:
1.488 raeburn 1490: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.532 raeburn 1491: $rewrites->{$oldurl}{$id} = $ressrc;
1.491 raeburn 1492: $mapchanges->{$ressrc} = 1;
1.533 raeburn 1493: unless (&url_paste_fixups($ressrc,$folder,$prefixchg,$cdom,
1494: $cnum,$srcdom,$srcnum,$allmaps,
1495: $rewrites,$retitles,$copies,$dbcopies,
1496: $zombies,$params,$mapmoves,$mapchanges,
1497: $tomove,$newsubdir,$newurls)) {
1.491 raeburn 1498: $mapmoves->{$ressrc} = 1;
1499: }
1500: $changed = 1;
1.488 raeburn 1501: } else {
1.532 raeburn 1502: $rewrites->{$oldurl}{$id} = $ressrc;
1.488 raeburn 1503: $copies->{$oldurl}{$ressrc} = $id;
1.491 raeburn 1504: $changed = 1;
1.488 raeburn 1505: }
1506: }
1.533 raeburn 1507: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1508: next if ($skip);
1.492 raeburn 1509: my $srcdom = $1;
1510: my $srcnum = $2;
1511: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.532 raeburn 1512: $rewrites->{$oldurl}{$id} = $ressrc;
1.533 raeburn 1513: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
1514: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
1515: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1516: $changed = 1;
1517: }
1518: } elsif ($ressrc =~ m{^/adm/$match_domain/$match_username/\d+/(smppg|bulletinboard)$}) {
1519: if (($fromcdom ne $cdom) || ($fromcnum ne $cnum) ||
1520: ($env{'form.docs.markedcopy_options'} ne 'move')) {
1521: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
1522: $dbcopies->{$oldurl}{$id}{'cdom'} = $fromcdom;
1523: $dbcopies->{$oldurl}{$id}{'cnum'} = $fromcnum;
1.491 raeburn 1524: $changed = 1;
1.488 raeburn 1525: }
1526: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1.492 raeburn 1527: next if ($skip);
1528: my $srcdom = $1;
1529: my $srcnum = $2;
1530: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.533 raeburn 1531: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
1532: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
1533: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.491 raeburn 1534: $changed = 1;
1.488 raeburn 1535: }
1536: }
1537: } elsif ($token->[1] eq 'param') {
1.492 raeburn 1538: next if ($skip);
1.488 raeburn 1539: my $to = $token->[2]->{'to'};
1540: if ($to ne '') {
1541: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1.492 raeburn 1542: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1.488 raeburn 1543: } else {
1544: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
1545: }
1546: }
1547: }
1548: }
1.491 raeburn 1549: return $changed;
1.488 raeburn 1550: }
1551:
1552: sub apply_fixups {
1.529 raeburn 1553: my ($folder,$is_map,$cdom,$cnum,$errors,$updated,$info,$moves,$prefixchg,
1554: $oldurl,$url,$caller) = @_;
1555: my (%rewrites,%zombies,%removefrommap,%removeparam,%dbcopies,%retitles,
1.533 raeburn 1556: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1557: %lockerrors,$lockmsg);
1.529 raeburn 1558: if (ref($updated) eq 'HASH') {
1559: if (ref($updated->{'rewrites'}) eq 'HASH') {
1560: %rewrites = %{$updated->{'rewrites'}};
1561: }
1562: if (ref($updated->{'zombies'}) eq 'HASH') {
1563: %zombies = %{$updated->{'zombies'}};
1564: }
1565: if (ref($updated->{'removefrommap'}) eq 'HASH') {
1566: %removefrommap = %{$updated->{'removefrommap'}};
1567: }
1568: if (ref($updated->{'removeparam'}) eq 'HASH') {
1569: %removeparam = %{$updated->{'removeparam'}};
1570: }
1571: if (ref($updated->{'dbcopies'}) eq 'HASH') {
1572: %dbcopies = %{$updated->{'dbcopies'}};
1573: }
1574: if (ref($updated->{'retitles'}) eq 'HASH') {
1575: %retitles = %{$updated->{'retitles'}};
1576: }
1577: }
1578: if (ref($info) eq 'HASH') {
1579: if (ref($info->{'newsubdir'}) eq 'HASH') {
1580: %newsubdir = %{$info->{'newsubdir'}};
1581: }
1582: if (ref($info->{'params'}) eq 'HASH') {
1583: %params = %{$info->{'params'}};
1584: }
1585: if (ref($info->{'before'}) eq 'HASH') {
1586: %before = %{$info->{'before'}};
1587: }
1588: if (ref($info->{'after'}) eq 'HASH') {
1589: %after = %{$info->{'after'}};
1590: }
1591: }
1592: if (ref($moves) eq 'HASH') {
1593: if (ref($moves->{'copies'}) eq 'HASH') {
1594: %copies = %{$moves->{'copies'}};
1595: }
1596: if (ref($moves->{'docmoves'}) eq 'HASH') {
1597: %docmoves = %{$moves->{'docmoves'}};
1598: }
1599: if (ref($moves->{'mapmoves'}) eq 'HASH') {
1600: %mapmoves = %{$moves->{'mapmoves'}};
1601: }
1602: }
1603: foreach my $key (keys(%copies),keys(%docmoves)) {
1.491 raeburn 1604: my @allcopies;
1.529 raeburn 1605: if (exists($copies{$key})) {
1606: if (ref($copies{$key}) eq 'HASH') {
1607: my %added;
1608: foreach my $innerkey (keys(%{$copies{$key}})) {
1609: if (($innerkey ne '') && (!$added{$innerkey})) {
1610: push(@allcopies,$innerkey);
1611: $added{$innerkey} = 1;
1612: }
1.491 raeburn 1613: }
1.529 raeburn 1614: undef(%added);
1.491 raeburn 1615: }
1616: }
1617: if ($key eq $oldurl) {
1.529 raeburn 1618: if ((exists($docmoves{$key}))) {
1.532 raeburn 1619: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.491 raeburn 1620: push(@allcopies,$oldurl);
1621: }
1622: }
1623: }
1624: if (@allcopies > 0) {
1625: foreach my $item (@allcopies) {
1.492 raeburn 1626: my ($relpath,$oldsubdir,$fname) =
1627: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1.491 raeburn 1628: if ($fname ne '') {
1629: my $content = &Apache::lonnet::getfile($item);
1630: unless ($content eq '-1') {
1631: my $storefn;
1.529 raeburn 1632: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
1633: $storefn = $docmoves{$key};
1.491 raeburn 1634: } else {
1635: $storefn = $relpath;
1636: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 1637: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
1638: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.491 raeburn 1639: }
1.529 raeburn 1640: if ($newsubdir{$key}) {
1.532 raeburn 1641: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.491 raeburn 1642: }
1643: }
1644: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1645: my $copyurl =
1646: &Apache::lonclonecourse::writefile($env{'request.course.id'},
1647: $storefn.$fname,$content);
1648: if ($copyurl eq '/adm/notfound.html') {
1.529 raeburn 1649: if (exists($docmoves{$oldurl})) {
1.491 raeburn 1650: return &mt('Paste failed: an error occurred copying the file.');
1651: } elsif (ref($errors) eq 'HASH') {
1652: $errors->{$item} = 1;
1.489 raeburn 1653: }
1654: }
1.488 raeburn 1655: }
1656: }
1.491 raeburn 1657: }
1658: }
1659: }
1.529 raeburn 1660: foreach my $key (keys(%mapmoves)) {
1.491 raeburn 1661: my $storefn=$key;
1662: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 1663: if ($prefixchg && $before{'map'} && $after{'map'}) {
1664: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 1665: }
1.529 raeburn 1666: if ($newsubdir{$key}) {
1667: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 1668: }
1.491 raeburn 1669: my $mapcontent = &Apache::lonnet::getfile($key);
1670: if ($mapcontent eq '-1') {
1671: if (ref($errors) eq 'HASH') {
1672: $errors->{$key} = 1;
1673: }
1674: } else {
1675: my $newmap =
1676: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
1677: $mapcontent);
1678: if ($newmap eq '/adm/notfound.html') {
1679: if (ref($errors) eq 'HASH') {
1680: $errors->{$key} = 1;
1.489 raeburn 1681: }
1.488 raeburn 1682: }
1683: }
1684: }
1.491 raeburn 1685: my %updates;
1686: if ($is_map) {
1.529 raeburn 1687: if (ref($updated) eq 'HASH') {
1688: foreach my $type (keys(%{$updated})) {
1689: if (ref($updated->{$type}) eq 'HASH') {
1690: foreach my $key (keys(%{$updated->{$type}})) {
1691: $updates{$key} = 1;
1692: }
1693: }
1694: }
1.491 raeburn 1695: }
1696: foreach my $key (keys(%updates)) {
1.492 raeburn 1697: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.529 raeburn 1698: if (ref($rewrites{$key}) eq 'HASH') {
1699: %torewrite = %{$rewrites{$key}};
1.491 raeburn 1700: }
1.529 raeburn 1701: if (ref($retitles{$key}) eq 'HASH') {
1702: %toretitle = %{$retitles{$key}};
1.491 raeburn 1703: }
1.529 raeburn 1704: if (ref($removefrommap{$key}) eq 'HASH') {
1705: %toremove = %{$removefrommap{$key}};
1.491 raeburn 1706: }
1.529 raeburn 1707: if (ref($removeparam{$key}) eq 'HASH') {
1708: %remparam = %{$removeparam{$key}};
1.492 raeburn 1709: }
1.529 raeburn 1710: if (ref($zombies{$key}) eq 'HASH') {
1711: %zombie = %{$zombies{$key}};
1.491 raeburn 1712: }
1.529 raeburn 1713: if (ref($dbcopies{$key}) eq 'HASH') {
1.533 raeburn 1714: foreach my $idx (keys(%{$dbcopies{$key}})) {
1715: if (ref($dbcopies{$key}{$idx}) eq 'HASH') {
1716: my ($newurl,$result,$errtext) =
1717: &dbcopy($dbcopies{$key}{$idx},$cdom,$cnum,\%lockerrors);
1718: if ($result eq 'ok') {
1719: $newdb{$idx} = $newurl;
1720: } elsif (ref($errors) eq 'HASH') {
1721: $errors->{$key} = 1;
1722: }
1723: push(@msgs,$errtext);
1724: }
1.491 raeburn 1725: }
1726: }
1.529 raeburn 1727: if (ref($params{$key}) eq 'HASH') {
1728: %currparam = %{$params{$key}};
1.492 raeburn 1729: }
1730: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
1731: if ($fatal) {
1.533 raeburn 1732: return ($errtext);
1.492 raeburn 1733: }
1734: for (my $i=0; $i<@LONCAPA::map::zombies; $i++) {
1735: if (defined($LONCAPA::map::zombies[$i])) {
1736: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::zombies[$i]);
1.532 raeburn 1737: if ($zombie{$i} eq $src) {
1.492 raeburn 1738: undef($LONCAPA::map::zombies[$i]);
1739: }
1740: }
1741: }
1.529 raeburn 1742: for (my $i=0; $i<@LONCAPA::map::order; $i++) {
1743: my $idx = $LONCAPA::map::order[$i];
1744: if (defined($LONCAPA::map::resources[$idx])) {
1.492 raeburn 1745: my $changed;
1.529 raeburn 1746: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1747: if ((exists($toremove{$idx})) && ($toremove{$idx} eq $src)) {
1.492 raeburn 1748: splice(@LONCAPA::map::order,$i,1);
1.529 raeburn 1749: if (ref($currparam{$idx}) eq 'ARRAY') {
1750: foreach my $name (@{$currparam{$idx}}) {
1751: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.492 raeburn 1752: }
1753: }
1754: next;
1755: }
1756: my $origsrc = $src;
1.532 raeburn 1757: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.492 raeburn 1758: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1759: $changed = 1;
1.491 raeburn 1760: }
1.492 raeburn 1761: }
1.532 raeburn 1762: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.492 raeburn 1763: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
1764: if ($origsrc =~ m{^/uploaded/}) {
1.529 raeburn 1765: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.492 raeburn 1766: if ($src =~ /\.(page|sequence)$/) {
1.529 raeburn 1767: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.492 raeburn 1768: } else {
1.529 raeburn 1769: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.488 raeburn 1770: }
1.491 raeburn 1771: }
1.532 raeburn 1772: if ($origsrc =~ /\.(page|sequence)$/) {
1773: if ($newsubdir{$origsrc}) {
1.529 raeburn 1774: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.491 raeburn 1775: }
1.532 raeburn 1776: } elsif ($newsubdir{$key}) {
1777: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.488 raeburn 1778: }
1779: }
1.492 raeburn 1780: $changed = 1;
1.533 raeburn 1781: } elsif ($newdb{$idx} ne '') {
1782: $src = $newdb{$idx};
1.492 raeburn 1783: $changed = 1;
1784: }
1785: if ($changed) {
1.529 raeburn 1786: $LONCAPA::map::resources[$idx] = join(':',($title,$src,$ext,$type));
1.492 raeburn 1787: }
1788: }
1789: }
1790: foreach my $idx (keys(%remparam)) {
1791: if (ref($remparam{$idx}) eq 'ARRAY') {
1792: foreach my $name (@{$remparam{$idx}}) {
1793: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.491 raeburn 1794: }
1795: }
1796: }
1.533 raeburn 1797: if (values(%lockerrors) > 0) {
1798: $lockmsg = join('<br />',values(%lockerrors));
1799: }
1.491 raeburn 1800: my $storefn;
1801: if ($key eq $oldurl) {
1802: $storefn = $url;
1803: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1804: } else {
1805: $storefn = $key;
1806: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.529 raeburn 1807: if ($prefixchg && $before{'map'} && $after{'map'}) {
1808: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.491 raeburn 1809: }
1.529 raeburn 1810: if ($newsubdir{$key}) {
1811: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.492 raeburn 1812: }
1.491 raeburn 1813: }
1.492 raeburn 1814: my $report;
1815: if ($folder !~ /^supplemental/) {
1816: $report = 1;
1817: }
1.527 raeburn 1818: (my $outtext,$errtext) =
1.492 raeburn 1819: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
1820: if ($errtext) {
1.529 raeburn 1821: if ($caller eq 'paste') {
1.533 raeburn 1822: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.529 raeburn 1823: }
1.491 raeburn 1824: }
1825: }
1826: }
1.533 raeburn 1827: return ('ok',\@msgs,$lockmsg);
1.491 raeburn 1828: }
1829:
1830: sub copy_dependencies {
1831: my ($item,$storefn,$relpath,$errors,$contentref) = @_;
1832: my $content;
1833: if (ref($contentref)) {
1834: $content = $$contentref;
1835: } else {
1836: $content = &Apache::lonnet::getfile($item);
1837: }
1838: unless ($content eq '-1') {
1839: my $mm = new File::MMagic;
1840: my $mimetype = $mm->checktype_contents($content);
1841: if ($mimetype eq 'text/html') {
1842: my (%allfiles,%codebase,$state);
1843: my $res = &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,\$content);
1844: if ($res eq 'ok') {
1845: my ($numexisting,$numpathchanges,$existing);
1846: (undef,$numexisting,$numpathchanges,$existing) =
1847: &Apache::loncommon::ask_for_embedded_content(
1848: '/adm/coursedocs',$state,\%allfiles,\%codebase,
1849: {'error_on_invalid_names' => 1,
1850: 'ignore_remote_references' => 1,
1851: 'docs_url' => $item,
1852: 'context' => 'paste'});
1853: if ($numexisting > 0) {
1854: if (ref($existing) eq 'HASH') {
1855: foreach my $dep (keys(%{$existing})) {
1856: my $depfile = $dep;
1857: unless ($depfile =~ m{^\Q$relpath\E}) {
1858: $depfile = $relpath.$dep;
1859: }
1860: my $depcontent = &Apache::lonnet::getfile($depfile);
1861: unless ($depcontent eq '-1') {
1862: my $storedep = $dep;
1863: $storedep =~ s{^\Q$relpath\E}{};
1864: my $dep_url =
1865: &Apache::lonclonecourse::writefile(
1866: $env{'request.course.id'},
1867: $storefn.$storedep,$depcontent);
1868: if ($dep_url eq '/adm/notfound.html') {
1869: if (ref($errors) eq 'HASH') {
1870: $errors->{$depfile} = 1;
1871: }
1872: } else {
1873: ©_dependencies($depfile,$storefn,$relpath,$errors,\$depcontent);
1874: }
1875: }
1876: }
1.488 raeburn 1877: }
1878: }
1879: }
1880: }
1881: }
1882: return;
1883: }
1884:
1.329 droeschl 1885: my %parameter_type = ( 'randompick' => 'int_pos',
1886: 'hiddenresource' => 'string_yesno',
1887: 'encrypturl' => 'string_yesno',
1888: 'randomorder' => 'string_yesno',);
1889: my $valid_parameters_re = join('|',keys(%parameter_type));
1890: # set parameters
1891: sub update_parameter {
1892:
1893: return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1894:
1895: my $which = $env{'form.changeparms'};
1896: my $idx = $env{'form.setparms'};
1897: if ($env{'form.'.$which.'_'.$idx}) {
1898: my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
1899: : 'yes';
1900: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
1901: $parameter_type{$which});
1902: &remember_parms($idx,$which,'set',$value);
1903: } else {
1904: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
1.364 bisitz 1905:
1.329 droeschl 1906: &remember_parms($idx,$which,'del');
1907: }
1908: return 1;
1909: }
1910:
1911:
1912: sub handle_edit_cmd {
1913: my ($coursenum,$coursedom) =@_;
1914: my ($cmd,$idx)=split('_',$env{'form.cmd'});
1915:
1916: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1917: my ($title, $url, @rrest) = split(':', $ratstr);
1918:
1919: if ($cmd eq 'del') {
1920: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1.463 www 1921: ($url!~/$LONCAPA::assess_page_seq_re/)) {
1.329 droeschl 1922: &Apache::lonnet::removeuploadedurl($url);
1923: } else {
1924: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1925: }
1926: splice(@LONCAPA::map::order, $idx, 1);
1927:
1928: } elsif ($cmd eq 'cut') {
1929: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1930: splice(@LONCAPA::map::order, $idx, 1);
1931:
1.344 bisitz 1932: } elsif ($cmd eq 'up'
1.329 droeschl 1933: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
1934: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1935:
1936: } elsif ($cmd eq 'down'
1937: && defined($LONCAPA::map::order[$idx+1])) {
1938: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1939:
1940: } elsif ($cmd eq 'rename') {
1941:
1942: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
1943: if ($comment=~/\S/) {
1944: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
1945: $comment.':'.join(':', $url, @rrest);
1946: }
1947: # Devalidate title cache
1948: my $renamed_url=&LONCAPA::map::qtescape($url);
1949: &Apache::lonnet::devalidate_title_cache($renamed_url);
1950: } else {
1951: return 0;
1952: }
1953: return 1;
1954: }
1955:
1956: sub editor {
1.458 raeburn 1957: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
1.508 raeburn 1958: $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
1.519 raeburn 1959: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1.510 raeburn 1960: if ($allowed) {
1.519 raeburn 1961: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
1962: $is_random_order,$container) =
1.510 raeburn 1963: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1964: $r->print($breadcrumbtrail);
1.519 raeburn 1965: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
1966: $container = 'page';
1967: } else {
1968: $container = 'sequence';
1.510 raeburn 1969: }
1.484 raeburn 1970:
1.525 raeburn 1971: my $jumpto;
1972:
1973: unless ($supplementalflag) {
1974: $jumpto = "'uploaded/$coursedom/$coursenum/$folder.$container'";
1975: }
1.484 raeburn 1976:
1977: unless ($allowed) {
1978: $randompick = -1;
1979: }
1980:
1.329 droeschl 1981: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1982: $folder.'.'.$container);
1983: return $errtext if ($fatal);
1984:
1985: if ($#LONCAPA::map::order<1) {
1986: my $idx=&LONCAPA::map::getresidx();
1987: if ($idx<=0) { $idx=1; }
1988: $LONCAPA::map::order[0]=$idx;
1989: $LONCAPA::map::resources[$idx]='';
1990: }
1.364 bisitz 1991:
1.329 droeschl 1992: # ------------------------------------------------------------ Process commands
1993:
1994: # ---------------- if they are for this folder and user allowed to make changes
1995: if (($allowed) && ($env{'form.folder'} eq $folder)) {
1996: # set parameters and change order
1997: &snapshotbefore();
1998:
1999: if (&update_parameter()) {
2000: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2001: return $errtext if ($fatal);
2002: }
2003:
2004: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
2005: # change order
2006: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
2007: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
2008:
2009: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
2010: return $errtext if ($fatal);
2011: }
1.364 bisitz 2012:
1.329 droeschl 2013: if ($env{'form.pastemarked'}) {
1.491 raeburn 2014: my %paste_errors;
1.533 raeburn 2015: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.492 raeburn 2016: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2017: \%paste_errors);
1.533 raeburn 2018: if (ref($pastemsgarray) eq 'ARRAY') {
2019: if (@{$pastemsgarray} > 0) {
2020:
2021: $r->print('<p class="LC_info">'.
2022: join('<br />',@{$pastemsgarray}).
2023: '</p>');
2024: }
2025: }
2026: if ($lockerror) {
2027: $r->print('<p class="LC_error">'.
2028: $lockerror.
2029: '</p>');
2030: }
1.492 raeburn 2031: if ($save_error ne '') {
2032: return $save_error;
2033: }
2034: if ($paste_res ne 'ok') {
1.329 droeschl 2035: $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
2036: }
1.491 raeburn 2037: if (keys(%paste_errors) > 0) {
2038: $r->print('<p span class="LC_warning">'."\n".
2039: &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".
2040: '<ul>'."\n");
2041: foreach my $key (sort(keys(%paste_errors))) {
2042: $r->print('<li>'.$key.'</li>'."\n");
2043: }
2044: $r->print('</ul></p>'."\n");
2045: }
1.329 droeschl 2046: }
2047:
2048: $r->print($upload_output);
2049:
2050: if (&handle_edit_cmd()) {
1.492 raeburn 2051: my $contentchg;
2052: if ($env{'form.cmd'} =~ /^(del|cut)_/) {
2053: $contentchg = 1;
2054: }
2055: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container,$contentchg);
1.329 droeschl 2056: return $errtext if ($fatal);
2057: }
2058: # Group import/search
2059: if ($env{'form.importdetail'}) {
2060: my @imports;
2061: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
2062: if (defined($item)) {
2063: my ($name,$url,$residx)=
1.533 raeburn 2064: map { &unescape($_); } split(/\=/,$item);
2065: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
2066: my ($suffix,$errortxt,$locknotfreed) =
2067: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.504 raeburn 2068: if ($locknotfreed) {
2069: $r->print($locknotfreed);
2070: }
2071: if ($suffix) {
2072: $url =~ s/_new\./_$suffix./;
2073: } else {
2074: return $errortxt;
2075: }
1.533 raeburn 2076: } elsif ($url =~ m{^/adm/$match_domain/$match_username/new/(smppg|bulletinboard)$}) {
2077: my $type = $1;
2078: my ($suffix,$errortxt,$locknotfreed) =
2079: &new_timebased_suffix($coursedom,$coursenum,$type);
2080: if ($locknotfreed) {
2081: $r->print($locknotfreed);
2082: }
2083: if ($suffix) {
2084: $url =~ s{^(/adm/$match_domain/$match_username)/new}{$1/$suffix};
2085: } else {
2086: return $errortxt;
2087: }
1.534 raeburn 2088: } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
2089: if ($supplementalflag) {
2090: next unless ($1 eq 'supplemental');
2091: if ($folder eq 'supplemental') {
2092: next unless ($2 eq 'default');
2093: } else {
2094: next unless ($folder eq 'supplemental_'.$2);
2095: }
2096: } else {
2097: next unless ($1 eq 'docs');
2098: if ($folder eq 'default') {
2099: next unless ($2 eq 'default');
2100: } else {
2101: next unless ($folder eq 'default_'.$2);
2102: }
2103: }
1.504 raeburn 2104: }
1.329 droeschl 2105: push(@imports, [$name, $url, $residx]);
2106: }
2107: }
1.530 raeburn 2108: ($errtext,$fatal,my $fixuperrors) =
1.529 raeburn 2109: &group_import($coursenum, $coursedom, $folder,$container,
2110: 'londocs',@imports);
1.329 droeschl 2111: return $errtext if ($fatal);
1.529 raeburn 2112: if ($fixuperrors) {
2113: $r->print($fixuperrors);
2114: }
1.329 droeschl 2115: }
2116: # Loading a complete map
2117: if ($env{'form.loadmap'}) {
2118: if ($env{'form.importmap'}=~/\w/) {
2119: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
2120: my ($title,$url,$ext,$type)=split(/\:/,$res);
2121: my $idx=&LONCAPA::map::getresidx($url);
2122: $LONCAPA::map::resources[$idx]=$res;
2123: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
2124: }
2125: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 2126: $folder.'.'.$container,1);
1.329 droeschl 2127: return $errtext if ($fatal);
2128: } else {
2129: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 2130:
1.329 droeschl 2131: }
2132: }
2133: &log_differences($plain);
2134: }
2135: # ---------------------------------------------------------------- End commands
2136: # ---------------------------------------------------------------- Print screen
2137: my $idx=0;
2138: my $shown=0;
2139: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1.381 bisitz 2140: $r->print('<div class="LC_Box">'.
1.432 raeburn 2141: '<ol class="LC_docs_parameters"><li class="LC_docs_parameters_title">'.&mt('Parameters:').'</li>'.
2142: ($randompick>=0?'<li>'.&mt('randomly pick [quant,_1,resource]',$randompick).'</li>':'').
2143: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
2144: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
2145: ($is_random_order?'<li>'.&mt('random order').'</li>':'').
1.431 raeburn 2146: '</ol>');
1.381 bisitz 2147: if ($randompick>=0) {
2148: $r->print('<p class="LC_warning">'
2149: .&mt('Caution: this folder is set to randomly pick a subset'
2150: .' of resources. Adding or removing resources from this'
2151: .' folder will change the set of resources that the'
2152: .' students see, resulting in spurious or missing credit'
2153: .' for completed problems, not limited to ones you'
2154: .' modify. Do not modify the contents of this folder if'
2155: .' it is in active student use.')
2156: .'</p>'
2157: );
2158: }
2159: if ($is_random_order) {
2160: $r->print('<p class="LC_warning">'
2161: .&mt('Caution: this folder is set to randomly order its'
2162: .' contents. Adding or removing resources from this folder'
2163: .' will change the order of resources shown.')
2164: .'</p>'
2165: );
2166: }
2167: $r->print('</div>');
1.364 bisitz 2168: }
1.381 bisitz 2169:
1.458 raeburn 2170: my ($to_show,$output);
1.424 onken 2171:
2172: &Apache::loncommon::start_data_table_count(); #setup a row counter
1.381 bisitz 2173: foreach my $res (@LONCAPA::map::order) {
2174: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
2175: $name=&LONCAPA::map::qtescape($name);
2176: $url=&LONCAPA::map::qtescape($url);
2177: unless ($name) { $name=(split(/\//,$url))[-1]; }
2178: unless ($name) { $idx++; next; }
2179: $output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
1.501 raeburn 2180: $coursenum,$coursedom,$crstype,
1.519 raeburn 2181: $pathitem,$supplementalflag,$container);
1.381 bisitz 2182: $idx++;
2183: $shown++;
1.329 droeschl 2184: }
1.424 onken 2185: &Apache::loncommon::end_data_table_count();
1.510 raeburn 2186:
2187: if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
1.520 raeburn 2188: my $toolslink = '<table><tr><td>'
2189: .&Apache::loncommon::help_open_menu('Navigation Screen',
2190: 'Navigation_Screen',undef,'RAT')
2191: .'</td><td class="LC_middle">'.&mt('Tools:').'</td>'
2192: .'<td align="left"><ul id="LC_toolbar">'
1.525 raeburn 2193: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.520 raeburn 2194: .'id="LC_content_toolbar_edittoplevel" '
2195: .'class="LC_toolbarItem" '
2196: .'title="'.&mt('Supplemental Content Editor').'">'
2197: .'</a></li></ul></td></tr></table><br />';
1.510 raeburn 2198: if ($shown) {
2199: if ($allowed) {
2200: $to_show = &Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
2201: .&Apache::loncommon::start_data_table(undef,'contentlist')
2202: .&Apache::loncommon::start_data_table_header_row()
2203: .'<th colspan="2">'.&mt('Move').'</th>'
2204: .'<th>'.&mt('Actions').'</th>'
2205: .'<th colspan="2">'.&mt('Document').'</th>';
2206: if ($folder !~ /^supplemental/) {
2207: $to_show .= '<th colspan="4">'.&mt('Settings').'</th>';
2208: }
2209: $to_show .= &Apache::loncommon::end_data_table_header_row()
2210: .$output.' '
2211: .&Apache::loncommon::end_data_table()
2212: .'<br style="line-height:2px;" />'
2213: .&Apache::loncommon::end_scrollbox();
2214: } else {
1.520 raeburn 2215: $to_show .= $toolslink
1.510 raeburn 2216: .&Apache::loncommon::start_data_table('LC_tableOfContent')
2217: .$output.' '
2218: .&Apache::loncommon::end_data_table();
1.393 raeburn 2219: }
1.510 raeburn 2220: } else {
1.520 raeburn 2221: if (!$allowed) {
2222: $to_show .= $toolslink;
2223: }
1.510 raeburn 2224: $to_show .= &Apache::loncommon::start_scrollbox('400px','380px','200px','contentscroll')
2225: .'<div class="LC_info" id="contentlist">'
2226: .&mt('Currently no documents.')
2227: .'</div>'
2228: .&Apache::loncommon::end_scrollbox();
1.393 raeburn 2229: }
2230: } else {
1.510 raeburn 2231: if ($shown) {
2232: $to_show = '<div>'
2233: .&Apache::loncommon::start_data_table('LC_tableOfContent')
2234: .$output
2235: .&Apache::loncommon::end_data_table()
2236: .'</div>';
2237: } else {
2238: $to_show = '<div class="LC_info" id="contentlist">'
2239: .&mt('Currently no documents.')
2240: .'</div>'
2241: }
1.458 raeburn 2242: }
2243: my $tid = 1;
2244: if ($supplementalflag) {
2245: $tid = 2;
1.329 droeschl 2246: }
2247: if ($allowed) {
1.484 raeburn 2248: my $readfile="/uploaded/$coursedom/$coursenum/$folder.$container";
2249: $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto,
2250: $readfile));
1.492 raeburn 2251: &print_paste_buffer($r,$container,$folder,$coursedom,$coursenum);
1.460 raeburn 2252: } else {
2253: $r->print($to_show);
1.329 droeschl 2254: }
2255: return;
2256: }
2257:
2258: sub process_file_upload {
2259: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
2260: # upload a file, if present
1.440 raeburn 2261: my ($parseaction,$showupload,$nextphase,$mimetype);
2262: if ($env{'form.parserflag'}) {
1.329 droeschl 2263: $parseaction = 'parse';
2264: }
2265: my $folder=$env{'form.folder'};
2266: if ($folder eq '') {
2267: $folder='default';
2268: }
2269: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
2270: my $errtext='';
2271: my $fatal=0;
2272: my $container='sequence';
1.519 raeburn 2273: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 2274: $container='page';
2275: }
2276: ($errtext,$fatal)=
1.534 raeburn 2277: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1.329 droeschl 2278: if ($#LONCAPA::map::order<1) {
2279: $LONCAPA::map::order[0]=1;
2280: $LONCAPA::map::resources[1]='';
2281: }
2282: my $destination = 'docs/';
2283: if ($folder =~ /^supplemental/) {
2284: $destination = 'supplemental/';
2285: }
2286: if (($folder eq 'default') || ($folder eq 'supplemental')) {
2287: $destination .= 'default/';
2288: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
2289: $destination .= $2.'/';
2290: }
1.534 raeburn 2291: if ($fatal) {
2292: $$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>';
2293: return;
2294: }
1.440 raeburn 2295: # this is for a course, not a user, so set context to coursedoc.
1.329 droeschl 2296: my $newidx=&LONCAPA::map::getresidx();
2297: $destination .= $newidx;
1.439 raeburn 2298: my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
1.329 droeschl 2299: $parseaction,$allfiles,
1.440 raeburn 2300: $codebase,undef,undef,undef,undef,
2301: undef,undef,\$mimetype);
2302: if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
2303: my $stored = $1;
2304: $showupload = '<p>'.&mt('Uploaded [_1]','<span class="LC_filename">'.
2305: $stored.'</span>').'</p>';
2306: } else {
2307: my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
2308:
1.457 raeburn 2309: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
1.440 raeburn 2310: return;
2311: }
1.329 droeschl 2312: my $ext='false';
2313: if ($url=~m{^http://}) { $ext='true'; }
2314: $url = &LONCAPA::map::qtunescape($url);
2315: my $comment=$env{'form.comment'};
2316: $comment = &LONCAPA::map::qtunescape($comment);
2317: if ($folder=~/^supplemental/) {
2318: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
2319: $env{'user.domain'}.'___&&&___'.$comment;
2320: }
2321:
2322: $LONCAPA::map::resources[$newidx]=
2323: $comment.':'.$url.':'.$ext.':normal:res';
2324: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
2325: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1.492 raeburn 2326: $folder.'.'.$container,1);
1.329 droeschl 2327: if ($fatal) {
1.457 raeburn 2328: $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
1.440 raeburn 2329: return;
1.329 droeschl 2330: } else {
1.440 raeburn 2331: if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
2332: $$upload_output = $showupload;
1.384 raeburn 2333: my $total_embedded = scalar(keys(%{$allfiles}));
1.329 droeschl 2334: if ($total_embedded > 0) {
1.440 raeburn 2335: my $uploadphase = 'upload_embedded';
2336: my $primaryurl = &HTML::Entities::encode($url,'<>&"');
2337: my $state = &embedded_form_elems($uploadphase,$primaryurl,$newidx);
2338: my ($embedded,$num) =
2339: &Apache::loncommon::ask_for_embedded_content(
2340: '/adm/coursedocs',$state,$allfiles,$codebase,{'docs_url' => $url});
2341: if ($embedded) {
2342: if ($num) {
2343: $$upload_output .=
2344: '<p>'.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'</p>'.$embedded;
2345: $nextphase = $uploadphase;
2346: } else {
2347: $$upload_output .= $embedded;
2348: }
2349: } else {
2350: $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'<br />';
2351: }
1.329 droeschl 2352: } else {
1.440 raeburn 2353: $$upload_output .= &mt('No embedded items identified').'<br />';
1.329 droeschl 2354: }
1.457 raeburn 2355: $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
1.476 raeburn 2356: } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
2357: $nextphase = 'decompress_uploaded';
2358: my $position = scalar(@LONCAPA::map::order)-1;
2359: my $noextract = &return_to_editor();
2360: my $archiveurl = &HTML::Entities::encode($url,'<>&"');
2361: my %archiveitems = (
2362: folderpath => $env{'form.folderpath'},
2363: cmd => $nextphase,
2364: newidx => $newidx,
2365: position => $position,
2366: phase => $nextphase,
1.477 raeburn 2367: comment => $comment,
1.480 raeburn 2368: );
2369: my ($destination,$dir_root) = &embedded_destination($coursenum,$coursedom);
2370: my @current = &get_dir_list($url,$coursenum,$coursedom,$newidx);
1.476 raeburn 2371: $$upload_output = $showupload.
2372: &Apache::loncommon::decompress_form($mimetype,
2373: $archiveurl,'/adm/coursedocs',$noextract,
1.480 raeburn 2374: \%archiveitems,\@current);
1.329 droeschl 2375: }
2376: }
2377: }
1.440 raeburn 2378: return $nextphase;
1.329 droeschl 2379: }
2380:
1.480 raeburn 2381: sub get_dir_list {
2382: my ($url,$coursenum,$coursedom,$newidx) = @_;
2383: my ($destination,$dir_root) = &embedded_destination();
2384: my ($dirlistref,$listerror) =
2385: &Apache::lonnet::dirlist("$dir_root/$destination/$newidx",$coursedom,$coursenum,1);
2386: my @dir_lines;
2387: my $dirptr=16384;
2388: if (ref($dirlistref) eq 'ARRAY') {
2389: foreach my $dir_line (sort
2390: {
2391: my ($afile)=split('&',$a,2);
2392: my ($bfile)=split('&',$b,2);
2393: return (lc($afile) cmp lc($bfile));
2394: } (@{$dirlistref})) {
2395: my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$dir_line,16);
2396: $filename =~ s/\s+$//;
2397: next if ($filename =~ /^\.\.?$/);
2398: my $isdir = 0;
2399: if ($dirptr&$testdir) {
2400: $isdir = 1;
2401: }
2402: push(@dir_lines, [$filename,$dom,$isdir,$size,$mtime,$obs]);
2403: }
2404: }
2405: return @dir_lines;
2406: }
2407:
1.329 droeschl 2408: sub is_supplemental_title {
2409: my ($title) = @_;
2410: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
2411: }
2412:
2413: # --------------------------------------------------------------- An entry line
2414:
2415: sub entryline {
1.501 raeburn 2416: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.519 raeburn 2417: $crstype,$pathitem,$supplementalflag,$container)=@_;
2418: my ($foldertitle,$renametitle);
1.329 droeschl 2419: if (&is_supplemental_title($title)) {
1.488 raeburn 2420: ($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
1.329 droeschl 2421: } else {
2422: $title=&HTML::Entities::encode($title,'"<>&\'');
2423: $renametitle=$title;
2424: $foldertitle=$title;
2425: }
2426:
2427: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 2428:
1.329 droeschl 2429: $renametitle=~s/\\/\\\\/g;
2430: $renametitle=~s/\"\;/\\\"/g;
2431: $renametitle=~s/ /%20/g;
1.379 bisitz 2432: my $line=&Apache::loncommon::start_data_table_row();
1.478 raeburn 2433: my ($form_start,$form_end,$form_common);
1.329 droeschl 2434: # Edit commands
1.535 ! raeburn 2435: my ($esc_path, $path, $symb);
1.329 droeschl 2436: if ($env{'form.folderpath'}) {
2437: $esc_path=&escape($env{'form.folderpath'});
2438: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
2439: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
2440: }
1.505 raeburn 2441: my $isexternal;
1.510 raeburn 2442: if ($residx) {
1.501 raeburn 2443: my $currurl = $url;
2444: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.505 raeburn 2445: if ($currurl =~ m{^/adm/wrapper/ext/}) {
2446: $isexternal = 1;
2447: }
1.510 raeburn 2448: if (!$supplementalflag) {
2449: my $path = 'uploaded/'.
2450: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
2451: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
2452: $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
2453: $residx,
2454: &Apache::lonnet::declutter($currurl));
2455: }
1.501 raeburn 2456: }
1.517 raeburn 2457: my ($renamelink,%lt);
1.329 droeschl 2458: if ($allowed) {
2459: my $incindex=$index+1;
2460: my $selectbox='';
1.471 raeburn 2461: if (($#LONCAPA::map::order>0) &&
1.329 droeschl 2462: ((split(/\:/,
1.344 bisitz 2463: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
2464: ne '') &&
1.329 droeschl 2465: ((split(/\:/,
1.344 bisitz 2466: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 2467: ne '')) {
2468: $selectbox=
2469: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1.373 bisitz 2470: '<select name="newpos" onchange="this.form.submit()">';
1.329 droeschl 2471: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
2472: if ($i==$incindex) {
1.358 bisitz 2473: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 2474: } else {
2475: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
2476: }
2477: }
2478: $selectbox.='</select>';
2479: }
1.501 raeburn 2480: %lt=&Apache::lonlocal::texthash(
1.329 droeschl 2481: 'up' => 'Move Up',
2482: 'dw' => 'Move Down',
2483: 'rm' => 'Remove',
2484: 'ct' => 'Cut',
2485: 'rn' => 'Rename',
1.501 raeburn 2486: 'cp' => 'Copy',
2487: 'ex' => 'External Resource',
2488: 'ed' => 'Edit',
2489: 'pr' => 'Preview',
2490: 'sv' => 'Save',
2491: 'ul' => 'URL',
2492: 'ti' => 'Title',
2493: );
1.329 droeschl 2494: my $nocopy=0;
2495: my $nocut=0;
1.497 raeburn 2496: my $noremove=0;
1.492 raeburn 2497: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
2498: # no copy for published maps
2499: $nocopy=1;
1.329 droeschl 2500: }
1.344 bisitz 2501: if ($url=~/^\/res\/lib\/templates\//) {
2502: $nocopy=1;
1.329 droeschl 2503: $nocut=1;
2504: }
1.497 raeburn 2505: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2506: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2507: if ($url eq "/uploaded/$cdom/$cnum/group_allfolders.sequence") {
2508: if ($env{'form.folderpath'} =~ /^default&[^\&]+$/) {
2509: my %curr_groups = &Apache::longroup::coursegroups();
2510: if (keys(%curr_groups) > 0) {
2511: $noremove=1;
2512: }
2513: $nocut=1;
2514: $nocopy=1;
2515: }
2516: } elsif ($url =~ m{^\Q/uploaded/$cdom/$cnum/group_folder_\E(\w+)\.sequence$}) {
2517: my $group = $1;
2518: if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+$/) {
2519: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2520: if (keys(%curr_group) > 0) {
2521: $noremove=1;
2522: }
2523: }
2524: $nocut=1;
2525: $nocopy=1;
2526: } elsif ($url =~ m{^\Q/adm/$cdom/$cnum/\E(\w+)/smppg$}) {
2527: my $group = $1;
2528: if ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&\Qgroup_folder_$group\E\&[^\&]+$/) {
2529: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2530: my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group});
2531: if (keys(%groupsettings) > 0) {
2532: $noremove=1;
2533: }
2534: $nocut=1;
2535: $nocopy=1;
2536: }
2537: } elsif ($env{'form.folderpath'} =~ /^default&[^\&]+\&group_allfolders\&[^\&]+\&group_folder_(\w+)\&/) {
2538: my $group = $1;
2539: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2540: if ($url =~ /group_boards_\Q$group\E/) {
2541: my %curr_group = &Apache::longroup::coursegroups($cdom,$cnum,$group);
2542: my %groupsettings = &Apache::longroup::get_group_settings($curr_group{$group});
2543: if (keys(%groupsettings) > 0) {
2544: if (ref($groupsettings{'functions'}) eq 'HASH') {
2545: if ($groupsettings{'functions'}{'discussion'} eq 'on') {
2546: $noremove=1;
2547: }
2548: }
2549: }
2550: $nocut=1;
2551: $nocopy=1;
2552: }
2553: }
1.517 raeburn 2554: my ($copylink,$cutlink,$removelink);
1.329 droeschl 2555: my $skip_confirm = 0;
2556: if ( $folder =~ /^supplemental/
2557: || ($url =~ m{( /smppg$
2558: |/syllabus$
2559: |/aboutme$
2560: |/navmaps$
2561: |/bulletinboard$
1.505 raeburn 2562: |\.html$)}x)
2563: || $isexternal) {
1.329 droeschl 2564: $skip_confirm = 1;
2565: }
2566:
1.508 raeburn 2567: if ($nocopy) {
1.507 raeburn 2568: $copylink=(<<ENDCOPY);
2569: <span style="visibility: hidden;">$lt{'cp'}</span>
2570: ENDCOPY
2571: } else {
1.329 droeschl 2572: $copylink=(<<ENDCOPY);
1.519 raeburn 2573: <a href="javascript:markcopy('$esc_path','$index','$renametitle','$container','$folder');" class="LC_docs_copy">$lt{'cp'}</a>
1.329 droeschl 2574: ENDCOPY
2575: }
1.508 raeburn 2576: if ($nocut) {
1.507 raeburn 2577: $cutlink=(<<ENDCUT);
2578: <span style="visibility: hidden;">$lt{'ct'}</span>
2579: ENDCUT
2580: } else {
1.329 droeschl 2581: $cutlink=(<<ENDCUT);
1.519 raeburn 2582: <a href="javascript:cutres('$esc_path','$index','$renametitle','$container','$folder',$skip_confirm);" class="LC_docs_cut">$lt{'ct'}</a>
1.329 droeschl 2583: ENDCUT
2584: }
1.507 raeburn 2585: if ($noremove) {
2586: $removelink=(<<ENDREM);
2587: <span style="visibility: hidden;">$lt{'rm'}</a>
2588: ENDREM
2589: } else {
1.497 raeburn 2590: $removelink=(<<ENDREM);
1.519 raeburn 2591: <a href='javascript:removeres("$esc_path","$index","$renametitle",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
1.497 raeburn 2592: ENDREM
2593: }
1.518 raeburn 2594: unless ($isexternal) {
2595: $renamelink=(<<ENDREN);
1.519 raeburn 2596: <a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.507 raeburn 2597: ENDREN
1.518 raeburn 2598: }
1.478 raeburn 2599: $form_start = '
2600: <form action="/adm/coursedocs" method="post">
2601: ';
2602: $form_common=(<<END);
1.535 ! raeburn 2603: <input type="hidden" name="folderpath" value="$path" />
! 2604: <input type="hidden" name="symb" value="$symb" />
1.329 droeschl 2605: <input type="hidden" name="setparms" value="$orderidx" />
2606: <input type="hidden" name="changeparms" value="0" />
2607: END
2608: $form_end = '</form>';
2609: $line.=(<<END);
2610: <td>
1.379 bisitz 2611: <div class="LC_docs_entry_move">
1.535 ! raeburn 2612: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb'>
1.501 raeburn 2613: <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
1.379 bisitz 2614: </a>
2615: </div>
2616: <div class="LC_docs_entry_move">
1.535 ! raeburn 2617: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&$symb=$symb'>
1.501 raeburn 2618: <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
1.379 bisitz 2619: </a>
2620: </div>
1.329 droeschl 2621: </td>
2622: <td>
2623: $form_start
1.478 raeburn 2624: $form_common
1.329 droeschl 2625: $selectbox
2626: $form_end
2627: </td>
1.507 raeburn 2628: <td class="LC_docs_entry_commands"><span class="LC_nobreak">
1.497 raeburn 2629: $removelink
1.329 droeschl 2630: $cutlink
2631: $copylink
1.507 raeburn 2632: </span>
1.329 droeschl 2633: </td>
2634: END
2635:
2636: }
2637: # Figure out what kind of a resource this is
2638: my ($extension)=($url=~/\.(\w+)$/);
2639: my $uploaded=($url=~/^\/*uploaded\//);
2640: my $icon=&Apache::loncommon::icon($url);
1.519 raeburn 2641: my $isfolder;
2642: my $ispage;
2643: my $containerarg;
1.329 droeschl 2644: if ($uploaded) {
1.472 raeburn 2645: if (($extension eq 'sequence') || ($extension eq 'page')) {
2646: $url=~/\Q$coursenum\E\/([\/\w]+)\.\Q$extension\E$/;
1.519 raeburn 2647: $containerarg = $1;
1.472 raeburn 2648: if ($extension eq 'sequence') {
2649: $icon=$iconpath.'navmap.folder.closed.gif';
2650: $isfolder=1;
2651: } else {
2652: $icon=$iconpath.'page.gif';
2653: $ispage=1;
2654: }
2655: if ($allowed) {
2656: $url='/adm/coursedocs?';
2657: } else {
2658: $url='/adm/supplemental?';
2659: }
1.329 droeschl 2660: } else {
2661: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
2662: }
2663: }
1.364 bisitz 2664:
1.518 raeburn 2665: my ($editlink,$extresform);
1.329 droeschl 2666: my $orig_url = $url;
1.340 raeburn 2667: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.510 raeburn 2668: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.501 raeburn 2669: if (!$supplementalflag && $residx && $symb) {
2670: if ((!$isfolder) && (!$ispage)) {
2671: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
2672: $url=&Apache::lonnet::clutter($url);
2673: if ($url=~/^\/*uploaded\//) {
2674: $url=~/\.(\w+)$/;
2675: my $embstyle=&Apache::loncommon::fileembstyle($1);
2676: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
2677: $url='/adm/wrapper'.$url;
2678: } elsif ($embstyle eq 'ssi') {
2679: #do nothing with these
2680: } elsif ($url!~/\.(sequence|page)$/) {
2681: $url='/adm/coursedocs/showdoc'.$url;
2682: }
2683: } elsif ($url=~m|^/ext/|) {
2684: $url='/adm/wrapper'.$url;
1.329 droeschl 2685: }
1.501 raeburn 2686: if (&Apache::lonnet::symbverify($symb,$url)) {
2687: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
2688: } else {
2689: $url='';
2690: }
1.329 droeschl 2691: }
2692: }
1.478 raeburn 2693: my ($rand_pick_text,$rand_order_text);
1.519 raeburn 2694: if ($isfolder || $ispage || $extension eq 'sequence' || $extension eq 'page') {
1.329 droeschl 2695: my $foldername=&escape($foldertitle);
2696: my $folderpath=$env{'form.folderpath'};
2697: if ($folderpath) { $folderpath.='&' };
1.510 raeburn 2698: if (!$allowed && $supplementalflag) {
1.519 raeburn 2699: $folderpath.=$containerarg.'&'.$foldername;
1.510 raeburn 2700: $url.='folderpath='.&escape($folderpath);
2701: } else {
1.344 bisitz 2702: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329 droeschl 2703: # so it gets transferred between levels
1.519 raeburn 2704: $folderpath.=$containerarg.'&'.$foldername.
1.510 raeburn 2705: ':'.(&LONCAPA::map::getparameter($orderidx,
1.329 droeschl 2706: 'parameter_randompick'))[0]
2707: .':'.((&LONCAPA::map::getparameter($orderidx,
2708: 'parameter_hiddenresource'))[0]=~/^yes$/i)
2709: .':'.((&LONCAPA::map::getparameter($orderidx,
2710: 'parameter_encrypturl'))[0]=~/^yes$/i)
2711: .':'.((&LONCAPA::map::getparameter($orderidx,
1.519 raeburn 2712: 'parameter_randomorder'))[0]=~/^yes$/i)
2713: .':'.$ispage;
1.510 raeburn 2714: $url.='folderpath='.&escape($folderpath);
2715: my $rpicknum = (&LONCAPA::map::getparameter($orderidx,
2716: 'parameter_randompick'))[0];
2717: my $rpckchk;
2718: if ($rpicknum) {
2719: $rpckchk = ' checked="checked"';
2720: }
2721: my $formname = 'edit_rpick_'.$orderidx;
2722: $rand_pick_text =
1.478 raeburn 2723: '<form action="/adm/coursedocs" method="post" name="'.$formname.'">'."\n".
2724: $form_common."\n".
2725: '<span class="LC_nobreak"><label><input type="checkbox" name="randpickon_'.$orderidx.'" id="rpick_'.$orderidx.'" onclick="'."updatePick(this.form,'$orderidx','check');".'"'.$rpckchk.' /> '.&mt('Randomly Pick').'</label><input type="hidden" name="randompick_'.$orderidx.'" id="rpicknum_'.$orderidx.'" value="'.$rpicknum.'" />';
1.510 raeburn 2726: if ($rpicknum ne '') {
2727: $rand_pick_text .= ': <a href="javascript:updatePick('."document.$formname,'$orderidx','link'".')">'.$rpicknum.'</a>';
2728: }
2729: $rand_pick_text .= '</span></form>';
2730: my $ro_set=
2731: ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
2732: $rand_order_text =
1.478 raeburn 2733: $form_start.
2734: $form_common.'
2735: <span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="'."this.form.changeparms.value='randomorder';this.form.submit()".'" '.$ro_set.' /> '.&mt('Random Order').' </label></span></form>';
1.510 raeburn 2736: }
1.509 raeburn 2737: } elsif ($supplementalflag && !$allowed) {
1.510 raeburn 2738: $url .= ($url =~ /\?/) ? '&':'?';
1.509 raeburn 2739: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.510 raeburn 2740: if ($title) {
2741: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
2742: }
1.511 raeburn 2743: if ($isexternal && $orderidx) {
1.510 raeburn 2744: $url .= '&idx='.$orderidx;
2745: }
1.329 droeschl 2746: }
1.519 raeburn 2747: my ($tdalign,$tdwidth);
1.501 raeburn 2748: if ($allowed) {
2749: my $fileloc =
2750: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.510 raeburn 2751: if ($isexternal) {
1.518 raeburn 2752: ($editlink,$extresform) =
1.510 raeburn 2753: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
1.511 raeburn 2754: } elsif (!$isfolder && !$ispage) {
1.503 raeburn 2755: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
2756: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.511 raeburn 2757: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
1.501 raeburn 2758: my $jscall =
2759: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
2760: $switchserver,
1.503 raeburn 2761: $forceedit,
1.511 raeburn 2762: undef,$symb,
2763: &escape($env{'form.folderpath'}),
1.524 raeburn 2764: $renametitle,'','',1);
1.501 raeburn 2765: if ($jscall) {
1.518 raeburn 2766: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
2767: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.501 raeburn 2768: }
2769: }
2770: }
1.519 raeburn 2771: $tdalign = ' align="right" valign="top"';
2772: $tdwidth = ' width="80%"';
1.329 droeschl 2773: }
1.408 raeburn 2774: my $reinit;
2775: if ($crstype eq 'Community') {
2776: $reinit = &mt('(re-initialize community to access)');
2777: } else {
2778: $reinit = &mt('(re-initialize course to access)');
1.519 raeburn 2779: }
2780: $line.='<td class="LC_docs_entry_commands"'.$tdalign.'><span class="LC_nobreak">'.$editlink.$renamelink;
1.472 raeburn 2781: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 2782: $line.='<a href="'.$url.'"><img src="'.$icon.'" alt="" class="LC_icon" /></a>';
2783: } elsif ($url) {
1.484 raeburn 2784: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 2785: '<img src="'.$icon.'" alt="" class="LC_icon" />',600,500);
1.469 www 2786: } else {
2787: $line.='<img src="'.$icon.'" alt="" class="LC_icon" />';
2788: }
1.519 raeburn 2789: $line.='</span></td><td'.$tdwidth.'>';
1.472 raeburn 2790: if (($url=~m{/adm/(coursedocs|supplemental)}) || (!$allowed && $url)) {
1.469 www 2791: $line.='<a href="'.$url.'">'.$title.'</a>';
2792: } elsif ($url) {
1.484 raeburn 2793: $line.=&Apache::loncommon::modal_link($url.(($url=~/\?/)?'&':'?').'inhibitmenu=yes',
1.470 raeburn 2794: $title,600,500);
1.469 www 2795: } else {
2796: $line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
2797: }
1.518 raeburn 2798: $line.="$extresform</td>";
1.478 raeburn 2799: $rand_pick_text = ' ' if ($rand_pick_text eq '');
2800: $rand_order_text = ' ' if ($rand_order_text eq '');
1.329 droeschl 2801: if (($allowed) && ($folder!~/^supplemental/)) {
2802: my %lt=&Apache::lonlocal::texthash(
2803: 'hd' => 'Hidden',
2804: 'ec' => 'URL hidden');
2805: my $enctext=
1.358 bisitz 2806: ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
1.329 droeschl 2807: my $hidtext=
1.358 bisitz 2808: ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
1.329 droeschl 2809: $line.=(<<ENDPARMS);
2810: <td class="LC_docs_entry_parameter">
2811: $form_start
1.478 raeburn 2812: $form_common
1.369 bisitz 2813: <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
1.329 droeschl 2814: $form_end
1.458 raeburn 2815: <br />
1.329 droeschl 2816: $form_start
1.478 raeburn 2817: $form_common
1.369 bisitz 2818: <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
1.329 droeschl 2819: $form_end
2820: </td>
1.478 raeburn 2821: <td class="LC_docs_entry_parameter">$rand_pick_text<br />
2822: $rand_order_text</td>
1.329 droeschl 2823: ENDPARMS
2824: }
1.379 bisitz 2825: $line.=&Apache::loncommon::end_data_table_row();
1.329 droeschl 2826: return $line;
2827: }
2828:
1.533 raeburn 2829: sub new_timebased_suffix {
2830: my ($coursedom,$coursenum,$type,$area,$container) = @_;
2831: my ($prefix,$namespace,$idtype,$errtext,$locknotfreed);
2832: if ($type eq 'map') {
2833: $prefix = 'docs';
2834: if ($area eq 'supplemental') {
2835: $prefix = 'supp';
2836: }
2837: $prefix .= $container;
2838: $namespace = 'uploadedmaps';
2839: } else {
2840: $prefix = $type;
2841: $namespace = 'templated';
1.504 raeburn 2842: }
2843: $idtype = 'concat';
2844: my ($suffix,$freedlock,$error) =
1.533 raeburn 2845: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,
1.504 raeburn 2846: $coursedom,$coursenum);
2847: if (!$suffix) {
1.533 raeburn 2848: if ($type eq 'map') {
2849: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new folder/page.');
2850: } elsif ($type eq 'smppg') {
2851: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new simple page.');
2852: } else {
2853: $errtext = &mt('Failed to acquire a unique timestamp-based suffix for the new bulletin board.');
2854: }
1.504 raeburn 2855: if ($error) {
2856: $errtext .= '<br />'.$error;
2857: }
2858: }
2859: if ($freedlock ne 'ok') {
1.533 raeburn 2860: $locknotfreed =
2861: '<div class="LC_error">'.
2862: &mt('There was a problem removing a lockfile.').' ';
2863: if ($type eq 'map') {
2864: &mt('This will prevent creation of additional folders or composite pages in this course.');
2865: } elsif ($type eq 'smppg') {
2866: $locknotfreed .=
2867: &mt('This will prevent creation of additional simple pages in this course.');
2868: } else {
2869: $locknotfreed .=
2870: &mt('This will prevent creation of additional bulletin boards in this course.');
2871: }
2872: $locknotfreed .=
2873: ' '.&mt('Please contact the domain coordinator for your LON-CAPA domain.').
2874: '</div>';
1.504 raeburn 2875: }
2876: return ($suffix,$errtext,$locknotfreed);
2877: }
2878:
1.329 droeschl 2879: =pod
2880:
2881: =item tiehash()
2882:
2883: tie the hash
2884:
2885: =cut
2886:
2887: sub tiehash {
2888: my ($mode)=@_;
2889: $hashtied=0;
2890: if ($env{'request.course.fn'}) {
2891: if ($mode eq 'write') {
2892: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
2893: &GDBM_WRCREAT(),0640)) {
2894: $hashtied=2;
2895: }
2896: } else {
2897: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
2898: &GDBM_READER(),0640)) {
2899: $hashtied=1;
2900: }
2901: }
1.364 bisitz 2902: }
1.329 droeschl 2903: }
2904:
2905: sub untiehash {
2906: if ($hashtied) { untie %hash; }
2907: $hashtied=0;
2908: return OK;
2909: }
2910:
2911:
2912:
2913:
2914: sub checkonthis {
2915: my ($r,$url,$level,$title)=@_;
2916: $url=&unescape($url);
2917: $alreadyseen{$url}=1;
2918: $r->rflush();
2919: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
2920: $r->print("\n<br />");
2921: if ($level==0) {
2922: $r->print("<br />");
2923: }
2924: for (my $i=0;$i<=$level*5;$i++) {
2925: $r->print(' ');
2926: }
2927: $r->print('<a href="'.$url.'" target="cat">'.
2928: ($title?$title:$url).'</a> ');
2929: if ($url=~/^\/res\//) {
2930: my $result=&Apache::lonnet::repcopy(
2931: &Apache::lonnet::filelocation('',$url));
2932: if ($result eq 'ok') {
2933: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
2934: $r->rflush();
2935: &Apache::lonnet::countacc($url);
2936: $url=~/\.(\w+)$/;
2937: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
2938: $r->print('<br />');
2939: $r->rflush();
2940: for (my $i=0;$i<=$level*5;$i++) {
2941: $r->print(' ');
2942: }
2943: $r->print('- '.&mt('Rendering:').' ');
2944: my ($errorcount,$warningcount)=split(/:/,
2945: &Apache::lonnet::ssi_body($url,
2946: ('grade_target'=>'web',
2947: 'return_only_error_and_warning_counts' => 1)));
2948: if (($errorcount) ||
2949: ($warningcount)) {
2950: if ($errorcount) {
1.369 bisitz 2951: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 2952: &mt('[quant,_1,error]',$errorcount).'</span>');
2953: }
2954: if ($warningcount) {
2955: $r->print('<span class="LC_warning">'.
2956: &mt('[quant,_1,warning]',$warningcount).'</span>');
2957: }
2958: } else {
2959: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
2960: }
2961: $r->rflush();
2962: }
2963: my $dependencies=
2964: &Apache::lonnet::metadata($url,'dependencies');
2965: foreach my $dep (split(/\,/,$dependencies)) {
2966: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
2967: &checkonthis($r,$dep,$level+1);
2968: }
2969: }
2970: } elsif ($result eq 'unavailable') {
2971: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
2972: } elsif ($result eq 'not_found') {
2973: unless ($url=~/\$/) {
1.521 bisitz 2974: $r->print('<span class="LC_error">'.&mt('not found').'</span>');
1.329 droeschl 2975: } else {
1.366 bisitz 2976: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 2977: }
2978: } else {
2979: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
2980: }
2981: }
2982: }
2983: }
2984:
2985:
2986:
2987: =pod
2988:
2989: =item list_symbs()
2990:
1.485 raeburn 2991: List Content Identifiers
1.329 droeschl 2992:
2993: =cut
2994:
2995: sub list_symbs {
2996: my ($r) = @_;
2997:
1.408 raeburn 2998: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 2999: $r->print(&Apache::loncommon::start_page('List of Content Identifiers'));
3000: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Content Identifiers'));
3001: $r->print(&startContentScreen('tools'));
1.329 droeschl 3002: my $navmap = Apache::lonnavmaps::navmap->new();
3003: if (!defined($navmap)) {
3004: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
3005: '<div class="LC_error">'.
3006: &mt('Unable to retrieve information about course contents').
3007: '</div>');
1.408 raeburn 3008: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
1.329 droeschl 3009: } else {
1.484 raeburn 3010: $r->print('<h4 class="LC_info">'.&mt("$crstype Content Identifiers").'</h4>'.
3011: &Apache::loncommon::start_data_table().
3012: &Apache::loncommon::start_data_table_header_row().
3013: '<th>'.&mt('Title').'</th><th>'.&mt('Identifier').'</th>'.
3014: &Apache::loncommon::end_data_table_header_row()."\n");
3015: my $count;
1.329 droeschl 3016: foreach my $res ($navmap->retrieveResources()) {
1.484 raeburn 3017: $r->print(&Apache::loncommon::start_data_table_row().
3018: '<td>'.$res->compTitle().'</td>'.
3019: '<td>'.$res->symb().'</td>'.
1.521 bisitz 3020: &Apache::loncommon::end_data_table_row());
1.484 raeburn 3021: $count ++;
3022: }
3023: if (!$count) {
3024: $r->print(&Apache::loncommon::start_data_table_row().
3025: '<td colspan="2">'.&mt("$crstype is empty").'</td>'.
3026: &Apache::loncommon::end_data_table_row());
1.329 droeschl 3027: }
1.484 raeburn 3028: $r->print(&Apache::loncommon::end_data_table());
1.329 droeschl 3029: }
1.521 bisitz 3030: $r->print(&endContentScreen());
1.329 droeschl 3031: }
3032:
3033:
3034: sub verifycontent {
3035: my ($r) = @_;
1.408 raeburn 3036: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3037: $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
3038: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
3039: $r->print(&startContentScreen('tools'));
3040: $r->print('<h4 class="LC_info">'.&mt($crstype.' content verification').'</h4>');
1.329 droeschl 3041: $hashtied=0;
3042: undef %alreadyseen;
3043: %alreadyseen=();
3044: &tiehash();
1.484 raeburn 3045:
1.329 droeschl 3046: foreach my $key (keys(%hash)) {
3047: if ($hash{$key}=~/\.(page|sequence)$/) {
3048: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
3049: $r->print('<hr /><span class="LC_error">'.
1.419 bisitz 3050: &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
1.329 droeschl 3051: &unescape($hash{$key}).'</span><br />'.
1.419 bisitz 3052: &mt('Note that grading records for problems included in this sequence or folder will overlap.').'<hr />');
1.329 droeschl 3053: }
3054: }
3055: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
3056: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
3057: }
3058: }
3059: &untiehash();
1.442 www 3060: $r->print('<p class="LC_success">'.&mt('Done').'</p>');
1.521 bisitz 3061: $r->print(&endContentScreen());
1.329 droeschl 3062: }
3063:
3064:
3065: sub devalidateversioncache {
3066: my $src=shift;
3067: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
3068: &Apache::lonnet::clutter($src));
3069: }
3070:
3071: sub checkversions {
3072: my ($r) = @_;
1.408 raeburn 3073: my $crstype = &Apache::loncommon::course_type();
3074: $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
3075: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
1.484 raeburn 3076: $r->print(&startContentScreen('tools'));
1.442 www 3077:
1.329 droeschl 3078: my $header='';
3079: my $startsel='';
3080: my $monthsel='';
3081: my $weeksel='';
3082: my $daysel='';
3083: my $allsel='';
3084: my %changes=();
3085: my $starttime=0;
3086: my $haschanged=0;
3087: my %setversions=&Apache::lonnet::dump('resourceversions',
3088: $env{'course.'.$env{'request.course.id'}.'.domain'},
3089: $env{'course.'.$env{'request.course.id'}.'.num'});
3090:
3091: $hashtied=0;
3092: &tiehash();
3093: my %newsetversions=();
3094: if ($env{'form.setmostrecent'}) {
3095: $haschanged=1;
3096: foreach my $key (keys(%hash)) {
3097: if ($key=~/^ids\_(\/res\/.+)$/) {
3098: $newsetversions{$1}='mostrecent';
3099: &devalidateversioncache($1);
3100: }
3101: }
3102: } elsif ($env{'form.setcurrent'}) {
3103: $haschanged=1;
3104: foreach my $key (keys(%hash)) {
3105: if ($key=~/^ids\_(\/res\/.+)$/) {
3106: my $getvers=&Apache::lonnet::getversion($1);
3107: if ($getvers>0) {
3108: $newsetversions{$1}=$getvers;
3109: &devalidateversioncache($1);
3110: }
3111: }
3112: }
3113: } elsif ($env{'form.setversions'}) {
3114: $haschanged=1;
3115: foreach my $key (keys(%env)) {
3116: if ($key=~/^form\.set_version_(.+)$/) {
3117: my $src=$1;
3118: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
3119: $newsetversions{$src}=$env{$key};
3120: &devalidateversioncache($src);
3121: }
3122: }
3123: }
3124: }
3125: if ($haschanged) {
3126: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
3127: $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344 bisitz 3128: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.479 golterma 3129: $r->print(&Apache::loncommon::confirmwrapper(
3130: &Apache::lonhtmlcommon::confirm_success(&mt('Your Version Settings have been Saved'))));
1.329 droeschl 3131: } else {
1.479 golterma 3132: $r->print(&Apache::loncommon::confirmwrapper(
3133: &Apache::lonhtmlcommon::confirm_success(&mt('An Error Occured while Attempting to Save your Version Settings'),1)));
1.329 droeschl 3134: }
3135: &mark_hash_old();
3136: }
3137: &changewarning($r,'');
3138: if ($env{'form.timerange'} eq 'all') {
3139: # show all documents
1.408 raeburn 3140: $header=&mt('All Documents in '.$crstype);
1.521 bisitz 3141: $allsel=' selected="selected"';
1.329 droeschl 3142: foreach my $key (keys(%hash)) {
3143: if ($key=~/^ids\_(\/res\/.+)$/) {
3144: my $src=$1;
3145: $changes{$src}=1;
3146: }
3147: }
3148: } else {
3149: # show documents which changed
3150: %changes=&Apache::lonnet::dump
3151: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
3152: $env{'course.'.$env{'request.course.id'}.'.num'});
3153: my $firstkey=(keys(%changes))[0];
3154: unless ($firstkey=~/^error\:/) {
3155: unless ($env{'form.timerange'}) {
3156: $env{'form.timerange'}=604800;
3157: }
3158: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
3159: .&mt('seconds');
3160: if ($env{'form.timerange'}==-1) {
3161: $seltext='since start of course';
1.521 bisitz 3162: $startsel=' selected="selected"';
1.329 droeschl 3163: $env{'form.timerange'}=time;
3164: }
3165: $starttime=time-$env{'form.timerange'};
3166: if ($env{'form.timerange'}==2592000) {
3167: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 3168: $monthsel=' selected="selected"';
1.329 droeschl 3169: } elsif ($env{'form.timerange'}==604800) {
3170: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 3171: $weeksel=' selected="selected"';
1.329 droeschl 3172: } elsif ($env{'form.timerange'}==86400) {
3173: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.521 bisitz 3174: $daysel=' selected="selected"';
1.329 droeschl 3175: }
3176: $header=&mt('Content changed').' '.$seltext;
3177: } else {
3178: $header=&mt('No content modifications yet.');
3179: }
3180: }
3181: %setversions=&Apache::lonnet::dump('resourceversions',
3182: $env{'course.'.$env{'request.course.id'}.'.domain'},
3183: $env{'course.'.$env{'request.course.id'}.'.num'});
3184: my %lt=&Apache::lonlocal::texthash
1.408 raeburn 3185: ('st' => 'Version changes since start of '.$crstype,
1.329 droeschl 3186: 'lm' => 'Version changes since last Month',
3187: 'lw' => 'Version changes since last Week',
3188: 'sy' => 'Version changes since Yesterday',
3189: 'al' => 'All Resources (possibly large output)',
1.484 raeburn 3190: 'cd' => 'Change display',
1.329 droeschl 3191: 'sd' => 'Display',
3192: 'fi' => 'File',
3193: 'md' => 'Modification Date',
3194: 'mr' => 'Most recently published Version',
1.408 raeburn 3195: 've' => 'Version used in '.$crstype,
3196: 'vu' => 'Set Version to be used in '.$crstype,
3197: 'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
1.329 droeschl 3198: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
3199: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
1.479 golterma 3200: 'di' => 'Differences',
1.484 raeburn 3201: 'save' => 'Save changes',
3202: 'vers' => 'Version choice(s) for specific resources',
1.479 golterma 3203: 'act' => 'Actions');
1.329 droeschl 3204: $r->print(<<ENDHEADERS);
1.484 raeburn 3205: <h4 class="LC_info">$header</h4>
1.329 droeschl 3206: <form action="/adm/coursedocs" method="post">
3207: <input type="hidden" name="versions" value="1" />
1.484 raeburn 3208: <div class="LC_left_float">
1.479 golterma 3209: <fieldset>
1.484 raeburn 3210: <legend>$lt{'cd'}</legend>
1.329 droeschl 3211: <select name="timerange">
1.521 bisitz 3212: <option value='all'$allsel>$lt{'al'}</option>
3213: <option value="-1"$startsel>$lt{'st'}</option>
3214: <option value="2592000"$monthsel>$lt{'lm'}</option>
3215: <option value="604800"$weeksel>$lt{'lw'}</option>
3216: <option value="86400"$daysel>$lt{'sy'}</option>
1.329 droeschl 3217: </select>
3218: <input type="submit" name="display" value="$lt{'sd'}" />
1.484 raeburn 3219: </fieldset>
3220: </div>
3221: <div class="LC_left_float">
3222: <fieldset>
3223: <legend>$lt{'act'}</legend>
3224: $lt{'sm'}: <input type="submit" name="setmostrecent" value="Go" /><br />
3225: $lt{'sc'}: <input type="submit" name="setcurrent" value="Go" />
3226: </fieldset>
3227: </div>
3228: <br clear="all" />
3229: <hr />
3230: <h4>$lt{'vers'}</h4>
1.479 golterma 3231: <input type="submit" name="setversions" value="$lt{'save'}" />
1.329 droeschl 3232: ENDHEADERS
1.479 golterma 3233: #number of columns for version history
3234: $r->print(
1.521 bisitz 3235: &Apache::loncommon::start_data_table().
3236: &Apache::loncommon::start_data_table_header_row().
3237: '<th>'.&mt('Resources').'</th>'.
3238: "<th>$lt{'mr'}</th>".
3239: "<th>$lt{'ve'}</th>".
3240: "<th>$lt{'vu'}</th>".
3241: '<th>'.&mt('History').'</th>'.
3242: &Apache::loncommon::end_data_table_header_row()
3243: );
1.329 droeschl 3244: foreach my $key (sort(keys(%changes))) {
1.496 golterma 3245: #excludes not versionable problems from resource version history:
1.521 bisitz 3246: next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/);
3247: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
3248: my $currentversion=&Apache::lonnet::getversion($key);
3249: if ($currentversion<0) {
3250: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
3251: }
3252: my $linkurl=&Apache::lonnet::clutter($key);
1.479 golterma 3253: $r->print(
3254: &Apache::loncommon::start_data_table_row().
1.521 bisitz 3255: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
1.479 golterma 3256: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
1.521 bisitz 3257: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br />('.
1.479 golterma 3258: &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')</span></td>'.
1.521 bisitz 3259: '<td align="right">'
3260: );
3261: # Used in course
3262: my $usedversion=$hash{'version_'.$linkurl};
3263: if (($usedversion) && ($usedversion ne 'mostrecent')) {
3264: if ($usedversion != $currentversion) {
1.479 golterma 3265: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
1.521 bisitz 3266: } else {
1.479 golterma 3267: $r->print($usedversion);
3268: }
1.329 droeschl 3269: } else {
1.521 bisitz 3270: $r->print($currentversion);
1.329 droeschl 3271: }
1.521 bisitz 3272: $r->print('</td><td title="'.$lt{'vu'}.'">');
3273: # Set version
3274: $r->print(&Apache::loncommon::select_form(
3275: $setversions{$linkurl},
3276: 'set_version_'.$linkurl,
3277: {'select_form_order' => ['',1..$currentversion,'mostrecent'],
3278: '' => '',
3279: 'mostrecent' => &mt('most recent'),
3280: map {$_,$_} (1..$currentversion)}));
3281: my $lastold=1;
3282: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
3283: my $url=$root.'.'.$prevvers.'.'.$extension;
3284: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<$starttime) {
3285: $lastold=$prevvers;
3286: }
3287: }
3288: $r->print('</td>');
3289: # List all available versions
3290: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
3291: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
3292: my $url=$root.'.'.$prevvers.'.'.$extension;
3293: $r->print(
3294: '<span class="LC_nobreak">'
3295: .'<a href="'.&Apache::lonnet::clutter($url).'">'
3296: .&mt('Version [_1]',$prevvers).'</a>'
3297: .' ('.&Apache::lonlocal::locallocaltime(
3298: &Apache::lonnet::metadata($url,'lastrevisiondate'))
3299: .')');
3300: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
3301: $r->print(
3302: ' <a href="/adm/diff?filename='.
3303: &Apache::lonnet::clutter($root.'.'.$extension).
3304: &HTML::Entities::encode('&versionone='.$prevvers,'"<>&').
3305: '" target="diffs">'.&mt('Diffs').'</a>');
1.329 droeschl 3306: }
1.521 bisitz 3307: $r->print('</span><br />');
3308: }
3309: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.329 droeschl 3310: }
1.521 bisitz 3311: $r->print(
3312: &Apache::loncommon::end_data_table().
3313: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />'.
3314: '</form>'
3315: );
1.329 droeschl 3316:
3317: &untiehash();
1.521 bisitz 3318: $r->print(&endContentScreen());
1.329 droeschl 3319: }
3320:
3321: sub mark_hash_old {
3322: my $retie_hash=0;
3323: if ($hashtied) {
3324: $retie_hash=1;
3325: &untiehash();
3326: }
3327: &tiehash('write');
3328: $hash{'old'}=1;
3329: &untiehash();
3330: if ($retie_hash) { &tiehash(); }
3331: }
3332:
3333: sub is_hash_old {
3334: my $untie_hash=0;
3335: if (!$hashtied) {
3336: $untie_hash=1;
3337: &tiehash();
3338: }
3339: my $return=$hash{'old'};
3340: if ($untie_hash) { &untiehash(); }
3341: return $return;
3342: }
3343:
3344: sub changewarning {
3345: my ($r,$postexec,$message,$url)=@_;
3346: if (!&is_hash_old()) { return; }
3347: my $pathvar='folderpath';
3348: my $path=&escape($env{'form.folderpath'});
3349: if (!defined($url)) {
3350: $url='/adm/coursedocs?'.$pathvar.'='.$path;
3351: }
3352: my $course_type = &Apache::loncommon::course_type();
3353: if (!defined($message)) {
3354: $message='Changes will become active for your current session after [_1], or the next time you log in.';
3355: }
3356: $r->print("\n\n".
1.372 bisitz 3357: '<script type="text/javascript">'."\n".
3358: '// <![CDATA['."\n".
3359: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
3360: '// ]]>'."\n".
1.369 bisitz 3361: '</script>'."\n".
1.375 tempelho 3362: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 3363: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 3364: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 3365: &mt($message,' <input type="hidden" name="'.
3366: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 3367: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 3368: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 3369: }
3370:
3371:
3372: sub init_breadcrumbs {
3373: my ($form,$text)=@_;
3374: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 3375: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 3376: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 3377: faq=>273,
3378: bug=>'Instructor Interface',
3379: help => 'Docs_Adding_Course_Doc'});
3380: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
3381: text=>$text,
3382: faq=>273,
3383: bug=>'Instructor Interface'});
3384: }
3385:
1.441 www 3386: # subroutine to list form elements
3387: sub create_list_elements {
3388: my @formarr = @_;
3389: my $list = '';
1.501 raeburn 3390: foreach my $button (@formarr){
3391: foreach my $picture (keys(%{$button})) {
3392: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
1.441 www 3393: }
3394: }
3395: return $list;
3396: }
1.329 droeschl 3397:
1.441 www 3398: # subroutine to create ul from list elements
3399: sub create_form_ul {
3400: my $list = shift;
3401: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
3402: return $ul;
3403: }
1.329 droeschl 3404:
1.442 www 3405: #
3406: # Start tabs
3407: #
3408:
3409: sub startContentScreen {
1.484 raeburn 3410: my ($mode) = @_;
3411: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 3412: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 3413: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
3414: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
3415: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
3416: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
3417: } else {
3418: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'."\n";
3419: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
3420: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
3421: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
3422: }
3423: $output .= "\n".'</ul>'."\n";
3424: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
3425: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
3426: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
3427: return $output;
1.442 www 3428: }
3429:
3430: #
3431: # End tabs
3432: #
3433:
3434: sub endContentScreen {
1.484 raeburn 3435: return '</div></div></div>';
1.442 www 3436: }
1.329 droeschl 3437:
1.446 www 3438: sub supplemental_base {
1.472 raeburn 3439: return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
1.446 www 3440: }
3441:
1.329 droeschl 3442: sub handler {
3443: my $r = shift;
3444: &Apache::loncommon::content_type($r,'text/html');
3445: $r->send_http_header;
3446: return OK if $r->header_only;
1.484 raeburn 3447:
3448: # get course data
1.408 raeburn 3449: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3450: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
3451: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3452:
3453: # graphics settings
3454: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 3455:
1.443 www 3456: #
1.329 droeschl 3457: # --------------------------------------------- Initialize help topics for this
3458: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
3459: 'Adding_External_Resource','Navigate_Content',
3460: 'Adding_Folders','Docs_Overview', 'Load_Map',
3461: 'Supplemental','Score_Upload_Form','Adding_Pages',
1.501 raeburn 3462: 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
3463: 'Uploading_From_Harddrive',
1.329 droeschl 3464: 'Check_Resource_Versions','Verify_Content') {
3465: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
3466: }
3467: # Composite help files
3468: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
3469: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
3470: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
3471: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
3472: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
3473: 'Option_Response_Simple');
3474: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
3475: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 3476: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 3477: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 3478: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 3479: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.534 raeburn 3480: $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
3481: $help{'Web Page'} = &Apache::loncommon::help_open_topic('Docs_Web_Page');
3482:
1.472 raeburn 3483: my $allowed;
3484: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
3485: unless ($r->uri eq '/adm/supplemental') {
3486: # does this user have privileges to modify content.
3487: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
3488: }
3489:
1.484 raeburn 3490: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
3491: 'inhibitmenu']);
3492: if ($allowed && $env{'form.chooseserver'}) {
3493: &choose_dump_server($r);
3494: return OK;
3495: } elsif ($allowed && $env{'form.verify'}) {
1.329 droeschl 3496: &init_breadcrumbs('verify','Verify Content');
3497: &verifycontent($r);
3498: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 3499: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 3500: &list_symbs($r);
3501: } elsif ($allowed && $env{'form.docslog'}) {
3502: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 3503: my $folder = $env{'form.folder'};
3504: if ($folder eq '') {
3505: $folder='default';
3506: }
3507: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 3508: } elsif ($allowed && $env{'form.versions'}) {
3509: &init_breadcrumbs('versions','Check/Set Resource Versions');
3510: &checkversions($r);
3511: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.484 raeburn 3512: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 3513: &dumpcourse($r);
3514: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 3515: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 3516: &Apache::imsexport::exportcourse($r);
1.329 droeschl 3517: } else {
1.445 www 3518: #
3519: # Done catching special calls
1.484 raeburn 3520: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 3521: # Get the parameters that may be needed
3522: #
3523: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.519 raeburn 3524: ['folderpath',
3525: 'forcesupplement','forcestandard',
1.510 raeburn 3526: 'tools','symb','command','supppath']);
1.445 www 3527:
3528: # standard=1: this is a "new-style" course with an uploaded map as top level
3529: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 3530:
3531: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 3532:
1.484 raeburn 3533: # Decide whether this should display supplemental or main content or utilities
1.445 www 3534: # supplementalflag=1: show supplemental documents
3535: # supplementalflag=0: show standard documents
1.484 raeburn 3536: # toolsflag=1: show utilities
1.445 www 3537:
3538:
3539: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.519 raeburn 3540: if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
1.445 www 3541: $supplementalflag=0;
3542: }
3543: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
3544: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
3545: unless ($allowed) { $supplementalflag=1; }
3546: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 3547: my $toolsflag=0;
3548: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 3549:
1.329 droeschl 3550: my $script='';
3551: my $showdoc=0;
1.457 raeburn 3552: my $addentries = {};
1.475 raeburn 3553: my $container;
1.329 droeschl 3554: my $containertag;
1.508 raeburn 3555: my $pathitem;
1.329 droeschl 3556:
1.464 www 3557: # Do we directly jump somewhere?
1.466 www 3558:
1.525 raeburn 3559: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 3560: if ($env{'form.symb'} ne '') {
1.522 raeburn 3561: $env{'form.folderpath'}=
3562: &Apache::loncommon::symb_to_docspath($env{'form.symb'});
1.530 raeburn 3563: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 3564: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 3565: } elsif ($env{'form.supppath'} ne '') {
3566: $env{'form.folderpath'}=$env{'form.supppath'};
1.530 raeburn 3567: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
1.525 raeburn 3568: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 3569: }
1.472 raeburn 3570: } elsif ($env{'form.command'} eq 'editdocs') {
1.525 raeburn 3571: $env{'form.folderpath'} = 'default&'.
3572: &Apache::lonhtmlcommon::entity_encode('Main Course Content').
3573: ':::::';
3574: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 3575: } elsif ($env{'form.command'} eq 'editsupp') {
1.525 raeburn 3576: $env{'form.folderpath'} = 'supplemental&'.
1.472 raeburn 3577: &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
1.525 raeburn 3578: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
3579: } elsif ($env{'form.command'} eq 'contents') {
3580: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
3581: } elsif ($env{'form.command'} eq 'home') {
3582: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 3583: }
3584:
1.525 raeburn 3585:
1.445 www 3586: # Where do we store these for when we come back?
3587: my $stored_folderpath='docs_folderpath';
3588: if ($supplementalflag) {
3589: $stored_folderpath='docs_sup_folderpath';
3590: }
1.464 www 3591:
1.519 raeburn 3592: # No folderpath, and in edit mode, see if we have something stored
3593: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 3594: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.510 raeburn 3595: {'folderpath' => 'scalar'});
1.523 raeburn 3596: unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
3597: undef($env{'form.folderpath'});
3598: }
1.329 droeschl 3599: }
1.446 www 3600:
3601: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 3602: if (!$allowed) {
1.446 www 3603: unless ($env{'form.folderpath'} =~ /^supplemental/) {
3604: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 3605: }
3606: }
1.446 www 3607: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 3608: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 3609: $env{'form.folderpath'} = &supplemental_base()
3610: .'&'.
1.329 droeschl 3611: $env{'form.folderpath'};
3612: }
1.446 www 3613: # If after all of this, we still don't have any paths, make them
1.519 raeburn 3614: unless ($env{'form.folderpath'}) {
1.446 www 3615: if ($supplementalflag) {
3616: $env{'form.folderpath'}=&supplemental_base();
3617: } else {
1.519 raeburn 3618: $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Documents')).
3619: ':::::';
1.446 www 3620: }
1.472 raeburn 3621: }
1.446 www 3622:
1.445 www 3623: # Store this
1.484 raeburn 3624: unless ($toolsflag) {
1.510 raeburn 3625: if ($allowed) {
3626: &Apache::loncommon::store_course_settings($stored_folderpath,
1.519 raeburn 3627: {'folderpath' => 'scalar'});
1.510 raeburn 3628: }
1.519 raeburn 3629: my $folderpath;
1.484 raeburn 3630: if ($env{'form.folderpath'}) {
1.519 raeburn 3631: $folderpath = $env{'form.folderpath'};
3632: my (@folders)=split('&',$env{'form.folderpath'});
3633: $env{'form.foldername'}=&unescape(pop(@folders));
3634: if ($env{'form.foldername'} =~ /\:1$/) {
3635: $container = 'page';
3636: } else {
3637: $container = 'sequence';
3638: }
3639: $env{'form.folder'}=pop(@folders);
1.484 raeburn 3640: } else {
1.519 raeburn 3641: if ($env{'form.folder'} eq '' ||
3642: $env{'form.folder'} eq 'supplemental') {
3643: $folderpath='default&'.
3644: &escape(&mt('Main '.$crstype.' Documents')).
3645: ':::::';
1.484 raeburn 3646: }
3647: }
1.519 raeburn 3648: $containertag = '<input type="hidden" name="folderpath" value="" />';
3649: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 3650: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
3651: $showdoc='/'.$1;
3652: }
3653: if ($showdoc) { # got called in sequence from course
3654: $allowed=0;
3655: } else {
3656: if ($allowed) {
3657: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
3658: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 3659: }
3660: }
1.329 droeschl 3661: }
3662:
1.344 bisitz 3663: # get personal data
1.329 droeschl 3664: my $uname=$env{'user.name'};
3665: my $udom=$env{'user.domain'};
3666: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
3667:
3668: if ($allowed) {
1.484 raeburn 3669: if ($toolsflag) {
3670: $script .= &inject_data_js();
3671: my ($home,$other,%outhash)=&authorhosts();
3672: if (!$home && $other) {
3673: my @hosts;
3674: foreach my $aurole (keys(%outhash)) {
3675: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
3676: push(@hosts,$outhash{$aurole});
3677: }
3678: }
3679: $script .= &dump_switchserver_js(@hosts);
3680: }
1.458 raeburn 3681: } else {
1.484 raeburn 3682: my @tabids;
3683: if ($supplementalflag) {
3684: @tabids = ('002','ee2','ff2');
3685: } else {
3686: @tabids = ('aa1','bb1','cc1','ff1');
1.519 raeburn 3687: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 3688: unshift(@tabids,'001');
3689: push(@tabids,('dd1','ee1'));
3690: }
1.458 raeburn 3691: }
1.484 raeburn 3692: my $tabidstr = join("','",@tabids);
3693: $script .= &editing_js($udom,$uname,$supplementalflag).
3694: &history_tab_js().
3695: &inject_data_js().
1.510 raeburn 3696: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
3697: &Apache::lonextresedit::extedit_javascript();
1.484 raeburn 3698: $addentries = {
1.485 raeburn 3699: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 3700: };
1.458 raeburn 3701: }
1.492 raeburn 3702: if ($env{'docs.markedcopy_url'}) {
3703: $script .= &paste_popup_js();
3704: }
1.501 raeburn 3705: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
3706: &mt('Switch server?');
3707:
3708:
1.329 droeschl 3709: }
3710: # -------------------------------------------------------------------- Body tag
1.369 bisitz 3711: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 3712: .'// <![CDATA['."\n"
3713: .$script."\n"
3714: .'// ]]>'."\n"
3715: .'</script>'."\n";
1.385 bisitz 3716:
3717: # Breadcrumbs
3718: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.510 raeburn 3719:
3720: if ($showdoc) {
3721: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
3722: {'force_register' => $showdoc,}));
3723: } elsif ($r->uri eq '/adm/supplemental') {
3724: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
3725: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
3726: {'bread_crumbs' => $brcrum,}));
3727: } else {
1.392 raeburn 3728: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 3729: href=>"/adm/coursedocs",text=>"$crstype Contents"});
1.392 raeburn 3730:
1.446 www 3731: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.510 raeburn 3732: {'add_entries' => $addentries}
3733: )
1.392 raeburn 3734: .&Apache::loncommon::help_open_menu('','',273,'RAT')
3735: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 3736: 'Editing '.$crstype.' Contents',
1.392 raeburn 3737: 'Docs_Adding_Course_Doc')
3738: );
3739: }
1.364 bisitz 3740:
1.329 droeschl 3741: my %allfiles = ();
3742: my %codebase = ();
1.440 raeburn 3743: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 3744: if ($allowed) {
3745: if (($env{'form.uploaddoc.filename'}) &&
3746: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 3747: my $context = $1;
3748: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 3749: undef($hadchanges);
1.440 raeburn 3750: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
3751: \%allfiles,\%codebase,$context);
1.329 droeschl 3752: if ($hadchanges) {
3753: &mark_hash_old();
3754: }
1.440 raeburn 3755: $r->print($upload_output);
3756: } elsif ($env{'form.phase'} eq 'upload_embedded') {
3757: # Process file upload - phase two - upload embedded objects
3758: $uploadphase = 'check_embedded';
3759: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
3760: my $state = &embedded_form_elems($uploadphase,$primaryurl,
3761: $env{'form.newidx'});
3762: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3763: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3764: my ($destination,$dir_root) = &embedded_destination();
3765: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
3766: my $actionurl = '/adm/coursedocs';
3767: my ($result,$flag) =
3768: &Apache::loncommon::upload_embedded('coursedoc',$destination,
3769: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
3770: $actionurl);
3771: $r->print($result.&return_to_editor());
3772: } elsif ($env{'form.phase'} eq 'check_embedded') {
3773: # Process file upload - phase three - modify references in HTML file
3774: $uploadphase = 'modified_orightml';
3775: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3776: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3777: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 3778: my $result =
3779: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
3780: $docuname,$docudom,undef,
3781: $dir_root);
3782: $r->print($result.&return_to_editor());
1.476 raeburn 3783: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
3784: $uploadphase = 'decompress_phase_one';
3785: $r->print(&decompression_phase_one().
3786: &return_to_editor());
3787: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
3788: $uploadphase = 'decompress_phase_two';
3789: $r->print(&decompression_phase_two().
3790: &return_to_editor());
1.329 droeschl 3791: }
3792: }
3793:
1.484 raeburn 3794: if ($allowed && $toolsflag) {
3795: $r->print(&startContentScreen('tools'));
3796: $r->print(&generate_admin_menu($crstype));
3797: $r->print(&endContentScreen());
3798: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 3799: # -----------------------------------------------------------------------------
3800: my %lt=&Apache::lonlocal::texthash(
3801: 'copm' => 'All documents out of a published map into this folder',
1.501 raeburn 3802: 'upfi' => 'Upload File',
3803: 'upld' => 'Import Content',
1.329 droeschl 3804: 'srch' => 'Search',
3805: 'impo' => 'Import',
1.487 raeburn 3806: 'lnks' => 'Import from Stored Links',
1.502 raeburn 3807: 'impm' => 'Import from Assembled Map',
1.329 droeschl 3808: 'selm' => 'Select Map',
3809: 'load' => 'Load Map',
3810: 'newf' => 'New Folder',
3811: 'newp' => 'New Composite Page',
3812: 'syll' => 'Syllabus',
1.425 raeburn 3813: 'navc' => 'Table of Contents',
1.343 biermanm 3814: 'sipa' => 'Simple Course Page',
1.329 droeschl 3815: 'sipr' => 'Simple Problem',
1.534 raeburn 3816: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 3817: 'drbx' => 'Drop Box',
1.451 www 3818: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 3819: 'bull' => 'Discussion Board',
1.347 weissno 3820: 'mypi' => 'My Personal Information Page',
1.353 weissno 3821: 'grpo' => 'Group Portfolio',
1.329 droeschl 3822: 'rost' => 'Course Roster',
1.528 raeburn 3823: 'abou' => 'Personal Information Page for a User',
1.377 bisitz 3824: 'imsf' => 'IMS Import',
3825: 'imsl' => 'Import IMS package',
1.501 raeburn 3826: 'cms' => 'Origin of IMS package',
3827: 'se' => 'Select',
1.329 droeschl 3828: 'file' => 'File',
3829: 'title' => 'Title',
3830: 'comment' => 'Comment',
1.403 raeburn 3831: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.329 droeschl 3832: );
3833: # -----------------------------------------------------------------------------
3834: my $fileupload=(<<FIUP);
3835: $lt{'file'}:<br />
3836: <input type="file" name="uploaddoc" size="40" />
3837: FIUP
3838:
3839: my $checkbox=(<<CHBO);
3840: <!-- <label>$lt{'parse'}?
3841: <input type="checkbox" name="parserflag" />
3842: </label> -->
3843: <label>
3844: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
3845: </label>
3846: CHBO
1.501 raeburn 3847: my $imsfolder = $env{'form.folder'};
3848: if ($imsfolder eq '') {
3849: $imsfolder = 'default';
3850: }
3851: my $imspform=(<<IMSFORM);
3852: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
3853: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
3854: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.516 raeburn 3855: <fieldset id="uploadimsform" style="display: none;">
1.501 raeburn 3856: <legend>$lt{'imsf'}</legend>
3857: $fileupload
3858: <br />
3859: <p>
3860: $lt{'cms'}:
3861: <select name="source">
3862: <option value="-1" selected="selected">$lt{'se'}</option>
3863: <option value="bb5">Blackboard 5</option>
3864: <option value="bb6">Blackboard 6</option>
3865: <option value="angel5">ANGEL 5.5</option>
3866: <option value="webctce4">WebCT 4 Campus Edition</option>
3867: </select>
3868: <input type="hidden" name="folder" value="$imsfolder" />
3869: </p>
3870: <input type="hidden" name="phase" value="one" />
3871: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
3872: </fieldset>
3873: </form>
3874: IMSFORM
1.329 droeschl 3875:
3876: my $fileuploadform=(<<FUFORM);
1.501 raeburn 3877: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
3878: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
3879: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.516 raeburn 3880: <fieldset id="uploaddocform" style="display: none;">
1.501 raeburn 3881: <legend>$lt{'upfi'}</legend>
1.371 tempelho 3882: <input type="hidden" name="active" value="aa" />
1.329 droeschl 3883: $fileupload
3884: <br />
3885: $lt{'title'}:<br />
1.458 raeburn 3886: <input type="text" size="60" name="comment" />
1.508 raeburn 3887: $pathitem
1.329 droeschl 3888: <input type="hidden" name="cmd" value="upload_default" />
3889: <br />
1.458 raeburn 3890: <span class="LC_nobreak" style="float:left">
1.329 droeschl 3891: $checkbox
3892: </span>
1.501 raeburn 3893: <br clear="all" />
3894: <input type="submit" value="$lt{'upld'}" />
3895: </fieldset>
3896: </form>
1.383 tempelho 3897: FUFORM
1.329 droeschl 3898:
1.502 raeburn 3899: my $importpubform=(<<SEDFFORM);
1.514 raeburn 3900: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.502 raeburn 3901: $lt{'impm'}</a>$help{'Load_Map'}
3902: <form action="/adm/coursedocs" method="post" name="mapimportform">
1.516 raeburn 3903: <fieldset id="importmapform" style="display: none;">
1.502 raeburn 3904: <legend>$lt{'impm'}</legend>
1.371 tempelho 3905: <input type="hidden" name="active" value="bb" />
1.502 raeburn 3906: $lt{'copm'}<br />
3907: <span class="LC_nobreak">
3908: <input type="text" name="importmap" size="40" value=""
3909: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.516 raeburn 3910: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.502 raeburn 3911: <input type="submit" name="loadmap" value="$lt{'load'}" />
3912: </fieldset>
3913: </form>
3914:
1.383 tempelho 3915: SEDFFORM
1.502 raeburn 3916: my @importpubforma = (
1.508 raeburn 3917: { '<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 3918: { '<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 3919: { '<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 3920: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
1.383 tempelho 3921: );
1.502 raeburn 3922: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
1.510 raeburn 3923: my $extresourcesform =
3924: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
3925: $help{'Adding_External_Resource'});
1.329 droeschl 3926: if ($allowed) {
1.492 raeburn 3927: my $folder = $env{'form.folder'};
3928: if ($folder eq '') {
3929: $folder='default';
3930: }
3931: &update_paste_buffer($coursenum,$coursedom,$folder);
1.337 ehlerst 3932: $r->print(<<HIDDENFORM);
3933: <form name="renameform" method="post" action="/adm/coursedocs">
3934: <input type="hidden" name="title" />
3935: <input type="hidden" name="cmd" />
3936: <input type="hidden" name="markcopy" />
3937: <input type="hidden" name="copyfolder" />
3938: $containertag
3939: </form>
1.484 raeburn 3940:
1.337 ehlerst 3941: HIDDENFORM
1.508 raeburn 3942: $r->print(&makesimpleeditform($pathitem)."\n".
3943: &makedocslogform($pathitem."\n".
1.484 raeburn 3944: '<input type="hidden" name="folder" value="'.
3945: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 3946: }
1.442 www 3947:
3948: # Generate the tabs
1.510 raeburn 3949: my ($mode,$needs_end);
1.472 raeburn 3950: if (($supplementalflag) && (!$allowed)) {
1.510 raeburn 3951: my @folders = split('&',$env{'form.folderpath'});
3952: unless (@folders > 2) {
3953: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
3954: $needs_end = 1;
3955: }
1.472 raeburn 3956: } else {
1.484 raeburn 3957: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.510 raeburn 3958: $needs_end = 1;
1.472 raeburn 3959: }
1.443 www 3960:
1.442 www 3961: #
3962:
3963: my $savefolderpath;
3964:
1.395 raeburn 3965: if ($allowed) {
1.329 droeschl 3966: my $folder=$env{'form.folder'};
1.443 www 3967: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 3968: $folder='default';
1.356 tempelho 3969: $savefolderpath = $env{'form.folderpath'};
1.442 www 3970: $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
1.508 raeburn 3971: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 3972: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
3973: }
3974: my $postexec='';
3975: if ($folder eq 'default') {
1.372 bisitz 3976: $r->print('<script type="text/javascript">'."\n"
3977: .'// <![CDATA['."\n"
3978: .'this.window.name="loncapaclient";'."\n"
3979: .'// ]]>'."\n"
3980: .'</script>'."\n"
1.369 bisitz 3981: );
1.329 droeschl 3982: } else {
3983: #$postexec='self.close();';
3984: }
1.504 raeburn 3985: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
3986: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 3987: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
3988:
3989: my $newnavform=(<<NNFORM);
3990: <form action="/adm/coursedocs" method="post" name="newnav">
1.371 tempelho 3991: <input type="hidden" name="active" value="cc" />
1.508 raeburn 3992: $pathitem
1.329 droeschl 3993: <input type="hidden" name="importdetail"
3994: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 3995: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 3996: $help{'Navigate_Content'}
3997: </form>
3998: NNFORM
3999: my $newsmppageform=(<<NSPFORM);
4000: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.371 tempelho 4001: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4002: $pathitem
1.329 droeschl 4003: <input type="hidden" name="importdetail" value="" />
1.423 onken 4004: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 4005: $help{'Simple Page'}
1.329 droeschl 4006: </form>
4007: NSPFORM
4008:
4009: my $newsmpproblemform=(<<NSPROBFORM);
4010: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 4011: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4012: $pathitem
1.329 droeschl 4013: <input type="hidden" name="importdetail" value="" />
1.423 onken 4014: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.383 tempelho 4015: $help{'Simple Problem'}
1.329 droeschl 4016: </form>
4017:
4018: NSPROBFORM
4019:
4020: my $newdropboxform=(<<NDBFORM);
4021: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 4022: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4023: $pathitem
1.329 droeschl 4024: <input type="hidden" name="importdetail" value="" />
1.423 onken 4025: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.344 bisitz 4026: </form>
1.329 droeschl 4027: NDBFORM
4028:
4029: my $newexuploadform=(<<NEXUFORM);
4030: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 4031: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4032: $pathitem
1.329 droeschl 4033: <input type="hidden" name="importdetail" value="" />
1.423 onken 4034: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 4035: $help{'Score_Upload_Form'}
4036: </form>
4037: NEXUFORM
4038:
4039: my $newbulform=(<<NBFORM);
4040: <form action="/adm/coursedocs" method="post" name="newbul">
1.371 tempelho 4041: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4042: $pathitem
1.329 droeschl 4043: <input type="hidden" name="importdetail" value="" />
1.423 onken 4044: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 4045: $help{'Bulletin Board'}
4046: </form>
4047: NBFORM
4048:
4049: my $newaboutmeform=(<<NAMFORM);
4050: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.371 tempelho 4051: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4052: $pathitem
1.329 droeschl 4053: <input type="hidden" name="importdetail"
4054: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 4055: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 4056: $help{'My Personal Information Page'}
1.329 droeschl 4057: </form>
4058: NAMFORM
4059:
4060: my $newaboutsomeoneform=(<<NASOFORM);
4061: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.371 tempelho 4062: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4063: $pathitem
1.329 droeschl 4064: <input type="hidden" name="importdetail" value="" />
1.423 onken 4065: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 4066: </form>
4067: NASOFORM
4068:
4069: my $newrosterform=(<<NROSTFORM);
4070: <form action="/adm/coursedocs" method="post" name="newroster">
1.371 tempelho 4071: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4072: $pathitem
1.329 droeschl 4073: <input type="hidden" name="importdetail"
4074: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 4075: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.329 droeschl 4076: $help{'Course Roster'}
4077: </form>
4078: NROSTFORM
4079:
1.534 raeburn 4080: my $newwebpage;
4081: if ($folder =~ /^default_?(\d*)$/) {
4082: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
4083: if ($1) {
4084: $newwebpage .= $1;
4085: } else {
4086: $newwebpage .= 'default';
4087: }
4088: $newwebpage .= '/new.html';
4089: }
4090: my $newwebpageform =(<<NWEBFORM);
4091: <form action="/adm/coursedocs" method="post" name="newwebpage">
4092: <input type="hidden" name="active" value="cc" />
4093: $pathitem
4094: <input type="hidden" name="importdetail" value="$newwebpage" />
4095: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
4096: $help{'Web Page'}
4097: </form>
4098: NWEBFORM
4099:
4100:
1.342 ehlerst 4101: my $specialdocumentsform;
1.383 tempelho 4102: my @specialdocumentsforma;
1.451 www 4103: my $gradingform;
4104: my @gradingforma;
4105: my $communityform;
4106: my @communityforma;
1.351 ehlerst 4107: my $newfolderform;
1.390 tempelho 4108: my $newfolderb;
1.342 ehlerst 4109:
1.451 www 4110: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 4111:
1.329 droeschl 4112: my $newpageform=(<<NPFORM);
4113: <form action="/adm/coursedocs" method="post" name="newpage">
4114: <input type="hidden" name="folderpath" value="$path" />
4115: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 4116: <input type="hidden" name="active" value="cc" />
1.423 onken 4117: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 4118: $help{'Adding_Pages'}
1.329 droeschl 4119: </form>
4120: NPFORM
1.390 tempelho 4121:
4122:
1.351 ehlerst 4123: $newfolderform=(<<NFFORM);
1.329 droeschl 4124: <form action="/adm/coursedocs" method="post" name="newfolder">
1.508 raeburn 4125: $pathitem
1.329 droeschl 4126: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 4127: <input type="hidden" name="active" value="aa" />
1.422 onken 4128: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 4129: </form>
4130: NFFORM
4131:
4132: my $newsylform=(<<NSYLFORM);
4133: <form action="/adm/coursedocs" method="post" name="newsyl">
1.371 tempelho 4134: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4135: $pathitem
1.329 droeschl 4136: <input type="hidden" name="importdetail"
4137: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 4138: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 4139: $help{'Syllabus'}
1.383 tempelho 4140:
1.329 droeschl 4141: </form>
4142: NSYLFORM
1.364 bisitz 4143:
1.329 droeschl 4144: my $newgroupfileform=(<<NGFFORM);
4145: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.371 tempelho 4146: <input type="hidden" name="active" value="cc" />
1.508 raeburn 4147: $pathitem
1.329 droeschl 4148: <input type="hidden" name="importdetail"
4149: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 4150: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 4151: $help{'Group Portfolio'}
1.329 droeschl 4152: </form>
4153: NGFFORM
1.383 tempelho 4154: @specialdocumentsforma=(
1.421 onken 4155: {'<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 4156: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 4157: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
4158: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.534 raeburn 4159: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 4160: );
4161: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
4162:
1.434 raeburn 4163:
4164: my @importdoc = (
1.519 raeburn 4165: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
4166: );
4167: unless ($container eq 'page') {
4168: push(@importdoc,
4169: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
4170: );
4171: }
4172: push(@importdoc,
4173: {'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
4174: );
1.501 raeburn 4175: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 4176:
1.451 www 4177: @gradingforma=(
4178: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
4179: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
4180: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
4181:
4182: );
4183: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
4184:
4185: @communityforma=(
4186: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
4187: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
4188: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
4189: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
4190: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
4191: );
4192: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 4193:
1.330 tempelho 4194: my %orderhash = (
1.488 raeburn 4195: 'aa' => ['Import Content',$fileuploadform],
1.502 raeburn 4196: 'bb' => ['Published Content',$importpubform],
1.451 www 4197: 'cc' => ['Grading Resources',$gradingform],
1.330 tempelho 4198: );
1.519 raeburn 4199: unless ($container eq 'page') {
1.434 raeburn 4200: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 4201: $orderhash{'dd'} = ['Collaboration',$communityform];
1.515 raeburn 4202: $orderhash{'ee'} = ['Special Pages',$specialdocumentsform];
1.434 raeburn 4203: }
4204:
1.341 ehlerst 4205: $hadchanges=0;
1.484 raeburn 4206: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 4207: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 4208: $supplementalflag,\%orderhash,$iconpath,$pathitem);
1.443 www 4209: if ($error) {
4210: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
4211: }
4212: if ($hadchanges) {
4213: &mark_hash_old();
4214: }
1.341 ehlerst 4215:
1.443 www 4216: &changewarning($r,'');
4217: }
1.458 raeburn 4218: }
1.442 www 4219:
1.443 www 4220: # Supplemental documents start here
4221:
1.329 droeschl 4222: my $folder=$env{'form.folder'};
1.443 www 4223: unless ($supplementalflag) {
1.329 droeschl 4224: $folder='supplemental';
4225: }
4226: if ($folder =~ /^supplemental$/ &&
4227: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 4228: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 4229: } elsif ($allowed) {
1.356 tempelho 4230: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 4231: }
1.508 raeburn 4232: $pathitem = '<input type="hidden" name="folderpath" value="'.
4233: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 4234: if ($allowed) {
4235: my $folderseq=
1.504 raeburn 4236: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 4237:
4238: my $supupdocform=(<<SUPDOCFORM);
1.501 raeburn 4239: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
4240: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 4241: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.516 raeburn 4242: <fieldset id="uploadsuppdocform" style="display: none;">
1.501 raeburn 4243: <legend>$lt{'upfi'}</legend>
1.371 tempelho 4244: <input type="hidden" name="active" value="ee" />
1.329 droeschl 4245: $fileupload
4246: <br />
4247: <br />
4248: <span class="LC_nobreak">
4249: $checkbox
4250: </span>
4251: <br /><br />
4252: $lt{'comment'}:<br />
1.383 tempelho 4253: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 4254: <br />
1.508 raeburn 4255: $pathitem
1.329 droeschl 4256: <input type="hidden" name="cmd" value="upload_supplemental" />
1.501 raeburn 4257: <input type='submit' value="$lt{'upld'}" />
4258: </form>
1.329 droeschl 4259: SUPDOCFORM
4260:
4261: my $supnewfolderform=(<<SNFFORM);
4262: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.371 tempelho 4263: <input type="hidden" name="active" value="ee" />
1.508 raeburn 4264: $pathitem
1.329 droeschl 4265: <input type="hidden" name="importdetail" value="" />
1.423 onken 4266: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 4267: $help{'Adding_Folders'}
1.329 droeschl 4268: </form>
4269: SNFFORM
1.383 tempelho 4270:
1.510 raeburn 4271: my $supextform =
4272: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
4273: $help{'Adding_External_Resource'});
1.329 droeschl 4274:
4275: my $supnewsylform=(<<SNSFORM);
4276: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 4277: <input type="hidden" name="active" value="ff" />
1.508 raeburn 4278: $pathitem
1.329 droeschl 4279: <input type="hidden" name="importdetail"
4280: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 4281: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 4282: $help{'Syllabus'}
4283: </form>
4284: SNSFORM
4285:
4286: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 4287: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 4288: <input type="hidden" name="active" value="ff" />
1.508 raeburn 4289: $pathitem
1.329 droeschl 4290: <input type="hidden" name="importdetail"
4291: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 4292: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 4293: $help{'My Personal Information Page'}
1.329 droeschl 4294: </form>
4295: SNAMFORM
4296:
1.534 raeburn 4297: my $supwebpage;
4298: if ($folder =~ /^supplemental_?(\d*)$/) {
4299: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
4300: if ($1) {
4301: $supwebpage .= $1;
4302: } else {
4303: $supwebpage .= 'default';
4304: }
4305: $supwebpage .= '/new.html';
4306: }
4307: my $supwebpageform =(<<SWEBFORM);
4308: <form action="/adm/coursedocs" method="post" name="supwebpage">
4309: <input type="hidden" name="active" value="cc" />
4310: $pathitem
4311: <input type="hidden" name="importdetail" value="$supwebpage" />
4312: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
4313: $help{'Web Page'}
4314: </form>
4315: SWEBFORM
4316:
1.333 muellerd 4317:
1.383 tempelho 4318: my @specialdocs = (
1.417 droeschl 4319: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
4320: =>$supnewsylform},
4321: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
4322: =>$supnewaboutmeform},
1.534 raeburn 4323: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
4324:
1.383 tempelho 4325: );
1.417 droeschl 4326: my @supimportdoc = (
1.515 raeburn 4327: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.501 raeburn 4328: =>$supextform},
4329: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
4330: =>$supupdocform},
4331: );
4332:
4333: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 4334: my %suporderhash = (
1.390 tempelho 4335: '00' => ['Supnewfolder', $supnewfolderform],
1.488 raeburn 4336: 'ee' => ['Import Content',$supupdocform],
1.515 raeburn 4337: 'ff' => ['Special Pages',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 4338: );
1.443 www 4339: if ($supplementalflag) {
1.458 raeburn 4340: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 4341: $supplementalflag,\%suporderhash,$iconpath,$pathitem);
1.443 www 4342: if ($error) {
4343: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
4344: }
1.393 raeburn 4345: }
1.443 www 4346: } elsif ($supplementalflag) {
1.458 raeburn 4347: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.508 raeburn 4348: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 4349: if ($error) {
4350: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 4351: }
1.393 raeburn 4352: }
1.389 tempelho 4353:
1.510 raeburn 4354: if ($needs_end) {
4355: $r->print(&endContentScreen());
4356: }
1.383 tempelho 4357:
1.329 droeschl 4358: if ($allowed) {
4359: $r->print('
4360: <form method="post" name="extimport" action="/adm/coursedocs">
4361: <input type="hidden" name="title" />
4362: <input type="hidden" name="url" />
4363: <input type="hidden" name="useform" />
4364: <input type="hidden" name="residx" />
4365: </form>');
4366: }
1.484 raeburn 4367: } elsif ($showdoc) {
1.329 droeschl 4368: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 4369: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 bisitz 4370: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 4371: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 4372: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 4373: }
4374: }
4375: $r->print(&Apache::loncommon::end_page());
4376: return OK;
1.364 bisitz 4377: }
1.329 droeschl 4378:
1.440 raeburn 4379: sub embedded_form_elems {
4380: my ($phase,$primaryurl,$newidx) = @_;
4381: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
4382: return <<STATE;
4383: <input type="hidden" name="folderpath" value="$folderpath" />
4384: <input type="hidden" name="cmd" value="upload_embedded" />
4385: <input type="hidden" name="newidx" value="$newidx" />
4386: <input type="hidden" name="phase" value="$phase" />
4387: <input type="hidden" name="primaryurl" value="$primaryurl" />
4388: STATE
4389: }
4390:
4391: sub embedded_destination {
4392: my $folder=$env{'form.folder'};
4393: my $destination = 'docs/';
4394: if ($folder =~ /^supplemental/) {
4395: $destination = 'supplemental/';
4396: }
4397: if (($folder eq 'default') || ($folder eq 'supplemental')) {
4398: $destination .= 'default/';
4399: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
4400: $destination .= $2.'/';
4401: }
4402: $destination .= $env{'form.newidx'};
4403: my $dir_root = '/userfiles';
4404: return ($destination,$dir_root);
4405: }
4406:
4407: sub return_to_editor {
4408: my $actionurl = '/adm/coursedocs';
4409: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
4410: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
4411: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
4412: '</a></p>';
4413: }
4414:
1.476 raeburn 4415: sub decompression_info {
4416: my ($destination,$dir_root) = &embedded_destination();
4417: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
4418: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4419: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4420: my $container='sequence';
1.480 raeburn 4421: my ($pathitem,$hiddenelem);
1.519 raeburn 4422: my @hiddens = ('newidx','comment','position','folderpath');
4423: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 4424: $container='page';
4425: }
1.480 raeburn 4426: unshift(@hiddens,$pathitem);
4427: foreach my $item (@hiddens) {
4428: if ($env{'form.'.$item}) {
4429: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
4430: $env{'form.'.$item}.'" />'."\n";
4431: }
1.477 raeburn 4432: }
1.476 raeburn 4433: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
4434: $hiddenelem);
4435: }
4436:
4437: sub decompression_phase_one {
4438: my ($dir,$file,$warning,$error,$output);
4439: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4440: &decompression_info();
1.490 raeburn 4441: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 4442: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
4443: } else {
4444: my $file = $1;
1.481 raeburn 4445: $output =
4446: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
4447: $destination,$dir_root,
4448: $hiddenelem);
4449: if ($env{'form.autoextract_camtasia'}) {
4450: $output .= &remove_archive($docudom,$docuname,$container);
4451: }
1.476 raeburn 4452: }
4453: if ($error) {
4454: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
4455: $error.'</p>'."\n";
4456: }
4457: if ($warning) {
4458: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
4459: }
4460: return $output;
4461: }
4462:
4463: sub decompression_phase_two {
4464: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4465: &decompression_info();
1.481 raeburn 4466: my $output;
1.480 raeburn 4467: if ($env{'form.archivedelete'}) {
1.481 raeburn 4468: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 4469: }
4470: $output .=
1.481 raeburn 4471: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 4472: $destination,$dir_root,$hiddenelem);
4473: return $output;
4474: }
4475:
1.480 raeburn 4476: sub remove_archive {
4477: my ($docudom,$docuname,$container) = @_;
4478: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 4479: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 4480: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
4481: if ($fatal) {
4482: if ($container eq 'page') {
4483: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
4484: } else {
4485: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
4486: }
4487: $delwarning .= &mt('As a result the archive file has not been removed.');
4488: } else {
4489: my $currcmd = $env{'form.cmd'};
4490: my $position = $env{'form.position'};
4491: if ($position > 0) {
4492: $env{'form.cmd'} = 'del_'.$position;
4493: my ($title,$url,@rrest) =
4494: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
4495: if (&handle_edit_cmd($docuname,$docudom)) {
1.492 raeburn 4496: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 4497: if ($fatal) {
4498: if ($container eq 'page') {
4499: $delwarning = &mt('An error occurred updating the contents of the current page.');
4500: } else {
4501: $delwarning = &mt('An error occurred updating the contents of the current folder.');
4502: }
4503: } else {
1.481 raeburn 4504: $delresult = &mt('Archive file removed.');
1.480 raeburn 4505: }
4506: }
4507: }
4508: $env{'form.cmd'} = $currcmd;
4509: }
4510: if ($delwarning) {
4511: $output = '<p class="LC_warning">'.
4512: $delwarning.
4513: '</p>';
4514: }
4515: if ($delresult) {
4516: $output .= '<p class="LC_info">'.
4517: $delresult.
4518: '</p>';
4519: }
1.481 raeburn 4520: return $output;
1.480 raeburn 4521: }
4522:
1.484 raeburn 4523: sub generate_admin_menu {
4524: my ($crstype) = @_;
4525: my $lc_crstype = lc($crstype);
4526: my ($home,$other,%outhash)=&authorhosts();
4527: my %lt=&Apache::lonlocal::texthash (
4528: 'vc' => 'Verify Content',
4529: 'cv' => 'Check/Set Resource Versions',
4530: 'ls' => 'List Resource Identifiers',
4531: 'imse' => 'Export contents to IMS Archive',
4532: 'dcd' => "Dump $crstype Content to Authoring Space",
4533: );
4534: my ($candump,$dumpurl);
4535: if ($home + $other > 0) {
4536: $candump = 'F';
4537: if ($home) {
4538: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
4539: } else {
4540: my @hosts;
4541: foreach my $aurole (keys(%outhash)) {
4542: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4543: push(@hosts,$outhash{$aurole});
4544: }
4545: }
4546: if (@hosts == 1) {
4547: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
4548: '&role='.
4549: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
4550: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
4551: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
4552: } else {
4553: $dumpurl = "javascript:choose_switchserver_window()";
4554: }
4555: }
4556: }
4557: my @menu=
4558: ({ categorytitle=>'Administration',
4559: items =>[
4560: { linktext => $lt{'vc'},
4561: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
4562: permission => 'F',
4563: help => 'Verify_Content',
4564: icon => 'verify.png',
4565: linktitle => 'Verify contents can be retrieved/rendered',
4566: },
4567: { linktext => $lt{'cv'},
4568: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
4569: permission => 'F',
4570: help => 'Check_Resource_Versions',
4571: icon => 'resversion.png',
4572: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
4573: },
4574: { linktext => $lt{'ls'},
4575: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
4576: permission => 'F',
4577: #help => '',
4578: icon => 'symbs.png',
4579: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
4580: },
4581: ]
4582: },
4583: { categorytitle=>'Export',
4584: items =>[
4585: { linktext => $lt{'imse'},
4586: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
4587: permission => 'F',
4588: help => 'Docs_Export_Course_Docs',
4589: icon => 'imsexport.png',
4590: linktitle => $lt{'imse'},
4591: },
4592: { linktext => $lt{'dcd'},
4593: url => $dumpurl,
4594: permission => $candump,
4595: #help => '',
4596: icon => 'dump.png',
4597: linktitle => $lt{'dcd'},
4598: },
4599: ]
4600: });
4601: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
4602: '<input type="hidden" id="dummy" />'."\n".
4603: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
4604: '</form>';
1.329 droeschl 4605: }
4606:
4607: sub generate_edit_table {
1.484 raeburn 4608: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile) = @_;
1.406 raeburn 4609: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 4610: my %orderhash = %{$orderhash_ref};
1.344 bisitz 4611: my $form;
1.371 tempelho 4612: my $activetab;
4613: my $active;
1.526 raeburn 4614: if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) {
1.371 tempelho 4615: $activetab = $env{'form.active'};
4616: }
1.472 raeburn 4617: my $backicon = $iconpath.'clickhere.gif';
1.525 raeburn 4618: my $backtext = &mt('Exit Editor');
1.458 raeburn 4619: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 4620: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
4621: '<li class="goback">'.
1.525 raeburn 4622: '<a href="javascript:toContents('.$jumpto.');">'.
1.488 raeburn 4623: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
4624: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
4625: '<li>'.
4626: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
4627: &mt('Undo Delete').'</a></li>'."\n";
4628: if ($env{'form.docslog'}) {
4629: $form .= '<li class="active">';
4630: } else {
4631: $form .= '<li>';
4632: }
4633: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
4634: &mt('History').'</a></li>'."\n";
4635: if ($env{'form.docslog'}) {
4636: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
4637: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 4638: }
1.458 raeburn 4639: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 4640: if($name ne '00'){
1.371 tempelho 4641: if($activetab eq '' || $activetab ne $name){
4642: $active = '';
4643: }elsif($activetab eq $name){
4644: $active = 'class="active"';
4645: }
1.458 raeburn 4646: $form .= '<li style="float:right" '.$active
1.484 raeburn 4647: .' 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 4648: } else {
1.484 raeburn 4649: $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 4650:
4651: }
1.329 droeschl 4652: }
1.484 raeburn 4653: $form .= '</ul>'."\n";
4654: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 4655:
4656: if ($to_show ne '') {
1.484 raeburn 4657: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'."\n";
1.458 raeburn 4658: }
1.363 ehlerst 4659: foreach my $field (keys(%orderhash)){
1.390 tempelho 4660: if($field ne '00'){
1.422 onken 4661: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 4662: $active = 'style="display: none;float:left"';
1.422 onken 4663: }elsif($activetab eq $field){
1.458 raeburn 4664: $active = 'style="display:block;float:left"';
1.422 onken 4665: }
4666: $form .= '<div id="'.$field.$tid.'"'
4667: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 4668: .'</div>'."\n";
1.363 ehlerst 4669: }
4670: }
1.484 raeburn 4671: unless ($env{'form.docslog'}) {
4672: $form .= '</div></div>'."\n";
4673: }
1.329 droeschl 4674: return $form;
4675: }
4676:
4677: sub editing_js {
1.472 raeburn 4678: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 4679: my %lt = &Apache::lonlocal::texthash(
4680: p_mnf => 'Name of New Folder',
4681: t_mnf => 'New Folder',
4682: p_mnp => 'Name of New Page',
4683: t_mnp => 'New Page',
1.451 www 4684: p_mxu => 'Title for the External Score',
1.349 biermanm 4685: p_msp => 'Name of Simple Course Page',
1.329 droeschl 4686: p_msb => 'Title for the Problem',
4687: p_mdb => 'Title for the Drop Box',
1.336 schafran 4688: p_mbb => 'Title for the Discussion Board',
1.534 raeburn 4689: p_mwp => 'Title for Web Page',
1.348 weissno 4690: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 4691: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 4692: p_mab_alrt1 => 'Not a valid user:domain',
4693: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
4694: p_chn => 'New Title',
4695: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
4696: p_rmr2a => 'Remove[_99]',
4697: p_rmr2b => '?[_99]',
4698: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
4699: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
4700: p_ctr2a => 'Cut[_98]',
1.478 raeburn 4701: p_ctr2b => '?[_98]',
4702: rpck => 'Enter number to pick (e.g., 3)',
1.501 raeburn 4703: imsfile => 'You must choose an IMS package for import',
4704: imscms => 'You must select which Course Management System was the source of the IMS package',
4705: invurl => 'Invalid URL',
4706: titbl => 'Title is blank',
1.329 droeschl 4707: );
4708:
1.433 raeburn 4709: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 4710: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
4711: my $main_container_page;
1.519 raeburn 4712: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
4713: $main_container_page = 1;
1.434 raeburn 4714: }
1.519 raeburn 4715: my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents%3A%3A%3A%3A%3A';
1.446 www 4716: my $toplevelsupp = &supplemental_base();
1.433 raeburn 4717:
1.525 raeburn 4718: my $backtourl;
1.530 raeburn 4719: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
4720: my $caller = $1;
1.525 raeburn 4721: if ($caller =~ /^supplemental/) {
4722: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
4723: } else {
4724: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
4725: $res = &Apache::lonnet::clutter($res);
4726: if (&Apache::lonnet::is_on_map($res)) {
4727: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
4728: &HTML::Entities::encode($caller,'<>&"');
4729: }
4730: }
4731: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
4732: $backtourl = '/adm/menu';
4733: } elsif ($supplementalflag) {
1.472 raeburn 4734: $backtourl = '/adm/supplemental';
1.525 raeburn 4735: } else {
4736: $backtourl = '/adm/navmaps';
1.472 raeburn 4737: }
4738:
1.519 raeburn 4739: my $fieldsets = "'ext','doc'";
4740: unless ($main_container_page) {
4741: $fieldsets .=",'ims'";
4742: }
1.501 raeburn 4743: if ($supplementalflag) {
4744: $fieldsets = "'suppext','suppdoc'";
4745: }
4746:
1.329 droeschl 4747: return <<ENDNEWSCRIPT;
4748: function makenewfolder(targetform,folderseq) {
4749: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
4750: if (foldername) {
4751: targetform.importdetail.value=escape(foldername)+"="+folderseq;
4752: targetform.submit();
4753: }
4754: }
4755:
4756: function makenewpage(targetform,folderseq) {
4757: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
4758: if (pagename) {
4759: targetform.importdetail.value=escape(pagename)+"="+folderseq;
4760: targetform.submit();
4761: }
4762: }
4763:
4764: function makeexamupload() {
4765: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 4766: if (title) {
1.329 droeschl 4767: this.document.forms.newexamupload.importdetail.value=
4768: escape(title)+'=/res/lib/templates/examupload.problem';
4769: this.document.forms.newexamupload.submit();
4770: }
4771: }
4772:
4773: function makesmppage() {
4774: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 4775: if (title) {
1.329 droeschl 4776: this.document.forms.newsmppg.importdetail.value=
1.533 raeburn 4777: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 4778: this.document.forms.newsmppg.submit();
4779: }
4780: }
4781:
1.534 raeburn 4782: function makewebpage(type) {
4783: var title=prompt('$lt{"p_mwp"}');
4784: var formname;
4785: if (type == 'supp') {
4786: formname = this.document.forms.supwebpage;
4787: } else {
4788: formname = this.document.forms.newwebpage;
4789: }
4790: if (title) {
4791: var webpage = formname.importdetail.value;
4792: formname.importdetail.value = escape(title)+'='+webpage;
4793: formname.submit();
4794: }
4795: }
4796:
1.329 droeschl 4797: function makesmpproblem() {
4798: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 4799: if (title) {
1.329 droeschl 4800: this.document.forms.newsmpproblem.importdetail.value=
4801: escape(title)+'=/res/lib/templates/simpleproblem.problem';
4802: this.document.forms.newsmpproblem.submit();
4803: }
4804: }
4805:
4806: function makedropbox() {
4807: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 4808: if (title) {
1.329 droeschl 4809: this.document.forms.newdropbox.importdetail.value=
4810: escape(title)+'=/res/lib/templates/DropBox.problem';
4811: this.document.forms.newdropbox.submit();
4812: }
4813: }
4814:
4815: function makebulboard() {
4816: var title=prompt('$lt{"p_mbb"}');
4817: if (title) {
4818: this.document.forms.newbul.importdetail.value=
1.533 raeburn 4819: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 4820: this.document.forms.newbul.submit();
4821: }
4822: }
4823:
4824: function makeabout() {
4825: var user=prompt("$lt{'p_mab'}");
4826: if (user) {
4827: var comp=new Array();
4828: comp=user.split(':');
4829: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
4830: if ((comp[0]) && (comp[1])) {
4831: this.document.forms.newaboutsomeone.importdetail.value=
4832: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 4833: this.document.forms.newaboutsomeone.submit();
4834: } else {
4835: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 4836: }
1.335 ehlerst 4837: } else {
4838: alert("$lt{'p_mab_alrt2'}");
4839: }
4840: }
1.329 droeschl 4841: }
4842:
1.501 raeburn 4843: function toggleUpload(caller) {
4844: var blocks = Array($fieldsets);
4845: for (var i=0; i<blocks.length; i++) {
4846: var disp = 'none';
4847: if (caller == blocks[i]) {
4848: var curr = document.getElementById('upload'+caller+'form').style.display;
4849: if (curr == 'none') {
4850: disp='block';
4851: }
4852: }
4853: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
4854: }
1.502 raeburn 4855: resize_scrollbox('contentscroll','1','1');
4856: return;
4857: }
4858:
1.514 raeburn 4859: function toggleMap(caller) {
1.502 raeburn 4860: var disp = 'none';
1.510 raeburn 4861: if (document.getElementById('importmapform')) {
1.514 raeburn 4862: if (caller == 'map') {
4863: var curr = document.getElementById('importmapform').style.display;
4864: if (curr == 'none') {
4865: disp='block';
4866: }
1.510 raeburn 4867: }
4868: document.getElementById('importmapform').style.display=disp;
4869: resize_scrollbox('contentscroll','1','1');
1.502 raeburn 4870: }
1.501 raeburn 4871: return;
1.329 droeschl 4872: }
4873:
1.501 raeburn 4874: function makeims(imsform) {
4875: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
4876: alert("$lt{'imsfile'}");
4877: return;
4878: }
4879: if (imsform.source.selectedIndex == 0) {
4880: alert("$lt{'imscms'}");
4881: return;
4882: }
4883: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
4884: imsform.submit();
4885: }
4886:
1.519 raeburn 4887: function changename(folderpath,index,oldtitle) {
1.335 ehlerst 4888: var title=prompt('$lt{"p_chn"}',oldtitle);
4889: if (title) {
4890: this.document.forms.renameform.markcopy.value=-1;
4891: this.document.forms.renameform.title.value=title;
4892: this.document.forms.renameform.cmd.value='rename_'+index;
1.519 raeburn 4893: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4894: this.document.forms.renameform.submit();
4895: }
1.329 droeschl 4896: }
4897:
1.519 raeburn 4898: function removeres(folderpath,index,oldtitle,skip_confirm) {
1.335 ehlerst 4899: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
4900: this.document.forms.renameform.markcopy.value=-1;
4901: this.document.forms.renameform.cmd.value='del_'+index;
1.519 raeburn 4902: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4903: this.document.forms.renameform.submit();
4904: }
1.329 droeschl 4905: }
4906:
1.519 raeburn 4907: function cutres(folderpath,index,oldtitle,container,folder,skip_confirm) {
1.335 ehlerst 4908: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
4909: this.document.forms.renameform.cmd.value='cut_'+index;
4910: this.document.forms.renameform.markcopy.value=index;
4911: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
1.519 raeburn 4912: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4913: this.document.forms.renameform.submit();
4914: }
1.329 droeschl 4915: }
4916:
1.519 raeburn 4917: function markcopy(folderpath,index,oldtitle,container,folder) {
1.335 ehlerst 4918: this.document.forms.renameform.markcopy.value=index;
4919: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
4920: this.document.forms.renameform.folderpath.value=folderpath;
4921: this.document.forms.renameform.submit();
1.329 droeschl 4922: }
4923:
1.478 raeburn 4924: function updatePick(targetform,index,caller) {
4925: var pickitem = document.getElementById('rpick_'+index);
4926: var picknumitem = document.getElementById('rpicknum_'+index);
4927: if (pickitem.checked) {
4928: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
4929: if (picknum == '' || picknum == null) {
4930: if (caller == 'check') {
4931: pickitem.checked=false;
4932: return;
4933: }
4934: } else {
4935: picknum.toString();
4936: var regexdigit=/^\\d+\$/;
4937: if (regexdigit.test(picknum)) {
4938: picknumitem.value = picknum;
4939: targetform.changeparms.value='randompick';
4940: targetform.submit();
4941: } else {
4942: if (caller == 'check') {
4943: pickitem.checked=false;
4944: }
4945: return;
4946: }
4947: }
4948: } else {
4949: picknumitem.value = 0;
4950: targetform.changeparms.value='randompick';
4951: targetform.submit();
4952: }
4953: }
4954:
1.334 muellerd 4955: function unselectInactive(nav) {
1.335 ehlerst 4956: currentNav = document.getElementById(nav);
4957: currentLis = currentNav.getElementsByTagName('LI');
4958: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 4959: if (currentLis[i].className == 'goback') {
4960: currentLis[i].className = 'goback';
4961: } else {
4962: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 4963: currentLis[i].className = 'right';
1.472 raeburn 4964: } else {
1.374 tempelho 4965: currentLis[i].className = 'i';
1.472 raeburn 4966: }
4967: }
1.335 ehlerst 4968: }
1.332 tempelho 4969: }
4970:
1.334 muellerd 4971: function hideAll(current, nav, data) {
1.335 ehlerst 4972: unselectInactive(nav);
1.374 tempelho 4973: if(current.className == 'right'){
4974: current.className = 'right active'
4975: }else{
4976: current.className = 'active';
4977: }
1.335 ehlerst 4978: currentData = document.getElementById(data);
4979: currentDivs = currentData.getElementsByTagName('DIV');
4980: for (i = 0; i < currentDivs.length; i++) {
4981: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 4982: currentDivs[i].style.display = 'none';
1.330 tempelho 4983: }
4984: }
1.335 ehlerst 4985: }
1.330 tempelho 4986:
1.374 tempelho 4987: function openTabs(pageId) {
4988: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 4989: if(tabnav.length > 2 ){
1.389 tempelho 4990: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 4991: currentLis = currentNav.getElementsByTagName('LI');
4992: for(i = 0; i< currentLis.length; i++){
4993: if(currentLis[i].className == 'active') {
1.375 tempelho 4994: funcString = currentLis[i].onclick.toString();
4995: tab = funcString.split('"');
1.420 onken 4996: if(tab.length < 2) {
4997: tab = funcString.split("'");
4998: }
1.375 tempelho 4999: currentData = document.getElementById(tab[1]);
5000: currentData.style.display = 'block';
1.374 tempelho 5001: }
5002: }
5003: }
5004: }
5005:
1.334 muellerd 5006: function showPage(current, pageId, nav, data) {
5007: hideAll(current, nav, data);
1.375 tempelho 5008: openTabs(pageId);
1.334 muellerd 5009: unselectInactive(nav);
1.330 tempelho 5010: current.className = 'active';
5011: currentData = document.getElementById(pageId);
5012: currentData.style.display = 'block';
1.458 raeburn 5013: activeTab = pageId;
1.501 raeburn 5014: toggleUpload();
1.503 raeburn 5015: toggleMap();
1.433 raeburn 5016: if (nav == 'mainnav') {
5017: var storedpath = "$docs_folderpath";
1.434 raeburn 5018: var storedpage = "$main_container_page";
1.433 raeburn 5019: var reg = new RegExp("^supplemental");
5020: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 5021: if (storedpage == 1) {
5022: document.simpleedit.folderpath.value = '';
5023: document.uploaddocument.folderpath.value = '';
5024: } else {
5025: if (reg.test(storedpath)) {
5026: document.simpleedit.folderpath.value = '$toplevelmain';
5027: document.uploaddocument.folderpath.value = '$toplevelmain';
5028: document.newext.folderpath.value = '$toplevelmain';
5029: } else {
5030: document.simpleedit.folderpath.value = storedpath;
5031: document.uploaddocument.folderpath.value = storedpath;
5032: document.newext.folderpath.value = storedpath;
5033: }
1.433 raeburn 5034: }
5035: } else {
1.434 raeburn 5036: if (reg.test(storedpath)) {
5037: document.simpleedit.folderpath.value = storedpath;
5038: document.supuploaddocument.folderpath.value = storedpath;
5039: document.supnewext.folderpath.value = storedpath;
5040: } else {
1.433 raeburn 5041: document.simpleedit.folderpath.value = '$toplevelsupp';
5042: document.supuploaddocument.folderpath.value = '$toplevelsupp';
5043: document.supnewext.folderpath.value = '$toplevelsupp';
5044: }
5045: }
5046: }
1.485 raeburn 5047: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 5048: return false;
5049: }
1.329 droeschl 5050:
1.472 raeburn 5051: function toContents(jumpto) {
5052: var newurl = '$backtourl';
1.525 raeburn 5053: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 5054: newurl = newurl+'?postdata='+jumpto;
5055: }
5056: location.href=newurl;
5057: }
5058:
1.329 droeschl 5059: ENDNEWSCRIPT
5060: }
1.457 raeburn 5061:
1.483 raeburn 5062: sub history_tab_js {
5063: return <<"ENDHIST";
5064: function toggleHistoryDisp(choice) {
5065: document.docslogform.docslog.value = choice;
5066: document.docslogform.submit();
5067: return;
5068: }
5069:
5070: ENDHIST
5071: }
5072:
1.484 raeburn 5073: sub inject_data_js {
5074: return <<ENDINJECT;
5075:
5076: function injectData(current, hiddenField, name, value) {
5077: currentElement = document.getElementById(hiddenField);
5078: currentElement.name = name;
5079: currentElement.value = value;
5080: current.submit();
5081: }
5082:
5083: ENDINJECT
5084: }
5085:
5086: sub dump_switchserver_js {
5087: my @hosts = @_;
5088: my %lt = &Apache::lonlocal::texthash(
5089: dump => 'Dumping to Authoring Space requires switching server.',
5090: swit => 'Switch server?',
5091: duco => 'Dump content to Authoring Space',
5092: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
5093: chos => 'Choose server',
5094: );
5095: my $role = $env{'request.role'};
5096: my $js = <<"ENDSWJS";
5097: <script type="text/javascript">
5098: function write_switchserver() {
5099: var server;
5100: if (document.setserver.posshosts.length > 0) {
5101: for (var i=0; i<document.setserver.posshosts.length; i++) {
5102: if (document.setserver.posshosts[i].checked) {
5103: server = document.setserver.posshosts[i].value;
5104: }
5105: }
5106: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
5107: }
5108: window.close();
5109: }
5110: </script>
5111:
5112: ENDSWJS
5113:
5114: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
5115: {'only_body' => 1,
5116: 'js_ready' => 1,});
5117: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
5118:
5119: my $hostpicker;
5120: my $count = 0;
5121: foreach my $host (sort(@hosts)) {
5122: my $checked;
5123: if ($count == 0) {
5124: $checked = ' checked="checked"';
5125: }
5126: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
5127: $host.'"'.$checked.' />'.$host.'</label> ';
5128: $count++;
5129: }
5130:
5131: return <<"ENDSWITCHJS";
5132:
5133: function dump_needs_switchserver(url) {
5134: if (url!='' && url!= null) {
5135: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
5136: go(url);
5137: }
5138: }
5139: return;
5140: }
5141:
5142: function choose_switchserver_window() {
5143: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
5144: newWindow.document.open();
5145: newWindow.document.writeln('$startpage');
5146: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
5147: '<p>$lt{'yone'}<\\/p>\\n'+
5148: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
5149: '<form name="setserver" method="post" action="" \\/>\\n'+
5150: '$hostpicker\\n'+
5151: '<br \\/><br \\/>\\n'+
5152: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
5153: 'onclick="write_switchserver();" \\/>\\n'+
5154: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
5155: newWindow.document.writeln('$endpage');
5156: newWindow.document.close();
5157: newWindow.focus();
5158: }
5159:
5160: ENDSWITCHJS
5161: }
5162:
5163: sub makedocslogform {
5164: my ($formelems,$docslog) = @_;
5165: return <<"LOGSFORM";
5166: <form action="/adm/coursedocs" method="post" name="docslogform">
5167: <input type="hidden" name="docslog" value="$docslog" />
5168: $formelems
5169: </form>
5170: LOGSFORM
5171: }
5172:
5173: sub makesimpleeditform {
5174: my ($formelems) = @_;
5175: return <<"SIMPFORM";
5176: <form name="simpleedit" method="post" action="/adm/coursedocs">
5177: <input type="hidden" name="importdetail" value="" />
5178: $formelems
5179: </form>
5180: SIMPFORM
5181: }
5182:
1.329 droeschl 5183: 1;
5184: __END__
5185:
5186:
5187: =head1 NAME
5188:
5189: Apache::londocs.pm
5190:
5191: =head1 SYNOPSIS
5192:
5193: This is part of the LearningOnline Network with CAPA project
5194: described at http://www.lon-capa.org.
5195:
5196: =head1 SUBROUTINES
5197:
5198: =over
5199:
5200: =item %help=()
5201:
5202: Available help topics
5203:
5204: =item mapread()
5205:
1.344 bisitz 5206: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 5207: @order and @resources, determines status
5208: sets @order - pointer to resources in right order
5209: sets @resources - array with the resources with correct idx
5210:
5211: =item authorhosts()
5212:
5213: Return hash with valid author names
5214:
5215: =item clean()
5216:
5217: =item dumpcourse()
5218:
5219: Actually dump course
5220:
5221: =item group_import()
5222:
5223: Imports the given (name, url) resources into the course
5224: coursenum, coursedom, and folder must precede the list
5225:
5226: =item breadcrumbs()
5227:
5228: =item log_docs()
5229:
5230: =item docs_change_log()
5231:
5232: =item update_paste_buffer()
5233:
5234: =item print_paste_buffer()
5235:
5236: =item do_paste_from_buffer()
5237:
1.492 raeburn 5238: =item get_newmap_url()
5239:
5240: =item dbcopy()
5241:
5242: =item uniqueness_check()
5243:
5244: =item contained_map_check()
5245:
5246: =item url_paste_fixups()
5247:
5248: =item apply_fixups()
5249:
5250: =item copy_dependencies()
5251:
1.329 droeschl 5252: =item update_parameter()
5253:
5254: =item handle_edit_cmd()
5255:
5256: =item editor()
5257:
5258: =item process_file_upload()
5259:
5260: =item process_secondary_uploads()
5261:
5262: =item is_supplemental_title()
5263:
5264: =item entryline()
5265:
5266: =item tiehash()
5267:
5268: =item untiehash()
5269:
5270: =item checkonthis()
5271:
5272: check on this
5273:
5274: =item verifycontent()
5275:
5276: Verify Content
5277:
5278: =item devalidateversioncache() & checkversions()
5279:
5280: Check Versions
5281:
5282: =item mark_hash_old()
5283:
5284: =item is_hash_old()
5285:
5286: =item changewarning()
5287:
5288: =item init_breadcrumbs()
5289:
5290: Breadcrumbs for special functions
5291:
1.484 raeburn 5292: =item create_list_elements()
5293:
5294: =item create_form_ul()
5295:
5296: =item startContentScreen()
5297:
5298: =item endContentScreen()
5299:
5300: =item supplemental_base()
5301:
5302: =item embedded_form_elems()
5303:
5304: =item embedded_destination()
5305:
5306: =item return_to_editor()
5307:
5308: =item decompression_info()
5309:
5310: =item decompression_phase_one()
5311:
5312: =item decompression_phase_two()
5313:
5314: =item remove_archive()
5315:
5316: =item generate_admin_menu()
5317:
5318: =item generate_edit_table()
5319:
5320: =item editing_js()
5321:
5322: =item history_tab_js()
5323:
5324: =item inject_data_js()
5325:
5326: =item dump_switchserver_js()
5327:
1.485 raeburn 5328: =item resize_scrollbox_js()
1.484 raeburn 5329:
5330: =item makedocslogform()
5331:
1.485 raeburn 5332: =item makesimpleeditform()
5333:
1.329 droeschl 5334: =back
5335:
5336: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>