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