Annotation of loncom/interface/londocs.pm, revision 1.484.2.28
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.484.2.28! raeburn 4: # $Id: londocs.pm,v 1.484.2.27 2013/03/17 18:46:21 raeburn Exp $
1.329 droeschl 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::londocs;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use Apache::imsexport;
34: use Apache::lonnet;
35: use Apache::loncommon;
1.383 tempelho 36: use Apache::lonhtmlcommon;
1.329 droeschl 37: use LONCAPA::map();
38: use Apache::lonratedt();
39: use Apache::lonxml;
40: use Apache::lonclonecourse;
41: use Apache::lonnavmaps;
1.472 raeburn 42: use Apache::lonnavdisplay();
1.484.2.19 raeburn 43: use Apache::lonextresedit();
1.329 droeschl 44: use HTML::Entities;
1.484.2.7 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.484.2.7 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.484.2.7 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.484.2.24 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.484.2.23 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.484.2.27 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.484.2.23 raeburn 301: if (($caller eq 'londocs') &&
302: ($folder =~ /^default/)) {
1.484.2.27 raeburn 303: if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
1.484.2.23 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.484.2.27 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.484.2.23 raeburn 374: if ($importuploaded) {
375: my %import_errors;
376: my %updated = (
377: removefrommap => \%removefrommap,
378: removeparam => \%removeparam,
379: );
1.484.2.26 raeburn 380: my ($result,$msgsarray,$lockerror) =
381: &apply_fixups($folder,1,$coursedom,$coursenum,\%import_errors,\%updated);
1.484.2.23 raeburn 382: if (keys(%import_errors) > 0) {
383: $fixuperrors =
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.484.2.26 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.484.2.23 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.484.2.8 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.484.2.6 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.484.2.6 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.484.2.7 raeburn 484: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484 raeburn 485: my %orderhash;
486: my $container='sequence';
487: my $pathitem;
1.484.2.19 raeburn 488: if ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 489: $container='page';
490: }
1.484.2.19 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.484.2.7 raeburn 501: if ($supplementalflag) {
502: $tid = 2;
503: }
1.484.2.19 raeburn 504: my ($breadcrumbtrail) =
1.484.2.18 raeburn 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.484.2.19 raeburn 579: my $is_supp = 0;
1.484.2.7 raeburn 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.484.2.7 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.484.2.7 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: }
1.484.2.19 raeburn 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 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.484.2.7 raeburn 739: my ($r,$container,$folder,$coursedom,$coursenum) = @_;
1.329 droeschl 740: return if (!defined($env{'docs.markedcopy_url'}));
741:
1.484.2.7 raeburn 742: my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent);
743: my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
1.329 droeschl 744: if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1.484.2.7 raeburn 745: $is_external = 1;
746: }
747:
1.484.2.20 raeburn 748: my ($canpaste,$nopaste,$othercrs,$areachange);
1.484.2.7 raeburn 749: if ($folder =~ /^supplemental/) {
750: $canpaste = &supp_pasteable($env{'docs.markedcopy_url'});
751: unless ($canpaste) {
752: $nopaste = &mt('Paste into Supplemental Content unavailable for this type of content.');
1.484.2.19 raeburn 753: }
1.484.2.7 raeburn 754: } else {
755: $canpaste = 1;
756: }
757:
758: if ($canpaste) {
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) {
1.484.2.19 raeburn 767: $othercrs = '<br />'.&mt('(from another course).');
1.484.2.7 raeburn 768: }
769: } else {
770: $canpaste = 0;
1.484.2.19 raeburn 771: $nopaste = &mt('Paste from another course unavailable.')
1.484.2.7 raeburn 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: }
783: }
784:
785: $r->print('<fieldset>'
786: .'<legend>'.&mt('Clipboard').'</legend>');
787: my ($type,$buffer);
788: if ($is_external) {
1.484.2.19 raeburn 789: $type = &mt('External Resource');
790: $buffer = $type.': '.
791: &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
1.484.2.7 raeburn 792: &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')';
1.484.2.26 raeburn 793: } else {
1.484.2.19 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" />';
1.484.2.7 raeburn 801: $buffer = $icon.$type.': '. &Apache::loncommon::parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'}));
1.329 droeschl 802: }
1.484.2.7 raeburn 803: if ($canpaste) {
804: $r->print('<form name="pasteform" action="/adm/coursedocs" method="post">'.$buffer);
1.484.2.26 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.484.2.7 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.484.2.26 raeburn 830: $copytext.'</label>'.(' ' x2).
1.484.2.19 raeburn 831: '<label>'.
1.484.2.7 raeburn 832: '<input type="radio" name="docs.markedcopy_options" value="move" />'.
1.484.2.26 raeburn 833: $movetext.'</label><br />');
834: if (($is_uploaded_map) && ($env{'docs.markedcopy_nested'})) {
1.484.2.7 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: );
1.484.2.19 raeburn 843: my (%display,%deps);
1.484.2.7 raeburn 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;
1.484.2.19 raeburn 855: $display{$subfolders[$j]} =
1.484.2.7 raeburn 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.484.2.19 raeburn 872: $r->print('
1.329 droeschl 873: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
874: ');
1.484.2.7 raeburn 875: $r->print('</form>');
876: } else {
877: $r->print(&mt('Paste buffer contains:').' '.$buffer.
878: '<br /><p class="LC_info">'.$nopaste.'</p>');
1.329 droeschl 879: }
1.484.2.7 raeburn 880: $r->print('</fieldset>');
1.329 droeschl 881: }
882:
1.484.2.7 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:
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;
903: }
904:
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.484.2.7 raeburn 932: my ($coursenum,$coursedom,$folder,$container,$errors) = @_;
1.329 droeschl 933:
1.484.2.7 raeburn 934: # Early out if paste buffer is empty
1.329 droeschl 935: if (!$env{'form.pastemarked'}) {
1.484.2.7 raeburn 936: return ();
937: }
938:
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: }
1.329 droeschl 945: }
946:
1.484.2.7 raeburn 947: # Prepare to paste resource at end of list
1.329 droeschl 948: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
949: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
1.484.2.7 raeburn 950:
951: my ($is_map,$srcdom,$srcnum,$prefixchg,%before,%after,%mapchanges,%tomove);
952: if ($url=~/\.(page|sequence)$/) {
1.484.2.19 raeburn 953: $is_map = 1;
1.484.2.7 raeburn 954: }
955: if ($url =~ m{^/uploaded/($match_domain)/($match_courseid)/([^/]+)}) {
956: $srcdom = $1;
957: $srcnum = $2;
958: my $oldprefix = $3;
959: # When paste buffer was populated using an active role in a different course
1.484.2.19 raeburn 960: # check for mdc privilege in the course from which the resource was pasted
1.484.2.7 raeburn 961: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum)) {
962: unless ($env{"user.priv.cm./$srcdom/$srcnum"} =~ /\Q:mdc&F\E/) {
963: return (&mt('Paste failed: Item is from a different course which you do not have rights to edit.'));
1.329 droeschl 964: }
965: }
1.484.2.19 raeburn 966: # When pasting content from Main Content to Supplemental Content and vice versa
1.484.2.7 raeburn 967: # URLs will contain different paths (which depend on whether pasted item is
1.484.2.19 raeburn 968: # a folder/page or a document.
1.484.2.7 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:
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.329 droeschl 1001: }
1.484.2.7 raeburn 1002: }
1003:
1004: # Maps need to be copied first
1005: my ($oldurl,%removefrommap,%removeparam,%addedmaps,%rewrites,%retitles,%copies,
1006: %dbcopies,%zombies,%params,%docmoves,%mapmoves,%newsubdir,%newurls);
1007: $oldurl = $url;
1008: if ($is_map) {
1009: # If pasting a map, check if map contains other maps
1.484.2.23 raeburn 1010: my ($allmaps,%hierarchy,%titles);
1011: $allmaps = {};
1.484.2.7 raeburn 1012: if ($folder =~ /^default/) {
1.484.2.23 raeburn 1013: $allmaps =
1014: &Apache::loncommon::allmaps_incourse($coursedom,$coursenum,
1015: $env{"course.$env{'request.course.id'}.home"},
1016: $env{'request.course.id'});
1.329 droeschl 1017: }
1.484.2.7 raeburn 1018: &contained_map_check($url,$folder,\%removefrommap,\%removeparam,
1.484.2.23 raeburn 1019: \%addedmaps,\%hierarchy,\%titles,$allmaps);
1.484.2.7 raeburn 1020: if ($url=~ m{^/uploaded/}) {
1021: my $newurl;
1022: unless ($env{'form.docs.markedcopy_options'} eq 'move') {
1.484.2.19 raeburn 1023: ($newurl,my $error) =
1.484.2.7 raeburn 1024: &get_newmap_url($url,$folder,$prefixchg,$coursedom,$coursenum,
1.484.2.23 raeburn 1025: $srcdom,$srcnum,\$title,$allmaps,\%newurls);
1.484.2.7 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: }
1036: }
1037: }
1038: if (($srcdom ne $coursedom) || ($srcnum ne $coursenum) || ($prefixchg) ||
1039: (($newurl ne '') && ($newurl ne $url))) {
1.484.2.26 raeburn 1040: unless (&url_paste_fixups($url,$folder,$prefixchg,$coursedom,
1041: $coursenum,$srcdom,$srcnum,$allmaps,
1042: \%rewrites,\%retitles,\%copies,\%dbcopies,
1.484.2.7 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.484.2.26 raeburn 1049: &url_paste_fixups($url,$folder,$prefixchg,$coursedom,$coursenum,
1050: $srcdom,$srcnum,$allmaps,\%rewrites,
1.484.2.7 raeburn 1051: \%retitles,\%copies,\%dbcopies,\%zombies,\%params,\%mapmoves,
1.484.2.26 raeburn 1052: \%mapchanges,\%tomove,\%newsubdir,\%newurls);
1.484.2.7 raeburn 1053: }
1054: } elsif ($url=~m {^/res/}) {
1.329 droeschl 1055: # published maps can only exists once, so remove it from paste buffer when done
1.484.2.7 raeburn 1056: &Apache::lonnet::delenv('docs.markedcopy');
1057: # if pasting published map (main content are only) check map is not already in course
1058: if ($folder =~ /^default/) {
1.484.2.23 raeburn 1059: if ((ref($allmaps) eq 'HASH') && ($allmaps->{$url})) {
1.484.2.7 raeburn 1060: return (&mt('Paste failed: only one instance of a particular published sequence or page is allowed within each course.'));
1061: }
1062: }
1063: }
1.329 droeschl 1064: }
1.484.2.26 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.484.2.7 raeburn 1080: $title=&mt('Copy of').' '.$title;
1081: } else {
1.484.2.26 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});
1.484.2.7 raeburn 1088: }
1.484.2.26 raeburn 1089: if ($lockerr{$prefix}) {
1090: $lockerrors = $lockerr{$prefix};
1091: }
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.484.2.7 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:
1103: my $newidx;
1104: unless ($is_map) {
1.329 droeschl 1105: # Now insert the URL at the bottom
1.484.2.7 raeburn 1106: $newidx = &LONCAPA::map::getresidx($url);
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+)/(.+)$});
1111: my ($newloc,$newdocsdir) = ($folder =~ /^(default|supplemental)_?(\d*)/);
1112: my $newprefix = $newloc;
1113: if ($newloc eq 'default') {
1114: $newprefix = 'docs';
1115: }
1116: if ($newdocsdir eq '') {
1117: $newdocsdir = 'default';
1118: }
1.484.2.26 raeburn 1119: if (($prefixchg) ||
1120: ($srcdom ne $coursedom) || ($srcnum ne $coursenum) ||
1121: ($env{'form.docs.markedcopy_options'} ne 'move')) {
1.484.2.7 raeburn 1122: my $newpath = "$newprefix/$newdocsdir/$newidx/$rem";
1123: $url =
1124: &Apache::lonclonecourse::writefile($env{'request.course.id'},$newpath,
1125: &Apache::lonnet::getfile($oldurl));
1126: if ($url eq '/adm/notfound.html') {
1127: return (&mt('Paste failed: an error occurred saving the file.'));
1128: } else {
1129: my ($newsubpath) = ($newpath =~ m{^(.*/)[^/]*$});
1130: $newsubpath =~ s{/+$}{/};
1131: $docmoves{$oldurl} = $newsubpath;
1132: }
1133: }
1134: }
1135: }
1136: }
1.484.2.19 raeburn 1137: # Apply any changes to maps, or copy dependencies for uploaded HTML pages
1.484.2.7 raeburn 1138: my ($result,$save_err);
1.484.2.23 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,
1157: );
1.484.2.26 raeburn 1158: ($result,my $msgsarray,my $lockerror) =
1.484.2.23 raeburn 1159: &apply_fixups($folder,$is_map,$coursedom,$coursenum,$errors,
1160: \%updated,\%info,\%moves,$prefixchg,$oldurl,$url,'paste');
1.484.2.26 raeburn 1161: $lockerrors .= $lockerror;
1.484.2.7 raeburn 1162: if ($result eq 'ok') {
1.484.2.19 raeburn 1163: if ($is_map) {
1.484.2.7 raeburn 1164: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1165: $folder.'.'.$container);
1.484.2.26 raeburn 1166: return ($errtext,$save_err,$msgsarray,$lockerrors) if ($fatal);
1.484.2.7 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: }
1176: if ($env{'docs.markedcopy_supplemental'}) {
1177: if ($folder !~ /^supplemental/) {
1178: (undef,undef,$title) =
1179: &Apache::loncommon::parse_supplemental_title($env{'docs.markedcopy_supplemental'});
1180: }
1.329 droeschl 1181: } else {
1.484.2.7 raeburn 1182: if ($folder=~/^supplemental/) {
1183: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1184: $env{'user.domain'}.'___&&&___'.$title;
1185: }
1.329 droeschl 1186: }
1.484.2.19 raeburn 1187: $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
1.484.2.7 raeburn 1188: push(@LONCAPA::map::order, $newidx);
1189:
1190: # Store the result
1.484.2.19 raeburn 1191: my ($errtext,$fatal) =
1.484.2.7 raeburn 1192: &storemap($coursenum,$coursedom,$folder.'.'.$container,1);
1193: if ($fatal) {
1194: $save_err = $errtext;
1.329 droeschl 1195: }
1196: }
1.484.2.19 raeburn 1197:
1.484.2.7 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.484.2.26 raeburn 1203: return ($result,$save_err,$msgsarray,$lockerrors);
1.484.2.7 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: }
1262: }
1263: return ($newurl);
1264: }
1265:
1266: sub dbcopy {
1.484.2.26 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.484.2.7 raeburn 1354: }
1355: }
1.484.2.26 raeburn 1356: return ($url,$result,$errtext);
1.329 droeschl 1357: }
1358:
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.484.2.7 raeburn 1373: sub contained_map_check {
1374: my ($url,$folder,$removefrommap,$removeparam,$addedmaps,$hierarchy,$titles,
1375: $allmaps) = @_;
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)) {
1387: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1388: next;
1389: }
1390: }
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'};
1395: } else {
1396: if ($allmaps->{$ressrc}) {
1.484.2.23 raeburn 1397: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1.484.2.7 raeburn 1398: } elsif (ref($addedmaps->{$ressrc}) eq 'ARRAY') {
1399: $removefrommap->{$url}{$token->[2]->{'id'}} = $ressrc;
1400: } else {
1401: $addedmaps->{$ressrc} = [$url];
1402: }
1403: }
1404: &contained_map_check($ressrc,$folder,$removefrommap,$removeparam,
1405: $addedmaps,$hierarchy,$titles,$allmaps);
1406: }
1407: } elsif ($token->[1] eq 'param') {
1408: if ($folder =~ /^supplemental/) {
1409: if (ref($removeparam->{$url}{$token->[2]->{'to'}}) eq 'ARRAY') {
1410: push(@{$removeparam->{$url}{$token->[2]->{'to'}}},$token->[2]->{'name'});
1411: } else {
1.484.2.19 raeburn 1412: $removeparam->{$url}{$token->[2]->{'to'}} = [$token->[2]->{'name'}];
1.484.2.7 raeburn 1413: }
1414: }
1415: }
1416: }
1417: }
1418: return;
1419: }
1420:
1421: sub url_paste_fixups {
1.484.2.26 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.484.2.7 raeburn 1425: my $checktitle;
1426: if (($prefixchg) &&
1427: ($oldurl =~ m{^/uploaded/$match_domain/$match_courseid/supplemental})) {
1428: $checktitle = 1;
1429: }
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: }
1437: my $file = &Apache::lonnet::getfile($oldurl);
1438: return if ($file eq '-1');
1439: my $parser = HTML::TokeParser->new(\$file);
1440: $parser->attr_encoded(1);
1441: my $changed = 0;
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 '');
1447: my $id = $token->[2]->{'id'};
1448: my $title = $token->[2]->{'title'};
1449: if ($checktitle) {
1450: if ($title =~ m{\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1.484.2.25 raeburn 1451: $retitles->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1452: }
1453: }
1454: next if ($token->[2]->{'type'} eq 'external');
1455: if ($token->[2]->{'type'} eq 'zombie') {
1.484.2.19 raeburn 1456: next if ($skip);
1.484.2.25 raeburn 1457: $zombies->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1458: $changed = 1;
1459: } elsif ($ressrc =~ m{^/uploaded/($match_domain)/($match_courseid)/(.+)$}) {
1460: my $srcdom = $1;
1461: my $srcnum = $2;
1462: my $rem = $3;
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.484.2.26 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.484.2.7 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))) {
1.484.2.19 raeburn 1489:
1.484.2.7 raeburn 1490: if ($rem =~ /^(default|supplemental)(_?\d*).(sequence|page)$/) {
1.484.2.25 raeburn 1491: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1492: $mapchanges->{$ressrc} = 1;
1.484.2.26 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.484.2.7 raeburn 1498: $mapmoves->{$ressrc} = 1;
1499: }
1500: $changed = 1;
1501: } else {
1.484.2.25 raeburn 1502: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.7 raeburn 1503: $copies->{$oldurl}{$ressrc} = $id;
1504: $changed = 1;
1505: }
1506: }
1.484.2.26 raeburn 1507: } elsif ($ressrc =~ m{^/adm/($match_domain)/($match_courseid)/.+$}) {
1.484.2.19 raeburn 1508: next if ($skip);
1.484.2.7 raeburn 1509: my $srcdom = $1;
1510: my $srcnum = $2;
1511: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.25 raeburn 1512: $rewrites->{$oldurl}{$id} = $ressrc;
1.484.2.26 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.484.2.7 raeburn 1524: $changed = 1;
1525: }
1526: } elsif ($ressrc =~ m{^/public/($match_domain)/($match_courseid)/(.+)$}) {
1527: next if ($skip);
1528: my $srcdom = $1;
1529: my $srcnum = $2;
1530: if (($srcdom ne $cdom) || ($srcnum ne $cnum)) {
1.484.2.26 raeburn 1531: $dbcopies->{$oldurl}{$id}{'src'} = $ressrc;
1532: $dbcopies->{$oldurl}{$id}{'cdom'} = $srcdom;
1533: $dbcopies->{$oldurl}{$id}{'cnum'} = $srcnum;
1.484.2.7 raeburn 1534: $changed = 1;
1535: }
1536: }
1537: } elsif ($token->[1] eq 'param') {
1538: next if ($skip);
1.484.2.19 raeburn 1539: my $to = $token->[2]->{'to'};
1.484.2.7 raeburn 1540: if ($to ne '') {
1541: if (ref($params->{$oldurl}{$to}) eq 'ARRAY') {
1542: push(@{$params->{$oldurl}{$to}},$token->[2]->{'name'});
1543: } else {
1544: @{$params->{$oldurl}{$to}} = ($token->[2]->{'name'});
1545: }
1546: }
1547: }
1548: }
1549: return $changed;
1550: }
1551:
1552: sub apply_fixups {
1.484.2.23 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.484.2.26 raeburn 1556: %params,%newsubdir,%before,%after,%copies,%docmoves,%mapmoves,@msgs,
1557: %lockerrors,$lockmsg);
1.484.2.23 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.484.2.7 raeburn 1604: my @allcopies;
1.484.2.23 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.484.2.7 raeburn 1613: }
1.484.2.23 raeburn 1614: undef(%added);
1.484.2.7 raeburn 1615: }
1616: }
1617: if ($key eq $oldurl) {
1.484.2.23 raeburn 1618: if ((exists($docmoves{$key}))) {
1.484.2.25 raeburn 1619: unless (grep(/^\Q$oldurl\E$/,@allcopies)) {
1.484.2.7 raeburn 1620: push(@allcopies,$oldurl);
1621: }
1622: }
1623: }
1624: if (@allcopies > 0) {
1625: foreach my $item (@allcopies) {
1.484.2.19 raeburn 1626: my ($relpath,$oldsubdir,$fname) =
1.484.2.7 raeburn 1627: ($item =~ m{^(/uploaded/$match_domain/$match_courseid/(?:docs|supplemental)/(default|\d+)/.*/)([^/]+)$});
1628: if ($fname ne '') {
1629: my $content = &Apache::lonnet::getfile($item);
1630: unless ($content eq '-1') {
1631: my $storefn;
1.484.2.23 raeburn 1632: if (($key eq $oldurl) && (exists($docmoves{$key}))) {
1633: $storefn = $docmoves{$key};
1.484.2.7 raeburn 1634: } else {
1635: $storefn = $relpath;
1636: $storefn =~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 1637: if ($prefixchg && $before{'doc'} && $after{'doc'}) {
1638: $storefn =~ s/^\Q$before{'doc'}\E/$after{'doc'}/;
1.484.2.7 raeburn 1639: }
1.484.2.23 raeburn 1640: if ($newsubdir{$key}) {
1.484.2.25 raeburn 1641: $storefn =~ s#^(docs|supplemental)/\Q$oldsubdir\E/#$1/$newsubdir{$key}/#;
1.484.2.7 raeburn 1642: }
1643: }
1644: ©_dependencies($item,$storefn,$relpath,$errors,\$content);
1.484.2.19 raeburn 1645: my $copyurl =
1.484.2.7 raeburn 1646: &Apache::lonclonecourse::writefile($env{'request.course.id'},
1647: $storefn.$fname,$content);
1648: if ($copyurl eq '/adm/notfound.html') {
1.484.2.23 raeburn 1649: if (exists($docmoves{$oldurl})) {
1.484.2.7 raeburn 1650: return &mt('Paste failed: an error occurred copying the file.');
1651: } elsif (ref($errors) eq 'HASH') {
1652: $errors->{$item} = 1;
1653: }
1654: }
1655: }
1656: }
1657: }
1658: }
1659: }
1.484.2.23 raeburn 1660: foreach my $key (keys(%mapmoves)) {
1.484.2.7 raeburn 1661: my $storefn=$key;
1662: $storefn=~s{^/uploaded/$match_domain/$match_courseid/}{};
1.484.2.23 raeburn 1663: if ($prefixchg && $before{'map'} && $after{'map'}) {
1664: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 1665: }
1.484.2.23 raeburn 1666: if ($newsubdir{$key}) {
1667: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 1668: }
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;
1681: }
1682: }
1683: }
1684: }
1685: my %updates;
1686: if ($is_map) {
1.484.2.23 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.484.2.7 raeburn 1695: }
1696: foreach my $key (keys(%updates)) {
1697: my (%torewrite,%toretitle,%toremove,%remparam,%currparam,%zombie,%newdb);
1.484.2.23 raeburn 1698: if (ref($rewrites{$key}) eq 'HASH') {
1699: %torewrite = %{$rewrites{$key}};
1.484.2.7 raeburn 1700: }
1.484.2.23 raeburn 1701: if (ref($retitles{$key}) eq 'HASH') {
1702: %toretitle = %{$retitles{$key}};
1.484.2.7 raeburn 1703: }
1.484.2.23 raeburn 1704: if (ref($removefrommap{$key}) eq 'HASH') {
1705: %toremove = %{$removefrommap{$key}};
1.484.2.7 raeburn 1706: }
1.484.2.23 raeburn 1707: if (ref($removeparam{$key}) eq 'HASH') {
1708: %remparam = %{$removeparam{$key}};
1.484.2.7 raeburn 1709: }
1.484.2.23 raeburn 1710: if (ref($zombies{$key}) eq 'HASH') {
1711: %zombie = %{$zombies{$key}};
1.484.2.7 raeburn 1712: }
1.484.2.23 raeburn 1713: if (ref($dbcopies{$key}) eq 'HASH') {
1.484.2.26 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.484.2.7 raeburn 1725: }
1726: }
1.484.2.23 raeburn 1727: if (ref($params{$key}) eq 'HASH') {
1728: %currparam = %{$params{$key}};
1.484.2.7 raeburn 1729: }
1730: my ($errtext,$fatal) = &LONCAPA::map::mapread($key);
1731: if ($fatal) {
1.484.2.26 raeburn 1732: return ($errtext);
1.484.2.7 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.484.2.25 raeburn 1737: if ($zombie{$i} eq $src) {
1.484.2.7 raeburn 1738: undef($LONCAPA::map::zombies[$i]);
1739: }
1740: }
1741: }
1.484.2.23 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.484.2.7 raeburn 1745: my $changed;
1.484.2.23 raeburn 1746: my ($title,$src,$ext,$type)=split(/\:/,$LONCAPA::map::resources[$idx]);
1747: if ((exists($toremove{$idx})) && ($toremove{$idx} eq $src)) {
1.484.2.7 raeburn 1748: splice(@LONCAPA::map::order,$i,1);
1.484.2.23 raeburn 1749: if (ref($currparam{$idx}) eq 'ARRAY') {
1750: foreach my $name (@{$currparam{$idx}}) {
1751: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1.484.2.7 raeburn 1752: }
1753: }
1754: next;
1755: }
1756: my $origsrc = $src;
1.484.2.25 raeburn 1757: if ((exists($toretitle{$idx})) && ($toretitle{$idx} eq $src)) {
1.484.2.7 raeburn 1758: if ($title =~ m{^\d+\Q___&&&___\E$match_username\Q___&&&___\E$match_domain\Q___&&&___\E(.+)$}) {
1759: $changed = 1;
1760: }
1761: }
1.484.2.25 raeburn 1762: if ((exists($torewrite{$idx})) && ($torewrite{$idx} eq $src)) {
1.484.2.7 raeburn 1763: $src =~ s{^/(uploaded|adm|public)/$match_domain/$match_courseid/}{/$1/$cdom/$cnum/};
1764: if ($origsrc =~ m{^/uploaded/}) {
1.484.2.23 raeburn 1765: if ($prefixchg && $before{'map'} && $after{'map'}) {
1.484.2.7 raeburn 1766: if ($src =~ /\.(page|sequence)$/) {
1.484.2.23 raeburn 1767: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'map'}\E#$1$after{'map'}#;
1.484.2.7 raeburn 1768: } else {
1.484.2.23 raeburn 1769: $src =~ s#^(/uploaded/$match_domain/$match_courseid/)\Q$before{'doc'}\E#$1$after{'doc'}#;
1.484.2.7 raeburn 1770: }
1771: }
1.484.2.25 raeburn 1772: if ($origsrc =~ /\.(page|sequence)$/) {
1773: if ($newsubdir{$origsrc}) {
1.484.2.23 raeburn 1774: $src =~ s#^(/uploaded/$match_domain/$match_courseid/(?:default|supplemental)_)(\d+)#$1$newsubdir{$origsrc}#;
1.484.2.7 raeburn 1775: }
1.484.2.25 raeburn 1776: } elsif ($newsubdir{$key}) {
1777: $src =~ s#^(/uploaded/$match_domain/$match_courseid/\w+/)(\d+)#$1$newsubdir{$key}#;
1.484.2.7 raeburn 1778: }
1779: }
1780: $changed = 1;
1.484.2.26 raeburn 1781: } elsif ($newdb{$idx} ne '') {
1782: $src = $newdb{$idx};
1.484.2.7 raeburn 1783: $changed = 1;
1784: }
1785: if ($changed) {
1.484.2.23 raeburn 1786: $LONCAPA::map::resources[$idx] = join(':',($title,$src,$ext,$type));
1.484.2.7 raeburn 1787: }
1788: }
1789: }
1790: foreach my $idx (keys(%remparam)) {
1791: if (ref($remparam{$idx}) eq 'ARRAY') {
1.484.2.19 raeburn 1792: foreach my $name (@{$remparam{$idx}}) {
1.484.2.7 raeburn 1793: &LONCAPA::map::delparameter($idx,'parameter_'.$name);
1794: }
1795: }
1796: }
1.484.2.26 raeburn 1797: if (values(%lockerrors) > 0) {
1798: $lockmsg = join('<br />',values(%lockerrors));
1799: }
1.484.2.7 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.484.2.23 raeburn 1807: if ($prefixchg && $before{'map'} && $after{'map'}) {
1808: $storefn =~ s/^\Q$before{'map'}\E/$after{'map'}/;
1.484.2.7 raeburn 1809: }
1.484.2.23 raeburn 1810: if ($newsubdir{$key}) {
1811: $storefn =~ s/^((?:default|supplemental)_)(\d+)/$1$newsubdir{$key}/;
1.484.2.7 raeburn 1812: }
1813: }
1814: my $report;
1815: if ($folder !~ /^supplemental/) {
1816: $report = 1;
1817: }
1.484.2.20 raeburn 1818: (my $outtext,$errtext) =
1.484.2.7 raeburn 1819: &LONCAPA::map::storemap("/uploaded/$cdom/$cnum/$storefn",1,$report);
1820: if ($errtext) {
1.484.2.23 raeburn 1821: if ($caller eq 'paste') {
1.484.2.26 raeburn 1822: return (&mt('Paste failed: an error occurred saving the folder or page.'));
1.484.2.23 raeburn 1823: }
1.484.2.7 raeburn 1824: }
1825: }
1826: }
1.484.2.26 raeburn 1827: return ('ok',\@msgs,$lockmsg);
1.484.2.7 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: }
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.484.2.17 raeburn 1958: $supplementalflag,$orderhash,$iconpath,$pathitem)=@_;
1.484.2.19 raeburn 1959: my ($randompick,$ishidden,$isencrypted,$plain,$is_random_order,$container);
1960: if ($allowed) {
1961: (my $breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,
1962: $is_random_order,$container) =
1963: &Apache::lonhtmlcommon::docs_breadcrumbs($allowed,$crstype,1);
1964: $r->print($breadcrumbtrail);
1965: } elsif ($env{'form.folderpath'} =~ /\:1$/) {
1966: $container = 'page';
1967: } else {
1968: $container = 'sequence';
1969: }
1.484 raeburn 1970:
1.484.2.21 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.484.2.7 raeburn 2014: my %paste_errors;
1.484.2.26 raeburn 2015: my ($paste_res,$save_error,$pastemsgarray,$lockerror) =
1.484.2.7 raeburn 2016: &do_paste_from_buffer($coursenum,$coursedom,$folder,$container,
2017: \%paste_errors);
1.484.2.26 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.484.2.7 raeburn 2031: if ($save_error ne '') {
1.484.2.19 raeburn 2032: return $save_error;
1.484.2.7 raeburn 2033: }
2034: if ($paste_res ne 'ok') {
1.329 droeschl 2035: $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
2036: }
1.484.2.7 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.484.2.7 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.484.2.26 raeburn 2064: map { &unescape($_); } split(/\=/,$item);
2065: if ($url =~ m{^\Q/uploaded/$coursedom/$coursenum/\E(default|supplemental)_new\.(sequence|page)$}) {
1.484.2.19 raeburn 2066: my ($suffix,$errortxt,$locknotfreed) =
1.484.2.26 raeburn 2067: &new_timebased_suffix($coursedom,$coursenum,'map',$1,$2);
1.484.2.15 raeburn 2068: if ($locknotfreed) {
2069: $r->print($locknotfreed);
2070: }
2071: if ($suffix) {
1.484.2.19 raeburn 2072: $url =~ s/_new\./_$suffix./;
1.484.2.15 raeburn 2073: } else {
2074: return $errortxt;
2075: }
1.484.2.26 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.484.2.27 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.484.2.15 raeburn 2104: }
1.329 droeschl 2105: push(@imports, [$name, $url, $residx]);
2106: }
2107: }
1.484.2.23 raeburn 2108: ($errtext,$fatal,my $fixuperrors) =
2109: &group_import($coursenum, $coursedom, $folder,$container,
2110: 'londocs',@imports);
1.329 droeschl 2111: return $errtext if ($fatal);
1.484.2.23 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.484.2.7 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.484.2.12 raeburn 2180: $coursenum,$coursedom,$crstype,
1.484.2.19 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.484.2.19 raeburn 2186:
2187: if (($allowed) || ($supplementalflag && $folder eq 'supplemental')) {
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.484.2.21 raeburn 2193: .'<li><a href="/adm/coursedocs?forcesupplement=1&command=editsupp" '
1.484.2.19 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 />';
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 {
2215: $to_show .= $toolslink
2216: .&Apache::loncommon::start_data_table('LC_tableOfContent')
2217: .$output.' '
2218: .&Apache::loncommon::end_data_table();
2219: }
2220: } else {
2221: if (!$allowed) {
2222: $to_show .= $toolslink;
1.393 raeburn 2223: }
1.484.2.19 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.484.2.19 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.484.2.7 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.484.2.19 raeburn 2273: if ($env{'form.folderpath'} =~ /:1$/) {
1.329 droeschl 2274: $container='page';
2275: }
2276: ($errtext,$fatal)=
1.484.2.27 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.484.2.27 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.484.2.7 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.484.2.12 raeburn 2416: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
1.484.2.19 raeburn 2417: $crstype,$pathitem,$supplementalflag,$container)=@_;
2418: my ($foldertitle,$renametitle);
1.329 droeschl 2419: if (&is_supplemental_title($title)) {
1.484.2.7 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.484.2.28! 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.484.2.16 raeburn 2441: my $isexternal;
1.484.2.19 raeburn 2442: if ($residx) {
1.484.2.12 raeburn 2443: my $currurl = $url;
2444: $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.16 raeburn 2445: if ($currurl =~ m{^/adm/wrapper/ext/}) {
2446: $isexternal = 1;
2447: }
1.484.2.19 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.484.2.12 raeburn 2456: }
1.484.2.19 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.484.2.12 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.484.2.12 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.484.2.9 raeburn 2496: my $noremove=0;
1.484.2.7 raeburn 2497: if ($url=~ m{^/res/.+\.(page|sequence)$}) {
1.484.2.19 raeburn 2498: # no copy for published maps
2499: $nocopy=1;
2500: }
1.344 bisitz 2501: if ($url=~/^\/res\/lib\/templates\//) {
2502: $nocopy=1;
1.329 droeschl 2503: $nocut=1;
2504: }
1.484.2.9 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.484.2.19 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.484.2.16 raeburn 2562: |\.html$)}x)
1.484.2.19 raeburn 2563: || $isexternal) {
1.329 droeschl 2564: $skip_confirm = 1;
2565: }
1.484.2.19 raeburn 2566:
2567: if ($nocopy) {
1.484.2.16 raeburn 2568: $copylink=(<<ENDCOPY);
2569: <span style="visibility: hidden;">$lt{'cp'}</span>
2570: ENDCOPY
2571: } else {
1.484.2.19 raeburn 2572: $copylink=(<<ENDCOPY);
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.484.2.19 raeburn 2576: if ($nocut) {
1.484.2.16 raeburn 2577: $cutlink=(<<ENDCUT);
2578: <span style="visibility: hidden;">$lt{'ct'}</span>
2579: ENDCUT
2580: } else {
1.484.2.19 raeburn 2581: $cutlink=(<<ENDCUT);
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.484.2.16 raeburn 2585: if ($noremove) {
2586: $removelink=(<<ENDREM);
2587: <span style="visibility: hidden;">$lt{'rm'}</a>
2588: ENDREM
2589: } else {
1.484.2.9 raeburn 2590: $removelink=(<<ENDREM);
1.484.2.19 raeburn 2591: <a href='javascript:removeres("$esc_path","$index","$renametitle",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
1.484.2.9 raeburn 2592: ENDREM
2593: }
1.484.2.19 raeburn 2594: unless ($isexternal) {
2595: $renamelink=(<<ENDREN);
2596: <a href='javascript:changename("$esc_path","$index","$renametitle");' class="LC_docs_rename">$lt{'rn'}</a>
1.484.2.16 raeburn 2597: ENDREN
1.484.2.19 raeburn 2598: }
1.478 raeburn 2599: $form_start = '
2600: <form action="/adm/coursedocs" method="post">
2601: ';
2602: $form_common=(<<END);
1.484.2.28! 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.484.2.28! raeburn 2612: <a href='/adm/coursedocs?cmd=up_$index&folderpath=$esc_path&symb=$symb'>
1.484.2.12 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.484.2.28! raeburn 2617: <a href='/adm/coursedocs?cmd=down_$index&folderpath=$esc_path&symb=$symb'>
1.484.2.12 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.484.2.16 raeburn 2628: <td class="LC_docs_entry_commands"><span class="LC_nobreak">
1.484.2.9 raeburn 2629: $removelink
1.329 droeschl 2630: $cutlink
2631: $copylink
1.484.2.16 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.484.2.19 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.484.2.19 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.484.2.19 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.484.2.19 raeburn 2668: $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
1.484.2.12 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.484.2.19 raeburn 2685: }
1.484.2.12 raeburn 2686: if (&Apache::lonnet::symbverify($symb,$url)) {
1.484.2.19 raeburn 2687: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1.484.2.12 raeburn 2688: } else {
2689: $url='';
2690: }
1.484.2.19 raeburn 2691: }
1.329 droeschl 2692: }
1.478 raeburn 2693: my ($rand_pick_text,$rand_order_text);
1.484.2.19 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.484.2.19 raeburn 2698: if (!$allowed && $supplementalflag) {
2699: $folderpath.=$containerarg.'&'.$foldername;
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.484.2.19 raeburn 2704: $folderpath.=$containerarg.'&'.$foldername.
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.484.2.19 raeburn 2712: 'parameter_randomorder'))[0]=~/^yes$/i)
2713: .':'.$ispage;
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.484.2.19 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.484.2.19 raeburn 2736: }
1.484.2.18 raeburn 2737: } elsif ($supplementalflag && !$allowed) {
1.484.2.19 raeburn 2738: $url .= ($url =~ /\?/) ? '&':'?';
1.484.2.18 raeburn 2739: $url .= 'folderpath='.&HTML::Entities::encode($esc_path,'<>&"');
1.484.2.19 raeburn 2740: if ($title) {
2741: $url .= '&title='.&HTML::Entities::encode($renametitle,'<>&"');
2742: }
2743: if ($isexternal && $orderidx) {
2744: $url .= '&idx='.$orderidx;
2745: }
1.329 droeschl 2746: }
1.484.2.19 raeburn 2747: my ($tdalign,$tdwidth);
1.484.2.12 raeburn 2748: if ($allowed) {
1.484.2.19 raeburn 2749: my $fileloc =
1.484.2.12 raeburn 2750: &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
1.484.2.19 raeburn 2751: if ($isexternal) {
2752: ($editlink,$extresform) =
2753: &Apache::lonextresedit::extedit_form(0,$residx,$orig_url,$title,$pathitem);
2754: } elsif (!$isfolder && !$ispage) {
2755: my ($cfile,$home,$switchserver,$forceedit,$forceview) =
1.484.2.14 raeburn 2756: &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom,$orig_url);
1.484.2.19 raeburn 2757: if (($cfile ne '') && ($symb ne '' || $supplementalflag)) {
2758: my $jscall =
1.484.2.12 raeburn 2759: &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
2760: $switchserver,
1.484.2.14 raeburn 2761: $forceedit,
1.484.2.19 raeburn 2762: undef,$symb,
2763: &escape($env{'form.folderpath'}),
2764: $renametitle,'','',1);
1.484.2.12 raeburn 2765: if ($jscall) {
1.484.2.19 raeburn 2766: $editlink = '<a class="LC_docs_ext_edit" href="javascript:'.
2767: $jscall.'" >'.&mt('Edit').'</a> '."\n";
1.484.2.12 raeburn 2768: }
2769: }
2770: }
1.484.2.19 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.484.2.19 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.484.2.19 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.484.2.19 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.484.2.26 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.484.2.15 raeburn 2842: }
2843: $idtype = 'concat';
2844: my ($suffix,$freedlock,$error) =
1.484.2.26 raeburn 2845: &Apache::lonnet::get_timebased_id($prefix,'num',$namespace,
1.484.2.15 raeburn 2846: $coursedom,$coursenum);
2847: if (!$suffix) {
1.484.2.26 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.484.2.15 raeburn 2855: if ($error) {
2856: $errtext .= '<br />'.$error;
2857: }
2858: }
2859: if ($freedlock ne 'ok') {
1.484.2.26 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.484.2.15 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.484.2.19 raeburn 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.484.2.3 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 3171: $weeksel=' selected="selected"';
1.329 droeschl 3172: } elsif ($env{'form.timerange'}==86400) {
3173: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
1.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.10 raeburn 3245: #excludes not versionable problems from resource version history:
3246: next unless ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/);
1.484.2.19 raeburn 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.484.2.19 raeburn 3255: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br />'.
1.479 golterma 3256: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
1.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.19 raeburn 3266: } else {
1.479 golterma 3267: $r->print($usedversion);
3268: }
1.329 droeschl 3269: } else {
1.484.2.19 raeburn 3270: $r->print($currentversion);
1.329 droeschl 3271: }
1.484.2.19 raeburn 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.484.2.19 raeburn 3307: $r->print('</span><br />');
3308: }
3309: $r->print('</span></td>'.&Apache::loncommon::end_data_table_row());
1.329 droeschl 3310: }
1.484.2.19 raeburn 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.484.2.19 raeburn 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.484.2.12 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 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
3416: } else {
3417: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'."\n";
3418: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
3419: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
3420: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
3421: }
3422: $output .= "\n".'</ul>'."\n";
3423: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
3424: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
3425: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
3426: return $output;
1.442 www 3427: }
3428:
3429: #
3430: # End tabs
3431: #
3432:
3433: sub endContentScreen {
1.484 raeburn 3434: return '</div></div></div>';
1.442 www 3435: }
1.329 droeschl 3436:
1.446 www 3437: sub supplemental_base {
1.472 raeburn 3438: return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
1.446 www 3439: }
3440:
1.329 droeschl 3441: sub handler {
3442: my $r = shift;
3443: &Apache::loncommon::content_type($r,'text/html');
3444: $r->send_http_header;
3445: return OK if $r->header_only;
1.484 raeburn 3446:
3447: # get course data
1.408 raeburn 3448: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3449: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
3450: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3451:
3452: # graphics settings
3453: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 3454:
1.443 www 3455: #
1.329 droeschl 3456: # --------------------------------------------- Initialize help topics for this
3457: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
3458: 'Adding_External_Resource','Navigate_Content',
3459: 'Adding_Folders','Docs_Overview', 'Load_Map',
3460: 'Supplemental','Score_Upload_Form','Adding_Pages',
1.484.2.19 raeburn 3461: 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
1.484.2.12 raeburn 3462: 'Uploading_From_Harddrive',
1.329 droeschl 3463: 'Check_Resource_Versions','Verify_Content') {
3464: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
3465: }
3466: # Composite help files
3467: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
3468: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
3469: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
3470: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
3471: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
3472: 'Option_Response_Simple');
3473: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
3474: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 3475: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 3476: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 3477: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 3478: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
1.484.2.27 raeburn 3479: $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
3480: $help{'Web Page'} = &Apache::loncommon::help_open_topic('Docs_Web_Page');
1.472 raeburn 3481:
3482: my $allowed;
3483: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
3484: unless ($r->uri eq '/adm/supplemental') {
3485: # does this user have privileges to modify content.
3486: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
3487: }
3488:
1.484 raeburn 3489: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
3490: 'inhibitmenu']);
3491: if ($allowed && $env{'form.chooseserver'}) {
3492: &choose_dump_server($r);
3493: return OK;
3494: } elsif ($allowed && $env{'form.verify'}) {
1.329 droeschl 3495: &init_breadcrumbs('verify','Verify Content');
3496: &verifycontent($r);
3497: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 3498: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 3499: &list_symbs($r);
3500: } elsif ($allowed && $env{'form.docslog'}) {
3501: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 3502: my $folder = $env{'form.folder'};
3503: if ($folder eq '') {
3504: $folder='default';
3505: }
3506: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 3507: } elsif ($allowed && $env{'form.versions'}) {
3508: &init_breadcrumbs('versions','Check/Set Resource Versions');
3509: &checkversions($r);
3510: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.484 raeburn 3511: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 3512: &dumpcourse($r);
3513: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 3514: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 3515: &Apache::imsexport::exportcourse($r);
1.329 droeschl 3516: } else {
1.445 www 3517: #
3518: # Done catching special calls
1.484 raeburn 3519: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 3520: # Get the parameters that may be needed
3521: #
3522: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.484.2.19 raeburn 3523: ['folderpath',
3524: 'forcesupplement','forcestandard',
3525: 'tools','symb','command','supppath']);
1.445 www 3526:
3527: # standard=1: this is a "new-style" course with an uploaded map as top level
3528: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 3529:
3530: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 3531:
1.484 raeburn 3532: # Decide whether this should display supplemental or main content or utilities
1.445 www 3533: # supplementalflag=1: show supplemental documents
3534: # supplementalflag=0: show standard documents
1.484 raeburn 3535: # toolsflag=1: show utilities
1.445 www 3536:
3537:
3538: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
1.484.2.19 raeburn 3539: if (($env{'form.folderpath'}=~/^default/) || ($env{'form.folderpath'} eq "")) {
1.445 www 3540: $supplementalflag=0;
3541: }
3542: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
3543: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
3544: unless ($allowed) { $supplementalflag=1; }
3545: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 3546: my $toolsflag=0;
3547: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 3548:
1.329 droeschl 3549: my $script='';
3550: my $showdoc=0;
1.457 raeburn 3551: my $addentries = {};
1.475 raeburn 3552: my $container;
1.329 droeschl 3553: my $containertag;
1.484.2.17 raeburn 3554: my $pathitem;
1.329 droeschl 3555:
1.464 www 3556: # Do we directly jump somewhere?
1.466 www 3557:
1.484.2.21 raeburn 3558: if (($env{'form.command'} eq 'direct') || ($env{'form.command'} eq 'directnav')) {
1.472 raeburn 3559: if ($env{'form.symb'} ne '') {
1.484.2.19 raeburn 3560: $env{'form.folderpath'}=
3561: &Apache::loncommon::symb_to_docspath($env{'form.symb'});
1.484.2.21 raeburn 3562: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
3563: $env{'form.command'}.'_'.$env{'form.symb'}});
1.472 raeburn 3564: } elsif ($env{'form.supppath'} ne '') {
3565: $env{'form.folderpath'}=$env{'form.supppath'};
1.484.2.21 raeburn 3566: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} =>
3567: $env{'form.command'}.'_'.$env{'form.supppath'}});
1.466 www 3568: }
1.472 raeburn 3569: } elsif ($env{'form.command'} eq 'editdocs') {
1.484.2.21 raeburn 3570: $env{'form.folderpath'} = 'default&'.
3571: &Apache::lonhtmlcommon::entity_encode('Main Course Content').
3572: ':::::';
3573: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => $env{'form.command'}});
1.472 raeburn 3574: } elsif ($env{'form.command'} eq 'editsupp') {
1.484.2.21 raeburn 3575: $env{'form.folderpath'} = 'supplemental&'.
1.472 raeburn 3576: &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
1.484.2.21 raeburn 3577: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/supplemental'});
3578: } elsif ($env{'form.command'} eq 'contents') {
3579: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/navmaps'});
3580: } elsif ($env{'form.command'} eq 'home') {
3581: &Apache::lonnet::appenv({'docs.exit.'.$env{'request.course.id'} => '/adm/menu'});
1.464 www 3582: }
3583:
1.484.2.23 raeburn 3584:
1.445 www 3585: # Where do we store these for when we come back?
3586: my $stored_folderpath='docs_folderpath';
3587: if ($supplementalflag) {
3588: $stored_folderpath='docs_sup_folderpath';
3589: }
1.464 www 3590:
1.484.2.19 raeburn 3591: # No folderpath, and in edit mode, see if we have something stored
3592: if ((!$env{'form.folderpath'}) && $allowed) {
1.445 www 3593: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.484.2.19 raeburn 3594: {'folderpath' => 'scalar'});
3595: unless (&unescape($env{'form.folderpath'}) =~ m{^(default|supplemental)&}) {
3596: undef($env{'form.folderpath'});
3597: }
1.329 droeschl 3598: }
1.446 www 3599:
3600: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 3601: if (!$allowed) {
1.446 www 3602: unless ($env{'form.folderpath'} =~ /^supplemental/) {
3603: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 3604: }
3605: }
1.446 www 3606: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 3607: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 3608: $env{'form.folderpath'} = &supplemental_base()
3609: .'&'.
1.329 droeschl 3610: $env{'form.folderpath'};
3611: }
1.446 www 3612: # If after all of this, we still don't have any paths, make them
1.484.2.19 raeburn 3613: unless ($env{'form.folderpath'}) {
1.446 www 3614: if ($supplementalflag) {
3615: $env{'form.folderpath'}=&supplemental_base();
3616: } else {
1.484.2.19 raeburn 3617: $env{'form.folderpath'}='default'.&escape(&mt('Main '.$crstype.' Documents')).
3618: ':::::';
1.446 www 3619: }
1.472 raeburn 3620: }
1.446 www 3621:
1.445 www 3622: # Store this
1.484 raeburn 3623: unless ($toolsflag) {
1.484.2.19 raeburn 3624: if ($allowed) {
3625: &Apache::loncommon::store_course_settings($stored_folderpath,
3626: {'folderpath' => 'scalar'});
3627: }
3628: my $folderpath;
1.484 raeburn 3629: if ($env{'form.folderpath'}) {
1.484.2.19 raeburn 3630: $folderpath = $env{'form.folderpath'};
3631: my (@folders)=split('&',$env{'form.folderpath'});
3632: $env{'form.foldername'}=&unescape(pop(@folders));
3633: if ($env{'form.foldername'} =~ /\:1$/) {
3634: $container = 'page';
3635: } else {
3636: $container = 'sequence';
3637: }
3638: $env{'form.folder'}=pop(@folders);
1.484 raeburn 3639: } else {
1.484.2.19 raeburn 3640: if ($env{'form.folder'} eq '' ||
3641: $env{'form.folder'} eq 'supplemental') {
3642: $folderpath='default&'.
3643: &escape(&mt('Main '.$crstype.' Documents')).
3644: ':::::';
1.484 raeburn 3645: }
3646: }
1.484.2.19 raeburn 3647: $containertag = '<input type="hidden" name="folderpath" value="" />';
3648: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
1.484 raeburn 3649: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
3650: $showdoc='/'.$1;
3651: }
3652: if ($showdoc) { # got called in sequence from course
3653: $allowed=0;
3654: } else {
3655: if ($allowed) {
3656: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
3657: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 3658: }
3659: }
1.329 droeschl 3660: }
3661:
1.344 bisitz 3662: # get personal data
1.329 droeschl 3663: my $uname=$env{'user.name'};
3664: my $udom=$env{'user.domain'};
3665: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
3666:
3667: if ($allowed) {
1.484 raeburn 3668: if ($toolsflag) {
3669: $script .= &inject_data_js();
3670: my ($home,$other,%outhash)=&authorhosts();
3671: if (!$home && $other) {
3672: my @hosts;
3673: foreach my $aurole (keys(%outhash)) {
3674: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
3675: push(@hosts,$outhash{$aurole});
3676: }
3677: }
3678: $script .= &dump_switchserver_js(@hosts);
3679: }
1.458 raeburn 3680: } else {
1.484 raeburn 3681: my @tabids;
3682: if ($supplementalflag) {
3683: @tabids = ('002','ee2','ff2');
3684: } else {
3685: @tabids = ('aa1','bb1','cc1','ff1');
1.484.2.19 raeburn 3686: unless ($env{'form.folderpath'} =~ /\:1$/) {
1.484 raeburn 3687: unshift(@tabids,'001');
3688: push(@tabids,('dd1','ee1'));
3689: }
1.458 raeburn 3690: }
1.484 raeburn 3691: my $tabidstr = join("','",@tabids);
3692: $script .= &editing_js($udom,$uname,$supplementalflag).
3693: &history_tab_js().
3694: &inject_data_js().
1.484.2.19 raeburn 3695: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
3696: &Apache::lonextresedit::extedit_javascript();
1.484 raeburn 3697: $addentries = {
1.484.2.3 raeburn 3698: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 3699: };
1.458 raeburn 3700: }
1.484.2.7 raeburn 3701: if ($env{'docs.markedcopy_url'}) {
1.484.2.19 raeburn 3702: $script .= &paste_popup_js();
1.484.2.7 raeburn 3703: }
1.484.2.12 raeburn 3704: my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
3705: &mt('Switch server?');
1.484.2.19 raeburn 3706:
3707:
1.329 droeschl 3708: }
3709: # -------------------------------------------------------------------- Body tag
1.369 bisitz 3710: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 3711: .'// <![CDATA['."\n"
3712: .$script."\n"
3713: .'// ]]>'."\n"
3714: .'</script>'."\n";
1.385 bisitz 3715:
3716: # Breadcrumbs
3717: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484.2.19 raeburn 3718:
3719: if ($showdoc) {
3720: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
3721: {'force_register' => $showdoc,}));
3722: } elsif ($r->uri eq '/adm/supplemental') {
3723: my $brcrum = &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype);
3724: $r->print(&Apache::loncommon::start_page("Supplemental $crstype Content",undef,
3725: {'bread_crumbs' => $brcrum,}));
3726: } else {
1.392 raeburn 3727: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 3728: href=>"/adm/coursedocs",text=>"$crstype Contents"});
1.392 raeburn 3729:
1.446 www 3730: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.484.2.19 raeburn 3731: {'add_entries' => $addentries}
3732: )
1.392 raeburn 3733: .&Apache::loncommon::help_open_menu('','',273,'RAT')
3734: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 3735: 'Editing '.$crstype.' Contents',
1.392 raeburn 3736: 'Docs_Adding_Course_Doc')
3737: );
3738: }
1.364 bisitz 3739:
1.329 droeschl 3740: my %allfiles = ();
3741: my %codebase = ();
1.440 raeburn 3742: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 3743: if ($allowed) {
3744: if (($env{'form.uploaddoc.filename'}) &&
3745: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 3746: my $context = $1;
3747: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 3748: undef($hadchanges);
1.440 raeburn 3749: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
3750: \%allfiles,\%codebase,$context);
1.329 droeschl 3751: if ($hadchanges) {
3752: &mark_hash_old();
3753: }
1.440 raeburn 3754: $r->print($upload_output);
3755: } elsif ($env{'form.phase'} eq 'upload_embedded') {
3756: # Process file upload - phase two - upload embedded objects
3757: $uploadphase = 'check_embedded';
3758: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
3759: my $state = &embedded_form_elems($uploadphase,$primaryurl,
3760: $env{'form.newidx'});
3761: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3762: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3763: my ($destination,$dir_root) = &embedded_destination();
3764: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
3765: my $actionurl = '/adm/coursedocs';
3766: my ($result,$flag) =
3767: &Apache::loncommon::upload_embedded('coursedoc',$destination,
3768: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
3769: $actionurl);
3770: $r->print($result.&return_to_editor());
3771: } elsif ($env{'form.phase'} eq 'check_embedded') {
3772: # Process file upload - phase three - modify references in HTML file
3773: $uploadphase = 'modified_orightml';
3774: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3775: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3776: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 3777: my $result =
3778: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
3779: $docuname,$docudom,undef,
3780: $dir_root);
3781: $r->print($result.&return_to_editor());
1.476 raeburn 3782: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
3783: $uploadphase = 'decompress_phase_one';
3784: $r->print(&decompression_phase_one().
3785: &return_to_editor());
3786: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
3787: $uploadphase = 'decompress_phase_two';
3788: $r->print(&decompression_phase_two().
3789: &return_to_editor());
1.329 droeschl 3790: }
3791: }
3792:
1.484 raeburn 3793: if ($allowed && $toolsflag) {
3794: $r->print(&startContentScreen('tools'));
3795: $r->print(&generate_admin_menu($crstype));
3796: $r->print(&endContentScreen());
3797: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 3798: # -----------------------------------------------------------------------------
3799: my %lt=&Apache::lonlocal::texthash(
3800: 'copm' => 'All documents out of a published map into this folder',
1.484.2.12 raeburn 3801: 'upfi' => 'Upload File',
3802: 'upld' => 'Import Content',
1.329 droeschl 3803: 'srch' => 'Search',
3804: 'impo' => 'Import',
1.484.2.19 raeburn 3805: 'lnks' => 'Import from Stored Links',
1.484.2.13 raeburn 3806: 'impm' => 'Import from Assembled Map',
1.329 droeschl 3807: 'selm' => 'Select Map',
3808: 'load' => 'Load Map',
3809: 'newf' => 'New Folder',
3810: 'newp' => 'New Composite Page',
3811: 'syll' => 'Syllabus',
1.425 raeburn 3812: 'navc' => 'Table of Contents',
1.343 biermanm 3813: 'sipa' => 'Simple Course Page',
1.329 droeschl 3814: 'sipr' => 'Simple Problem',
1.484.2.27 raeburn 3815: 'webp' => 'Blank Web Page (editable)',
1.329 droeschl 3816: 'drbx' => 'Drop Box',
1.451 www 3817: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 3818: 'bull' => 'Discussion Board',
1.347 weissno 3819: 'mypi' => 'My Personal Information Page',
1.353 weissno 3820: 'grpo' => 'Group Portfolio',
1.329 droeschl 3821: 'rost' => 'Course Roster',
1.484.2.22 raeburn 3822: 'abou' => 'Personal Information Page for a User',
1.377 bisitz 3823: 'imsf' => 'IMS Import',
3824: 'imsl' => 'Import IMS package',
1.484.2.12 raeburn 3825: 'cms' => 'Origin of IMS package',
3826: 'se' => 'Select',
1.484.2.19 raeburn 3827: 'file' => 'File',
1.329 droeschl 3828: 'title' => 'Title',
3829: 'comment' => 'Comment',
1.403 raeburn 3830: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.329 droeschl 3831: );
3832: # -----------------------------------------------------------------------------
3833: my $fileupload=(<<FIUP);
3834: $lt{'file'}:<br />
3835: <input type="file" name="uploaddoc" size="40" />
3836: FIUP
3837:
3838: my $checkbox=(<<CHBO);
3839: <!-- <label>$lt{'parse'}?
3840: <input type="checkbox" name="parserflag" />
3841: </label> -->
3842: <label>
3843: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
3844: </label>
3845: CHBO
1.484.2.12 raeburn 3846: my $imsfolder = $env{'form.folder'};
3847: if ($imsfolder eq '') {
1.484.2.19 raeburn 3848: $imsfolder = 'default';
1.484.2.12 raeburn 3849: }
3850: my $imspform=(<<IMSFORM);
3851: <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
3852: $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
3853: <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
1.484.2.19 raeburn 3854: <fieldset id="uploadimsform" style="display: none;">
1.484.2.12 raeburn 3855: <legend>$lt{'imsf'}</legend>
3856: $fileupload
3857: <br />
3858: <p>
1.484.2.19 raeburn 3859: $lt{'cms'}:
1.484.2.12 raeburn 3860: <select name="source">
3861: <option value="-1" selected="selected">$lt{'se'}</option>
3862: <option value="bb5">Blackboard 5</option>
3863: <option value="bb6">Blackboard 6</option>
3864: <option value="angel5">ANGEL 5.5</option>
3865: <option value="webctce4">WebCT 4 Campus Edition</option>
3866: </select>
3867: <input type="hidden" name="folder" value="$imsfolder" />
3868: </p>
3869: <input type="hidden" name="phase" value="one" />
3870: <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
3871: </fieldset>
3872: </form>
3873: IMSFORM
3874:
1.484.2.19 raeburn 3875: my $fileuploadform=(<<FUFORM);
1.484.2.12 raeburn 3876: <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
3877: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
3878: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.484.2.19 raeburn 3879: <fieldset id="uploaddocform" style="display: none;">
1.484.2.12 raeburn 3880: <legend>$lt{'upfi'}</legend>
1.371 tempelho 3881: <input type="hidden" name="active" value="aa" />
1.329 droeschl 3882: $fileupload
3883: <br />
3884: $lt{'title'}:<br />
1.458 raeburn 3885: <input type="text" size="60" name="comment" />
1.484.2.17 raeburn 3886: $pathitem
1.329 droeschl 3887: <input type="hidden" name="cmd" value="upload_default" />
3888: <br />
1.458 raeburn 3889: <span class="LC_nobreak" style="float:left">
1.329 droeschl 3890: $checkbox
3891: </span>
1.484.2.12 raeburn 3892: <br clear="all" />
3893: <input type="submit" value="$lt{'upld'}" />
3894: </fieldset>
3895: </form>
1.383 tempelho 3896: FUFORM
1.329 droeschl 3897:
1.484.2.19 raeburn 3898: my $importpubform=(<<SEDFFORM);
3899: <a class="LC_menubuttons_link" href="javascript:toggleMap('map');">
1.484.2.13 raeburn 3900: $lt{'impm'}</a>$help{'Load_Map'}
1.484.2.19 raeburn 3901: <form action="/adm/coursedocs" method="post" name="mapimportform">
3902: <fieldset id="importmapform" style="display: none;">
1.484.2.13 raeburn 3903: <legend>$lt{'impm'}</legend>
1.484.2.19 raeburn 3904: <input type="hidden" name="active" value="bb" />
1.484.2.13 raeburn 3905: $lt{'copm'}<br />
3906: <span class="LC_nobreak">
1.484.2.19 raeburn 3907: <input type="text" name="importmap" size="40" value=""
1.484.2.13 raeburn 3908: onfocus="this.blur();openbrowser('mapimportform','importmap','sequence,page','');" />
1.484.2.19 raeburn 3909: <a href="javascript:openbrowser('mapimportform','importmap','sequence,page','');">$lt{'selm'}</a></span><br />
1.484.2.13 raeburn 3910: <input type="submit" name="loadmap" value="$lt{'load'}" />
3911: </fieldset>
3912: </form>
3913:
1.383 tempelho 3914: SEDFFORM
1.484.2.19 raeburn 3915: my @importpubforma = (
3916: { '<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 3917: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/res.png" alt="'.$lt{impo}.'" onclick="javascript:groupimport();"/>' => "<a class='LC_menubuttons_link' href='javascript:groupimport();'>$lt{'impo'}</a>$help{'Importing_LON-CAPA_Resource'}" },
1.484.2.19 raeburn 3918: { '<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>" },
3919: { '<img class="LC_noBorder LC_middle" src="/res/adm/pages/sequence.png" alt="'.$lt{impm}.'" onclick="javascript:toggleMap(\'map\');" />' => $importpubform }
3920: );
3921: $importpubform = &create_form_ul(&create_list_elements(@importpubforma));
3922: my $extresourcesform =
3923: &Apache::lonextresedit::extedit_form(0,0,undef,undef,$pathitem,
3924: $help{'Adding_External_Resource'});
1.329 droeschl 3925: if ($allowed) {
1.484.2.7 raeburn 3926: my $folder = $env{'form.folder'};
3927: if ($folder eq '') {
3928: $folder='default';
3929: }
3930: &update_paste_buffer($coursenum,$coursedom,$folder);
1.337 ehlerst 3931: $r->print(<<HIDDENFORM);
3932: <form name="renameform" method="post" action="/adm/coursedocs">
3933: <input type="hidden" name="title" />
3934: <input type="hidden" name="cmd" />
3935: <input type="hidden" name="markcopy" />
3936: <input type="hidden" name="copyfolder" />
3937: $containertag
3938: </form>
1.484 raeburn 3939:
1.337 ehlerst 3940: HIDDENFORM
1.484.2.17 raeburn 3941: $r->print(&makesimpleeditform($pathitem)."\n".
3942: &makedocslogform($pathitem."\n".
1.484 raeburn 3943: '<input type="hidden" name="folder" value="'.
3944: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 3945: }
1.442 www 3946:
3947: # Generate the tabs
1.484.2.19 raeburn 3948: my ($mode,$needs_end);
1.472 raeburn 3949: if (($supplementalflag) && (!$allowed)) {
1.484.2.19 raeburn 3950: my @folders = split('&',$env{'form.folderpath'});
3951: unless (@folders > 2) {
3952: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
3953: $needs_end = 1;
3954: }
1.472 raeburn 3955: } else {
1.484 raeburn 3956: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.484.2.19 raeburn 3957: $needs_end = 1;
1.472 raeburn 3958: }
1.443 www 3959:
1.442 www 3960: #
3961:
3962: my $savefolderpath;
3963:
1.395 raeburn 3964: if ($allowed) {
1.329 droeschl 3965: my $folder=$env{'form.folder'};
1.443 www 3966: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 3967: $folder='default';
1.356 tempelho 3968: $savefolderpath = $env{'form.folderpath'};
1.442 www 3969: $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
1.484.2.17 raeburn 3970: $pathitem = '<input type="hidden" name="folderpath" value="'.
1.329 droeschl 3971: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
3972: }
3973: my $postexec='';
3974: if ($folder eq 'default') {
1.372 bisitz 3975: $r->print('<script type="text/javascript">'."\n"
3976: .'// <![CDATA['."\n"
3977: .'this.window.name="loncapaclient";'."\n"
3978: .'// ]]>'."\n"
3979: .'</script>'."\n"
1.369 bisitz 3980: );
1.329 droeschl 3981: } else {
3982: #$postexec='self.close();';
3983: }
1.484.2.15 raeburn 3984: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.sequence';
3985: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_new.page';
1.329 droeschl 3986: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
3987:
3988: my $newnavform=(<<NNFORM);
3989: <form action="/adm/coursedocs" method="post" name="newnav">
1.371 tempelho 3990: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 3991: $pathitem
1.329 droeschl 3992: <input type="hidden" name="importdetail"
3993: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 3994: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 3995: $help{'Navigate_Content'}
3996: </form>
3997: NNFORM
3998: my $newsmppageform=(<<NSPFORM);
3999: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.371 tempelho 4000: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4001: $pathitem
1.329 droeschl 4002: <input type="hidden" name="importdetail" value="" />
1.423 onken 4003: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 4004: $help{'Simple Page'}
1.329 droeschl 4005: </form>
4006: NSPFORM
4007:
4008: my $newsmpproblemform=(<<NSPROBFORM);
4009: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 4010: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4011: $pathitem
1.329 droeschl 4012: <input type="hidden" name="importdetail" value="" />
1.423 onken 4013: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.383 tempelho 4014: $help{'Simple Problem'}
1.329 droeschl 4015: </form>
4016:
4017: NSPROBFORM
4018:
4019: my $newdropboxform=(<<NDBFORM);
4020: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 4021: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4022: $pathitem
1.329 droeschl 4023: <input type="hidden" name="importdetail" value="" />
1.423 onken 4024: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.344 bisitz 4025: </form>
1.329 droeschl 4026: NDBFORM
4027:
4028: my $newexuploadform=(<<NEXUFORM);
4029: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 4030: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4031: $pathitem
1.329 droeschl 4032: <input type="hidden" name="importdetail" value="" />
1.423 onken 4033: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 4034: $help{'Score_Upload_Form'}
4035: </form>
4036: NEXUFORM
4037:
4038: my $newbulform=(<<NBFORM);
4039: <form action="/adm/coursedocs" method="post" name="newbul">
1.371 tempelho 4040: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4041: $pathitem
1.329 droeschl 4042: <input type="hidden" name="importdetail" value="" />
1.423 onken 4043: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 4044: $help{'Bulletin Board'}
4045: </form>
4046: NBFORM
4047:
4048: my $newaboutmeform=(<<NAMFORM);
4049: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.371 tempelho 4050: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4051: $pathitem
1.329 droeschl 4052: <input type="hidden" name="importdetail"
4053: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 4054: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 4055: $help{'My Personal Information Page'}
1.329 droeschl 4056: </form>
4057: NAMFORM
4058:
4059: my $newaboutsomeoneform=(<<NASOFORM);
4060: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.371 tempelho 4061: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4062: $pathitem
1.329 droeschl 4063: <input type="hidden" name="importdetail" value="" />
1.423 onken 4064: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 4065: </form>
4066: NASOFORM
4067:
4068: my $newrosterform=(<<NROSTFORM);
4069: <form action="/adm/coursedocs" method="post" name="newroster">
1.371 tempelho 4070: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4071: $pathitem
1.329 droeschl 4072: <input type="hidden" name="importdetail"
4073: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 4074: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.329 droeschl 4075: $help{'Course Roster'}
4076: </form>
4077: NROSTFORM
4078:
1.484.2.27 raeburn 4079: my $newwebpage;
4080: if ($folder =~ /^default_?(\d*)$/) {
4081: $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
4082: if ($1) {
4083: $newwebpage .= $1;
4084: } else {
4085: $newwebpage .= 'default';
4086: }
4087: $newwebpage .= '/new.html';
4088: }
4089: my $newwebpageform =(<<NWEBFORM);
4090: <form action="/adm/coursedocs" method="post" name="newwebpage">
4091: <input type="hidden" name="active" value="cc" />
4092: $pathitem
4093: <input type="hidden" name="importdetail" value="$newwebpage" />
4094: <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
4095: $help{'Web Page'}
4096: </form>
4097: NWEBFORM
4098:
4099:
1.342 ehlerst 4100: my $specialdocumentsform;
1.383 tempelho 4101: my @specialdocumentsforma;
1.451 www 4102: my $gradingform;
4103: my @gradingforma;
4104: my $communityform;
4105: my @communityforma;
1.351 ehlerst 4106: my $newfolderform;
1.390 tempelho 4107: my $newfolderb;
1.342 ehlerst 4108:
1.451 www 4109: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 4110:
1.329 droeschl 4111: my $newpageform=(<<NPFORM);
4112: <form action="/adm/coursedocs" method="post" name="newpage">
4113: <input type="hidden" name="folderpath" value="$path" />
4114: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 4115: <input type="hidden" name="active" value="cc" />
1.423 onken 4116: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 4117: $help{'Adding_Pages'}
1.329 droeschl 4118: </form>
4119: NPFORM
1.390 tempelho 4120:
4121:
1.351 ehlerst 4122: $newfolderform=(<<NFFORM);
1.329 droeschl 4123: <form action="/adm/coursedocs" method="post" name="newfolder">
1.484.2.19 raeburn 4124: $pathitem
1.329 droeschl 4125: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 4126: <input type="hidden" name="active" value="aa" />
1.422 onken 4127: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 4128: </form>
4129: NFFORM
4130:
4131: my $newsylform=(<<NSYLFORM);
4132: <form action="/adm/coursedocs" method="post" name="newsyl">
1.371 tempelho 4133: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4134: $pathitem
1.329 droeschl 4135: <input type="hidden" name="importdetail"
4136: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 4137: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 4138: $help{'Syllabus'}
1.383 tempelho 4139:
1.329 droeschl 4140: </form>
4141: NSYLFORM
1.364 bisitz 4142:
1.329 droeschl 4143: my $newgroupfileform=(<<NGFFORM);
4144: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.371 tempelho 4145: <input type="hidden" name="active" value="cc" />
1.484.2.17 raeburn 4146: $pathitem
1.329 droeschl 4147: <input type="hidden" name="importdetail"
4148: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 4149: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 4150: $help{'Group Portfolio'}
1.329 droeschl 4151: </form>
4152: NGFFORM
1.383 tempelho 4153: @specialdocumentsforma=(
1.421 onken 4154: {'<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 4155: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 4156: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
4157: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
1.484.2.27 raeburn 4158: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
1.451 www 4159: );
4160: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
4161:
1.434 raeburn 4162:
4163: my @importdoc = (
1.484.2.19 raeburn 4164: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform}
4165: );
4166: unless ($container eq 'page') {
4167: push(@importdoc,
4168: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform}
4169: );
4170: }
4171: push(@importdoc,
4172: {'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform}
4173: );
1.484.2.12 raeburn 4174: $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
1.434 raeburn 4175:
1.451 www 4176: @gradingforma=(
4177: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
4178: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
4179: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
4180:
4181: );
4182: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
4183:
4184: @communityforma=(
4185: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
4186: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
4187: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
4188: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
4189: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
4190: );
4191: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 4192:
1.330 tempelho 4193: my %orderhash = (
1.484.2.7 raeburn 4194: 'aa' => ['Import Content',$fileuploadform],
1.484.2.13 raeburn 4195: 'bb' => ['Published Content',$importpubform],
1.451 www 4196: 'cc' => ['Grading Resources',$gradingform],
1.330 tempelho 4197: );
1.484.2.19 raeburn 4198: unless ($container eq 'page') {
1.434 raeburn 4199: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 4200: $orderhash{'dd'} = ['Collaboration',$communityform];
1.484.2.19 raeburn 4201: $orderhash{'ee'} = ['Special Pages',$specialdocumentsform];
1.434 raeburn 4202: }
4203:
1.341 ehlerst 4204: $hadchanges=0;
1.484 raeburn 4205: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 4206: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 4207: $supplementalflag,\%orderhash,$iconpath,$pathitem);
1.443 www 4208: if ($error) {
4209: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
4210: }
4211: if ($hadchanges) {
4212: &mark_hash_old();
4213: }
1.341 ehlerst 4214:
1.443 www 4215: &changewarning($r,'');
4216: }
1.458 raeburn 4217: }
1.442 www 4218:
1.443 www 4219: # Supplemental documents start here
4220:
1.329 droeschl 4221: my $folder=$env{'form.folder'};
1.443 www 4222: unless ($supplementalflag) {
1.329 droeschl 4223: $folder='supplemental';
4224: }
4225: if ($folder =~ /^supplemental$/ &&
4226: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 4227: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 4228: } elsif ($allowed) {
1.356 tempelho 4229: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 4230: }
1.484.2.17 raeburn 4231: $pathitem = '<input type="hidden" name="folderpath" value="'.
4232: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.329 droeschl 4233: if ($allowed) {
4234: my $folderseq=
1.484.2.15 raeburn 4235: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_new.sequence';
1.329 droeschl 4236:
4237: my $supupdocform=(<<SUPDOCFORM);
1.484.2.12 raeburn 4238: <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
4239: $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
1.383 tempelho 4240: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.484.2.19 raeburn 4241: <fieldset id="uploadsuppdocform" style="display: none;">
1.484.2.12 raeburn 4242: <legend>$lt{'upfi'}</legend>
1.371 tempelho 4243: <input type="hidden" name="active" value="ee" />
1.329 droeschl 4244: $fileupload
4245: <br />
4246: <br />
4247: <span class="LC_nobreak">
4248: $checkbox
4249: </span>
4250: <br /><br />
4251: $lt{'comment'}:<br />
1.383 tempelho 4252: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 4253: <br />
1.484.2.19 raeburn 4254: $pathitem
1.329 droeschl 4255: <input type="hidden" name="cmd" value="upload_supplemental" />
1.484.2.12 raeburn 4256: <input type='submit' value="$lt{'upld'}" />
4257: </form>
1.484.2.19 raeburn 4258: SUPDOCFORM
1.329 droeschl 4259:
4260: my $supnewfolderform=(<<SNFFORM);
4261: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.371 tempelho 4262: <input type="hidden" name="active" value="ee" />
1.484.2.17 raeburn 4263: $pathitem
1.329 droeschl 4264: <input type="hidden" name="importdetail" value="" />
1.423 onken 4265: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 4266: $help{'Adding_Folders'}
1.329 droeschl 4267: </form>
4268: SNFFORM
1.383 tempelho 4269:
1.484.2.19 raeburn 4270: my $supextform =
4271: &Apache::lonextresedit::extedit_form(1,0,undef,undef,$pathitem,
4272: $help{'Adding_External_Resource'});
1.329 droeschl 4273:
4274: my $supnewsylform=(<<SNSFORM);
4275: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 4276: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 4277: $pathitem
1.329 droeschl 4278: <input type="hidden" name="importdetail"
4279: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 4280: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 4281: $help{'Syllabus'}
4282: </form>
4283: SNSFORM
4284:
4285: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 4286: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 4287: <input type="hidden" name="active" value="ff" />
1.484.2.19 raeburn 4288: $pathitem
1.329 droeschl 4289: <input type="hidden" name="importdetail"
4290: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 4291: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 4292: $help{'My Personal Information Page'}
1.329 droeschl 4293: </form>
4294: SNAMFORM
4295:
1.484.2.27 raeburn 4296: my $supwebpage;
4297: if ($folder =~ /^supplemental_?(\d*)$/) {
4298: $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
4299: if ($1) {
4300: $supwebpage .= $1;
4301: } else {
4302: $supwebpage .= 'default';
4303: }
4304: $supwebpage .= '/new.html';
4305: }
4306: my $supwebpageform =(<<SWEBFORM);
4307: <form action="/adm/coursedocs" method="post" name="supwebpage">
4308: <input type="hidden" name="active" value="cc" />
4309: $pathitem
4310: <input type="hidden" name="importdetail" value="$supwebpage" />
4311: <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
4312: $help{'Web Page'}
4313: </form>
4314: SWEBFORM
4315:
1.333 muellerd 4316:
1.383 tempelho 4317: my @specialdocs = (
1.417 droeschl 4318: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
4319: =>$supnewsylform},
4320: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
4321: =>$supnewaboutmeform},
1.484.2.27 raeburn 4322: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
4323:
1.383 tempelho 4324: );
1.417 droeschl 4325: my @supimportdoc = (
1.484.2.19 raeburn 4326: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
1.484.2.12 raeburn 4327: =>$supextform},
4328: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
4329: =>$supupdocform},
1.484.2.19 raeburn 4330: );
4331:
1.484.2.12 raeburn 4332: $supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
1.333 muellerd 4333: my %suporderhash = (
1.390 tempelho 4334: '00' => ['Supnewfolder', $supnewfolderform],
1.484.2.7 raeburn 4335: 'ee' => ['Import Content',$supupdocform],
1.484.2.19 raeburn 4336: 'ff' => ['Special Pages',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 4337: );
1.443 www 4338: if ($supplementalflag) {
1.458 raeburn 4339: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 4340: $supplementalflag,\%suporderhash,$iconpath,$pathitem);
1.443 www 4341: if ($error) {
4342: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
4343: }
1.393 raeburn 4344: }
1.443 www 4345: } elsif ($supplementalflag) {
1.458 raeburn 4346: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.484.2.17 raeburn 4347: $supplementalflag,'',$iconpath,$pathitem);
1.393 raeburn 4348: if ($error) {
4349: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 4350: }
1.393 raeburn 4351: }
1.389 tempelho 4352:
1.484.2.19 raeburn 4353: if ($needs_end) {
4354: $r->print(&endContentScreen());
4355: }
1.383 tempelho 4356:
1.329 droeschl 4357: if ($allowed) {
4358: $r->print('
4359: <form method="post" name="extimport" action="/adm/coursedocs">
4360: <input type="hidden" name="title" />
4361: <input type="hidden" name="url" />
4362: <input type="hidden" name="useform" />
4363: <input type="hidden" name="residx" />
4364: </form>');
4365: }
1.484 raeburn 4366: } elsif ($showdoc) {
1.329 droeschl 4367: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 4368: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.484.2.10 raeburn 4369: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 4370: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 4371: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 4372: }
4373: }
4374: $r->print(&Apache::loncommon::end_page());
4375: return OK;
1.364 bisitz 4376: }
1.329 droeschl 4377:
1.440 raeburn 4378: sub embedded_form_elems {
4379: my ($phase,$primaryurl,$newidx) = @_;
4380: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
4381: return <<STATE;
4382: <input type="hidden" name="folderpath" value="$folderpath" />
4383: <input type="hidden" name="cmd" value="upload_embedded" />
4384: <input type="hidden" name="newidx" value="$newidx" />
4385: <input type="hidden" name="phase" value="$phase" />
4386: <input type="hidden" name="primaryurl" value="$primaryurl" />
4387: STATE
4388: }
4389:
4390: sub embedded_destination {
4391: my $folder=$env{'form.folder'};
4392: my $destination = 'docs/';
4393: if ($folder =~ /^supplemental/) {
4394: $destination = 'supplemental/';
4395: }
4396: if (($folder eq 'default') || ($folder eq 'supplemental')) {
4397: $destination .= 'default/';
4398: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
4399: $destination .= $2.'/';
4400: }
4401: $destination .= $env{'form.newidx'};
4402: my $dir_root = '/userfiles';
4403: return ($destination,$dir_root);
4404: }
4405:
4406: sub return_to_editor {
4407: my $actionurl = '/adm/coursedocs';
4408: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
4409: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
4410: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
4411: '</a></p>';
4412: }
4413:
1.476 raeburn 4414: sub decompression_info {
4415: my ($destination,$dir_root) = &embedded_destination();
4416: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
4417: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4418: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4419: my $container='sequence';
1.480 raeburn 4420: my ($pathitem,$hiddenelem);
1.484.2.19 raeburn 4421: my @hiddens = ('newidx','comment','position','folderpath');
4422: if ($env{'form.folderpath'} =~ /\:1$/) {
1.476 raeburn 4423: $container='page';
4424: }
1.480 raeburn 4425: unshift(@hiddens,$pathitem);
4426: foreach my $item (@hiddens) {
4427: if ($env{'form.'.$item}) {
4428: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
4429: $env{'form.'.$item}.'" />'."\n";
4430: }
1.477 raeburn 4431: }
1.476 raeburn 4432: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
4433: $hiddenelem);
4434: }
4435:
4436: sub decompression_phase_one {
4437: my ($dir,$file,$warning,$error,$output);
4438: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4439: &decompression_info();
1.484.2.7 raeburn 4440: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 4441: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
4442: } else {
4443: my $file = $1;
1.481 raeburn 4444: $output =
4445: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
4446: $destination,$dir_root,
4447: $hiddenelem);
4448: if ($env{'form.autoextract_camtasia'}) {
4449: $output .= &remove_archive($docudom,$docuname,$container);
4450: }
1.476 raeburn 4451: }
4452: if ($error) {
4453: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
4454: $error.'</p>'."\n";
4455: }
4456: if ($warning) {
4457: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
4458: }
4459: return $output;
4460: }
4461:
4462: sub decompression_phase_two {
4463: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4464: &decompression_info();
1.481 raeburn 4465: my $output;
1.480 raeburn 4466: if ($env{'form.archivedelete'}) {
1.481 raeburn 4467: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 4468: }
4469: $output .=
1.481 raeburn 4470: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 4471: $destination,$dir_root,$hiddenelem);
4472: return $output;
4473: }
4474:
1.480 raeburn 4475: sub remove_archive {
4476: my ($docudom,$docuname,$container) = @_;
4477: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 4478: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 4479: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
4480: if ($fatal) {
4481: if ($container eq 'page') {
4482: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
4483: } else {
4484: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
4485: }
4486: $delwarning .= &mt('As a result the archive file has not been removed.');
4487: } else {
4488: my $currcmd = $env{'form.cmd'};
4489: my $position = $env{'form.position'};
4490: if ($position > 0) {
4491: $env{'form.cmd'} = 'del_'.$position;
4492: my ($title,$url,@rrest) =
4493: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
4494: if (&handle_edit_cmd($docuname,$docudom)) {
1.484.2.7 raeburn 4495: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 4496: if ($fatal) {
4497: if ($container eq 'page') {
4498: $delwarning = &mt('An error occurred updating the contents of the current page.');
4499: } else {
4500: $delwarning = &mt('An error occurred updating the contents of the current folder.');
4501: }
4502: } else {
1.481 raeburn 4503: $delresult = &mt('Archive file removed.');
1.480 raeburn 4504: }
4505: }
4506: }
4507: $env{'form.cmd'} = $currcmd;
4508: }
4509: if ($delwarning) {
4510: $output = '<p class="LC_warning">'.
4511: $delwarning.
4512: '</p>';
4513: }
4514: if ($delresult) {
4515: $output .= '<p class="LC_info">'.
4516: $delresult.
4517: '</p>';
4518: }
1.481 raeburn 4519: return $output;
1.480 raeburn 4520: }
4521:
1.484 raeburn 4522: sub generate_admin_menu {
4523: my ($crstype) = @_;
4524: my $lc_crstype = lc($crstype);
4525: my ($home,$other,%outhash)=&authorhosts();
4526: my %lt=&Apache::lonlocal::texthash (
4527: 'vc' => 'Verify Content',
4528: 'cv' => 'Check/Set Resource Versions',
4529: 'ls' => 'List Resource Identifiers',
4530: 'imse' => 'Export contents to IMS Archive',
4531: 'dcd' => "Dump $crstype Content to Authoring Space",
4532: );
4533: my ($candump,$dumpurl);
4534: if ($home + $other > 0) {
4535: $candump = 'F';
4536: if ($home) {
4537: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
4538: } else {
4539: my @hosts;
4540: foreach my $aurole (keys(%outhash)) {
4541: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4542: push(@hosts,$outhash{$aurole});
4543: }
4544: }
4545: if (@hosts == 1) {
4546: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
4547: '&role='.
4548: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
4549: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
4550: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
4551: } else {
4552: $dumpurl = "javascript:choose_switchserver_window()";
4553: }
4554: }
4555: }
4556: my @menu=
4557: ({ categorytitle=>'Administration',
4558: items =>[
4559: { linktext => $lt{'vc'},
4560: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
4561: permission => 'F',
4562: help => 'Verify_Content',
4563: icon => 'verify.png',
4564: linktitle => 'Verify contents can be retrieved/rendered',
4565: },
4566: { linktext => $lt{'cv'},
4567: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
4568: permission => 'F',
4569: help => 'Check_Resource_Versions',
4570: icon => 'resversion.png',
4571: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
4572: },
4573: { linktext => $lt{'ls'},
4574: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
4575: permission => 'F',
4576: #help => '',
4577: icon => 'symbs.png',
4578: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
4579: },
4580: ]
4581: },
4582: { categorytitle=>'Export',
4583: items =>[
4584: { linktext => $lt{'imse'},
4585: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
4586: permission => 'F',
4587: help => 'Docs_Export_Course_Docs',
4588: icon => 'imsexport.png',
4589: linktitle => $lt{'imse'},
4590: },
4591: { linktext => $lt{'dcd'},
4592: url => $dumpurl,
4593: permission => $candump,
4594: #help => '',
4595: icon => 'dump.png',
4596: linktitle => $lt{'dcd'},
4597: },
4598: ]
4599: });
4600: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
4601: '<input type="hidden" id="dummy" />'."\n".
4602: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
4603: '</form>';
1.329 droeschl 4604: }
4605:
4606: sub generate_edit_table {
1.484 raeburn 4607: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile) = @_;
1.406 raeburn 4608: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 4609: my %orderhash = %{$orderhash_ref};
1.344 bisitz 4610: my $form;
1.371 tempelho 4611: my $activetab;
4612: my $active;
1.484.2.20 raeburn 4613: if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) {
1.371 tempelho 4614: $activetab = $env{'form.active'};
4615: }
1.472 raeburn 4616: my $backicon = $iconpath.'clickhere.gif';
1.484.2.21 raeburn 4617: my $backtext = &mt('Exit Editor');
1.458 raeburn 4618: $form = '<div class="LC_Box" style="margin:0;">'.
1.484.2.19 raeburn 4619: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
4620: '<li class="goback">'.
1.484.2.21 raeburn 4621: '<a href="javascript:toContents('.$jumpto.');">'.
1.484.2.19 raeburn 4622: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
4623: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
4624: '<li>'.
4625: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
4626: &mt('Undo Delete').'</a></li>'."\n";
1.484.2.7 raeburn 4627: if ($env{'form.docslog'}) {
4628: $form .= '<li class="active">';
4629: } else {
4630: $form .= '<li>';
4631: }
4632: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
4633: &mt('History').'</a></li>'."\n";
4634: if ($env{'form.docslog'}) {
4635: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
4636: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 4637: }
1.458 raeburn 4638: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 4639: if($name ne '00'){
1.371 tempelho 4640: if($activetab eq '' || $activetab ne $name){
4641: $active = '';
4642: }elsif($activetab eq $name){
4643: $active = 'class="active"';
4644: }
1.458 raeburn 4645: $form .= '<li style="float:right" '.$active
1.484 raeburn 4646: .' 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 4647: } else {
1.484 raeburn 4648: $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 4649:
4650: }
1.329 droeschl 4651: }
1.484 raeburn 4652: $form .= '</ul>'."\n";
4653: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 4654:
4655: if ($to_show ne '') {
1.484 raeburn 4656: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'."\n";
1.458 raeburn 4657: }
1.363 ehlerst 4658: foreach my $field (keys(%orderhash)){
1.390 tempelho 4659: if($field ne '00'){
1.422 onken 4660: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 4661: $active = 'style="display: none;float:left"';
1.422 onken 4662: }elsif($activetab eq $field){
1.458 raeburn 4663: $active = 'style="display:block;float:left"';
1.422 onken 4664: }
4665: $form .= '<div id="'.$field.$tid.'"'
4666: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 4667: .'</div>'."\n";
1.363 ehlerst 4668: }
4669: }
1.484 raeburn 4670: unless ($env{'form.docslog'}) {
4671: $form .= '</div></div>'."\n";
4672: }
1.329 droeschl 4673: return $form;
4674: }
4675:
4676: sub editing_js {
1.472 raeburn 4677: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 4678: my %lt = &Apache::lonlocal::texthash(
4679: p_mnf => 'Name of New Folder',
4680: t_mnf => 'New Folder',
4681: p_mnp => 'Name of New Page',
4682: t_mnp => 'New Page',
1.451 www 4683: p_mxu => 'Title for the External Score',
1.349 biermanm 4684: p_msp => 'Name of Simple Course Page',
1.329 droeschl 4685: p_msb => 'Title for the Problem',
4686: p_mdb => 'Title for the Drop Box',
1.336 schafran 4687: p_mbb => 'Title for the Discussion Board',
1.484.2.27 raeburn 4688: p_mwp => 'Title for Web Page',
1.348 weissno 4689: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 4690: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 4691: p_mab_alrt1 => 'Not a valid user:domain',
4692: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
4693: p_chn => 'New Title',
4694: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
4695: p_rmr2a => 'Remove[_99]',
4696: p_rmr2b => '?[_99]',
4697: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
4698: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
4699: p_ctr2a => 'Cut[_98]',
1.478 raeburn 4700: p_ctr2b => '?[_98]',
4701: rpck => 'Enter number to pick (e.g., 3)',
1.484.2.12 raeburn 4702: imsfile => 'You must choose an IMS package for import',
4703: imscms => 'You must select which Course Management System was the source of the IMS package',
4704: invurl => 'Invalid URL',
4705: titbl => 'Title is blank',
1.329 droeschl 4706: );
4707:
1.433 raeburn 4708: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 4709: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
4710: my $main_container_page;
1.484.2.19 raeburn 4711: if (&HTML::Entities::decode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'}) =~ /\:1$/) {
4712: $main_container_page = 1;
1.434 raeburn 4713: }
1.484.2.19 raeburn 4714: my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents%3A%3A%3A%3A%3A';
1.446 www 4715: my $toplevelsupp = &supplemental_base();
1.433 raeburn 4716:
1.484.2.21 raeburn 4717: my $backtourl;
4718: if ($env{'docs.exit.'.$env{'request.course.id'}} =~ /^direct_(.+)$/) {
4719: my $caller = $1;
4720: if ($caller =~ /^supplemental/) {
4721: $backtourl = '/adm/supplemental?folderpath='.&escape($caller);
4722: } else {
4723: my ($map,$id,$res)=&Apache::lonnet::decode_symb($caller);
4724: $res = &Apache::lonnet::clutter($res);
4725: if (&Apache::lonnet::is_on_map($res)) {
4726: $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($res),'<>&"').'?symb='.
4727: &HTML::Entities::encode($caller,'<>&"');
4728: }
4729: }
4730: } elsif ($env{'docs.exit.'.$env{'request.course.id'}} eq '/adm/menu') {
4731: $backtourl = '/adm/menu';
4732: } elsif ($supplementalflag) {
1.472 raeburn 4733: $backtourl = '/adm/supplemental';
1.484.2.21 raeburn 4734: } else {
4735: $backtourl = '/adm/navmaps';
1.472 raeburn 4736: }
4737:
1.484.2.19 raeburn 4738: my $fieldsets = "'ext','doc'";
4739: unless ($main_container_page) {
4740: $fieldsets .=",'ims'";
4741: }
1.484.2.12 raeburn 4742: if ($supplementalflag) {
4743: $fieldsets = "'suppext','suppdoc'";
4744: }
4745:
1.329 droeschl 4746: return <<ENDNEWSCRIPT;
4747: function makenewfolder(targetform,folderseq) {
4748: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
4749: if (foldername) {
4750: targetform.importdetail.value=escape(foldername)+"="+folderseq;
4751: targetform.submit();
4752: }
4753: }
4754:
4755: function makenewpage(targetform,folderseq) {
4756: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
4757: if (pagename) {
4758: targetform.importdetail.value=escape(pagename)+"="+folderseq;
4759: targetform.submit();
4760: }
4761: }
4762:
4763: function makeexamupload() {
4764: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 4765: if (title) {
1.329 droeschl 4766: this.document.forms.newexamupload.importdetail.value=
4767: escape(title)+'=/res/lib/templates/examupload.problem';
4768: this.document.forms.newexamupload.submit();
4769: }
4770: }
4771:
4772: function makesmppage() {
4773: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 4774: if (title) {
1.329 droeschl 4775: this.document.forms.newsmppg.importdetail.value=
1.484.2.26 raeburn 4776: escape(title)+'=/adm/$udom/$uname/new/smppg';
1.329 droeschl 4777: this.document.forms.newsmppg.submit();
4778: }
4779: }
4780:
1.484.2.27 raeburn 4781: function makewebpage(type) {
4782: var title=prompt('$lt{"p_mwp"}');
4783: var formname;
4784: if (type == 'supp') {
4785: formname = this.document.forms.supwebpage;
4786: } else {
4787: formname = this.document.forms.newwebpage;
4788: }
4789: if (title) {
4790: var webpage = formname.importdetail.value;
4791: formname.importdetail.value = escape(title)+'='+webpage;
4792: formname.submit();
4793: }
4794: }
4795:
1.329 droeschl 4796: function makesmpproblem() {
4797: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 4798: if (title) {
1.329 droeschl 4799: this.document.forms.newsmpproblem.importdetail.value=
4800: escape(title)+'=/res/lib/templates/simpleproblem.problem';
4801: this.document.forms.newsmpproblem.submit();
4802: }
4803: }
4804:
4805: function makedropbox() {
4806: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 4807: if (title) {
1.329 droeschl 4808: this.document.forms.newdropbox.importdetail.value=
4809: escape(title)+'=/res/lib/templates/DropBox.problem';
4810: this.document.forms.newdropbox.submit();
4811: }
4812: }
4813:
4814: function makebulboard() {
4815: var title=prompt('$lt{"p_mbb"}');
4816: if (title) {
4817: this.document.forms.newbul.importdetail.value=
1.484.2.26 raeburn 4818: escape(title)+'=/adm/$udom/$uname/new/bulletinboard';
1.329 droeschl 4819: this.document.forms.newbul.submit();
4820: }
4821: }
4822:
4823: function makeabout() {
4824: var user=prompt("$lt{'p_mab'}");
4825: if (user) {
4826: var comp=new Array();
4827: comp=user.split(':');
4828: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
4829: if ((comp[0]) && (comp[1])) {
4830: this.document.forms.newaboutsomeone.importdetail.value=
4831: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 4832: this.document.forms.newaboutsomeone.submit();
4833: } else {
4834: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 4835: }
1.335 ehlerst 4836: } else {
4837: alert("$lt{'p_mab_alrt2'}");
4838: }
4839: }
1.329 droeschl 4840: }
4841:
1.484.2.13 raeburn 4842: function toggleUpload(caller) {
4843: var blocks = Array($fieldsets);
4844: for (var i=0; i<blocks.length; i++) {
4845: var disp = 'none';
4846: if (caller == blocks[i]) {
4847: var curr = document.getElementById('upload'+caller+'form').style.display;
4848: if (curr == 'none') {
4849: disp='block';
4850: }
4851: }
4852: document.getElementById('upload'+blocks[i]+'form').style.display=disp;
4853: }
4854: resize_scrollbox('contentscroll','1','1');
4855: return;
4856: }
4857:
1.484.2.19 raeburn 4858: function toggleMap(caller) {
1.484.2.13 raeburn 4859: var disp = 'none';
1.484.2.19 raeburn 4860: if (document.getElementById('importmapform')) {
4861: if (caller == 'map') {
4862: var curr = document.getElementById('importmapform').style.display;
4863: if (curr == 'none') {
4864: disp='block';
4865: }
1.484.2.12 raeburn 4866: }
1.484.2.19 raeburn 4867: document.getElementById('importmapform').style.display=disp;
4868: resize_scrollbox('contentscroll','1','1');
1.484.2.12 raeburn 4869: }
1.484.2.19 raeburn 4870: return;
1.329 droeschl 4871: }
4872:
1.484.2.12 raeburn 4873: function makeims(imsform) {
4874: if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
4875: alert("$lt{'imsfile'}");
4876: return;
4877: }
4878: if (imsform.source.selectedIndex == 0) {
4879: alert("$lt{'imscms'}");
4880: return;
4881: }
4882: newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
4883: imsform.submit();
4884: }
4885:
1.484.2.19 raeburn 4886: function changename(folderpath,index,oldtitle) {
1.335 ehlerst 4887: var title=prompt('$lt{"p_chn"}',oldtitle);
4888: if (title) {
4889: this.document.forms.renameform.markcopy.value=-1;
4890: this.document.forms.renameform.title.value=title;
4891: this.document.forms.renameform.cmd.value='rename_'+index;
1.484.2.19 raeburn 4892: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4893: this.document.forms.renameform.submit();
4894: }
1.329 droeschl 4895: }
4896:
1.484.2.19 raeburn 4897: function removeres(folderpath,index,oldtitle,skip_confirm) {
1.335 ehlerst 4898: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
4899: this.document.forms.renameform.markcopy.value=-1;
4900: this.document.forms.renameform.cmd.value='del_'+index;
1.484.2.19 raeburn 4901: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4902: this.document.forms.renameform.submit();
4903: }
1.329 droeschl 4904: }
4905:
1.484.2.19 raeburn 4906: function cutres(folderpath,index,oldtitle,container,folder,skip_confirm) {
1.335 ehlerst 4907: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
4908: this.document.forms.renameform.cmd.value='cut_'+index;
4909: this.document.forms.renameform.markcopy.value=index;
4910: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
1.484.2.19 raeburn 4911: this.document.forms.renameform.folderpath.value=folderpath;
1.335 ehlerst 4912: this.document.forms.renameform.submit();
4913: }
1.329 droeschl 4914: }
4915:
1.484.2.19 raeburn 4916: function markcopy(folderpath,index,oldtitle,container,folder) {
1.335 ehlerst 4917: this.document.forms.renameform.markcopy.value=index;
4918: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
4919: this.document.forms.renameform.folderpath.value=folderpath;
4920: this.document.forms.renameform.submit();
1.329 droeschl 4921: }
4922:
1.478 raeburn 4923: function updatePick(targetform,index,caller) {
4924: var pickitem = document.getElementById('rpick_'+index);
4925: var picknumitem = document.getElementById('rpicknum_'+index);
4926: if (pickitem.checked) {
4927: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
4928: if (picknum == '' || picknum == null) {
4929: if (caller == 'check') {
4930: pickitem.checked=false;
4931: return;
4932: }
4933: } else {
4934: picknum.toString();
4935: var regexdigit=/^\\d+\$/;
4936: if (regexdigit.test(picknum)) {
4937: picknumitem.value = picknum;
4938: targetform.changeparms.value='randompick';
4939: targetform.submit();
4940: } else {
4941: if (caller == 'check') {
4942: pickitem.checked=false;
4943: }
4944: return;
4945: }
4946: }
4947: } else {
4948: picknumitem.value = 0;
4949: targetform.changeparms.value='randompick';
4950: targetform.submit();
4951: }
4952: }
4953:
1.334 muellerd 4954: function unselectInactive(nav) {
1.335 ehlerst 4955: currentNav = document.getElementById(nav);
4956: currentLis = currentNav.getElementsByTagName('LI');
4957: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 4958: if (currentLis[i].className == 'goback') {
4959: currentLis[i].className = 'goback';
4960: } else {
4961: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 4962: currentLis[i].className = 'right';
1.472 raeburn 4963: } else {
1.374 tempelho 4964: currentLis[i].className = 'i';
1.472 raeburn 4965: }
4966: }
1.335 ehlerst 4967: }
1.332 tempelho 4968: }
4969:
1.334 muellerd 4970: function hideAll(current, nav, data) {
1.335 ehlerst 4971: unselectInactive(nav);
1.374 tempelho 4972: if(current.className == 'right'){
4973: current.className = 'right active'
4974: }else{
4975: current.className = 'active';
4976: }
1.335 ehlerst 4977: currentData = document.getElementById(data);
4978: currentDivs = currentData.getElementsByTagName('DIV');
4979: for (i = 0; i < currentDivs.length; i++) {
4980: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 4981: currentDivs[i].style.display = 'none';
1.330 tempelho 4982: }
4983: }
1.335 ehlerst 4984: }
1.330 tempelho 4985:
1.374 tempelho 4986: function openTabs(pageId) {
4987: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 4988: if(tabnav.length > 2 ){
1.389 tempelho 4989: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 4990: currentLis = currentNav.getElementsByTagName('LI');
4991: for(i = 0; i< currentLis.length; i++){
4992: if(currentLis[i].className == 'active') {
1.375 tempelho 4993: funcString = currentLis[i].onclick.toString();
4994: tab = funcString.split('"');
1.420 onken 4995: if(tab.length < 2) {
4996: tab = funcString.split("'");
4997: }
1.375 tempelho 4998: currentData = document.getElementById(tab[1]);
4999: currentData.style.display = 'block';
1.374 tempelho 5000: }
5001: }
5002: }
5003: }
5004:
1.334 muellerd 5005: function showPage(current, pageId, nav, data) {
5006: hideAll(current, nav, data);
1.375 tempelho 5007: openTabs(pageId);
1.334 muellerd 5008: unselectInactive(nav);
1.330 tempelho 5009: current.className = 'active';
5010: currentData = document.getElementById(pageId);
5011: currentData.style.display = 'block';
1.458 raeburn 5012: activeTab = pageId;
1.484.2.12 raeburn 5013: toggleUpload();
1.484.2.14 raeburn 5014: toggleMap();
1.433 raeburn 5015: if (nav == 'mainnav') {
5016: var storedpath = "$docs_folderpath";
1.434 raeburn 5017: var storedpage = "$main_container_page";
1.433 raeburn 5018: var reg = new RegExp("^supplemental");
5019: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 5020: if (storedpage == 1) {
5021: document.simpleedit.folderpath.value = '';
5022: document.uploaddocument.folderpath.value = '';
5023: } else {
5024: if (reg.test(storedpath)) {
5025: document.simpleedit.folderpath.value = '$toplevelmain';
5026: document.uploaddocument.folderpath.value = '$toplevelmain';
5027: document.newext.folderpath.value = '$toplevelmain';
5028: } else {
5029: document.simpleedit.folderpath.value = storedpath;
5030: document.uploaddocument.folderpath.value = storedpath;
5031: document.newext.folderpath.value = storedpath;
5032: }
1.433 raeburn 5033: }
5034: } else {
1.434 raeburn 5035: if (reg.test(storedpath)) {
5036: document.simpleedit.folderpath.value = storedpath;
5037: document.supuploaddocument.folderpath.value = storedpath;
5038: document.supnewext.folderpath.value = storedpath;
5039: } else {
1.433 raeburn 5040: document.simpleedit.folderpath.value = '$toplevelsupp';
5041: document.supuploaddocument.folderpath.value = '$toplevelsupp';
5042: document.supnewext.folderpath.value = '$toplevelsupp';
5043: }
5044: }
5045: }
1.484.2.3 raeburn 5046: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 5047: return false;
5048: }
1.329 droeschl 5049:
1.472 raeburn 5050: function toContents(jumpto) {
5051: var newurl = '$backtourl';
1.484.2.21 raeburn 5052: if ((newurl == '/adm/navmaps') && (jumpto != '')) {
1.472 raeburn 5053: newurl = newurl+'?postdata='+jumpto;
5054: }
5055: location.href=newurl;
5056: }
5057:
1.329 droeschl 5058: ENDNEWSCRIPT
5059: }
1.457 raeburn 5060:
1.483 raeburn 5061: sub history_tab_js {
5062: return <<"ENDHIST";
5063: function toggleHistoryDisp(choice) {
5064: document.docslogform.docslog.value = choice;
5065: document.docslogform.submit();
5066: return;
5067: }
5068:
5069: ENDHIST
5070: }
5071:
1.484 raeburn 5072: sub inject_data_js {
5073: return <<ENDINJECT;
5074:
5075: function injectData(current, hiddenField, name, value) {
5076: currentElement = document.getElementById(hiddenField);
5077: currentElement.name = name;
5078: currentElement.value = value;
5079: current.submit();
5080: }
5081:
5082: ENDINJECT
5083: }
5084:
5085: sub dump_switchserver_js {
5086: my @hosts = @_;
5087: my %lt = &Apache::lonlocal::texthash(
5088: dump => 'Dumping to Authoring Space requires switching server.',
5089: swit => 'Switch server?',
5090: duco => 'Dump content to Authoring Space',
5091: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
5092: chos => 'Choose server',
5093: );
5094: my $role = $env{'request.role'};
5095: my $js = <<"ENDSWJS";
5096: <script type="text/javascript">
5097: function write_switchserver() {
5098: var server;
5099: if (document.setserver.posshosts.length > 0) {
5100: for (var i=0; i<document.setserver.posshosts.length; i++) {
5101: if (document.setserver.posshosts[i].checked) {
5102: server = document.setserver.posshosts[i].value;
5103: }
5104: }
5105: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
5106: }
5107: window.close();
5108: }
5109: </script>
5110:
5111: ENDSWJS
5112:
5113: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
5114: {'only_body' => 1,
5115: 'js_ready' => 1,});
5116: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
5117:
5118: my $hostpicker;
5119: my $count = 0;
5120: foreach my $host (sort(@hosts)) {
5121: my $checked;
5122: if ($count == 0) {
5123: $checked = ' checked="checked"';
5124: }
5125: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
5126: $host.'"'.$checked.' />'.$host.'</label> ';
5127: $count++;
5128: }
5129:
5130: return <<"ENDSWITCHJS";
5131:
5132: function dump_needs_switchserver(url) {
5133: if (url!='' && url!= null) {
5134: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
5135: go(url);
5136: }
5137: }
5138: return;
5139: }
5140:
5141: function choose_switchserver_window() {
5142: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
5143: newWindow.document.open();
5144: newWindow.document.writeln('$startpage');
5145: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
5146: '<p>$lt{'yone'}<\\/p>\\n'+
5147: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
5148: '<form name="setserver" method="post" action="" \\/>\\n'+
5149: '$hostpicker\\n'+
5150: '<br \\/><br \\/>\\n'+
5151: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
5152: 'onclick="write_switchserver();" \\/>\\n'+
5153: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
5154: newWindow.document.writeln('$endpage');
5155: newWindow.document.close();
5156: newWindow.focus();
5157: }
5158:
5159: ENDSWITCHJS
5160: }
5161:
5162: sub makedocslogform {
5163: my ($formelems,$docslog) = @_;
5164: return <<"LOGSFORM";
5165: <form action="/adm/coursedocs" method="post" name="docslogform">
5166: <input type="hidden" name="docslog" value="$docslog" />
5167: $formelems
5168: </form>
5169: LOGSFORM
5170: }
5171:
5172: sub makesimpleeditform {
5173: my ($formelems) = @_;
5174: return <<"SIMPFORM";
5175: <form name="simpleedit" method="post" action="/adm/coursedocs">
5176: <input type="hidden" name="importdetail" value="" />
5177: $formelems
5178: </form>
5179: SIMPFORM
5180: }
5181:
1.329 droeschl 5182: 1;
5183: __END__
5184:
5185:
5186: =head1 NAME
5187:
5188: Apache::londocs.pm
5189:
5190: =head1 SYNOPSIS
5191:
5192: This is part of the LearningOnline Network with CAPA project
5193: described at http://www.lon-capa.org.
5194:
5195: =head1 SUBROUTINES
5196:
5197: =over
5198:
5199: =item %help=()
5200:
5201: Available help topics
5202:
5203: =item mapread()
5204:
1.344 bisitz 5205: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 5206: @order and @resources, determines status
5207: sets @order - pointer to resources in right order
5208: sets @resources - array with the resources with correct idx
5209:
5210: =item authorhosts()
5211:
5212: Return hash with valid author names
5213:
5214: =item clean()
5215:
5216: =item dumpcourse()
5217:
5218: Actually dump course
5219:
5220: =item group_import()
5221:
5222: Imports the given (name, url) resources into the course
5223: coursenum, coursedom, and folder must precede the list
5224:
5225: =item breadcrumbs()
5226:
5227: =item log_docs()
5228:
5229: =item docs_change_log()
5230:
5231: =item update_paste_buffer()
5232:
5233: =item print_paste_buffer()
5234:
5235: =item do_paste_from_buffer()
5236:
1.484.2.7 raeburn 5237: =item get_newmap_url()
5238:
5239: =item dbcopy()
5240:
5241: =item uniqueness_check()
5242:
5243: =item contained_map_check()
5244:
5245: =item url_paste_fixups()
5246:
5247: =item apply_fixups()
5248:
5249: =item copy_dependencies()
5250:
1.329 droeschl 5251: =item update_parameter()
5252:
5253: =item handle_edit_cmd()
5254:
5255: =item editor()
5256:
5257: =item process_file_upload()
5258:
5259: =item process_secondary_uploads()
5260:
5261: =item is_supplemental_title()
5262:
5263: =item entryline()
5264:
5265: =item tiehash()
5266:
5267: =item untiehash()
5268:
5269: =item checkonthis()
5270:
5271: check on this
5272:
5273: =item verifycontent()
5274:
5275: Verify Content
5276:
5277: =item devalidateversioncache() & checkversions()
5278:
5279: Check Versions
5280:
5281: =item mark_hash_old()
5282:
5283: =item is_hash_old()
5284:
5285: =item changewarning()
5286:
5287: =item init_breadcrumbs()
5288:
5289: Breadcrumbs for special functions
5290:
1.484 raeburn 5291: =item create_list_elements()
5292:
5293: =item create_form_ul()
5294:
5295: =item startContentScreen()
5296:
5297: =item endContentScreen()
5298:
5299: =item supplemental_base()
5300:
5301: =item embedded_form_elems()
5302:
5303: =item embedded_destination()
5304:
5305: =item return_to_editor()
5306:
5307: =item decompression_info()
5308:
5309: =item decompression_phase_one()
5310:
5311: =item decompression_phase_two()
5312:
5313: =item remove_archive()
5314:
5315: =item generate_admin_menu()
5316:
5317: =item generate_edit_table()
5318:
5319: =item editing_js()
5320:
5321: =item history_tab_js()
5322:
5323: =item inject_data_js()
5324:
5325: =item dump_switchserver_js()
5326:
1.484.2.3 raeburn 5327: =item resize_scrollbox_js()
1.484 raeburn 5328:
5329: =item makedocslogform()
5330:
1.484.2.3 raeburn 5331: =item makesimpleeditform()
5332:
1.329 droeschl 5333: =back
5334:
5335: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>