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