Annotation of loncom/interface/londocs.pm, revision 1.498
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.498 ! bisitz 4: # $Id: londocs.pm,v 1.497 2012/10/01 12:34:18 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.497 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.497 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.497 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.497 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.497 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))) {
1.496 golterma 2867: #excludes not versionable problems from resource version history:
2868: if ($changes{$key}>$starttime && $key !~ /^\/res\/lib\/templates/) {
1.329 droeschl 2869: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
2870: my $currentversion=&Apache::lonnet::getversion($key);
2871: if ($currentversion<0) {
1.479 golterma 2872: $currentversion='<span class="LC_error">'.&mt('Could not be determined.').'</span>';
1.329 droeschl 2873: }
2874: my $linkurl=&Apache::lonnet::clutter($key);
1.479 golterma 2875: $r->print(
2876: &Apache::loncommon::end_data_table_header_row().
2877: &Apache::loncommon::start_data_table_row().
2878: '<td><b>'.&Apache::lonnet::gettitle($linkurl).'</b><br>'.
2879: '<a href="'.$linkurl.'" target="cat">'.$linkurl.'</a></td>'.
2880: '<td align="right">'.$currentversion.'<span class="LC_fontsize_medium"><br>('.
2881: &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).')</span></td>'.
2882: '<td align="right">');
1.329 droeschl 2883: # Used in course
2884: my $usedversion=$hash{'version_'.$linkurl};
2885: if (($usedversion) && ($usedversion ne 'mostrecent')) {
1.479 golterma 2886: if($usedversion != $currentversion){
2887: $r->print('<span class="LC_warning">'.$usedversion.'</span>');
2888: }else{
2889: $r->print($usedversion);
2890: }
1.329 droeschl 2891: } else {
2892: $r->print($currentversion);
2893: }
1.479 golterma 2894: $r->print('</td><td title="'.$lt{'vu'}.'">');
1.329 droeschl 2895: # Set version
2896: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
2897: 'set_version_'.$linkurl,
1.428 raeburn 2898: {'select_form_order' =>
1.329 droeschl 2899: ['',1..$currentversion,'mostrecent'],
2900: '' => '',
1.411 bisitz 2901: 'mostrecent' => &mt('most recent'),
1.428 raeburn 2902: map {$_,$_} (1..$currentversion)}));
1.329 droeschl 2903: my $lastold=1;
2904: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
2905: my $url=$root.'.'.$prevvers.'.'.$extension;
2906: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
2907: $starttime) {
2908: $lastold=$prevvers;
2909: }
2910: }
1.364 bisitz 2911: #
1.329 droeschl 2912: # Code to figure out how many version entries should go in
2913: # each of the four columns
2914: my $entries_per_col = 0;
2915: my $num_entries = ($currentversion-$lastold);
1.479 golterma 2916: if ($num_entries % $num_ver_col == 0) {
2917: $entries_per_col = $num_entries/$num_ver_col;
1.329 droeschl 2918: } else {
1.479 golterma 2919: $entries_per_col = $num_entries/$num_ver_col + 1;
1.329 droeschl 2920: }
2921: my $entries_count = 0;
1.479 golterma 2922: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1.329 droeschl 2923: my $cols_output = 1;
2924: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
2925: my $url=$root.'.'.$prevvers.'.'.$extension;
2926: $r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
2927: '">'.&mt('Version').' '.$prevvers.'</a> ('.
2928: &Apache::lonlocal::locallocaltime(
2929: &Apache::lonnet::metadata($url,
2930: 'lastrevisiondate')
2931: ).
2932: ')');
2933: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
2934: $r->print(' <a href="/adm/diff?filename='.
2935: &Apache::lonnet::clutter($root.'.'.$extension).
2936: '&versionone='.$prevvers.
1.462 raeburn 2937: '" target="diffs">'.&mt('Diffs').'</a>');
1.329 droeschl 2938: }
2939: $r->print('</span><br />');
2940: if (++$entries_count % $entries_per_col == 0) {
1.479 golterma 2941: $r->print('</span></td>');
2942: if ($cols_output != $num_ver_col) {
2943: $r->print('<td valign="top"><span class="LC_fontsize_medium">');
1.329 droeschl 2944: $cols_output++;
2945: }
2946: }
2947: }
1.479 golterma 2948: while($cols_output++ < $num_ver_col) {
2949: $r->print('</span></td><td>');
1.329 droeschl 2950: }
2951: }
2952: }
1.479 golterma 2953: $r->print('</td>'.&Apache::loncommon::end_data_table_row().
2954: &Apache::loncommon::end_data_table().
2955: '<input type="submit" name="setversions" value="'.$lt{'save'}.'" />');
1.329 droeschl 2956:
2957: &untiehash();
2958: }
2959:
2960: sub mark_hash_old {
2961: my $retie_hash=0;
2962: if ($hashtied) {
2963: $retie_hash=1;
2964: &untiehash();
2965: }
2966: &tiehash('write');
2967: $hash{'old'}=1;
2968: &untiehash();
2969: if ($retie_hash) { &tiehash(); }
2970: }
2971:
2972: sub is_hash_old {
2973: my $untie_hash=0;
2974: if (!$hashtied) {
2975: $untie_hash=1;
2976: &tiehash();
2977: }
2978: my $return=$hash{'old'};
2979: if ($untie_hash) { &untiehash(); }
2980: return $return;
2981: }
2982:
2983: sub changewarning {
2984: my ($r,$postexec,$message,$url)=@_;
2985: if (!&is_hash_old()) { return; }
2986: my $pathvar='folderpath';
2987: my $path=&escape($env{'form.folderpath'});
2988: if (!defined($url)) {
2989: if (defined($env{'form.pagepath'})) {
2990: $pathvar='pagepath';
2991: $path=&escape($env{'form.pagepath'});
2992: $path.='&pagesymb='.&escape($env{'form.pagesymb'});
2993: }
2994: $url='/adm/coursedocs?'.$pathvar.'='.$path;
2995: }
2996: my $course_type = &Apache::loncommon::course_type();
2997: if (!defined($message)) {
2998: $message='Changes will become active for your current session after [_1], or the next time you log in.';
2999: }
3000: $r->print("\n\n".
1.372 bisitz 3001: '<script type="text/javascript">'."\n".
3002: '// <![CDATA['."\n".
3003: 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
3004: '// ]]>'."\n".
1.369 bisitz 3005: '</script>'."\n".
1.375 tempelho 3006: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
1.329 droeschl 3007: '<input type="hidden" name="orgurl" value="'.$url.
1.372 bisitz 3008: '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
1.329 droeschl 3009: &mt($message,' <input type="hidden" name="'.
3010: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 3011: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.372 bisitz 3012: $help{'Caching'}.'</p></form>'."\n\n");
1.329 droeschl 3013: }
3014:
3015:
3016: sub init_breadcrumbs {
3017: my ($form,$text)=@_;
3018: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.484 raeburn 3019: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?tools=1",
1.405 bisitz 3020: text=>&Apache::loncommon::course_type().' Editor',
1.329 droeschl 3021: faq=>273,
3022: bug=>'Instructor Interface',
3023: help => 'Docs_Adding_Course_Doc'});
3024: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
3025: text=>$text,
3026: faq=>273,
3027: bug=>'Instructor Interface'});
3028: }
3029:
1.441 www 3030: # subroutine to list form elements
3031: sub create_list_elements {
3032: my @formarr = @_;
3033: my $list = '';
3034: for my $button (@formarr){
3035: for my $picture(keys %$button) {
3036: $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
3037: }
3038: }
3039: return $list;
3040: }
1.329 droeschl 3041:
1.441 www 3042: # subroutine to create ul from list elements
3043: sub create_form_ul {
3044: my $list = shift;
3045: my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'});
3046: return $ul;
3047: }
1.329 droeschl 3048:
1.442 www 3049: #
3050: # Start tabs
3051: #
3052:
3053: sub startContentScreen {
1.484 raeburn 3054: my ($mode) = @_;
3055: my $output = '<ul class="LC_TabContentBigger" id="mainnav">';
1.472 raeburn 3056: if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
1.484 raeburn 3057: $output .= '<li'.(($mode eq 'navmaps')?' class="active"':'').'><a href="/adm/navmaps"><b> '.&mt('Content Overview').' </b></a></li>'."\n";
3058: $output .= '<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>'."\n";
3059: $output .= '<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>'."\n";
3060: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/supplemental"><b>'.&mt('Supplemental Content').'</b></a></li>';
3061: } else {
3062: $output .= '<li '.(($mode eq 'docs')?' class="active"':'').' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>'."\n";
3063: $output .= '<li '.(($mode eq 'suppdocs')?' class="active"':'').'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Content Editor').'</b></a></li>'."\n";
3064: $output .= '<li '.(($mode eq 'tools')?' class="active"':'').'><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>'."\n";
3065: '><a href="/adm/coursedocs?tools=1"><b> '.&mt('Content Utilities').' </b></a></li>';
3066: }
3067: $output .= "\n".'</ul>'."\n";
3068: $output .= '<div class="LC_DocsBox" style="clear:both;margin:0;" id="contenteditor">'.
3069: '<div id="maincoursedoc" style="margin:0 0;padding:0 0;">'.
3070: '<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">';
3071: return $output;
1.442 www 3072: }
3073:
3074: #
3075: # End tabs
3076: #
3077:
3078: sub endContentScreen {
1.484 raeburn 3079: return '</div></div></div>';
1.442 www 3080: }
1.329 droeschl 3081:
1.446 www 3082: sub supplemental_base {
1.472 raeburn 3083: return 'supplemental&'.&escape(&mt('Supplemental '.&Apache::loncommon::course_type().' Content'));
1.446 www 3084: }
3085:
1.329 droeschl 3086: sub handler {
3087: my $r = shift;
3088: &Apache::loncommon::content_type($r,'text/html');
3089: $r->send_http_header;
3090: return OK if $r->header_only;
1.484 raeburn 3091:
3092: # get course data
1.408 raeburn 3093: my $crstype = &Apache::loncommon::course_type();
1.484 raeburn 3094: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
3095: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3096:
3097: # graphics settings
3098: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL').'/');
1.329 droeschl 3099:
1.443 www 3100: #
1.329 droeschl 3101: # --------------------------------------------- Initialize help topics for this
3102: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
3103: 'Adding_External_Resource','Navigate_Content',
3104: 'Adding_Folders','Docs_Overview', 'Load_Map',
3105: 'Supplemental','Score_Upload_Form','Adding_Pages',
3106: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
3107: 'Check_Resource_Versions','Verify_Content') {
3108: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
3109: }
3110: # Composite help files
3111: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
3112: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
3113: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
3114: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
3115: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
3116: 'Option_Response_Simple');
3117: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
3118: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 3119: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 3120: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 3121: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 3122: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
3123:
1.472 raeburn 3124:
3125: my $allowed;
3126: # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
3127: unless ($r->uri eq '/adm/supplemental') {
3128: # does this user have privileges to modify content.
3129: $allowed = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
3130: }
3131:
1.484 raeburn 3132: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['chooseserver',
3133: 'inhibitmenu']);
3134: if ($allowed && $env{'form.chooseserver'}) {
3135: &choose_dump_server($r);
3136: return OK;
3137: } elsif ($allowed && $env{'form.verify'}) {
1.329 droeschl 3138: &init_breadcrumbs('verify','Verify Content');
3139: &verifycontent($r);
3140: } elsif ($allowed && $env{'form.listsymbs'}) {
1.484 raeburn 3141: &init_breadcrumbs('listsymbs','List Content IDs');
1.329 droeschl 3142: &list_symbs($r);
3143: } elsif ($allowed && $env{'form.docslog'}) {
3144: &init_breadcrumbs('docslog','Show Log');
1.484 raeburn 3145: my $folder = $env{'form.folder'};
3146: if ($folder eq '') {
3147: $folder='default';
3148: }
3149: &docs_change_log($r,$coursenum,$coursedom,$folder,$allowed,$crstype,$iconpath);
1.329 droeschl 3150: } elsif ($allowed && $env{'form.versions'}) {
3151: &init_breadcrumbs('versions','Check/Set Resource Versions');
3152: &checkversions($r);
3153: } elsif ($allowed && $env{'form.dumpcourse'}) {
1.484 raeburn 3154: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space');
1.329 droeschl 3155: &dumpcourse($r);
3156: } elsif ($allowed && $env{'form.exportcourse'}) {
1.377 bisitz 3157: &init_breadcrumbs('exportcourse','IMS Export');
1.475 raeburn 3158: &Apache::imsexport::exportcourse($r);
1.329 droeschl 3159: } else {
1.445 www 3160: #
3161: # Done catching special calls
1.484 raeburn 3162: # The whole rest is for course and supplemental documents and utilities menu
1.445 www 3163: # Get the parameters that may be needed
3164: #
3165: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
3166: ['folderpath','pagepath',
1.466 www 3167: 'pagesymb','forcesupplement','forcestandard',
1.484 raeburn 3168: 'tools','symb','command']);
1.445 www 3169:
3170: # standard=1: this is a "new-style" course with an uploaded map as top level
3171: # standard=2: this is a "old-style" course, and there is nothing we can do
1.329 droeschl 3172:
3173: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
1.445 www 3174:
1.484 raeburn 3175: # Decide whether this should display supplemental or main content or utilities
1.445 www 3176: # supplementalflag=1: show supplemental documents
3177: # supplementalflag=0: show standard documents
1.484 raeburn 3178: # toolsflag=1: show utilities
1.445 www 3179:
3180:
3181: my $supplementalflag=($env{'form.folderpath'}=~/^supplemental/);
3182: if (($env{'form.folderpath'}=~/^default/) || $env{'form.folderpath'} eq "" || ($env{'form.pagepath'})) {
3183: $supplementalflag=0;
3184: }
3185: if ($env{'form.forcesupplement'}) { $supplementalflag=1; }
3186: if ($env{'form.forcestandard'}) { $supplementalflag=0; }
3187: unless ($allowed) { $supplementalflag=1; }
3188: unless ($standard) { $supplementalflag=1; }
1.484 raeburn 3189: my $toolsflag=0;
3190: if ($env{'form.tools'}) { $toolsflag=1; }
1.445 www 3191:
1.329 droeschl 3192: my $script='';
3193: my $showdoc=0;
1.457 raeburn 3194: my $addentries = {};
1.475 raeburn 3195: my $container;
1.329 droeschl 3196: my $containertag;
3197: my $uploadtag;
3198:
1.464 www 3199: # Do we directly jump somewhere?
1.466 www 3200:
1.464 www 3201: if ($env{'form.command'} eq 'direct') {
1.468 raeburn 3202: my ($mapurl,$id,$resurl);
1.472 raeburn 3203: if ($env{'form.symb'} ne '') {
1.468 raeburn 3204: ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($env{'form.symb'});
3205: if ($resurl=~/\.(sequence|page)$/) {
3206: $mapurl=$resurl;
3207: } elsif ($resurl eq 'adm/navmaps') {
3208: $mapurl=$env{'course.'.$env{'request.course.id'}.'.url'};
3209: }
1.472 raeburn 3210: my $mapresobj;
3211: my $navmap = Apache::lonnavmaps::navmap->new();
3212: if (ref($navmap)) {
3213: $mapresobj = $navmap->getResourceByUrl($mapurl);
3214: }
3215: $mapurl=~s{^.*/([^/]+)\.(\w+)$}{$1};
3216: my $type=$2;
3217: my $path;
3218: if (ref($mapresobj)) {
3219: my $pcslist = $mapresobj->map_hierarchy();
3220: if ($pcslist ne '') {
3221: foreach my $pc (split(/,/,$pcslist)) {
3222: next if ($pc <= 1);
3223: my $res = $navmap->getByMapPc($pc);
3224: if (ref($res)) {
3225: my $thisurl = $res->src();
3226: $thisurl=~s{^.*/([^/]+)\.\w+$}{$1};
3227: my $thistitle = $res->title();
3228: $path .= '&'.
3229: &Apache::lonhtmlcommon::entity_encode($thisurl).'&'.
3230: &Apache::lonhtmlcommon::entity_encode($thistitle).
3231: ':'.$res->randompick().
3232: ':'.$res->randomout().
3233: ':'.$res->encrypted().
3234: ':'.$res->randomorder();
3235: }
1.467 raeburn 3236: }
3237: }
1.472 raeburn 3238: $path .= '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
1.467 raeburn 3239: &Apache::lonhtmlcommon::entity_encode($mapresobj->title()).
3240: ':'.$mapresobj->randompick().
3241: ':'.$mapresobj->randomout().
3242: ':'.$mapresobj->encrypted().
3243: ':'.$mapresobj->randomorder();
1.472 raeburn 3244: } else {
3245: my $maptitle = &Apache::lonnet::gettitle($mapurl);
3246: $path = '&default&...::::'.
3247: '&'.&Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
3248: &Apache::lonhtmlcommon::entity_encode($maptitle).'::::';
3249: }
3250: $path = 'default&'.
3251: &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
3252: $path;
3253: if ($type eq 'sequence') {
3254: $env{'form.folderpath'}=$path;
3255: $env{'form.pagepath'}='';
3256: } else {
3257: $env{'form.pagepath'}=$path;
3258: $env{'form.folderpath'}='';
3259: }
3260: } elsif ($env{'form.supppath'} ne '') {
3261: $env{'form.folderpath'}=$env{'form.supppath'};
1.466 www 3262: }
1.472 raeburn 3263: } elsif ($env{'form.command'} eq 'editdocs') {
3264: $env{'form.folderpath'} = 'default&'.
3265: &Apache::lonhtmlcommon::entity_encode('Main Course Content');
3266: $env{'form.pagepath'}='';
3267: } elsif ($env{'form.command'} eq 'editsupp') {
3268: $env{'form.folderpath'} = 'default&'.
3269: &Apache::lonhtmlcommon::entity_encode('Supplemental Content');
3270: $env{'form.pagepath'}='';
1.464 www 3271: }
3272:
1.445 www 3273: # Where do we store these for when we come back?
3274: my $stored_folderpath='docs_folderpath';
3275: if ($supplementalflag) {
3276: $stored_folderpath='docs_sup_folderpath';
3277: }
1.464 www 3278:
1.329 droeschl 3279: # No folderpath, no pagepath, see if we have something stored
3280: if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
1.445 www 3281: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.329 droeschl 3282: {'folderpath' => 'scalar'});
3283: }
1.446 www 3284:
3285: # If we are not allowed to make changes, all we can see are supplemental docs
1.409 raeburn 3286: if (!$allowed) {
1.446 www 3287: $env{'form.pagepath'}='';
3288: unless ($env{'form.folderpath'} =~ /^supplemental/) {
3289: $env{'form.folderpath'} = &supplemental_base();
1.409 raeburn 3290: }
3291: }
1.446 www 3292: # If we still not have a folderpath, see if we can resurrect at pagepath
1.409 raeburn 3293: if (!$env{'form.folderpath'} && $allowed) {
1.445 www 3294: &Apache::loncommon::restore_course_settings($stored_folderpath,
1.329 droeschl 3295: {'pagepath' => 'scalar'});
3296: }
1.446 www 3297: # Make the zeroth entry in supplemental docs page paths, so we can get to top level
1.329 droeschl 3298: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
1.446 www 3299: $env{'form.folderpath'} = &supplemental_base()
3300: .'&'.
1.329 droeschl 3301: $env{'form.folderpath'};
3302: }
1.446 www 3303: # If after all of this, we still don't have any paths, make them
3304: unless (($env{'form.pagepath'}) || ($env{'form.folderpath'})) {
3305: if ($supplementalflag) {
3306: $env{'form.folderpath'}=&supplemental_base();
3307: } else {
3308: $env{'form.folderpath'}='default';
3309: }
1.472 raeburn 3310: }
1.446 www 3311:
1.445 www 3312: # Store this
1.484 raeburn 3313: unless ($toolsflag) {
3314: &Apache::loncommon::store_course_settings($stored_folderpath,
3315: {'pagepath' => 'scalar',
3316: 'folderpath' => 'scalar'});
3317: if ($env{'form.folderpath'}) {
3318: my (@folderpath)=split('&',$env{'form.folderpath'});
3319: $env{'form.foldername'}=&unescape(pop(@folderpath));
3320: $env{'form.folder'}=pop(@folderpath);
3321: $container='sequence';
3322: }
3323: if ($env{'form.pagepath'}) {
3324: my (@pagepath)=split('&',$env{'form.pagepath'});
3325: $env{'form.pagename'}=&unescape(pop(@pagepath));
3326: $env{'form.folder'}=pop(@pagepath);
3327: $container='page';
3328: $containertag = '<input type="hidden" name="pagepath" value="" />'.
3329: '<input type="hidden" name="pagesymb" value="" />';
3330: $uploadtag =
3331: '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
3332: '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />'.
3333: '<input type="hidden" name="folderpath" value="" />';
3334: } else {
3335: my $folderpath=$env{'form.folderpath'};
3336: if (!$folderpath) {
3337: if ($env{'form.folder'} eq '' ||
3338: $env{'form.folder'} eq 'supplemental') {
3339: $folderpath='default&'.
3340: &escape(&mt('Main '.$crstype.' Documents'));
3341: }
3342: }
3343: $containertag = '<input type="hidden" name="folderpath" value="" />';
3344: $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
3345: }
3346: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
3347: $showdoc='/'.$1;
3348: }
3349: if ($showdoc) { # got called in sequence from course
3350: $allowed=0;
3351: } else {
3352: if ($allowed) {
3353: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
3354: $script=&Apache::lonratedt::editscript('simple');
1.433 raeburn 3355: }
3356: }
1.329 droeschl 3357: }
3358:
1.344 bisitz 3359: # get personal data
1.329 droeschl 3360: my $uname=$env{'user.name'};
3361: my $udom=$env{'user.domain'};
3362: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
3363:
3364: if ($allowed) {
1.484 raeburn 3365: if ($toolsflag) {
3366: $script .= &inject_data_js();
3367: my ($home,$other,%outhash)=&authorhosts();
3368: if (!$home && $other) {
3369: my @hosts;
3370: foreach my $aurole (keys(%outhash)) {
3371: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
3372: push(@hosts,$outhash{$aurole});
3373: }
3374: }
3375: $script .= &dump_switchserver_js(@hosts);
3376: }
1.458 raeburn 3377: } else {
1.484 raeburn 3378: my @tabids;
3379: if ($supplementalflag) {
3380: @tabids = ('002','ee2','ff2');
3381: } else {
3382: @tabids = ('aa1','bb1','cc1','ff1');
3383: unless ($env{'form.pagepath'}) {
3384: unshift(@tabids,'001');
3385: push(@tabids,('dd1','ee1'));
3386: }
1.458 raeburn 3387: }
1.484 raeburn 3388: my $tabidstr = join("','",@tabids);
3389: $script .= &editing_js($udom,$uname,$supplementalflag).
3390: &history_tab_js().
3391: &inject_data_js().
1.485 raeburn 3392: &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr);
1.484 raeburn 3393: $addentries = {
1.485 raeburn 3394: onload => "javascript:resize_scrollbox('contentscroll','1','1');",
1.484 raeburn 3395: };
1.458 raeburn 3396: }
1.492 raeburn 3397: if ($env{'docs.markedcopy_url'}) {
3398: $script .= &paste_popup_js();
3399: }
1.329 droeschl 3400: }
3401: # -------------------------------------------------------------------- Body tag
1.369 bisitz 3402: $script = '<script type="text/javascript">'."\n"
1.372 bisitz 3403: .'// <![CDATA['."\n"
3404: .$script."\n"
3405: .'// ]]>'."\n"
3406: .'</script>'."\n";
1.385 bisitz 3407:
3408: # Breadcrumbs
3409: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.446 www 3410: unless ($showdoc) {
1.392 raeburn 3411: &Apache::lonhtmlcommon::add_breadcrumb({
1.446 www 3412: href=>"/adm/coursedocs",text=>"$crstype Contents"});
1.392 raeburn 3413:
1.446 www 3414: $r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
1.457 raeburn 3415: {'force_register' => $showdoc,
3416: 'add_entries' => $addentries,
3417: })
1.392 raeburn 3418: .&Apache::loncommon::help_open_menu('','',273,'RAT')
3419: .&Apache::lonhtmlcommon::breadcrumbs(
1.484 raeburn 3420: 'Editing '.$crstype.' Contents',
1.392 raeburn 3421: 'Docs_Adding_Course_Doc')
3422: );
1.446 www 3423: } else {
1.408 raeburn 3424: $r->print(&Apache::loncommon::start_page("$crstype documents",undef,
1.402 raeburn 3425: {'force_register' => $showdoc,}));
1.392 raeburn 3426: }
1.364 bisitz 3427:
1.329 droeschl 3428: my %allfiles = ();
3429: my %codebase = ();
1.440 raeburn 3430: my ($upload_result,$upload_output,$uploadphase);
1.329 droeschl 3431: if ($allowed) {
3432: if (($env{'form.uploaddoc.filename'}) &&
3433: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.440 raeburn 3434: my $context = $1;
3435: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 3436: undef($hadchanges);
1.440 raeburn 3437: $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
3438: \%allfiles,\%codebase,$context);
1.329 droeschl 3439: if ($hadchanges) {
3440: &mark_hash_old();
3441: }
1.440 raeburn 3442: $r->print($upload_output);
3443: } elsif ($env{'form.phase'} eq 'upload_embedded') {
3444: # Process file upload - phase two - upload embedded objects
3445: $uploadphase = 'check_embedded';
3446: my $primaryurl = &HTML::Entities::encode($env{'form.primaryurl'},'<>&"');
3447: my $state = &embedded_form_elems($uploadphase,$primaryurl,
3448: $env{'form.newidx'});
3449: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3450: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3451: my ($destination,$dir_root) = &embedded_destination();
3452: my $url_root = '/uploaded/'.$docudom.'/'.$docuname;
3453: my $actionurl = '/adm/coursedocs';
3454: my ($result,$flag) =
3455: &Apache::loncommon::upload_embedded('coursedoc',$destination,
3456: $docuname,$docudom,$dir_root,$url_root,undef,undef,undef,$state,
3457: $actionurl);
3458: $r->print($result.&return_to_editor());
3459: } elsif ($env{'form.phase'} eq 'check_embedded') {
3460: # Process file upload - phase three - modify references in HTML file
3461: $uploadphase = 'modified_orightml';
3462: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
3463: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
3464: my ($destination,$dir_root) = &embedded_destination();
1.482 raeburn 3465: my $result =
3466: &Apache::loncommon::modify_html_refs('coursedoc',$destination,
3467: $docuname,$docudom,undef,
3468: $dir_root);
3469: $r->print($result.&return_to_editor());
1.476 raeburn 3470: } elsif ($env{'form.phase'} eq 'decompress_uploaded') {
3471: $uploadphase = 'decompress_phase_one';
3472: $r->print(&decompression_phase_one().
3473: &return_to_editor());
3474: } elsif ($env{'form.phase'} eq 'decompress_cleanup') {
3475: $uploadphase = 'decompress_phase_two';
3476: $r->print(&decompression_phase_two().
3477: &return_to_editor());
1.329 droeschl 3478: }
3479: }
3480:
1.484 raeburn 3481: if ($allowed && $toolsflag) {
3482: $r->print(&startContentScreen('tools'));
3483: $r->print(&generate_admin_menu($crstype));
3484: $r->print(&endContentScreen());
3485: } elsif ((!$showdoc) && (!$uploadphase)) {
1.329 droeschl 3486: # -----------------------------------------------------------------------------
3487: my %lt=&Apache::lonlocal::texthash(
1.408 raeburn 3488: 'uplm' => 'Upload a new main '.lc($crstype).' document',
3489: 'upls' => 'Upload a new supplemental '.lc($crstype).' document',
1.329 droeschl 3490: 'impp' => 'Import a document',
3491: 'copm' => 'All documents out of a published map into this folder',
1.417 droeschl 3492: 'upld' => 'Import Document',
1.329 droeschl 3493: 'srch' => 'Search',
3494: 'impo' => 'Import',
1.487 raeburn 3495: 'lnks' => 'Import from Stored Links',
1.329 droeschl 3496: 'selm' => 'Select Map',
3497: 'load' => 'Load Map',
1.419 bisitz 3498: 'reco' => 'Recover Deleted Documents',
1.329 droeschl 3499: 'newf' => 'New Folder',
3500: 'newp' => 'New Composite Page',
3501: 'extr' => 'External Resource',
3502: 'syll' => 'Syllabus',
1.425 raeburn 3503: 'navc' => 'Table of Contents',
1.343 biermanm 3504: 'sipa' => 'Simple Course Page',
1.329 droeschl 3505: 'sipr' => 'Simple Problem',
3506: 'drbx' => 'Drop Box',
1.451 www 3507: 'scuf' => 'External Scores (handgrade, upload, clicker)',
1.336 schafran 3508: 'bull' => 'Discussion Board',
1.347 weissno 3509: 'mypi' => 'My Personal Information Page',
1.353 weissno 3510: 'grpo' => 'Group Portfolio',
1.329 droeschl 3511: 'rost' => 'Course Roster',
1.348 weissno 3512: 'abou' => 'Personal Information Page for a User',
1.377 bisitz 3513: 'imsf' => 'IMS Import',
3514: 'imsl' => 'Import IMS package',
1.329 droeschl 3515: 'file' => 'File',
3516: 'title' => 'Title',
3517: 'comment' => 'Comment',
1.403 raeburn 3518: 'parse' => 'Upload embedded images/multimedia files if HTML file',
1.368 truskell 3519: 'nd' => 'Upload Document',
1.329 droeschl 3520: 'pm' => 'Published Map',
3521: 'sd' => 'Special Document',
3522: 'mo' => 'More Options',
3523: );
3524: # -----------------------------------------------------------------------------
3525: my $fileupload=(<<FIUP);
3526: $lt{'file'}:<br />
3527: <input type="file" name="uploaddoc" size="40" />
3528: FIUP
3529:
3530: my $checkbox=(<<CHBO);
3531: <!-- <label>$lt{'parse'}?
3532: <input type="checkbox" name="parserflag" />
3533: </label> -->
3534: <label>
3535: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
3536: </label>
3537: CHBO
3538:
1.458 raeburn 3539: my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";
1.329 droeschl 3540: my $fileuploadform=(<<FUFORM);
3541: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.371 tempelho 3542: <input type="hidden" name="active" value="aa" />
1.329 droeschl 3543: $fileupload
3544: <br />
3545: $lt{'title'}:<br />
1.458 raeburn 3546: <input type="text" size="60" name="comment" />
1.329 droeschl 3547: $uploadtag
3548: <input type="hidden" name="cmd" value="upload_default" />
3549: <br />
1.458 raeburn 3550: <span class="LC_nobreak" style="float:left">
1.329 droeschl 3551: $checkbox
3552: </span>
1.383 tempelho 3553: FUFORM
1.459 raeburn 3554: $fileuploadform .= $fileuploada.'</form>';
1.329 droeschl 3555:
3556: my $simpleeditdefaultform=(<<SEDFFORM);
3557: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.371 tempelho 3558: <input type="hidden" name="active" value="bb" />
1.383 tempelho 3559: SEDFFORM
3560: my @simpleeditdefaultforma = (
1.423 onken 3561: { '<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>" },
3562: { '<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 3563: { '<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 3564: );
1.443 www 3565: $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
1.383 tempelho 3566: $simpleeditdefaultform .=(<<SEDFFORM);
1.459 raeburn 3567: <hr id="bb_hrule" style="width:0px;text-align:left;margin-left:0" />
1.329 droeschl 3568: $lt{'copm'}<br />
3569: <input type="text" size="40" name="importmap" /><br />
1.458 raeburn 3570: <span class="LC_nobreak" style="float:left"><input type="button"
1.369 bisitz 3571: onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.329 droeschl 3572: value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
3573: $help{'Load_Map'}</span>
3574: </form>
3575: SEDFFORM
3576:
1.442 www 3577: my $extresourcesform=(<<ERFORM);
3578: <form action="/adm/coursedocs" method="post" name="newext">
3579: $uploadtag
3580: <input type="hidden" name="importdetail" value="" />
3581: <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
3582: </form>
1.329 droeschl 3583: ERFORM
3584:
1.442 www 3585:
1.329 droeschl 3586: if ($allowed) {
1.492 raeburn 3587: my $folder = $env{'form.folder'};
3588: if ($folder eq '') {
3589: $folder='default';
3590: }
3591: &update_paste_buffer($coursenum,$coursedom,$folder);
1.337 ehlerst 3592: $r->print(<<HIDDENFORM);
3593: <form name="renameform" method="post" action="/adm/coursedocs">
3594: <input type="hidden" name="title" />
3595: <input type="hidden" name="cmd" />
3596: <input type="hidden" name="markcopy" />
3597: <input type="hidden" name="copyfolder" />
3598: $containertag
3599: </form>
1.484 raeburn 3600:
1.337 ehlerst 3601: HIDDENFORM
1.484 raeburn 3602: $r->print(&makesimpleeditform($uploadtag)."\n".
3603: &makedocslogform($uploadtag."\n".
3604: '<input type="hidden" name="folder" value="'.
3605: $env{'form.folder'}.'" />'."\n"));
1.329 droeschl 3606: }
1.442 www 3607:
3608: # Generate the tabs
1.472 raeburn 3609: my $mode;
3610: if (($supplementalflag) && (!$allowed)) {
3611: &Apache::lonnavdisplay::startContentScreen($r,'supplemental');
3612: } else {
1.484 raeburn 3613: $r->print(&startContentScreen(($supplementalflag?'suppdocs':'docs')));
1.472 raeburn 3614: }
1.443 www 3615:
1.442 www 3616: #
3617:
3618: my $savefolderpath;
3619:
1.395 raeburn 3620: if ($allowed) {
1.329 droeschl 3621: my $folder=$env{'form.folder'};
1.443 www 3622: if ($folder eq '' || $supplementalflag) {
1.329 droeschl 3623: $folder='default';
1.356 tempelho 3624: $savefolderpath = $env{'form.folderpath'};
1.442 www 3625: $env{'form.folderpath'}='default&'.&escape(&mt('Content'));
1.329 droeschl 3626: $uploadtag = '<input type="hidden" name="folderpath" value="'.
3627: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
3628: }
3629: my $postexec='';
3630: if ($folder eq 'default') {
1.372 bisitz 3631: $r->print('<script type="text/javascript">'."\n"
3632: .'// <![CDATA['."\n"
3633: .'this.window.name="loncapaclient";'."\n"
3634: .'// ]]>'."\n"
3635: .'</script>'."\n"
1.369 bisitz 3636: );
1.329 droeschl 3637: } else {
3638: #$postexec='self.close();';
3639: }
3640: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
3641: '.sequence';
3642: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
3643: '.page';
3644: my $container='sequence';
3645: if ($env{'form.pagepath'}) {
3646: $container='page';
3647: }
3648: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
3649:
3650: my $imspform=(<<IMSPFORM);
3651: <form action="/adm/imsimportdocs" method="post" name="ims">
3652: <input type="hidden" name="folder" value="$folder" />
1.423 onken 3653: <a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a>
1.329 droeschl 3654: </form>
3655: IMSPFORM
3656:
3657: my $newnavform=(<<NNFORM);
3658: <form action="/adm/coursedocs" method="post" name="newnav">
1.371 tempelho 3659: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3660: $uploadtag
3661: <input type="hidden" name="importdetail"
3662: value="$lt{'navc'}=/adm/navmaps" />
1.423 onken 3663: <a class="LC_menubuttons_link" href="javascript:document.newnav.submit()">$lt{'navc'}</a>
1.329 droeschl 3664: $help{'Navigate_Content'}
3665: </form>
3666: NNFORM
3667: my $newsmppageform=(<<NSPFORM);
3668: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.371 tempelho 3669: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3670: $uploadtag
3671: <input type="hidden" name="importdetail" value="" />
1.423 onken 3672: <a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
1.383 tempelho 3673: $help{'Simple Page'}
1.329 droeschl 3674: </form>
3675: NSPFORM
3676:
3677: my $newsmpproblemform=(<<NSPROBFORM);
3678: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 tempelho 3679: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3680: $uploadtag
3681: <input type="hidden" name="importdetail" value="" />
1.423 onken 3682: <a class="LC_menubuttons_link" href="javascript:makesmpproblem();">$lt{'sipr'}</a>
1.383 tempelho 3683: $help{'Simple Problem'}
1.329 droeschl 3684: </form>
3685:
3686: NSPROBFORM
3687:
3688: my $newdropboxform=(<<NDBFORM);
3689: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 tempelho 3690: <input type="hidden" name="active" value="cc" />
1.344 bisitz 3691: $uploadtag
1.329 droeschl 3692: <input type="hidden" name="importdetail" value="" />
1.423 onken 3693: <a class="LC_menubuttons_link" href="javascript:makedropbox();">$lt{'drbx'}</a>
1.344 bisitz 3694: </form>
1.329 droeschl 3695: NDBFORM
3696:
3697: my $newexuploadform=(<<NEXUFORM);
3698: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 tempelho 3699: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3700: $uploadtag
3701: <input type="hidden" name="importdetail" value="" />
1.423 onken 3702: <a class="LC_menubuttons_link" href="javascript:makeexamupload();">$lt{'scuf'}</a>
1.329 droeschl 3703: $help{'Score_Upload_Form'}
3704: </form>
3705: NEXUFORM
3706:
3707: my $newbulform=(<<NBFORM);
3708: <form action="/adm/coursedocs" method="post" name="newbul">
1.371 tempelho 3709: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3710: $uploadtag
3711: <input type="hidden" name="importdetail" value="" />
1.423 onken 3712: <a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
1.329 droeschl 3713: $help{'Bulletin Board'}
3714: </form>
3715: NBFORM
3716:
3717: my $newaboutmeform=(<<NAMFORM);
3718: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.371 tempelho 3719: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3720: $uploadtag
3721: <input type="hidden" name="importdetail"
3722: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 3723: <a class="LC_menubuttons_link" href="javascript:document.newaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 3724: $help{'My Personal Information Page'}
1.329 droeschl 3725: </form>
3726: NAMFORM
3727:
3728: my $newaboutsomeoneform=(<<NASOFORM);
3729: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.371 tempelho 3730: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3731: $uploadtag
3732: <input type="hidden" name="importdetail" value="" />
1.423 onken 3733: <a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
1.329 droeschl 3734: </form>
3735: NASOFORM
3736:
3737:
3738: my $newrosterform=(<<NROSTFORM);
3739: <form action="/adm/coursedocs" method="post" name="newroster">
1.371 tempelho 3740: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3741: $uploadtag
3742: <input type="hidden" name="importdetail"
3743: value="$lt{'rost'}=/adm/viewclasslist" />
1.423 onken 3744: <a class="LC_menubuttons_link" href="javascript:document.newroster.submit()">$lt{'rost'}</a>
1.329 droeschl 3745: $help{'Course Roster'}
3746: </form>
3747: NROSTFORM
3748:
1.342 ehlerst 3749: my $specialdocumentsform;
1.383 tempelho 3750: my @specialdocumentsforma;
1.451 www 3751: my $gradingform;
3752: my @gradingforma;
3753: my $communityform;
3754: my @communityforma;
1.351 ehlerst 3755: my $newfolderform;
1.390 tempelho 3756: my $newfolderb;
1.342 ehlerst 3757:
1.451 www 3758: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1.383 tempelho 3759:
1.329 droeschl 3760: my $newpageform=(<<NPFORM);
3761: <form action="/adm/coursedocs" method="post" name="newpage">
3762: <input type="hidden" name="folderpath" value="$path" />
3763: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 3764: <input type="hidden" name="active" value="cc" />
1.423 onken 3765: <a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
1.383 tempelho 3766: $help{'Adding_Pages'}
1.329 droeschl 3767: </form>
3768: NPFORM
1.390 tempelho 3769:
3770:
1.351 ehlerst 3771: $newfolderform=(<<NFFORM);
1.329 droeschl 3772: <form action="/adm/coursedocs" method="post" name="newfolder">
3773: <input type="hidden" name="folderpath" value="$path" />
3774: <input type="hidden" name="importdetail" value="" />
1.371 tempelho 3775: <input type="hidden" name="active" value="aa" />
1.422 onken 3776: <a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
1.329 droeschl 3777: </form>
3778: NFFORM
3779:
3780: my $newsylform=(<<NSYLFORM);
3781: <form action="/adm/coursedocs" method="post" name="newsyl">
1.371 tempelho 3782: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3783: $uploadtag
3784: <input type="hidden" name="importdetail"
3785: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 3786: <a class="LC_menubuttons_link" href="javascript:document.newsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 3787: $help{'Syllabus'}
1.383 tempelho 3788:
1.329 droeschl 3789: </form>
3790: NSYLFORM
1.364 bisitz 3791:
1.329 droeschl 3792: my $newgroupfileform=(<<NGFFORM);
3793: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.371 tempelho 3794: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3795: $uploadtag
3796: <input type="hidden" name="importdetail"
3797: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
1.423 onken 3798: <a class="LC_menubuttons_link" href="javascript:document.newgroupfiles.submit()">$lt{'grpo'}</a>
1.353 weissno 3799: $help{'Group Portfolio'}
1.329 droeschl 3800: </form>
3801: NGFFORM
1.383 tempelho 3802: @specialdocumentsforma=(
1.421 onken 3803: {'<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 3804: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
1.451 www 3805: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
3806: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
3807: );
3808: $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
3809:
1.434 raeburn 3810:
3811: my @importdoc = (
3812: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
3813: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
1.459 raeburn 3814: $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 3815:
1.451 www 3816: @gradingforma=(
3817: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
3818: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/dropbox.png" alt="'.$lt{drbx}.'" onclick="javascript:makedropbox();" />'=>$newdropboxform},
3819: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/scoreupfrm.png" alt="'.$lt{scuf}.'" onclick="javascript:makeexamupload();" />'=>$newexuploadform},
3820:
3821: );
3822: $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
3823:
3824: @communityforma=(
3825: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/bchat.png" alt="'.$lt{bull}.'" onclick="javascript:makebulboard();" />'=>$newbulform},
3826: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="javascript:makebulboard();" />'=>$newaboutmeform},
3827: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/aboutme.png" alt="'.$lt{abou}.'" onclick="javascript:makeabout();" />'=>$newaboutsomeoneform},
3828: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/clst.png" alt="'.$lt{rost}.'" onclick="document.newroster.submit()" />'=>$newrosterform},
3829: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/groupportfolio.png" alt="'.$lt{grpo}.'" onclick="document.newgroupfiles.submit()" />'=>$newgroupfileform},
3830: );
3831: $communityform = &create_form_ul(&create_list_elements(@communityforma));
1.383 tempelho 3832:
1.330 tempelho 3833: my %orderhash = (
1.488 raeburn 3834: 'aa' => ['Import Content',$fileuploadform],
3835: 'bb' => ['Published Content',$simpleeditdefaultform],
1.451 www 3836: 'cc' => ['Grading Resources',$gradingform],
1.330 tempelho 3837: );
1.451 www 3838: unless ($env{'form.pagepath'}) {
1.434 raeburn 3839: $orderhash{'00'} = ['Newfolder',$newfolderform];
1.484 raeburn 3840: $orderhash{'dd'} = ['Collaboration',$communityform];
1.451 www 3841: $orderhash{'ee'} = ['Special Documents',$specialdocumentsform];
1.434 raeburn 3842: }
3843:
1.341 ehlerst 3844: $hadchanges=0;
1.484 raeburn 3845: unless (($supplementalflag || $toolsflag)) {
1.458 raeburn 3846: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472 raeburn 3847: $supplementalflag,\%orderhash,$iconpath);
1.443 www 3848: if ($error) {
3849: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
3850: }
3851: if ($hadchanges) {
3852: &mark_hash_old();
3853: }
1.341 ehlerst 3854:
1.443 www 3855: &changewarning($r,'');
3856: }
1.458 raeburn 3857: }
1.442 www 3858:
1.443 www 3859: # Supplemental documents start here
3860:
1.329 droeschl 3861: my $folder=$env{'form.folder'};
1.443 www 3862: unless ($supplementalflag) {
1.329 droeschl 3863: $folder='supplemental';
3864: }
3865: if ($folder =~ /^supplemental$/ &&
3866: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
1.446 www 3867: $env{'form.folderpath'} = &supplemental_base();
1.393 raeburn 3868: } elsif ($allowed) {
1.356 tempelho 3869: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 3870: }
1.362 ehlerst 3871: $env{'form.pagepath'} = '';
1.329 droeschl 3872: if ($allowed) {
3873: my $folderseq=
3874: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
3875: '.sequence';
3876:
3877: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3878:
1.400 droeschl 3879: my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}";
1.329 droeschl 3880: my $supupdocform=(<<SUPDOCFORM);
1.383 tempelho 3881: <form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
1.371 tempelho 3882: <input type="hidden" name="active" value="ee" />
1.329 droeschl 3883: $fileupload
3884: <br />
3885: <br />
3886: <span class="LC_nobreak">
3887: $checkbox
3888: </span>
3889: <br /><br />
3890: $lt{'comment'}:<br />
1.383 tempelho 3891: <textarea cols="50" rows="4" name="comment"></textarea>
1.329 droeschl 3892: <br />
3893: <input type="hidden" name="folderpath" value="$path" />
3894: <input type="hidden" name="cmd" value="upload_supplemental" />
3895: SUPDOCFORM
1.443 www 3896: $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>";
1.329 droeschl 3897:
3898: my $supnewfolderform=(<<SNFFORM);
3899: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.371 tempelho 3900: <input type="hidden" name="active" value="ee" />
1.329 droeschl 3901: <input type="hidden" name="folderpath" value="$path" />
3902: <input type="hidden" name="importdetail" value="" />
1.423 onken 3903: <a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a>
1.383 tempelho 3904: $help{'Adding_Folders'}
1.329 droeschl 3905: </form>
3906: SNFFORM
1.383 tempelho 3907:
1.329 droeschl 3908:
3909: my $supnewextform=(<<SNEFORM);
3910: <form action="/adm/coursedocs" method="post" name="supnewext">
1.371 tempelho 3911: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3912: <input type="hidden" name="folderpath" value="$path" />
3913: <input type="hidden" name="importdetail" value="" />
1.423 onken 3914: <a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'}
1.329 droeschl 3915: </form>
3916: SNEFORM
3917:
3918: my $supnewsylform=(<<SNSFORM);
3919: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 tempelho 3920: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3921: <input type="hidden" name="folderpath" value="$path" />
3922: <input type="hidden" name="importdetail"
3923: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
1.423 onken 3924: <a class="LC_menubuttons_link" href="javascript:document.supnewsyl.submit()">$lt{'syll'}</a>
1.329 droeschl 3925: $help{'Syllabus'}
3926: </form>
3927: SNSFORM
3928:
3929: my $supnewaboutmeform=(<<SNAMFORM);
1.383 tempelho 3930: <form action="/adm/coursedocs" method="post" name="supnewaboutme">
1.371 tempelho 3931: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3932: <input type="hidden" name="folderpath" value="$path" />
3933: <input type="hidden" name="importdetail"
3934: value="$plainname=/adm/$udom/$uname/aboutme" />
1.423 onken 3935: <a class="LC_menubuttons_link" href="javascript:document.supnewaboutme.submit()">$lt{'mypi'}</a>
1.347 weissno 3936: $help{'My Personal Information Page'}
1.329 droeschl 3937: </form>
3938: SNAMFORM
3939:
1.333 muellerd 3940:
1.383 tempelho 3941: my @specialdocs = (
1.417 droeschl 3942: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
3943: =>$supnewsylform},
3944: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
3945: =>$supnewaboutmeform},
1.383 tempelho 3946: );
1.417 droeschl 3947: my @supimportdoc = (
3948: {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'
3949: =>$supnewextform},
3950: );
1.459 raeburn 3951: $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 3952: my %suporderhash = (
1.390 tempelho 3953: '00' => ['Supnewfolder', $supnewfolderform],
1.488 raeburn 3954: 'ee' => ['Import Content',$supupdocform],
1.443 www 3955: 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
1.333 muellerd 3956: );
1.443 www 3957: if ($supplementalflag) {
1.458 raeburn 3958: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472 raeburn 3959: $supplementalflag,\%suporderhash,$iconpath);
1.443 www 3960: if ($error) {
3961: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
3962: }
1.393 raeburn 3963: }
1.443 www 3964: } elsif ($supplementalflag) {
1.458 raeburn 3965: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
1.472 raeburn 3966: $supplementalflag,'',$iconpath);
1.393 raeburn 3967: if ($error) {
3968: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
1.383 tempelho 3969: }
1.393 raeburn 3970: }
1.389 tempelho 3971:
1.484 raeburn 3972: $r->print(&endContentScreen());
1.383 tempelho 3973:
1.329 droeschl 3974: if ($allowed) {
3975: $r->print('
3976: <form method="post" name="extimport" action="/adm/coursedocs">
3977: <input type="hidden" name="title" />
3978: <input type="hidden" name="url" />
3979: <input type="hidden" name="useform" />
3980: <input type="hidden" name="residx" />
3981: </form>');
3982: }
1.484 raeburn 3983: } elsif ($showdoc) {
1.329 droeschl 3984: # -------------------------------------------------------- This is showdoc mode
1.484 raeburn 3985: $r->print("<h1>".&mt('Uploaded Document').' - '.
1.498 ! bisitz 3986: &Apache::lonnet::gettitle($r->uri).'</h1><p class="LC_warning">'.
1.329 droeschl 3987: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
1.484 raeburn 3988: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
1.329 droeschl 3989: }
3990: }
3991: $r->print(&Apache::loncommon::end_page());
3992: return OK;
1.364 bisitz 3993: }
1.329 droeschl 3994:
1.440 raeburn 3995: sub embedded_form_elems {
3996: my ($phase,$primaryurl,$newidx) = @_;
3997: my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3998: return <<STATE;
3999: <input type="hidden" name="folderpath" value="$folderpath" />
4000: <input type="hidden" name="cmd" value="upload_embedded" />
4001: <input type="hidden" name="newidx" value="$newidx" />
4002: <input type="hidden" name="phase" value="$phase" />
4003: <input type="hidden" name="primaryurl" value="$primaryurl" />
4004: STATE
4005: }
4006:
4007: sub embedded_destination {
4008: my $folder=$env{'form.folder'};
4009: my $destination = 'docs/';
4010: if ($folder =~ /^supplemental/) {
4011: $destination = 'supplemental/';
4012: }
4013: if (($folder eq 'default') || ($folder eq 'supplemental')) {
4014: $destination .= 'default/';
4015: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
4016: $destination .= $2.'/';
4017: }
4018: $destination .= $env{'form.newidx'};
4019: my $dir_root = '/userfiles';
4020: return ($destination,$dir_root);
4021: }
4022:
4023: sub return_to_editor {
4024: my $actionurl = '/adm/coursedocs';
4025: return '<p><form name="backtoeditor" method="post" action="'.$actionurl.'" />'."\n".
4026: '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" /></form>'."\n".
4027: '<a href="javascript:document.backtoeditor.submit();">'.&mt('Return to Editor').
4028: '</a></p>';
4029: }
4030:
1.476 raeburn 4031: sub decompression_info {
4032: my ($destination,$dir_root) = &embedded_destination();
4033: my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
4034: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
4035: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
4036: my $container='sequence';
1.480 raeburn 4037: my ($pathitem,$hiddenelem);
4038: my @hiddens = ('newidx','comment','position');
1.476 raeburn 4039: if ($env{'form.pagepath'}) {
4040: $container='page';
1.480 raeburn 4041: $pathitem = 'pagepath';
1.476 raeburn 4042: } else {
1.480 raeburn 4043: $pathitem = 'folderpath';
1.476 raeburn 4044: }
1.480 raeburn 4045: unshift(@hiddens,$pathitem);
4046: foreach my $item (@hiddens) {
4047: if ($env{'form.'.$item}) {
4048: $hiddenelem .= '<input type="hidden" name="'.$item.'" value="'.
4049: $env{'form.'.$item}.'" />'."\n";
4050: }
1.477 raeburn 4051: }
1.476 raeburn 4052: return ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,
4053: $hiddenelem);
4054: }
4055:
4056: sub decompression_phase_one {
4057: my ($dir,$file,$warning,$error,$output);
4058: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4059: &decompression_info();
1.490 raeburn 4060: if ($env{'form.archiveurl'} !~ m{^/uploaded/\Q$docudom/$docuname/\E(?:docs|supplemental)/(?:default|\d+).*/([^/]+)$}) {
1.476 raeburn 4061: $error = &mt('Archive file "[_1]" not in the expected location.',$env{'form.archiveurl'});
4062: } else {
4063: my $file = $1;
1.481 raeburn 4064: $output =
4065: &Apache::loncommon::process_decompression($docudom,$docuname,$file,
4066: $destination,$dir_root,
4067: $hiddenelem);
4068: if ($env{'form.autoextract_camtasia'}) {
4069: $output .= &remove_archive($docudom,$docuname,$container);
4070: }
1.476 raeburn 4071: }
4072: if ($error) {
4073: $output .= '<p class="LC_error">'.&mt('Not extracted.').'<br />'.
4074: $error.'</p>'."\n";
4075: }
4076: if ($warning) {
4077: $output .= '<p class="LC_warning">'.$warning.'</p>'."\n";
4078: }
4079: return $output;
4080: }
4081:
4082: sub decompression_phase_two {
4083: my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)=
4084: &decompression_info();
1.481 raeburn 4085: my $output;
1.480 raeburn 4086: if ($env{'form.archivedelete'}) {
1.481 raeburn 4087: $output = &remove_archive($docudom,$docuname,$container);
1.480 raeburn 4088: }
4089: $output .=
1.481 raeburn 4090: &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname,
1.476 raeburn 4091: $destination,$dir_root,$hiddenelem);
4092: return $output;
4093: }
4094:
1.480 raeburn 4095: sub remove_archive {
4096: my ($docudom,$docuname,$container) = @_;
4097: my $map = $env{'form.folder'}.'.'.$container;
1.481 raeburn 4098: my ($output,$delwarning,$delresult,$url);
1.480 raeburn 4099: my ($errtext,$fatal) = &mapread($docuname,$docudom,$map);
4100: if ($fatal) {
4101: if ($container eq 'page') {
4102: $delwarning = &mt('An error occurred retrieving the contents of the current page.');
4103: } else {
4104: $delwarning = &mt('An error occurred retrieving the contents of the current folder.');
4105: }
4106: $delwarning .= &mt('As a result the archive file has not been removed.');
4107: } else {
4108: my $currcmd = $env{'form.cmd'};
4109: my $position = $env{'form.position'};
4110: if ($position > 0) {
4111: $env{'form.cmd'} = 'del_'.$position;
4112: my ($title,$url,@rrest) =
4113: split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]);
4114: if (&handle_edit_cmd($docuname,$docudom)) {
1.492 raeburn 4115: ($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
1.480 raeburn 4116: if ($fatal) {
4117: if ($container eq 'page') {
4118: $delwarning = &mt('An error occurred updating the contents of the current page.');
4119: } else {
4120: $delwarning = &mt('An error occurred updating the contents of the current folder.');
4121: }
4122: } else {
1.481 raeburn 4123: $delresult = &mt('Archive file removed.');
1.480 raeburn 4124: }
4125: }
4126: }
4127: $env{'form.cmd'} = $currcmd;
4128: }
4129: if ($delwarning) {
4130: $output = '<p class="LC_warning">'.
4131: $delwarning.
4132: '</p>';
4133: }
4134: if ($delresult) {
4135: $output .= '<p class="LC_info">'.
4136: $delresult.
4137: '</p>';
4138: }
1.481 raeburn 4139: return $output;
1.480 raeburn 4140: }
4141:
1.484 raeburn 4142: sub generate_admin_menu {
4143: my ($crstype) = @_;
4144: my $lc_crstype = lc($crstype);
4145: my ($home,$other,%outhash)=&authorhosts();
4146: my %lt=&Apache::lonlocal::texthash (
4147: 'vc' => 'Verify Content',
4148: 'cv' => 'Check/Set Resource Versions',
4149: 'ls' => 'List Resource Identifiers',
4150: 'imse' => 'Export contents to IMS Archive',
4151: 'dcd' => "Dump $crstype Content to Authoring Space",
4152: );
4153: my ($candump,$dumpurl);
4154: if ($home + $other > 0) {
4155: $candump = 'F';
4156: if ($home) {
4157: $dumpurl = "javascript:injectData(document.courseverify,'dummy','dumpcourse','$lt{'dcd'}')";
4158: } else {
4159: my @hosts;
4160: foreach my $aurole (keys(%outhash)) {
4161: unless(grep(/^\Q$outhash{$aurole}\E/,@hosts)) {
4162: push(@hosts,$outhash{$aurole});
4163: }
4164: }
4165: if (@hosts == 1) {
4166: my $switchto = '/adm/switchserver?otherserver='.$hosts[0].
4167: '&role='.
4168: &HTML::Entities::encode($env{'request.role'},'"<>&').'&origurl='.
4169: &HTML::Entities::encode('/adm/coursedocs?dumpcourse=1','"<>&');
4170: $dumpurl = "javascript:dump_needs_switchserver('$switchto')";
4171: } else {
4172: $dumpurl = "javascript:choose_switchserver_window()";
4173: }
4174: }
4175: }
4176: my @menu=
4177: ({ categorytitle=>'Administration',
4178: items =>[
4179: { linktext => $lt{'vc'},
4180: url => "javascript:injectData(document.courseverify,'dummy','verify','$lt{'vc'}')",
4181: permission => 'F',
4182: help => 'Verify_Content',
4183: icon => 'verify.png',
4184: linktitle => 'Verify contents can be retrieved/rendered',
4185: },
4186: { linktext => $lt{'cv'},
4187: url => "javascript:injectData(document.courseverify,'dummy','versions','$lt{'cv'}')",
4188: permission => 'F',
4189: help => 'Check_Resource_Versions',
4190: icon => 'resversion.png',
4191: linktitle => "View version information for resources in your $lc_crstype, and fix/unfix use of specific versions",
4192: },
4193: { linktext => $lt{'ls'},
4194: url => "javascript:injectData(document.courseverify,'dummy','listsymbs','$lt{'ls'}')",
4195: permission => 'F',
4196: #help => '',
4197: icon => 'symbs.png',
4198: linktitle => "List the unique identifier used for each resource instance in your $lc_crstype"
4199: },
4200: ]
4201: },
4202: { categorytitle=>'Export',
4203: items =>[
4204: { linktext => $lt{'imse'},
4205: url => "javascript:injectData(document.courseverify,'dummy','exportcourse','$lt{'imse'}')",
4206: permission => 'F',
4207: help => 'Docs_Export_Course_Docs',
4208: icon => 'imsexport.png',
4209: linktitle => $lt{'imse'},
4210: },
4211: { linktext => $lt{'dcd'},
4212: url => $dumpurl,
4213: permission => $candump,
4214: #help => '',
4215: icon => 'dump.png',
4216: linktitle => $lt{'dcd'},
4217: },
4218: ]
4219: });
4220: return '<form action="/adm/coursedocs" method="post" name="courseverify">'."\n".
4221: '<input type="hidden" id="dummy" />'."\n".
4222: &Apache::lonhtmlcommon::generate_menu(@menu)."\n".
4223: '</form>';
1.329 droeschl 4224: }
4225:
4226: sub generate_edit_table {
1.484 raeburn 4227: my ($tid,$orderhash_ref,$to_show,$iconpath,$jumpto,$readfile) = @_;
1.406 raeburn 4228: return unless(ref($orderhash_ref) eq 'HASH');
1.342 ehlerst 4229: my %orderhash = %{$orderhash_ref};
1.344 bisitz 4230: my $form;
1.371 tempelho 4231: my $activetab;
4232: my $active;
4233: if($env{'form.active'} ne ''){
4234: $activetab = $env{'form.active'};
4235: }
1.472 raeburn 4236: my $backicon = $iconpath.'clickhere.gif';
1.481 raeburn 4237: my $backtext = &mt('To Overview');
1.458 raeburn 4238: $form = '<div class="LC_Box" style="margin:0;">'.
1.488 raeburn 4239: '<ul id="navigation'.$tid.'" class="LC_TabContent">'."\n".
4240: '<li class="goback">'.
4241: '<a href="javascript:toContents('."'$jumpto'".');">'.
4242: '<img src="'.$backicon.'" class="LC_icon" style="border: none; vertical-align: top;"'.
4243: ' alt="'.$backtext.'" />'.$backtext.'</a></li>'."\n".
4244: '<li>'.
4245: '<a href="javascript:groupopen('."'$readfile'".',1);">'.
4246: &mt('Undo Delete').'</a></li>'."\n";
4247: if ($env{'form.docslog'}) {
4248: $form .= '<li class="active">';
4249: } else {
4250: $form .= '<li>';
4251: }
4252: $form .= '<a href="javascript:toggleHistoryDisp(1);">'.
4253: &mt('History').'</a></li>'."\n";
4254: if ($env{'form.docslog'}) {
4255: $form .= '<li><a href="javascript:toggleHistoryDisp(0);">'.
4256: &mt('Edit').'</a></li>'."\n";
1.484 raeburn 4257: }
1.458 raeburn 4258: foreach my $name (reverse(sort(keys(%orderhash)))) {
1.390 tempelho 4259: if($name ne '00'){
1.371 tempelho 4260: if($activetab eq '' || $activetab ne $name){
4261: $active = '';
4262: }elsif($activetab eq $name){
4263: $active = 'class="active"';
4264: }
1.458 raeburn 4265: $form .= '<li style="float:right" '.$active
1.429 droeschl 4266: .' onmouseover="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"'
1.484 raeburn 4267: .' 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 4268: } else {
1.484 raeburn 4269: $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
1.390 tempelho 4270:
4271: }
1.329 droeschl 4272: }
1.484 raeburn 4273: $form .= '</ul>'."\n";
4274: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0; overflow: hidden; clear:right">'."\n";
1.458 raeburn 4275:
4276: if ($to_show ne '') {
1.484 raeburn 4277: $form .= '<div style="padding:0;margin:0;float:left">'.$to_show.'</div>'."\n";
1.458 raeburn 4278: }
1.363 ehlerst 4279: foreach my $field (keys(%orderhash)){
1.390 tempelho 4280: if($field ne '00'){
1.422 onken 4281: if($activetab eq '' || $activetab ne $field){
1.458 raeburn 4282: $active = 'style="display: none;float:left"';
1.422 onken 4283: }elsif($activetab eq $field){
1.458 raeburn 4284: $active = 'style="display:block;float:left"';
1.422 onken 4285: }
4286: $form .= '<div id="'.$field.$tid.'"'
4287: .' class="LC_ContentBox" '.$active.'>'.${$orderhash{$field}}[1]
1.484 raeburn 4288: .'</div>'."\n";
1.363 ehlerst 4289: }
4290: }
1.484 raeburn 4291: unless ($env{'form.docslog'}) {
4292: $form .= '</div></div>'."\n";
4293: }
1.329 droeschl 4294: return $form;
4295: }
4296:
4297: sub editing_js {
1.472 raeburn 4298: my ($udom,$uname,$supplementalflag) = @_;
1.329 droeschl 4299: my $now = time();
4300: my %lt = &Apache::lonlocal::texthash(
4301: p_mnf => 'Name of New Folder',
4302: t_mnf => 'New Folder',
4303: p_mnp => 'Name of New Page',
4304: t_mnp => 'New Page',
1.451 www 4305: p_mxu => 'Title for the External Score',
1.349 biermanm 4306: p_msp => 'Name of Simple Course Page',
1.329 droeschl 4307: p_msb => 'Title for the Problem',
4308: p_mdb => 'Title for the Drop Box',
1.336 schafran 4309: p_mbb => 'Title for the Discussion Board',
1.348 weissno 4310: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 4311: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 4312: p_mab_alrt1 => 'Not a valid user:domain',
4313: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
4314: p_chn => 'New Title',
4315: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
4316: p_rmr2a => 'Remove[_99]',
4317: p_rmr2b => '?[_99]',
4318: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
4319: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
4320: p_ctr2a => 'Cut[_98]',
1.478 raeburn 4321: p_ctr2b => '?[_98]',
4322: rpck => 'Enter number to pick (e.g., 3)',
1.329 droeschl 4323: );
4324:
1.433 raeburn 4325: my $crstype = &Apache::loncommon::course_type();
1.434 raeburn 4326: my $docs_folderpath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.folderpath'},'<>&"');
4327: my $docs_pagepath = &HTML::Entities::encode($env{'environment.internal.'.$env{'request.course.id'}.'.docs_folderpath.pagepath'},'<>&"');
4328: my $main_container_page;
4329: if ($docs_folderpath eq '') {
4330: if ($docs_pagepath ne '') {
4331: $main_container_page = 1;
4332: }
4333: }
1.433 raeburn 4334: my $toplevelmain = 'default&Main%20'.$crstype.'%20Documents';
1.446 www 4335: my $toplevelsupp = &supplemental_base();
1.433 raeburn 4336:
1.472 raeburn 4337: my $backtourl = '/adm/navmaps';
4338: if ($supplementalflag) {
4339: $backtourl = '/adm/supplemental';
4340: }
4341:
1.329 droeschl 4342: return <<ENDNEWSCRIPT;
4343: function makenewfolder(targetform,folderseq) {
4344: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
4345: if (foldername) {
4346: targetform.importdetail.value=escape(foldername)+"="+folderseq;
4347: targetform.submit();
4348: }
4349: }
4350:
4351: function makenewpage(targetform,folderseq) {
4352: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
4353: if (pagename) {
4354: targetform.importdetail.value=escape(pagename)+"="+folderseq;
4355: targetform.submit();
4356: }
4357: }
4358:
4359: function makenewext(targetname) {
4360: this.document.forms.extimport.useform.value=targetname;
4361: this.document.forms.extimport.title.value='';
4362: this.document.forms.extimport.url.value='';
4363: this.document.forms.extimport.residx.value='';
4364: window.open('/adm/rat/extpickframe.html');
4365: }
4366:
4367: function edittext(targetname,residx,title,url) {
4368: this.document.forms.extimport.useform.value=targetname;
4369: this.document.forms.extimport.residx.value=residx;
4370: this.document.forms.extimport.url.value=url;
4371: this.document.forms.extimport.title.value=title;
4372: window.open('/adm/rat/extpickframe.html');
4373: }
4374:
4375: function makeexamupload() {
4376: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 4377: if (title) {
1.329 droeschl 4378: this.document.forms.newexamupload.importdetail.value=
4379: escape(title)+'=/res/lib/templates/examupload.problem';
4380: this.document.forms.newexamupload.submit();
4381: }
4382: }
4383:
4384: function makesmppage() {
4385: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 4386: if (title) {
1.329 droeschl 4387: this.document.forms.newsmppg.importdetail.value=
4388: escape(title)+'=/adm/$udom/$uname/$now/smppg';
4389: this.document.forms.newsmppg.submit();
4390: }
4391: }
4392:
4393: function makesmpproblem() {
4394: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 4395: if (title) {
1.329 droeschl 4396: this.document.forms.newsmpproblem.importdetail.value=
4397: escape(title)+'=/res/lib/templates/simpleproblem.problem';
4398: this.document.forms.newsmpproblem.submit();
4399: }
4400: }
4401:
4402: function makedropbox() {
4403: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 4404: if (title) {
1.329 droeschl 4405: this.document.forms.newdropbox.importdetail.value=
4406: escape(title)+'=/res/lib/templates/DropBox.problem';
4407: this.document.forms.newdropbox.submit();
4408: }
4409: }
4410:
4411: function makebulboard() {
4412: var title=prompt('$lt{"p_mbb"}');
4413: if (title) {
4414: this.document.forms.newbul.importdetail.value=
4415: escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
4416: this.document.forms.newbul.submit();
4417: }
4418: }
4419:
4420: function makeabout() {
4421: var user=prompt("$lt{'p_mab'}");
4422: if (user) {
4423: var comp=new Array();
4424: comp=user.split(':');
4425: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
4426: if ((comp[0]) && (comp[1])) {
4427: this.document.forms.newaboutsomeone.importdetail.value=
4428: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 4429: this.document.forms.newaboutsomeone.submit();
4430: } else {
4431: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 4432: }
1.335 ehlerst 4433: } else {
4434: alert("$lt{'p_mab_alrt2'}");
4435: }
4436: }
1.329 droeschl 4437: }
4438:
4439: function makeims() {
1.335 ehlerst 4440: var caller = document.forms.ims.folder.value;
4441: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
4442: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
4443: newWindow.location.href = newlocation;
1.329 droeschl 4444: }
4445:
4446: function finishpick() {
1.335 ehlerst 4447: var title=this.document.forms.extimport.title.value;
4448: var url=this.document.forms.extimport.url.value;
4449: var form=this.document.forms.extimport.useform.value;
4450: var residx=this.document.forms.extimport.residx.value;
4451: eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
1.329 droeschl 4452: }
4453:
4454: function changename(folderpath,index,oldtitle,container,pagesymb) {
1.335 ehlerst 4455: var title=prompt('$lt{"p_chn"}',oldtitle);
4456: if (title) {
4457: this.document.forms.renameform.markcopy.value=-1;
4458: this.document.forms.renameform.title.value=title;
4459: this.document.forms.renameform.cmd.value='rename_'+index;
4460: if (container == 'sequence') {
4461: this.document.forms.renameform.folderpath.value=folderpath;
4462: }
4463: if (container == 'page') {
4464: this.document.forms.renameform.pagepath.value=folderpath;
4465: this.document.forms.renameform.pagesymb.value=pagesymb;
4466: }
4467: this.document.forms.renameform.submit();
4468: }
1.329 droeschl 4469: }
4470:
4471: function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
1.335 ehlerst 4472: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
4473: this.document.forms.renameform.markcopy.value=-1;
4474: this.document.forms.renameform.cmd.value='del_'+index;
4475: if (container == 'sequence') {
4476: this.document.forms.renameform.folderpath.value=folderpath;
4477: }
4478: if (container == 'page') {
4479: this.document.forms.renameform.pagepath.value=folderpath;
4480: this.document.forms.renameform.pagesymb.value=pagesymb;
4481: }
4482: this.document.forms.renameform.submit();
4483: }
1.329 droeschl 4484: }
4485:
4486: function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
1.335 ehlerst 4487: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
4488: this.document.forms.renameform.cmd.value='cut_'+index;
4489: this.document.forms.renameform.markcopy.value=index;
4490: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
4491: if (container == 'sequence') {
4492: this.document.forms.renameform.folderpath.value=folderpath;
4493: }
4494: if (container == 'page') {
4495: this.document.forms.renameform.pagepath.value=folderpath;
4496: this.document.forms.renameform.pagesymb.value=pagesymb;
4497: }
4498: this.document.forms.renameform.submit();
4499: }
1.329 droeschl 4500: }
4501:
4502: function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
1.335 ehlerst 4503: this.document.forms.renameform.markcopy.value=index;
4504: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
4505: if (container == 'sequence') {
4506: this.document.forms.renameform.folderpath.value=folderpath;
4507: }
4508: if (container == 'page') {
4509: this.document.forms.renameform.pagepath.value=folderpath;
4510: this.document.forms.renameform.pagesymb.value=pagesymb;
4511: }
4512: this.document.forms.renameform.submit();
1.329 droeschl 4513: }
4514:
1.478 raeburn 4515: function updatePick(targetform,index,caller) {
4516: var pickitem = document.getElementById('rpick_'+index);
4517: var picknumitem = document.getElementById('rpicknum_'+index);
4518: if (pickitem.checked) {
4519: var picknum=prompt('$lt{"rpck"}',picknumitem.value);
4520: if (picknum == '' || picknum == null) {
4521: if (caller == 'check') {
4522: pickitem.checked=false;
4523: return;
4524: }
4525: } else {
4526: picknum.toString();
4527: var regexdigit=/^\\d+\$/;
4528: if (regexdigit.test(picknum)) {
4529: picknumitem.value = picknum;
4530: targetform.changeparms.value='randompick';
4531: targetform.submit();
4532: } else {
4533: if (caller == 'check') {
4534: pickitem.checked=false;
4535: }
4536: return;
4537: }
4538: }
4539: } else {
4540: picknumitem.value = 0;
4541: targetform.changeparms.value='randompick';
4542: targetform.submit();
4543: }
4544: }
4545:
1.334 muellerd 4546: function unselectInactive(nav) {
1.335 ehlerst 4547: currentNav = document.getElementById(nav);
4548: currentLis = currentNav.getElementsByTagName('LI');
4549: for (i = 0; i < currentLis.length; i++) {
1.472 raeburn 4550: if (currentLis[i].className == 'goback') {
4551: currentLis[i].className = 'goback';
4552: } else {
4553: if (currentLis[i].className == 'right active' || currentLis[i].className == 'right') {
1.374 tempelho 4554: currentLis[i].className = 'right';
1.472 raeburn 4555: } else {
1.374 tempelho 4556: currentLis[i].className = 'i';
1.472 raeburn 4557: }
4558: }
1.335 ehlerst 4559: }
1.332 tempelho 4560: }
4561:
1.334 muellerd 4562: function hideAll(current, nav, data) {
1.335 ehlerst 4563: unselectInactive(nav);
1.374 tempelho 4564: if(current.className == 'right'){
4565: current.className = 'right active'
4566: }else{
4567: current.className = 'active';
4568: }
1.335 ehlerst 4569: currentData = document.getElementById(data);
4570: currentDivs = currentData.getElementsByTagName('DIV');
4571: for (i = 0; i < currentDivs.length; i++) {
4572: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 4573: currentDivs[i].style.display = 'none';
1.330 tempelho 4574: }
4575: }
1.335 ehlerst 4576: }
1.330 tempelho 4577:
1.374 tempelho 4578: function openTabs(pageId) {
4579: tabnav = document.getElementById(pageId).getElementsByTagName('UL');
1.383 tempelho 4580: if(tabnav.length > 2 ){
1.389 tempelho 4581: currentNav = document.getElementById(tabnav[1].id);
1.374 tempelho 4582: currentLis = currentNav.getElementsByTagName('LI');
4583: for(i = 0; i< currentLis.length; i++){
4584: if(currentLis[i].className == 'active') {
1.375 tempelho 4585: funcString = currentLis[i].onclick.toString();
4586: tab = funcString.split('"');
1.420 onken 4587: if(tab.length < 2) {
4588: tab = funcString.split("'");
4589: }
1.375 tempelho 4590: currentData = document.getElementById(tab[1]);
4591: currentData.style.display = 'block';
1.374 tempelho 4592: }
4593: }
4594: }
4595: }
4596:
1.334 muellerd 4597: function showPage(current, pageId, nav, data) {
4598: hideAll(current, nav, data);
1.375 tempelho 4599: openTabs(pageId);
1.334 muellerd 4600: unselectInactive(nav);
1.330 tempelho 4601: current.className = 'active';
4602: currentData = document.getElementById(pageId);
4603: currentData.style.display = 'block';
1.458 raeburn 4604: activeTab = pageId;
1.433 raeburn 4605: if (nav == 'mainnav') {
4606: var storedpath = "$docs_folderpath";
4607: if (storedpath == '') {
4608: storedpath = "$docs_pagepath";
4609: }
1.434 raeburn 4610: var storedpage = "$main_container_page";
1.433 raeburn 4611: var reg = new RegExp("^supplemental");
4612: if (pageId == 'mainCourseDocuments') {
1.434 raeburn 4613: if (storedpage == 1) {
4614: document.simpleedit.folderpath.value = '';
4615: document.uploaddocument.folderpath.value = '';
4616: } else {
4617: if (reg.test(storedpath)) {
4618: document.simpleedit.folderpath.value = '$toplevelmain';
4619: document.uploaddocument.folderpath.value = '$toplevelmain';
4620: document.newext.folderpath.value = '$toplevelmain';
4621: } else {
4622: document.simpleedit.folderpath.value = storedpath;
4623: document.uploaddocument.folderpath.value = storedpath;
4624: document.newext.folderpath.value = storedpath;
4625: }
1.433 raeburn 4626: }
4627: } else {
1.434 raeburn 4628: if (reg.test(storedpath)) {
4629: document.simpleedit.folderpath.value = storedpath;
4630: document.supuploaddocument.folderpath.value = storedpath;
4631: document.supnewext.folderpath.value = storedpath;
4632: } else {
1.433 raeburn 4633: document.simpleedit.folderpath.value = '$toplevelsupp';
4634: document.supuploaddocument.folderpath.value = '$toplevelsupp';
4635: document.supnewext.folderpath.value = '$toplevelsupp';
4636: }
4637: }
4638: }
1.485 raeburn 4639: resize_scrollbox('contentscroll','1','0');
1.330 tempelho 4640: return false;
4641: }
1.329 droeschl 4642:
1.472 raeburn 4643: function toContents(jumpto) {
4644: var newurl = '$backtourl';
4645: if (jumpto != '') {
4646: newurl = newurl+'?postdata='+jumpto;
4647: ;
4648: }
4649: location.href=newurl;
4650: }
4651:
1.329 droeschl 4652: ENDNEWSCRIPT
4653: }
1.457 raeburn 4654:
1.483 raeburn 4655: sub history_tab_js {
4656: return <<"ENDHIST";
4657: function toggleHistoryDisp(choice) {
4658: document.docslogform.docslog.value = choice;
4659: document.docslogform.submit();
4660: return;
4661: }
4662:
4663: ENDHIST
4664: }
4665:
1.484 raeburn 4666: sub inject_data_js {
4667: return <<ENDINJECT;
4668:
4669: function injectData(current, hiddenField, name, value) {
4670: currentElement = document.getElementById(hiddenField);
4671: currentElement.name = name;
4672: currentElement.value = value;
4673: current.submit();
4674: }
4675:
4676: ENDINJECT
4677: }
4678:
4679: sub dump_switchserver_js {
4680: my @hosts = @_;
4681: my %lt = &Apache::lonlocal::texthash(
4682: dump => 'Dumping to Authoring Space requires switching server.',
4683: swit => 'Switch server?',
4684: duco => 'Dump content to Authoring Space',
4685: yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
4686: chos => 'Choose server',
4687: );
4688: my $role = $env{'request.role'};
4689: my $js = <<"ENDSWJS";
4690: <script type="text/javascript">
4691: function write_switchserver() {
4692: var server;
4693: if (document.setserver.posshosts.length > 0) {
4694: for (var i=0; i<document.setserver.posshosts.length; i++) {
4695: if (document.setserver.posshosts[i].checked) {
4696: server = document.setserver.posshosts[i].value;
4697: }
4698: }
4699: opener.document.location.href="/adm/switchserver?otherserver="+server+"&role=$role&origurl=/adm/coursedocs";
4700: }
4701: window.close();
4702: }
4703: </script>
4704:
4705: ENDSWJS
4706:
4707: my $startpage = &Apache::loncommon::start_page('Choose server',$js,
4708: {'only_body' => 1,
4709: 'js_ready' => 1,});
4710: my $endpage = &Apache::loncommon::end_page({'js_ready' => 1});
4711:
4712: my $hostpicker;
4713: my $count = 0;
4714: foreach my $host (sort(@hosts)) {
4715: my $checked;
4716: if ($count == 0) {
4717: $checked = ' checked="checked"';
4718: }
4719: $hostpicker .= '<label><input type="radio" name="posshosts" value="'.
4720: $host.'"'.$checked.' />'.$host.'</label> ';
4721: $count++;
4722: }
4723:
4724: return <<"ENDSWITCHJS";
4725:
4726: function dump_needs_switchserver(url) {
4727: if (url!='' && url!= null) {
4728: if (confirm("$lt{'dump'}\\n$lt{'swit'}")) {
4729: go(url);
4730: }
4731: }
4732: return;
4733: }
4734:
4735: function choose_switchserver_window() {
4736: newWindow = window.open('','ChooseServer','height=400,width=500,scrollbars=yes')
4737: newWindow.document.open();
4738: newWindow.document.writeln('$startpage');
4739: newWindow.document.write('<h3>$lt{'duco'}<\\/h3>\\n'+
4740: '<p>$lt{'yone'}<\\/p>\\n'+
4741: '<div class="LC_left_float"><fieldset><legend>$lt{'chos'}<\\/legend>\\n'+
4742: '<form name="setserver" method="post" action="" \\/>\\n'+
4743: '$hostpicker\\n'+
4744: '<br \\/><br \\/>\\n'+
4745: '<input type="button" name="makeswitch" value="$lt{'swit'}" '+
4746: 'onclick="write_switchserver();" \\/>\\n'+
4747: '<\\/form><\\/fieldset><\\/div><br clear="all" \\/>\\n');
4748: newWindow.document.writeln('$endpage');
4749: newWindow.document.close();
4750: newWindow.focus();
4751: }
4752:
4753: ENDSWITCHJS
4754: }
4755:
4756: sub makedocslogform {
4757: my ($formelems,$docslog) = @_;
4758: return <<"LOGSFORM";
4759: <form action="/adm/coursedocs" method="post" name="docslogform">
4760: <input type="hidden" name="docslog" value="$docslog" />
4761: $formelems
4762: </form>
4763: LOGSFORM
4764: }
4765:
4766: sub makesimpleeditform {
4767: my ($formelems) = @_;
4768: return <<"SIMPFORM";
4769: <form name="simpleedit" method="post" action="/adm/coursedocs">
4770: <input type="hidden" name="importdetail" value="" />
4771: $formelems
4772: </form>
4773: SIMPFORM
4774: }
4775:
1.329 droeschl 4776: 1;
4777: __END__
4778:
4779:
4780: =head1 NAME
4781:
4782: Apache::londocs.pm
4783:
4784: =head1 SYNOPSIS
4785:
4786: This is part of the LearningOnline Network with CAPA project
4787: described at http://www.lon-capa.org.
4788:
4789: =head1 SUBROUTINES
4790:
4791: =over
4792:
4793: =item %help=()
4794:
4795: Available help topics
4796:
4797: =item mapread()
4798:
1.344 bisitz 4799: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 4800: @order and @resources, determines status
4801: sets @order - pointer to resources in right order
4802: sets @resources - array with the resources with correct idx
4803:
4804: =item authorhosts()
4805:
4806: Return hash with valid author names
4807:
4808: =item clean()
4809:
4810: =item dumpcourse()
4811:
4812: Actually dump course
4813:
4814: =item group_import()
4815:
4816: Imports the given (name, url) resources into the course
4817: coursenum, coursedom, and folder must precede the list
4818:
4819: =item breadcrumbs()
4820:
4821: =item log_docs()
4822:
4823: =item docs_change_log()
4824:
4825: =item update_paste_buffer()
4826:
4827: =item print_paste_buffer()
4828:
4829: =item do_paste_from_buffer()
4830:
1.492 raeburn 4831: =item get_newmap_url()
4832:
4833: =item dbcopy()
4834:
4835: =item uniqueness_check()
4836:
4837: =item contained_map_check()
4838:
4839: =item reinit_role()
4840:
4841: =item url_paste_fixups()
4842:
4843: =item apply_fixups()
4844:
4845: =item copy_dependencies()
4846:
1.329 droeschl 4847: =item update_parameter()
4848:
4849: =item handle_edit_cmd()
4850:
4851: =item editor()
4852:
4853: =item process_file_upload()
4854:
4855: =item process_secondary_uploads()
4856:
4857: =item is_supplemental_title()
4858:
4859: =item entryline()
4860:
4861: =item tiehash()
4862:
4863: =item untiehash()
4864:
4865: =item checkonthis()
4866:
4867: check on this
4868:
4869: =item verifycontent()
4870:
4871: Verify Content
4872:
4873: =item devalidateversioncache() & checkversions()
4874:
4875: Check Versions
4876:
4877: =item mark_hash_old()
4878:
4879: =item is_hash_old()
4880:
4881: =item changewarning()
4882:
4883: =item init_breadcrumbs()
4884:
4885: Breadcrumbs for special functions
4886:
1.484 raeburn 4887: =item create_list_elements()
4888:
4889: =item create_form_ul()
4890:
4891: =item startContentScreen()
4892:
4893: =item endContentScreen()
4894:
4895: =item supplemental_base()
4896:
4897: =item embedded_form_elems()
4898:
4899: =item embedded_destination()
4900:
4901: =item return_to_editor()
4902:
4903: =item decompression_info()
4904:
4905: =item decompression_phase_one()
4906:
4907: =item decompression_phase_two()
4908:
4909: =item remove_archive()
4910:
4911: =item generate_admin_menu()
4912:
4913: =item generate_edit_table()
4914:
4915: =item editing_js()
4916:
4917: =item history_tab_js()
4918:
4919: =item inject_data_js()
4920:
4921: =item dump_switchserver_js()
4922:
1.485 raeburn 4923: =item resize_scrollbox_js()
1.484 raeburn 4924:
4925: =item makedocslogform()
4926:
1.485 raeburn 4927: =item makesimpleeditform()
4928:
1.329 droeschl 4929: =back
4930:
4931: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>