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