Annotation of loncom/interface/londocs.pm, revision 1.371
1.329 droeschl 1: # The LearningOnline Network
2: # Documents
3: #
1.371 ! tempelho 4: # $Id: londocs.pm,v 1.370 2009/06/08 18:04:45 bisitz 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:
30:
31: package Apache::londocs;
32:
33: use strict;
34: use Apache::Constants qw(:common :http);
35: use Apache::imsexport;
36: use Apache::lonnet;
37: use Apache::loncommon;
38: use LONCAPA::map();
39: use Apache::lonratedt();
40: use Apache::lonxml;
41: use Apache::lonclonecourse;
42: use Apache::lonnavmaps;
43: use HTML::Entities;
44: use GDBM_File;
45: use Apache::lonlocal;
46: use Cwd;
47: use LONCAPA qw(:DEFAULT :match);
48:
49: my $iconpath;
50:
51: my %hash;
52:
53: my $hashtied;
54: my %alreadyseen=();
55:
56: my $hadchanges;
57:
58:
59: my %help=();
60:
61:
62: sub mapread {
63: my ($coursenum,$coursedom,$map)=@_;
64: return
65: &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
66: $map);
67: }
68:
69: sub storemap {
70: my ($coursenum,$coursedom,$map)=@_;
71: my ($outtext,$errtext)=
72: &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
73: $map,1);
74: if ($errtext) { return ($errtext,2); }
1.364 bisitz 75:
1.329 droeschl 76: $hadchanges=1;
77: return ($errtext,0);
78: }
79:
80:
81:
82: sub authorhosts {
83: my %outhash=();
84: my $home=0;
85: my $other=0;
86: foreach my $key (keys(%env)) {
87: if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
88: my $role=$1;
89: my $realm=$2;
90: my ($start,$end)=split(/\./,$env{$key});
91: if (($start) && ($start>time)) { next; }
92: if (($end) && (time>$end)) { next; }
93: my ($ca,$cd);
94: if ($1 eq 'au') {
95: $ca=$env{'user.name'};
96: $cd=$env{'user.domain'};
97: } else {
98: ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/);
99: }
100: my $allowed=0;
101: my $myhome=&Apache::lonnet::homeserver($ca,$cd);
102: my @ids=&Apache::lonnet::current_machine_ids();
103: foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } }
104: if ($allowed) {
105: $home++;
106: $outhash{'home_'.$ca.'@'.$cd}=1;
107: } else {
108: $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome;
109: $other++;
110: }
111: }
112: }
113: return ($home,$other,%outhash);
114: }
115:
116:
117: sub dumpbutton {
118: my ($home,$other,%outhash)=&authorhosts();
119: my $type = &Apache::loncommon::course_type();
120: if ($home+$other==0) { return ''; }
121: if ($home) {
122: return '<input type="submit" name="dumpcourse" value="'.
123: &mt('Dump '.$type.' DOCS to Construction Space').'" />'.
1.362 ehlerst 124: &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').'<br />';
1.329 droeschl 125: } else {
126: return '<div>'.
127: &mt('Dump '.$type.
128: ' DOCS to Construction Space: available on other servers').
129: '</div>';
130: }
131: }
132:
133: sub clean {
134: my ($title)=@_;
135: $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
1.344 bisitz 136: return $title;
1.329 droeschl 137: }
138:
139:
140:
141: sub dumpcourse {
142: my ($r) = @_;
143: my $type = &Apache::loncommon::course_type();
144: $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
1.369 bisitz 145: '<form name="dumpdoc" action="" method="post">');
1.329 droeschl 146: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space'));
147: my ($home,$other,%outhash)=&authorhosts();
148: unless ($home) { return ''; }
149: my $origcrsid=$env{'request.course.id'};
150: my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
151: if (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
152: # Do the dumping
153: unless ($outhash{'home_'.$env{'form.authorspace'}}) { return ''; }
154: my ($ca,$cd)=split(/\@/,$env{'form.authorspace'});
155: $r->print('<h3>'.&mt('Copying Files').'</h3>');
156: my $title=$env{'form.authorfolder'};
157: $title=&clean($title);
158: my %replacehash=();
159: foreach my $key (keys(%env)) {
160: if ($key=~/^form\.namefor\_(.+)/) {
161: $replacehash{$1}=$env{$key};
162: }
163: }
164: my $crs='/uploaded/'.$env{'request.course.id'}.'/';
165: $crs=~s/\_/\//g;
166: foreach my $item (keys(%replacehash)) {
167: my $newfilename=$title.'/'.$replacehash{$item};
168: $newfilename=~s/\.(\w+)$//;
169: my $ext=$1;
170: $newfilename=&clean($newfilename);
171: $newfilename.='.'.$ext;
172: my @dirs=split(/\//,$newfilename);
173: my $path='/home/'.$ca.'/public_html';
174: my $makepath=$path;
175: my $fail=0;
176: for (my $i=0;$i<$#dirs;$i++) {
177: $makepath.='/'.$dirs[$i];
1.344 bisitz 178: unless (-e $makepath) {
179: unless(mkdir($makepath,0777)) { $fail=1; }
1.329 droeschl 180: }
181: }
182: $r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
183: if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
184: if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
185: print $fh &Apache::lonclonecourse::rewritefile(
186: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
187: (%replacehash,$crs => '')
188: );
189: } else {
190: print $fh
191: &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
192: }
193: $fh->close();
194: } else {
195: $fail=1;
196: }
197: if ($fail) {
198: $r->print('<span class="LC_error">'.&mt('fail').'</span>');
199: } else {
200: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
201: }
202: }
203: } else {
204: # Input form
205: unless ($home==1) {
206: $r->print(
207: '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
208: }
209: foreach my $key (sort(keys(%outhash))) {
210: if ($key=~/^home_(.+)$/) {
211: if ($home==1) {
212: $r->print(
213: '<input type="hidden" name="authorspace" value="'.$1.'" />');
214: } else {
215: $r->print('<option value="'.$1.'">'.$1.' - '.
216: &Apache::loncommon::plainname(split(/\@/,$1)).'</option>');
217: }
218: }
219: }
220: unless ($home==1) {
221: $r->print('</select>');
222: }
223: my $title=$origcrsdata{'description'};
224: $title=~s/[\/\s]+/\_/gs;
225: $title=&clean($title);
226: $r->print('<h3>'.&mt('Folder in Construction Space').'</h3>'
227: .'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
228: &tiehash();
229: $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>'
230: .&Apache::loncommon::start_data_table()
231: .&Apache::loncommon::start_data_table_header_row()
232: .'<th>'.&mt('Internal Filename').'</th>'
233: .'<th>'.&mt('Title').'</th>'
234: .'<th>'.&mt('Save as ...').'</th>'
235: .&Apache::loncommon::end_data_table_header_row());
236: foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
237: $r->print(&Apache::loncommon::start_data_table_row()
238: .'<td>'.$file.'</td>');
239: my ($ext)=($file=~/\.(\w+)$/);
240: my $title=$hash{'title_'.$hash{
241: 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
242: $r->print('<td>'.($title?$title:' ').'</td>');
243: if (!$title) {
244: $title=$file;
245: } else {
246: $title=~s|/|_|g;
247: }
248: $title=~s/\.(\w+)$//;
249: $title=&clean($title);
250: $title.='.'.$ext;
251: $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
252: .&Apache::loncommon::end_data_table_row());
253: }
254: $r->print(&Apache::loncommon::end_data_table());
255: &untiehash();
256: $r->print(
257: '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $type DOCS").'" /></p></form>');
258: }
259: }
260:
261:
262:
263: sub exportbutton {
264: my $type = &Apache::loncommon::course_type();
265: return '<input type="submit" name="exportcourse" value="'.
266: &mt('Export '.$type.' to IMS').'" />'.
1.362 ehlerst 267: &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'<br />';
1.329 droeschl 268: }
269:
270:
271:
272: sub exportcourse {
273: my $r=shift;
274: my $type = &Apache::loncommon::course_type();
275: my %discussiontime = &Apache::lonnet::dump('discussiontimes',
276: $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
277: my $numdisc = keys(%discussiontime);
278: my $navmap = Apache::lonnavmaps::navmap->new();
279: if (!defined($navmap)) {
280: $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package').
281: '<h2>IMS Export Failed</h2>'.
282: '<div class="LC_error">'.
283: &mt('Unable to retrieve information about course contents').
284: '</div><a href="/adm/coursedocs">'.&mt('Return to Course Editor').'</a>');
285: &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
286: return;
287: }
288: my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
289: my $curRes;
290: my $outcome;
291:
292: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
293: ['finishexport']);
294: if ($env{'form.finishexport'}) {
295: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
296: ['archive','discussion']);
297:
298: my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
299: my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
300: if (@exportitems == 0 && @discussions == 0) {
301: $outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created. Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
302: } else {
303: my $now = time;
304: my %symbs;
305: my $manifestok = 0;
306: my $imsresources;
307: my $tempexport;
308: my $copyresult;
309: my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
310: if ($manifestok) {
311: &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest);
312: close($ims_manifest);
313:
314: #Create zip file in prtspool
315: my $imszipfile = '/prtspool/'.
316: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
317: time.'_'.rand(1000000000).'.zip';
318: my $cwd = &Cwd::getcwd();
319: my $imszip = '/home/httpd/'.$imszipfile;
320: chdir $tempexport;
321: open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
322: close(OUTPUT);
323: chdir $cwd;
1.369 bisitz 324: $outcome .= '<p>'
325: .&mt('Download the zip file from [_1]IMS '.lc($type).' archive[_2]'
326: ,'<a href="'.$imszipfile.'">','</a>')
327: .'</p>';
1.329 droeschl 328: if ($copyresult) {
1.369 bisitz 329: $outcome .= '<p class="LC_error">'
330: .&mt('The following errors occurred during export - [_1]'
331: ,$copyresult)
332: .'</p>';
1.329 droeschl 333: }
334: } else {
335: $outcome = '<br />'.&mt('Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.').'<br />';
336: }
337: }
338: $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
339: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
340: $r->print($outcome);
341: $r->print(&Apache::loncommon::end_page());
342: } else {
343: my $display;
1.369 bisitz 344: $display = '<form name="exportdoc" action="" method="post">'."\n";
345: $display .= '<p>'
346: .&mt('Choose which items you wish to export from your '.$type.'.')
347: .'</p>';
348: $display .= '<div class="LC_columnSection"><fieldset>'.
349: '<legend>'.&mt('Content items').'</legend>'.
350: '<input type="button" value="'.&mt('check all').'" '.
1.329 droeschl 351: 'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
1.369 bisitz 352: ' <input type="button" value="'.&mt('uncheck all').'"'.
353: ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset>'.
354: '<fieldset>'.
355: '<legend>'.&mt('Discussion posts').'</legend>'.
356: '<input type="button" value="'.&mt('check all').'"'.
1.329 droeschl 357: ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
1.369 bisitz 358: ' <input type="button" value="'.&mt('uncheck all').'"'.
359: ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" />'.
360: '</fieldset></div>';
1.329 droeschl 361: my $curRes;
362: my $depth = 0;
363: my $count = 0;
364: my $boards = 0;
365: my $startcount = 5;
366: my %parent = ();
367: my %children = ();
368: my $lastcontainer = $startcount;
1.369 bisitz 369: $display .= &Apache::loncommon::start_data_table()
370: .&Apache::loncommon::start_data_table_header_row()
371: .'<th>'.&mt('Export content item?').'</th>'
372: .'<th>';
1.329 droeschl 373: if ($numdisc > 0) {
1.369 bisitz 374: $display .= &mt('Export discussion posts?');
375: } else {
376: $display .= ' ';
1.329 droeschl 377: }
1.369 bisitz 378: $display .= '</th>'
379: .&Apache::loncommon::end_data_table_header_row();
1.329 droeschl 380: while ($curRes = $it->next()) {
381: if (ref($curRes)) {
382: $count ++;
383: }
384: if ($curRes == $it->BEGIN_MAP()) {
385: $depth++;
386: $parent{$depth} = $lastcontainer;
387: }
388: if ($curRes == $it->END_MAP()) {
389: $depth--;
390: $lastcontainer = $parent{$depth};
391: }
392: if (ref($curRes)) {
393: my $symb = $curRes->symb();
394: my $ressymb = $symb;
395: if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
396: unless ($ressymb =~ m|adm/wrapper/adm|) {
397: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
398: }
399: }
1.369 bisitz 400: $display .= &Apache::loncommon::start_data_table_row()
401: .'<td>'."\n"
402: .'<input type="checkbox" name="archive" value="'.$count.'" ';
1.329 droeschl 403: if (($curRes->is_sequence()) || ($curRes->is_page())) {
404: my $checkitem = $count + $boards + $startcount;
1.369 bisitz 405: $display .= 'onclick="javascript:propagateCheck('."'$checkitem'".')"';
1.329 droeschl 406: }
407: $display .= ' />'."\n";
408: for (my $i=0; $i<$depth; $i++) {
1.369 bisitz 409: $display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" alt="" />'
410: .'<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" alt="" />'."\n";
1.329 droeschl 411: }
412: if ($curRes->is_sequence()) {
1.365 bisitz 413: $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" /> '."\n";
1.329 droeschl 414: $lastcontainer = $count + $startcount + $boards;
415: } elsif ($curRes->is_page()) {
1.365 bisitz 416: $display .= '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" /> '."\n";
1.329 droeschl 417: $lastcontainer = $count + $startcount + $boards;
418: }
419: my $currelem = $count+$boards+$startcount;
420: $children{$parent{$depth}} .= $currelem.':';
1.369 bisitz 421: $display .= ' '.$curRes->title().'</td>'."\n";
422:
423: # Existing discussion posts?
1.329 droeschl 424: if ($discussiontime{$ressymb} > 0) {
425: $boards ++;
426: $currelem = $count+$boards+$startcount;
1.369 bisitz 427: $display .= '<td align="right">'
428: .'<input type="checkbox" name="discussion" value="'.$count.'" />'
429: .'</td>'."\n";
1.329 droeschl 430: } else {
1.369 bisitz 431: $display .= '<td> </td>'."\n";
1.329 droeschl 432: }
1.369 bisitz 433: $display .= &Apache::loncommon::end_data_table_row();
1.329 droeschl 434: }
435: }
1.369 bisitz 436: $display .= &Apache::loncommon::end_data_table();
1.329 droeschl 437: my $scripttag = qq|
1.369 bisitz 438: <script type="text/javascript">
439: // <![CDATA[
1.329 droeschl 440: function checkAll(field) {
441: if (field.length > 0) {
442: for (i = 0; i < field.length; i++) {
443: field[i].checked = true ;
444: }
445: } else {
446: field.checked = true
447: }
448: }
1.364 bisitz 449:
1.329 droeschl 450: function uncheckAll(field) {
451: if (field.length > 0) {
452: for (i = 0; i < field.length; i++) {
453: field[i].checked = false ;
454: }
455: } else {
456: field.checked = false ;
457: }
458: }
459:
460: function propagateCheck(item) {
461: if (document.exportdoc.elements[item].checked == true) {
462: containerCheck(item)
463: }
1.364 bisitz 464: }
1.329 droeschl 465:
466: function containerCheck(item) {
467: document.exportdoc.elements[item].checked = true
468: var numitems = $count + $boards + $startcount
469: var parents = new Array(numitems)
470: for (var i=$startcount; i<numitems; i++) {
471: parents[i] = new Array
472: }
473: |;
474:
475: foreach my $container (sort { $a <=> $b } (keys(%children))) {
476: my @contents = split(/:/,$children{$container});
477: for (my $i=0; $i<@contents; $i ++) {
478: $scripttag .= ' parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
479: }
480: }
481:
482: $scripttag .= qq|
483: if (parents[item].length > 0) {
484: for (var j=0; j<parents[item].length; j++) {
485: containerCheck(parents[item][j])
486: }
1.364 bisitz 487: }
1.329 droeschl 488: }
1.369 bisitz 489: // ]]>
1.329 droeschl 490: </script>
491: |;
492: $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package',
493: $scripttag));
494: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
1.369 bisitz 495: $r->print($display.
1.361 bisitz 496: '<p><input type="hidden" name="finishexport" value="1" />'.
1.329 droeschl 497: '<input type="submit" name="exportcourse" value="'.
498: &mt('Export '.$type.' DOCS').'" /></p></form>');
499: }
500: }
501:
502: sub create_ims_store {
503: my ($now,$manifestok,$outcome,$tempexport) = @_;
504: $$tempexport = $Apache::lonnet::perlvar{'lonDaemons'}.'/tmp/ims_exports';
505: my $ims_manifest;
506: if (!-e $$tempexport) {
507: mkdir($$tempexport,0700);
508: }
509: $$tempexport .= '/'.$now;
510: if (!-e $$tempexport) {
511: mkdir($$tempexport,0700);
512: }
513: $$tempexport .= '/'.$env{'user.domain'}.'_'.$env{'user.name'};
514: if (!-e $$tempexport) {
515: mkdir($$tempexport,0700);
516: }
517: if (!-e "$$tempexport/resources") {
518: mkdir("$$tempexport/resources",0700);
519: }
520: # open manifest file
521: my $manifest = '/imsmanifest.xml';
522: my $manifestfilename = $$tempexport.$manifest;
523: if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
524: $$manifestok=1;
525: print $ims_manifest
526: '<?xml version="1.0" encoding="UTF-8"?>'."\n".
527: '<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
528: ' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
529: ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'.
530: ' identifier="MANIFEST-'.$env{'request.course.id'}.'-'.$now.'"'.
531: ' xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1imscp_v1p1.xsd'.
532: ' http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">'."\n".
533: ' <metadata>
534: <schema></schema>
535: <imsmd:lom>
536: <imsmd:general>
537: <imsmd:identifier>'.$env{'request.course.id'}.'</imsmd:identifier>
538: <imsmd:title>
539: <imsmd:langstring xml:lang="en">'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</imsmd:langstring>
540: </imsmd:title>
541: </imsmd:general>
542: </imsmd:lom>
543: </metadata>'."\n".
544: ' <organizations default="ORG-'.$env{'request.course.id'}.'-'.$now.'">'."\n".
545: ' <organization identifier="ORG-'.$env{'request.course.id'}.'-'.$now.'"'.
546: ' structure="hierarchical">'."\n".
547: ' <title>'.$env{'course.'.$env{'request.course.id'}.'.description'}.'</title>'
548: } else {
549: $$outcome .= 'An error occurred opening the IMS manifest file.<br />'
550: ;
551: }
552: return $ims_manifest;
553: }
554:
555: sub build_package {
556: my ($now,$navmap,$exportitems,$discussions,$outcome,$tempexport,$copyresult,$ims_manifest) = @_;
557: # first iterator to look for dependencies
558: my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
559: my $curRes;
560: my $count = 0;
561: my $depth = 0;
562: my $lastcontainer = 0;
563: my %parent = ();
564: my @dependencies = ();
565: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
566: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
567: while ($curRes = $it->next()) {
568: if (ref($curRes)) {
569: $count ++;
570: }
571: if ($curRes == $it->BEGIN_MAP()) {
572: $depth++;
573: $parent{$depth} = $lastcontainer;
574: }
575: if ($curRes == $it->END_MAP()) {
576: $depth--;
577: $lastcontainer = $parent{$depth};
578: }
579: if (ref($curRes)) {
580: if ($curRes->is_sequence() || $curRes->is_page()) {
581: $lastcontainer = $count;
582: }
583: if (grep(/^$count$/,@$exportitems)) {
584: &get_dependencies($exportitems,\%parent,$depth,\@dependencies);
585: }
586: }
587: }
588: # second iterator to build manifest and store resources
589: $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
590: $depth = 0;
591: my $prevdepth;
592: $count = 0;
593: my $imsresources;
594: my $pkgdepth;
595: while ($curRes = $it->next()) {
596: if ($curRes == $it->BEGIN_MAP()) {
597: $prevdepth = $depth;
598: $depth++;
599: }
600: if ($curRes == $it->END_MAP()) {
601: $prevdepth = $depth;
602: $depth--;
603: }
604:
605: if (ref($curRes)) {
606: $count ++;
607: if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) {
608: my $symb = $curRes->symb();
609: my $isvisible = 'true';
610: my $resourceref;
611: if ($curRes->randomout()) {
612: $isvisible = 'false';
613: }
614: unless ($curRes->is_sequence()) {
615: $resourceref = 'identifierref="RES-'.$env{'request.course.id'}.'-'.$count.'"';
616: }
617: my $step = $prevdepth - $depth;
618: if (($step >= 0) && ($count > 1)) {
619: while ($step >= 0) {
620: print $ims_manifest "\n".' </item>'."\n";
621: $step --;
622: }
623: }
624: $prevdepth = $depth;
625:
626: my $itementry =
627: '<item identifier="ITEM-'.$env{'request.course.id'}.'-'.$count.
628: '" isvisible="'.$isvisible.'" '.$resourceref.'>'.
629: '<title>'.$curRes->title().'</title>';
630: print $ims_manifest "\n".$itementry;
631:
632: unless ($curRes->is_sequence()) {
633: my $content_file;
634: my @hrefs = ();
635: &process_content($count,$curRes,$cdom,$cnum,$symb,\$content_file,\@hrefs,$copyresult,$tempexport);
636: if ($content_file) {
637: $imsresources .= "\n".
638: ' <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
639: '" type="webcontent" href="'.$content_file.'">'."\n".
640: ' <file href="'.$content_file.'" />'."\n";
641: foreach my $item (@hrefs) {
642: $imsresources .=
643: ' <file href="'.$item.'" />'."\n";
644: }
645: if (grep(/^$count$/,@$discussions)) {
646: my $ressymb = $symb;
647: my $mode;
648: if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
649: unless ($ressymb =~ m|adm/wrapper/adm|) {
650: $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
651: }
652: $mode = 'board';
653: }
654: my %extras = (
655: caller => 'imsexport',
656: tempexport => $tempexport.'/resources',
657: count => $count
658: );
659: my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
660: }
661: $imsresources .= ' </resource>'."\n";
662: }
663: }
664: $pkgdepth = $depth;
665: }
666: }
667: }
668: while ($pkgdepth > 0) {
669: print $ims_manifest " </item>\n";
670: $pkgdepth --;
671: }
672: my $resource_text = qq|
673: </organization>
674: </organizations>
675: <resources>
676: $imsresources
677: </resources>
678: </manifest>
679: |;
680: print $ims_manifest $resource_text;
681: }
682:
683: sub get_dependencies {
684: my ($exportitems,$parent,$depth,$dependencies) = @_;
685: if ($depth > 1) {
686: if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) {
687: push(@{$dependencies},$$parent{$depth});
688: if ($depth > 2) {
689: &get_dependencies($exportitems,$parent,$depth-1,$dependencies);
690: }
691: }
692: }
693: }
694:
695: sub process_content {
696: my ($count,$curRes,$cdom,$cnum,$symb,$content_file,$href,$copyresult,$tempexport) = @_;
697: my $content_type;
698: my $message;
699: my @uploads = ();
700: if ($curRes->is_sequence()) {
701: $content_type = 'sequence';
702: } elsif ($curRes->is_page()) {
703: $content_type = 'page'; # need to handle individual items in pages.
704: } elsif ($symb =~ m-public/$cdom/$cnum/syllabus$-) {
705: $content_type = 'syllabus';
706: my $contents = &Apache::imsexport::templatedpage($content_type);
707: if ($contents) {
708: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
709: }
710: } elsif ($symb =~ m-\.sequence___\d+___ext-) {
711: $content_type = 'external';
712: my $title = $curRes->title;
713: my $contents = &Apache::imsexport::external($symb,$title);
714: if ($contents) {
715: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
716: }
717: } elsif ($symb =~ m-adm/navmaps$-) {
718: $content_type = 'navmap';
719: } elsif ($symb =~ m-adm/[^/]+/[^/]+/(\d+)/smppg$-) {
720: $content_type = 'simplepage';
721: my $contents = &Apache::imsexport::templatedpage($content_type,$1,$count,\@uploads);
722: if ($contents) {
723: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
724: }
725: } elsif ($symb =~ m-lib/templates/simpleproblem\.problem$-) {
726: $content_type = 'simpleproblem';
727: my $contents = &Apache::imsexport::simpleproblem($symb);
728: if ($contents) {
729: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
730: }
731: } elsif ($symb =~ m-lib/templates/examupload\.problem$-) {
732: $content_type = 'examupload';
733: } elsif ($symb =~ m-adm/($match_domain)/($match_username)/(\d+)/bulletinboard$-) {
734: $content_type = 'bulletinboard';
735: my $contents = &Apache::imsexport::templatedpage($content_type,$3,$count,\@uploads,$1,$2);
736: if ($contents) {
737: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
738: }
739: } elsif ($symb =~ m-adm/([^/]+)/([^/]+)/aboutme$-) {
740: $content_type = 'aboutme';
741: my $contents = &Apache::imsexport::templatedpage($content_type,undef,$count,\@uploads,$1,$2);
742: if ($contents) {
743: $$content_file = &store_template($contents,$tempexport,$count,$content_type);
744: }
745: } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
746: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
747: } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
748: my $canedit = 0;
749: if ($2 eq $env{'user.domain'} && $3 eq $env{'user.name'}) {
750: $canedit= 1;
751: }
752: # only include problem code where current user is author
753: if ($canedit) {
754: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
755: } else {
756: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
757: }
758: } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
759: $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
760: }
761: if (@uploads > 0) {
762: foreach my $item (@uploads) {
763: my $uploadmsg = '';
764: &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
765: if ($uploadmsg) {
766: $$copyresult .= $uploadmsg."\n";
767: }
768: }
769: }
770: if ($message) {
771: $$copyresult .= $message."\n";
772: }
773: }
774:
775: sub replicate_content {
776: my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
777: my ($map,$ind,$url);
778: if ($caller eq 'templateupload') {
779: $url = $symb;
780: $url =~ s#//#/#g;
1.344 bisitz 781: } else {
1.329 droeschl 782: ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
783: }
784: my $content;
785: my $filename;
786: my $repstatus;
787: my $content_name;
788: if ($url =~ m-/([^/]+)$-) {
789: $filename = $1;
790: if (!-e $tempexport.'/resources') {
791: mkdir($tempexport.'/resources',0700);
792: }
793: if (!-e $tempexport.'/resources/'.$count) {
794: mkdir($tempexport.'/resources/'.$count,0700);
795: }
796: my $destination = $tempexport.'/resources/'.$count.'/'.$filename;
797: my $copiedfile;
798: if ($copiedfile = Apache::File->new('>'.$destination)) {
799: my $content;
800: if ($caller eq 'resource') {
801: my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
802: my $filepath = &Apache::lonnet::filelocation($respath,$url);
803: $content = &Apache::lonnet::getfile($filepath);
804: if ($content eq -1) {
805: $$message = 'Could not copy file '.$filename;
806: } else {
807: &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'resource');
808: $repstatus = 'ok';
809: }
810: } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
811: my $rtncode;
812: $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
813: if ($repstatus eq 'ok') {
814: if ($url =~ /\.html?$/i) {
815: &extract_media($url,$cdom,$cnum,\$content,$count,$tempexport,$href,$message,'uploaded');
816: }
817: } else {
818: $$message = 'Could not render '.$url.' server message - '.$rtncode."<br />\n";
819: }
820: } elsif ($caller eq 'noedit') {
1.344 bisitz 821: # Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this.
1.329 droeschl 822: $repstatus = 'ok';
1.344 bisitz 823: $content = 'Not the owner of this resource';
1.329 droeschl 824: }
825: if ($repstatus eq 'ok') {
826: print $copiedfile $content;
827: }
828: close($copiedfile);
829: } else {
830: $$message = 'Could not open destination file for '.$filename."<br />\n";
831: }
832: } else {
833: $$message = 'Could not determine name of file for '.$symb."<br />\n";
834: }
835: if ($repstatus eq 'ok') {
836: $content_name = 'resources/'.$count.'/'.$filename;
837: }
838: return $content_name;
839: }
840:
841: sub extract_media {
842: my ($url,$cdom,$cnum,$content,$count,$tempexport,$href,$message,$caller) = @_;
843: my ($dirpath,$container);
844: my %allfiles = ();
845: my %codebase = ();
846: if ($url =~ m-(.*/)([^/]+)$-) {
847: $dirpath = $1;
848: $container = $2;
849: } else {
850: $dirpath = $url;
851: $container = '';
852: }
853: &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
854: foreach my $embed_file (keys(%allfiles)) {
855: my $filename;
856: if ($embed_file =~ m#([^/]+)$#) {
857: $filename = $1;
858: } else {
859: $filename = $embed_file;
860: }
861: my $newname = 'res/'.$filename;
862: my ($rtncode,$embed_content,$repstatus);
863: my $embed_url;
864: if ($embed_file =~ m-^/-) {
865: $embed_url = $embed_file; # points to absolute path
866: } else {
867: if ($embed_file =~ m-https?://-) {
868: next; # points to url
869: } else {
870: $embed_url = $dirpath.$embed_file; # points to relative path
871: }
872: }
873: if ($caller eq 'resource') {
1.344 bisitz 874: my $respath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/res';
875: my $embed_path = &Apache::lonnet::filelocation($respath,$embed_url);
1.329 droeschl 876: $embed_content = &Apache::lonnet::getfile($embed_path);
877: unless ($embed_content eq -1) {
878: $repstatus = 'ok';
879: }
880: } elsif ($caller eq 'uploaded') {
1.364 bisitz 881:
1.329 droeschl 882: $repstatus = &Apache::lonnet::getuploaded('GET',$embed_url,$cdom,$cnum,\$embed_content,$rtncode);
883: }
884: if ($repstatus eq 'ok') {
885: my $destination = $tempexport.'/resources/'.$count.'/res';
886: if (!-e "$destination") {
887: mkdir($destination,0755);
888: }
889: $destination .= '/'.$filename;
890: my $copiedfile;
891: if ($copiedfile = Apache::File->new('>'.$destination)) {
892: print $copiedfile $embed_content;
893: push(@{$href},'resources/'.$count.'/res/'.$filename);
894: my $attrib_regexp = '';
895: if (@{$allfiles{$embed_file}} > 1) {
896: $attrib_regexp = join('|',@{$allfiles{$embed_file}});
897: } else {
898: $attrib_regexp = $allfiles{$embed_file}[0];
899: }
900: $$content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$embed_file\E(['"]?)#$1$newname$2#gi;
901: if ($caller eq 'resource' && $container =~ /\.(problem|library)$/) {
902: $$content =~ s#\Q$embed_file\E#$newname#gi;
903: }
904: }
905: } else {
906: $$message .= 'replication of embedded file - '.$embed_file.' in '.$url.' failed, reason -'.$rtncode."<br />\n";
907: }
908: }
909: return;
910: }
911:
912: sub store_template {
913: my ($contents,$tempexport,$count,$content_type) = @_;
914: if ($contents) {
915: if ($tempexport) {
916: if (!-e $tempexport.'/resources') {
917: mkdir($tempexport.'/resources',0700);
918: }
919: if (!-e $tempexport.'/resources/'.$count) {
920: mkdir($tempexport.'/resources/'.$count,0700);
921: }
922: my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
923: my $storetemplate;
924: if ($storetemplate = Apache::File->new('>'.$destination)) {
925: print $storetemplate $contents;
926: close($storetemplate);
927: }
928: if ($content_type eq 'external') {
929: return 'resources/'.$count.'/'.$content_type.'.html';
930: } else {
931: return 'resources/'.$count.'/'.$content_type.'.xml';
932: }
933: }
934: }
935: }
936:
937:
938: sub group_import {
939: my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
940:
941: while (@files) {
942: my ($name, $url, $residx) = @{ shift(@files) };
1.344 bisitz 943: if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$})
1.329 droeschl 944: && ($caller eq 'londocs')
945: && (!&Apache::lonnet::stat_file($url))) {
1.364 bisitz 946:
1.329 droeschl 947: my $errtext = '';
948: my $fatal = 0;
949: my $newmapstr = '<map>'."\n".
950: '<resource id="1" src="" type="start"></resource>'."\n".
951: '<link from="1" to="2" index="1"></link>'."\n".
952: '<resource id="2" src="" type="finish"></resource>'."\n".
953: '</map>';
954: $env{'form.output'}=$newmapstr;
955: my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
956: 'output',$1.$2);
957: if ($result != m|^/uploaded/|) {
958: $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
959: $fatal = 2;
960: }
961: if ($fatal) {
962: return ($errtext,$fatal);
963: }
964: }
965: if ($url) {
1.344 bisitz 966: if (!$residx
1.329 droeschl 967: || defined($LONCAPA::map::zombies[$residx])) {
968: $residx = &LONCAPA::map::getresidx($url,$residx);
969: push(@LONCAPA::map::order, $residx);
970: }
971: my $ext = 'false';
972: if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
973: $url = &LONCAPA::map::qtunescape($url);
974: $name = &LONCAPA::map::qtunescape($name);
1.344 bisitz 975: $LONCAPA::map::resources[$residx] =
1.329 droeschl 976: join(':', ($name, $url, $ext, 'normal', 'res'));
977: }
978: }
979: return &storemap($coursenum, $coursedom, $folder.'.'.$container);
980: }
981:
982: sub breadcrumbs {
983: my ($where,$allowed,$type)=@_;
984: &Apache::lonhtmlcommon::clear_breadcrumbs();
985: my (@folders);
986: if ($env{'form.pagepath'}) {
987: @folders = split('&',$env{'form.pagepath'});
988: } else {
989: @folders=split('&',$env{'form.folderpath'});
990: }
991: my $folderpath;
992: my $cpinfo='';
993: my $plain='';
994: my $randompick=-1;
995: my $isencrypted=0;
996: my $ishidden=0;
997: my $is_random_order=0;
998: while (@folders) {
999: my $folder=shift(@folders);
1000: my $foldername=shift(@folders);
1001: if ($folderpath) {$folderpath.='&';}
1002: $folderpath.=$folder.'&'.$foldername;
1003: my $url='/adm/coursedocs?folderpath='.
1004: &escape($folderpath);
1005: my $name=&unescape($foldername);
1.344 bisitz 1006: # randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
1.329 droeschl 1007: $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
1.344 bisitz 1008: if ($1 ne '') {
1.329 droeschl 1009: $randompick=$1;
1010: } else {
1011: $randompick=-1;
1012: }
1013: if ($2) { $ishidden=1; }
1014: if ($3) { $isencrypted=1; }
1015: if ($4 ne '') { $is_random_order = 1; }
1016: if ($folder eq 'supplemental') {
1017: if ($allowed) {
1018: $name = &mt('Supplemental '.$type.' Documents');
1019: } else {
1020: $name = &mt($type.' Documents');
1021: }
1022: }
1023: &Apache::lonhtmlcommon::add_breadcrumb(
1024: {'href'=>$url.$cpinfo,
1025: 'title'=>$name,
1.367 droeschl 1026: 'text'=>$name,
1.329 droeschl 1027: 'no_mt'=>1,
1028: });
1029: $plain.=$name.' > ';
1030: }
1031: $plain=~s/\>\;\s*$//;
1032: return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
1.360 amueller 1033: 'LC_docs_path', undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
1.329 droeschl 1034: }
1035:
1036: sub log_docs {
1037: return &Apache::lonnet::instructor_log('docslog',@_);
1038: }
1039:
1040: {
1041: my @oldresources=();
1042: my @oldorder=();
1043: my $parmidx;
1044: my %parmaction=();
1045: my %parmvalue=();
1046: my $changedflag;
1047:
1048: sub snapshotbefore {
1049: @oldresources=@LONCAPA::map::resources;
1050: @oldorder=@LONCAPA::map::order;
1051: $parmidx=undef;
1052: %parmaction=();
1053: %parmvalue=();
1054: $changedflag=0;
1055: }
1056:
1057: sub remember_parms {
1058: my ($idx,$parameter,$action,$value)=@_;
1059: $parmidx=$idx;
1060: $parmaction{$parameter}=$action;
1061: $parmvalue{$parameter}=$value;
1062: $changedflag=1;
1063: }
1064:
1065: sub log_differences {
1066: my ($plain)=@_;
1067: my %storehash=('folder' => $plain,
1068: 'currentfolder' => $env{'form.folder'});
1069: if ($parmidx) {
1070: $storehash{'parameter_res'}=$oldresources[$parmidx];
1071: foreach my $parm (keys(%parmaction)) {
1072: $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
1073: $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
1074: }
1075: }
1076: my $maxidx=$#oldresources;
1077: if ($#LONCAPA::map::resources>$#oldresources) {
1078: $maxidx=$#LONCAPA::map::resources;
1079: }
1080: for (my $idx=0; $idx<=$maxidx; $idx++) {
1081: if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) {
1082: $storehash{'before_resources_'.$idx}=$oldresources[$idx];
1083: $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx];
1084: $changedflag=1;
1085: }
1086: if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) {
1087: $storehash{'before_order_res_'.$idx}=$oldresources[$oldorder[$idx]];
1088: $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1089: $changedflag=1;
1090: }
1091: }
1092: $storehash{'maxidx'}=$maxidx;
1093: if ($changedflag) { &log_docs(\%storehash); }
1094: }
1095: }
1096:
1097:
1098:
1099:
1100:
1101: sub docs_change_log {
1102: my ($r)=@_;
1103: my $folder=$env{'form.folder'};
1104: $r->print(&Apache::loncommon::start_page('Course Document Change Log'));
1105: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log'));
1106: my %docslog=&Apache::lonnet::dump('nohist_docslog',
1107: $env{'course.'.$env{'request.course.id'}.'.domain'},
1108: $env{'course.'.$env{'request.course.id'}.'.num'});
1109:
1110: if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); }
1111:
1112: $r->print('<form action="/adm/coursedocs" method="post" name="docslog">'.
1113: '<input type="hidden" name="docslog" value="1" />');
1114:
1115: my %saveable_parameters = ('show' => 'scalar',);
1116: &Apache::loncommon::store_course_settings('docs_log',
1117: \%saveable_parameters);
1118: &Apache::loncommon::restore_course_settings('docs_log',
1119: \%saveable_parameters);
1120: if (!$env{'form.show'}) { $env{'form.show'}=10; }
1121: my %lt=('hiddenresource' => 'Resources hidden',
1122: 'encrypturl' => 'URL hidden',
1123: 'randompick' => 'Randomly pick',
1124: 'randomorder' => 'Randomly ordered',
1125: 'set' => 'set to',
1126: 'del' => 'deleted');
1127: $r->print(&Apache::loncommon::display_filter().
1128: '<input type="hidden" name="folder" value="'.$folder.'" />'.
1129: '<input type="submit" value="'.&mt('Display').'" /></form>');
1130: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
1131: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Folder').'</th><th>'.&mt('Before').'</th><th>'.
1132: &mt('After').'</th>'.
1133: &Apache::loncommon::end_data_table_header_row());
1134: my $shown=0;
1135: foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) {
1136: if ($env{'form.displayfilter'} eq 'currentfolder') {
1137: if ($docslog{$id}{'logentry'}{'currentfolder'} ne $folder) { next; }
1138: }
1139: my @changes=keys(%{$docslog{$id}{'logentry'}});
1140: if ($env{'form.displayfilter'} eq 'containing') {
1141: my $wholeentry=$docslog{$id}{'exe_uname'}.':'.$docslog{$id}{'exe_udom'}.':'.
1142: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},$docslog{$id}{'exe_udom'});
1143: foreach my $key (@changes) {
1144: $wholeentry.=':'.$docslog{$id}{'logentry'}{$key};
1145: }
1.344 bisitz 1146: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
1.329 droeschl 1147: }
1148: my $count = 0;
1149: my $time =
1150: &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'});
1151: my $plainname =
1152: &Apache::loncommon::plainname($docslog{$id}{'exe_uname'},
1153: $docslog{$id}{'exe_udom'});
1154: my $about_me_link =
1155: &Apache::loncommon::aboutmewrapper($plainname,
1156: $docslog{$id}{'exe_uname'},
1157: $docslog{$id}{'exe_udom'});
1158: my $send_msg_link='';
1159: if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'})
1160: || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1161: $send_msg_link ='<br />'.
1162: &Apache::loncommon::messagewrapper(&mt('Send message'),
1163: $docslog{$id}{'exe_uname'},
1164: $docslog{$id}{'exe_udom'});
1165: }
1166: $r->print(&Apache::loncommon::start_data_table_row());
1167: $r->print('<td>'.$time.'</td>
1168: <td>'.$about_me_link.
1169: '<br /><tt>'.$docslog{$id}{'exe_uname'}.
1170: ':'.$docslog{$id}{'exe_udom'}.'</tt>'.
1171: $send_msg_link.'</td><td>'.
1172: $docslog{$id}{'logentry'}{'folder'}.'</td><td>');
1173: # Before
1174: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1175: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1176: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1177: if ($oldname ne $newname) {
1178: $r->print(&LONCAPA::map::qtescape($oldname));
1179: }
1180: }
1181: $r->print('<ul>');
1182: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1183: if ($docslog{$id}{'logentry'}{'before_order_res_'.$idx}) {
1184: $r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'before_order_res_'.$idx}))[0]).'</li>');
1185: }
1186: }
1187: $r->print('</ul>');
1188: # After
1189: $r->print('</td><td>');
1190:
1191: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1192: my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
1193: my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
1194: if ($oldname ne '' && $oldname ne $newname) {
1195: $r->print(&LONCAPA::map::qtescape($newname));
1196: }
1.364 bisitz 1197: }
1.329 droeschl 1198: $r->print('<ul>');
1199: for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
1200: if ($docslog{$id}{'logentry'}{'after_order_res_'.$idx}) {
1201: $r->print('<li>'.&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'after_order_res_'.$idx}))[0]).'</li>');
1202: }
1203: }
1204: $r->print('</ul>');
1205: if ($docslog{$id}{'logentry'}{'parameter_res'}) {
1206: $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
1207: foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
1208: if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
1209: $r->print('<li>'.
1210: &mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
1211: $docslog{$id}{'logentry'}{'parameter_value_'.$parameter})
1212: .'</li>');
1213: }
1214: }
1215: $r->print('</ul>');
1216: }
1217: # End
1218: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1219: $shown++;
1220: if (!($env{'form.show'} eq &mt('all')
1221: || $shown<=$env{'form.show'})) { last; }
1222: }
1223: $r->print(&Apache::loncommon::end_data_table());
1224: }
1225:
1226: sub update_paste_buffer {
1227: my ($coursenum,$coursedom) = @_;
1228:
1229: return if (!defined($env{'form.markcopy'}));
1230: return if (!defined($env{'form.copyfolder'}));
1231: return if ($env{'form.markcopy'} < 0);
1232:
1233: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1234: $env{'form.copyfolder'});
1.364 bisitz 1235:
1.329 droeschl 1236: return if ($fatal);
1237:
1238: # Mark for copying
1239: my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
1240: if (&is_supplemental_title($title)) {
1241: &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
1242: ($title) = &parse_supplemental_title($title);
1243: } elsif ($env{'docs.markedcopy_supplemental'}) {
1.346 raeburn 1244: &Apache::lonnet::delenv('docs.markedcopy_supplemental');
1.329 droeschl 1245: }
1246: $url=~s{http(:|:)//https(:|:)//}{https$2//};
1247:
1248: &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
1249: 'docs.markedcopy_url' => $url});
1250: delete($env{'form.markcopy'});
1251: }
1252:
1253: sub print_paste_buffer {
1254: my ($r,$container) = @_;
1255: return if (!defined($env{'docs.markedcopy_url'}));
1256:
1257: $r->print(<<ENDPASTE);
1258: <form name="pasteform" action="/adm/coursedocs" method="post"><p>
1259: ENDPASTE
1260: $r->print('<input type="submit" name="pastemarked" value="'.&mt('Paste').'" /> ');
1261:
1262: my $type;
1263: if ($env{'docs.markedcopy_url'} =~ m{^(?:/adm/wrapper/ext|(?:http|https)(?::|:))//} ) {
1264: $type = &mt('External Resource');
1265: $r->print($type.': '.
1266: &LONCAPA::map::qtescape($env{'docs.markedcopy_title'}).' ('.
1267: &LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
1268: } else {
1269: my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
1270: my $icon = &Apache::loncommon::icon($extension);
1271: if ($extension eq 'sequence' &&
1272: $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
1273: $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
1274: $icon .= '/folder_closed.gif';
1275: }
1276: $icon = '<img src="'.$icon.'" alt="" class="LC_icon" />';
1277: $r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
1278: }
1279: if ($container eq 'page') {
1280: $r->print('
1281: <input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />
1282: <input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />
1283: ');
1284: } else {
1285: $r->print('
1286: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
1287: ');
1288: }
1289: $r->print('</p></form>');
1290: }
1291:
1292: sub do_paste_from_buffer {
1293: my ($coursenum,$coursedom,$folder) = @_;
1294:
1295: if (!$env{'form.pastemarked'}) {
1296: return;
1297: }
1298:
1299: # paste resource to end of list
1300: my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
1301: my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
1302: # Maps need to be copied first
1303: if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
1304: $title=&mt('Copy of').' '.$title;
1305: my $newid=$$.int(rand(100)).time;
1306: my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
1307: if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
1308: my $path = $1;
1309: my $prefix = $2;
1310: my $ancestor = $3;
1311: if (length($ancestor) > 10) {
1312: $ancestor = substr($ancestor,-10,10);
1313: }
1314: $oldid = $path.$prefix.$ancestor;
1315: }
1316: my $counter = 0;
1317: my $newurl=$oldid.$newid.'.'.$ext;
1318: my $is_unique = &uniqueness_check($newurl);
1319: while (!$is_unique && $counter < 100) {
1320: $counter ++;
1321: $newid ++;
1322: $newurl = $oldid.$newid;
1323: $is_unique = &uniqueness_check($newurl);
1324: }
1325: if (!$is_unique) {
1326: if ($url=~/\.page$/) {
1327: return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
1328: } else {
1329: return &mt('Paste failed: an error occurred creating a unique URL for the folder');
1330: }
1331: }
1332: my $storefn=$newurl;
1333: $storefn=~s{^/\w+/$match_domain/$match_username/}{};
1334: my $paste_map_result =
1335: &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
1336: &Apache::lonnet::getfile($url));
1337: if ($paste_map_result eq '/adm/notfound.html') {
1338: if ($url=~/\.page$/) {
1339: return &mt('Paste failed: an error occurred saving the composite page');
1340: } else {
1341: return &mt('Paste failed: an error occurred saving the folder');
1342: }
1343: }
1344: $url = $newurl;
1345: }
1346: # published maps can only exists once, so remove it from paste buffer when done
1347: if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
1.346 raeburn 1348: &Apache::lonnet::delenv('docs.markedcopy');
1.329 droeschl 1349: }
1350: if ($url=~ m{/smppg$}) {
1351: my $db_name = &Apache::lonsimplepage::get_db_name($url);
1352: if ($db_name =~ /^smppage_/) {
1353: #simple pages, need to copy the db contents to a new one.
1354: my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
1355: my $now = time();
1356: $db_name =~ s{_\d*$ }{_$now}x;
1357: my $result=&Apache::lonnet::put($db_name,\%contents,
1358: $coursedom,$coursenum);
1.344 bisitz 1359: $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x;
1.329 droeschl 1360: $title=&mt('Copy of').' '.$title;
1361: }
1362: }
1363: $title = &LONCAPA::map::qtunescape($title);
1364: my $ext='false';
1365: if ($url=~m{^http(|s)://}) { $ext='true'; }
1366: $url = &LONCAPA::map::qtunescape($url);
1367: # Now insert the URL at the bottom
1368: my $newidx = &LONCAPA::map::getresidx($url);
1369: if ($env{'docs.markedcopy_supplemental'}) {
1370: if ($folder =~ /^supplemental/) {
1371: $title = $env{'docs.markedcopy_supplemental'};
1372: } else {
1.344 bisitz 1373: (undef,undef,$title) =
1.329 droeschl 1374: &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
1375: }
1376: } else {
1377: if ($folder=~/^supplemental/) {
1378: $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1379: $env{'user.domain'}.'___&&&___'.$title;
1380: }
1381: }
1382:
1383: $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
1384: push(@LONCAPA::map::order, $newidx);
1385: return 'ok';
1386: # Store the result
1387: }
1388:
1389: sub uniqueness_check {
1390: my ($newurl) = @_;
1391: my $unique = 1;
1392: foreach my $res (@LONCAPA::map::order) {
1393: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
1394: $url=&LONCAPA::map::qtescape($url);
1395: if ($newurl eq $url) {
1396: $unique = 0;
1.344 bisitz 1397: last;
1.329 droeschl 1398: }
1399: }
1400: return $unique;
1401: }
1402:
1403: my %parameter_type = ( 'randompick' => 'int_pos',
1404: 'hiddenresource' => 'string_yesno',
1405: 'encrypturl' => 'string_yesno',
1406: 'randomorder' => 'string_yesno',);
1407: my $valid_parameters_re = join('|',keys(%parameter_type));
1408: # set parameters
1409: sub update_parameter {
1410:
1411: return 0 if ($env{'form.changeparms'} !~ /^($valid_parameters_re)$/);
1412:
1413: my $which = $env{'form.changeparms'};
1414: my $idx = $env{'form.setparms'};
1415: if ($env{'form.'.$which.'_'.$idx}) {
1416: my $value = ($which eq 'randompick') ? $env{'form.'.$which.'_'.$idx}
1417: : 'yes';
1418: &LONCAPA::map::storeparameter($idx, 'parameter_'.$which, $value,
1419: $parameter_type{$which});
1420: &remember_parms($idx,$which,'set',$value);
1421: } else {
1422: &LONCAPA::map::delparameter($idx,'parameter_'.$which);
1.364 bisitz 1423:
1.329 droeschl 1424: &remember_parms($idx,$which,'del');
1425: }
1426: return 1;
1427: }
1428:
1429:
1430: sub handle_edit_cmd {
1431: my ($coursenum,$coursedom) =@_;
1432:
1433: my ($cmd,$idx)=split('_',$env{'form.cmd'});
1434:
1435: my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
1436: my ($title, $url, @rrest) = split(':', $ratstr);
1437:
1438: if ($cmd eq 'del') {
1439: if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
1440: ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
1441: &Apache::lonnet::removeuploadedurl($url);
1442: } else {
1443: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1444: }
1445: splice(@LONCAPA::map::order, $idx, 1);
1446:
1447: } elsif ($cmd eq 'cut') {
1448: &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
1449: splice(@LONCAPA::map::order, $idx, 1);
1450:
1.344 bisitz 1451: } elsif ($cmd eq 'up'
1.329 droeschl 1452: && ($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
1453: @LONCAPA::map::order[$idx-1,$idx] = @LONCAPA::map::order[$idx,$idx-1];
1454:
1455: } elsif ($cmd eq 'down'
1456: && defined($LONCAPA::map::order[$idx+1])) {
1457: @LONCAPA::map::order[$idx+1,$idx] = @LONCAPA::map::order[$idx,$idx+1];
1458:
1459: } elsif ($cmd eq 'rename') {
1460:
1461: my $comment = &LONCAPA::map::qtunescape($env{'form.title'});
1462: if ($comment=~/\S/) {
1463: $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
1464: $comment.':'.join(':', $url, @rrest);
1465: }
1466: # Devalidate title cache
1467: my $renamed_url=&LONCAPA::map::qtescape($url);
1468: &Apache::lonnet::devalidate_title_cache($renamed_url);
1469: } else {
1470: return 0;
1471: }
1472: return 1;
1473: }
1474:
1475: sub editor {
1476: my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
1477:
1478: my $container= ($env{'form.pagepath'}) ? 'page'
1479: : 'sequence';
1480:
1481: my ($errtext,$fatal) = &mapread($coursenum,$coursedom,
1482: $folder.'.'.$container);
1483: return $errtext if ($fatal);
1484:
1485: if ($#LONCAPA::map::order<1) {
1486: my $idx=&LONCAPA::map::getresidx();
1487: if ($idx<=0) { $idx=1; }
1488: $LONCAPA::map::order[0]=$idx;
1489: $LONCAPA::map::resources[$idx]='';
1490: }
1.364 bisitz 1491:
1.329 droeschl 1492: my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
1493: &breadcrumbs($folder,$allowed,$type);
1494: $r->print($breadcrumbtrail);
1.364 bisitz 1495:
1.329 droeschl 1496: # ------------------------------------------------------------ Process commands
1497:
1498: # ---------------- if they are for this folder and user allowed to make changes
1499: if (($allowed) && ($env{'form.folder'} eq $folder)) {
1500: # set parameters and change order
1501: &snapshotbefore();
1502:
1503: if (&update_parameter()) {
1504: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1505: return $errtext if ($fatal);
1506: }
1507:
1508: if ($env{'form.newpos'} && $env{'form.currentpos'}) {
1509: # change order
1510: my $res = splice(@LONCAPA::map::order,$env{'form.currentpos'}-1,1);
1511: splice(@LONCAPA::map::order,$env{'form.newpos'}-1,0,$res);
1512:
1513: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1514: return $errtext if ($fatal);
1515: }
1.364 bisitz 1516:
1.329 droeschl 1517: if ($env{'form.pastemarked'}) {
1.344 bisitz 1518: my $paste_res =
1.329 droeschl 1519: &do_paste_from_buffer($coursenum,$coursedom,$folder);
1520: if ($paste_res eq 'ok') {
1521: ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
1522: return $errtext if ($fatal);
1523: } elsif ($paste_res ne '') {
1524: $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
1525: }
1526: }
1527:
1528: $r->print($upload_output);
1529:
1530: if (&handle_edit_cmd()) {
1531: ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
1532: return $errtext if ($fatal);
1533: }
1534: # Group import/search
1535: if ($env{'form.importdetail'}) {
1536: my @imports;
1537: foreach my $item (split(/\&/,$env{'form.importdetail'})) {
1538: if (defined($item)) {
1539: my ($name,$url,$residx)=
1540: map {&unescape($_)} split(/\=/,$item);
1541: push(@imports, [$name, $url, $residx]);
1542: }
1543: }
1544: ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
1545: $container,'londocs',@imports);
1546: return $errtext if ($fatal);
1547: }
1548: # Loading a complete map
1549: if ($env{'form.loadmap'}) {
1550: if ($env{'form.importmap'}=~/\w/) {
1551: foreach my $res (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
1552: my ($title,$url,$ext,$type)=split(/\:/,$res);
1553: my $idx=&LONCAPA::map::getresidx($url);
1554: $LONCAPA::map::resources[$idx]=$res;
1555: $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
1556: }
1557: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1558: $folder.'.'.$container);
1559: return $errtext if ($fatal);
1560: } else {
1561: $r->print('<p><span class="LC_error">'.&mt('No map selected.').'</span></p>');
1.364 bisitz 1562:
1.329 droeschl 1563: }
1564: }
1565: &log_differences($plain);
1566: }
1567: # ---------------------------------------------------------------- End commands
1568: # ---------------------------------------------------------------- Print screen
1569: my $idx=0;
1570: my $shown=0;
1571: if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
1572: $r->print('<p>'.&mt('Parameters').':<ul>'.
1573: ($randompick>=0?'<li>'.&mt('randomly pick [_1] resources',$randompick).'</li>':'').
1574: ($ishidden?'<li>'.&mt('contents hidden').'</li>':'').
1575: ($isencrypted?'<li>'.&mt('URLs hidden').'</li>':'').
1576: '</ul></p>');
1.364 bisitz 1577: }
1.329 droeschl 1578: if ($randompick>=0) {
1579: $r->print('<p>'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'</p>');
1580: }
1581: if ($is_random_order) {
1582: $r->print('<p>'.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown.').'</p>');
1583: }
1584: $r->print('<table class="LC_docs_editor">');
1585: foreach my $res (@LONCAPA::map::order) {
1586: my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
1587: $name=&LONCAPA::map::qtescape($name);
1588: $url=&LONCAPA::map::qtescape($url);
1589: unless ($name) { $name=(split(/\//,$url))[-1]; }
1590: unless ($name) { $idx++; next; }
1591: $r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
1592: $coursenum));
1593: $idx++;
1594: $shown++;
1595: }
1596: unless ($shown) {
1597: $r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
1598: }
1599: $r->print("\n</table>\n");
1600: if ($allowed) {
1601: &print_paste_buffer($r,$container);
1602: }
1603: return;
1604: }
1605:
1606: sub process_file_upload {
1607: my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
1608: # upload a file, if present
1609: my $parseaction;
1610: if ($env{'form.parserflag'}) {
1611: $parseaction = 'parse';
1612: }
1613: my $phase_status;
1614: my $folder=$env{'form.folder'};
1615: if ($folder eq '') {
1616: $folder='default';
1617: }
1618: if ( ($folder=~/^$uploadcmd/) || ($uploadcmd eq 'default') ) {
1619: my $errtext='';
1620: my $fatal=0;
1621: my $container='sequence';
1622: if ($env{'form.pagepath'}) {
1623: $container='page';
1624: }
1625: ($errtext,$fatal)=
1626: &mapread($coursenum,$coursedom,$folder.'.'.$container);
1627: if ($#LONCAPA::map::order<1) {
1628: $LONCAPA::map::order[0]=1;
1629: $LONCAPA::map::resources[1]='';
1630: }
1631: if ($fatal) {
1632: return 'failed';
1633: }
1634: my $destination = 'docs/';
1635: if ($folder =~ /^supplemental/) {
1636: $destination = 'supplemental/';
1637: }
1638: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1639: $destination .= 'default/';
1640: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1641: $destination .= $2.'/';
1642: }
1643: # this is for a course, not a user, so set coursedoc flag
1644: # probably the only place in the system where this should be "1"
1645: my $newidx=&LONCAPA::map::getresidx();
1646: $destination .= $newidx;
1647: my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
1648: $parseaction,$allfiles,
1649: $codebase);
1650: my $ext='false';
1651: if ($url=~m{^http://}) { $ext='true'; }
1652: $url = &LONCAPA::map::qtunescape($url);
1653: my $comment=$env{'form.comment'};
1654: $comment = &LONCAPA::map::qtunescape($comment);
1655: if ($folder=~/^supplemental/) {
1656: $comment=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
1657: $env{'user.domain'}.'___&&&___'.$comment;
1658: }
1659:
1660: $LONCAPA::map::resources[$newidx]=
1661: $comment.':'.$url.':'.$ext.':normal:res';
1662: $LONCAPA::map::order[$#LONCAPA::map::order+1]= $newidx;
1663: ($errtext,$fatal)=&storemap($coursenum,$coursedom,
1664: $folder.'.'.$container);
1665: if ($fatal) {
1666: $$upload_output .= '<p><span class="LC_error">'.$errtext.'</span></p>';
1667: return 'failed';
1668: } else {
1669: if ($parseaction eq 'parse') {
1670: my $total_embedded = keys(%{$allfiles});
1671: if ($total_embedded > 0) {
1672: my $num = 0;
1673: my $state = '
1674: <input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />
1675: <input type="hidden" name="cmd" value="upload_embedded" />
1676: <input type="hidden" name="newidx" value="'.$newidx.'" />
1677: <input type="hidden" name="primaryurl" value="'.&escape($url).'" />
1678: <input type="hidden" name="phasetwo" value="'.$total_embedded.'" />';
1679: $phase_status = 'phasetwo';
1680:
1.344 bisitz 1681: $$upload_output .=
1.329 droeschl 1682: 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
1683: &Apache::loncommon::ask_for_embedded_content(
1684: '/adm/coursedocs',$state,$allfiles,$codebase);
1685: } else {
1686: $$upload_output .= 'No embedded items identified<br />';
1687: }
1688: }
1689: }
1690: }
1691: return $phase_status;
1692: }
1693:
1694: sub process_secondary_uploads {
1695: my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
1696: my $folder=$env{'form.folder'};
1697: my $destination = 'docs/';
1698: if ($folder =~ /^supplemental/) {
1699: $destination = 'supplemental/';
1700: }
1701: if (($folder eq 'default') || ($folder eq 'supplemental')) {
1702: $destination .= 'default/';
1703: } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
1704: $destination .= $2.'/';
1705: }
1706: $destination .= $newidx;
1707: my ($url,$filename);
1708: $url=&Apache::lonnet::userfileupload($formname.$num,1,$destination);
1709: ($filename) = ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/\Q$destination\E/(.+)$});
1710: return $filename;
1711: }
1712:
1713: sub is_supplemental_title {
1714: my ($title) = @_;
1715: return scalar($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/);
1716: }
1717:
1718: sub parse_supplemental_title {
1719: my ($title) = @_;
1720:
1721: my ($foldertitle,$renametitle);
1722: if ($title =~ /&&&/) {
1723: $title = &HTML::Entites::decode($title);
1724: }
1725: if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
1726: $renametitle=$4;
1727: my ($time,$uname,$udom) = ($1,$2,$3);
1728: $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
1729: my $name = &Apache::loncommon::plainname($uname,$udom);
1730: $name = &HTML::Entities::encode($name,'"<>&\'');
1731: $title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
1732: $name.': <br />'.$foldertitle;
1733: }
1734: if (wantarray) {
1735: return ($title,$foldertitle,$renametitle);
1.364 bisitz 1736: }
1.329 droeschl 1737: return $title;
1738: }
1739:
1740: # --------------------------------------------------------------- An entry line
1741:
1742: sub entryline {
1743: my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
1744:
1745: my ($foldertitle,$pagetitle,$renametitle);
1746: if (&is_supplemental_title($title)) {
1747: ($title,$foldertitle,$renametitle) = &parse_supplemental_title($title);
1748: $pagetitle = $foldertitle;
1749: } else {
1750: $title=&HTML::Entities::encode($title,'"<>&\'');
1751: $renametitle=$title;
1752: $foldertitle=$title;
1753: $pagetitle=$title;
1754: }
1755:
1756: my $orderidx=$LONCAPA::map::order[$index];
1.364 bisitz 1757:
1.329 droeschl 1758:
1759: $renametitle=~s/\\/\\\\/g;
1760: $renametitle=~s/\"\;/\\\"/g;
1761: $renametitle=~s/ /%20/g;
1762: my $line='<tr>';
1763: my ($form_start,$form_end);
1764: # Edit commands
1765: my ($container, $type, $esc_path, $path, $symb);
1766: if ($env{'form.folderpath'}) {
1767: $type = 'folder';
1768: $container = 'sequence';
1769: $esc_path=&escape($env{'form.folderpath'});
1770: $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
1771: # $htmlfoldername=&HTML::Entities::encode($env{'form.foldername'},'<>&"');
1772: }
1773: if ($env{'form.pagepath'}) {
1774: $type = $container = 'page';
1775: $esc_path=&escape($path = $env{'form.pagepath'});
1776: $path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
1777: $symb=&escape($env{'form.pagesymb'});
1778: }
1779: my $cpinfo='';
1780: if ($allowed) {
1781: my $incindex=$index+1;
1782: my $selectbox='';
1783: if (($folder!~/^supplemental/) &&
1.344 bisitz 1784: ($#LONCAPA::map::order>0) &&
1.329 droeschl 1785: ((split(/\:/,
1.344 bisitz 1786: $LONCAPA::map::resources[$LONCAPA::map::order[0]]))[1]
1787: ne '') &&
1.329 droeschl 1788: ((split(/\:/,
1.344 bisitz 1789: $LONCAPA::map::resources[$LONCAPA::map::order[1]]))[1]
1.329 droeschl 1790: ne '')) {
1791: $selectbox=
1792: '<input type="hidden" name="currentpos" value="'.$incindex.'" />'.
1793: '<select name="newpos" onChange="this.form.submit()">';
1794: for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
1795: if ($i==$incindex) {
1.358 bisitz 1796: $selectbox.='<option value="" selected="selected">('.$i.')</option>';
1.329 droeschl 1797: } else {
1798: $selectbox.='<option value="'.$i.'">'.$i.'</option>';
1799: }
1800: }
1801: $selectbox.='</select>';
1802: }
1803: my %lt=&Apache::lonlocal::texthash(
1804: 'up' => 'Move Up',
1805: 'dw' => 'Move Down',
1806: 'rm' => 'Remove',
1807: 'ct' => 'Cut',
1808: 'rn' => 'Rename',
1809: 'cp' => 'Copy');
1810: my $nocopy=0;
1811: my $nocut=0;
1812: if ($url=~/\.(page|sequence)$/) {
1813: if ($url =~ m{/res/}) {
1814: # no copy for published maps
1815: $nocopy = 1;
1816: } else {
1817: foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
1818: my ($title,$url,$ext,$type)=split(/\:/,$item);
1819: if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
1820: $nocopy=1;
1821: last;
1822: }
1823: }
1824: }
1825: }
1.344 bisitz 1826: if ($url=~/^\/res\/lib\/templates\//) {
1827: $nocopy=1;
1.329 droeschl 1828: $nocut=1;
1829: }
1830: my $copylink=' ';
1831: my $cutlink=' ';
1.364 bisitz 1832:
1.329 droeschl 1833: my $skip_confirm = 0;
1834: if ( $folder =~ /^supplemental/
1835: || ($url =~ m{( /smppg$
1836: |/syllabus$
1837: |/aboutme$
1838: |/navmaps$
1839: |/bulletinboard$
1840: |\.html$
1841: |^/adm/wrapper/ext)}x)) {
1842: $skip_confirm = 1;
1843: }
1844:
1845: if (!$nocopy) {
1846: $copylink=(<<ENDCOPY);
1847: <a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
1848: ENDCOPY
1849: }
1850: if (!$nocut) {
1851: $cutlink=(<<ENDCUT);
1852: <a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
1853: ENDCUT
1854: }
1855: $form_start = (<<END);
1856: <form action="/adm/coursedocs" method="post">
1857: <input type="hidden" name="${type}path" value="$path" />
1858: <input type="hidden" name="${type}symb" value="$symb" />
1859: <input type="hidden" name="setparms" value="$orderidx" />
1860: <input type="hidden" name="changeparms" value="0" />
1861: END
1862: $form_end = '</form>';
1863: $line.=(<<END);
1864: <td>
1865: <table class="LC_docs_entry_move">
1866: <tr>
1867: <td>
1868: <a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" /></a>
1869: </td>
1870: </tr>
1871: <tr>
1872: <td>
1873: <a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb$cpinfo'><img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" /></a>
1874: </td>
1875: </tr>
1876: </table>
1877: </td>
1878: <td>
1879: $form_start
1880: $selectbox
1881: $form_end
1882: </td>
1883: <td class="LC_docs_entry_commands">
1884: <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
1885: $cutlink
1886: <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
1887: $copylink
1888: </td>
1889: END
1890:
1891: }
1892: # Figure out what kind of a resource this is
1893: my ($extension)=($url=~/\.(\w+)$/);
1894: my $uploaded=($url=~/^\/*uploaded\//);
1895: my $icon=&Apache::loncommon::icon($url);
1896: my $isfolder=0;
1897: my $ispage=0;
1898: my $folderarg;
1899: my $pagearg;
1900: my $pagefile;
1901: if ($uploaded) {
1902: if ($extension eq 'sequence') {
1903: $icon=$iconpath.'/folder_closed.gif';
1904: $url=~/\Q$coursenum\E\/([\/\w]+)\.sequence$/;
1905: $url='/adm/coursedocs?';
1906: $folderarg=$1;
1907: $isfolder=1;
1908: } elsif ($extension eq 'page') {
1909: $icon=$iconpath.'/page.gif';
1910: $url=~/\Q$coursenum\E\/([\/\w]+)\.page$/;
1911: $pagearg=$1;
1912: $url='/adm/coursedocs?';
1913: $ispage=1;
1914: } else {
1915: &Apache::lonnet::allowuploaded('/adm/coursedoc',$url);
1916: }
1917: }
1.364 bisitz 1918:
1.329 droeschl 1919: my $orig_url = $url;
1.340 raeburn 1920: $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
1.329 droeschl 1921: my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
1922: if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
1923: my $symb=&Apache::lonnet::symbclean(
1924: &Apache::lonnet::declutter('uploaded/'.
1925: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1926: $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
1927: '.sequence').
1928: '___'.$residx.'___'.
1929: &Apache::lonnet::declutter($url));
1930: (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
1931: $url=&Apache::lonnet::clutter($url);
1932: if ($url=~/^\/*uploaded\//) {
1933: $url=~/\.(\w+)$/;
1934: my $embstyle=&Apache::loncommon::fileembstyle($1);
1935: if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
1936: $url='/adm/wrapper'.$url;
1937: } elsif ($embstyle eq 'ssi') {
1938: #do nothing with these
1939: } elsif ($url!~/\.(sequence|page)$/) {
1940: $url='/adm/coursedocs/showdoc'.$url;
1941: }
1.344 bisitz 1942: } elsif ($url=~m|^/ext/|) {
1.329 droeschl 1943: $url='/adm/wrapper'.$url;
1944: $external = 1;
1945: }
1946: if (&Apache::lonnet::symbverify($symb,$url)) {
1947: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1948: } else {
1949: $url='';
1950: }
1951: if ($container eq 'page') {
1952: my $symb=$env{'form.pagesymb'};
1.364 bisitz 1953:
1.329 droeschl 1954: $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
1955: $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
1956: }
1957: }
1958: my ($parameterset,$rand_order_text) = (' ', ' ');
1959: if ($isfolder || $extension eq 'sequence') {
1960: my $foldername=&escape($foldertitle);
1961: my $folderpath=$env{'form.folderpath'};
1962: if ($folderpath) { $folderpath.='&' };
1.344 bisitz 1963: # Append randompick number, hidden, and encrypted with ":" to foldername,
1.329 droeschl 1964: # so it gets transferred between levels
1965: $folderpath.=$folderarg.'&'.$foldername.':'.(&LONCAPA::map::getparameter($orderidx,
1966: 'parameter_randompick'))[0]
1967: .':'.((&LONCAPA::map::getparameter($orderidx,
1968: 'parameter_hiddenresource'))[0]=~/^yes$/i)
1969: .':'.((&LONCAPA::map::getparameter($orderidx,
1970: 'parameter_encrypturl'))[0]=~/^yes$/i)
1971: .':'.((&LONCAPA::map::getparameter($orderidx,
1972: 'parameter_randomorder'))[0]=~/^yes$/i);
1973: $url.='folderpath='.&escape($folderpath).$cpinfo;
1974: $parameterset='<label>'.&mt('Randomly Pick: ').
1975: '<input type="text" size="4" onChange="this.form.changeparms.value='."'randompick'".';this.form.submit()" name="randompick_'.$orderidx.'" value="'.
1976: (&LONCAPA::map::getparameter($orderidx,
1977: 'parameter_randompick'))[0].
1978: '" />'.
1979: '<a href="javascript:void(0)">'.&mt('Save').'</a></label>';
1980: my $ro_set=
1981: ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
1982: $rand_order_text ='
1.369 bisitz 1983: <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>';
1.329 droeschl 1984: }
1985: if ($ispage) {
1986: my $pagename=&escape($pagetitle);
1987: my $pagepath;
1988: my $folderpath=$env{'form.folderpath'};
1989: if ($folderpath) { $pagepath = $folderpath.'&' };
1990: $pagepath.=$pagearg.'&'.$pagename;
1991: my $symb=$env{'form.pagesymb'};
1992: if (!$symb) {
1993: my $path='uploaded/'.
1994: $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
1995: $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
1996: $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
1997: $residx,
1998: $path.$pagearg.'.page');
1999: }
2000: $url.='pagepath='.&escape($pagepath).
2001: '&pagesymb='.&escape($symb).$cpinfo;
2002: }
2003: if ($external) {
2004: my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
2005: $external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
2006: } else {
2007: undef($external);
2008: }
2009: $line.='
2010: <td class="LC_docs_entry_icon">
2011: '.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
2012: </td>
2013: <td class="LC_docs_entry_title">
2014: '.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
2015: </td>";
2016: if (($allowed) && ($folder!~/^supplemental/)) {
2017: my %lt=&Apache::lonlocal::texthash(
2018: 'hd' => 'Hidden',
2019: 'ec' => 'URL hidden');
2020: my $enctext=
1.358 bisitz 2021: ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
1.329 droeschl 2022: my $hidtext=
1.358 bisitz 2023: ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
1.329 droeschl 2024: $line.=(<<ENDPARMS);
2025: <td class="LC_docs_entry_parameter">
2026: $form_start
1.369 bisitz 2027: <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
1.329 droeschl 2028: $form_end
2029: </td>
2030: <td class="LC_docs_entry_parameter">
2031: $form_start
1.369 bisitz 2032: <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
1.329 droeschl 2033: $form_end
2034: </td>
2035: <td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
2036: <td class="LC_docs_entry_parameter">$form_start $parameterset $form_end</td>
2037: ENDPARMS
2038: }
2039: $line.="</tr>";
2040: return $line;
2041: }
2042:
2043: =pod
2044:
2045: =item tiehash()
2046:
2047: tie the hash
2048:
2049: =cut
2050:
2051: sub tiehash {
2052: my ($mode)=@_;
2053: $hashtied=0;
2054: if ($env{'request.course.fn'}) {
2055: if ($mode eq 'write') {
2056: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
2057: &GDBM_WRCREAT(),0640)) {
2058: $hashtied=2;
2059: }
2060: } else {
2061: if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.".db",
2062: &GDBM_READER(),0640)) {
2063: $hashtied=1;
2064: }
2065: }
1.364 bisitz 2066: }
1.329 droeschl 2067: }
2068:
2069: sub untiehash {
2070: if ($hashtied) { untie %hash; }
2071: $hashtied=0;
2072: return OK;
2073: }
2074:
2075:
2076:
2077:
2078: sub checkonthis {
2079: my ($r,$url,$level,$title)=@_;
2080: $url=&unescape($url);
2081: $alreadyseen{$url}=1;
2082: $r->rflush();
2083: if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
2084: $r->print("\n<br />");
2085: if ($level==0) {
2086: $r->print("<br />");
2087: }
2088: for (my $i=0;$i<=$level*5;$i++) {
2089: $r->print(' ');
2090: }
2091: $r->print('<a href="'.$url.'" target="cat">'.
2092: ($title?$title:$url).'</a> ');
2093: if ($url=~/^\/res\//) {
2094: my $result=&Apache::lonnet::repcopy(
2095: &Apache::lonnet::filelocation('',$url));
2096: if ($result eq 'ok') {
2097: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
2098: $r->rflush();
2099: &Apache::lonnet::countacc($url);
2100: $url=~/\.(\w+)$/;
2101: if (&Apache::loncommon::fileembstyle($1) eq 'ssi') {
2102: $r->print('<br />');
2103: $r->rflush();
2104: for (my $i=0;$i<=$level*5;$i++) {
2105: $r->print(' ');
2106: }
2107: $r->print('- '.&mt('Rendering:').' ');
2108: my ($errorcount,$warningcount)=split(/:/,
2109: &Apache::lonnet::ssi_body($url,
2110: ('grade_target'=>'web',
2111: 'return_only_error_and_warning_counts' => 1)));
2112: if (($errorcount) ||
2113: ($warningcount)) {
2114: if ($errorcount) {
1.369 bisitz 2115: $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
1.329 droeschl 2116: &mt('[quant,_1,error]',$errorcount).'</span>');
2117: }
2118: if ($warningcount) {
2119: $r->print('<span class="LC_warning">'.
2120: &mt('[quant,_1,warning]',$warningcount).'</span>');
2121: }
2122: } else {
2123: $r->print('<span class="LC_success">'.&mt('ok').'</span>');
2124: }
2125: $r->rflush();
2126: }
2127: my $dependencies=
2128: &Apache::lonnet::metadata($url,'dependencies');
2129: foreach my $dep (split(/\,/,$dependencies)) {
2130: if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
2131: &checkonthis($r,$dep,$level+1);
2132: }
2133: }
2134: } elsif ($result eq 'unavailable') {
2135: $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
2136: } elsif ($result eq 'not_found') {
2137: unless ($url=~/\$/) {
2138: $r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
2139: } else {
1.366 bisitz 2140: $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
1.329 droeschl 2141: }
2142: } else {
2143: $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
2144: }
2145: }
2146: }
2147: }
2148:
2149:
2150:
2151: =pod
2152:
2153: =item list_symbs()
2154:
2155: List Symbs
2156:
2157: =cut
2158:
2159: sub list_symbs {
2160: my ($r) = @_;
2161:
2162: my $type = &Apache::loncommon::course_type();
2163: $r->print(&Apache::loncommon::start_page('Symb List'));
2164: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
2165: my $navmap = Apache::lonnavmaps::navmap->new();
2166: if (!defined($navmap)) {
2167: $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
2168: '<div class="LC_error">'.
2169: &mt('Unable to retrieve information about course contents').
2170: '</div>');
2171: &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
2172: } else {
2173: $r->print("<pre>\n");
2174: foreach my $res ($navmap->retrieveResources()) {
2175: $r->print($res->compTitle()."\t".$res->symb()."\n");
2176: }
2177: $r->print("\n</pre>\n");
2178: }
2179: $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
2180: }
2181:
2182:
2183: sub verifycontent {
2184: my ($r) = @_;
2185: my $type = &Apache::loncommon::course_type();
2186: my $loaderror=&Apache::lonnet::overloaderror($r);
2187: if ($loaderror) { return $loaderror; }
2188: $r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
2189: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
2190: $hashtied=0;
2191: undef %alreadyseen;
2192: %alreadyseen=();
2193: &tiehash();
2194: foreach my $key (keys(%hash)) {
2195: if ($hash{$key}=~/\.(page|sequence)$/) {
2196: if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
2197: $r->print('<hr /><span class="LC_error">'.
2198: &mt('The following sequence or page is included more than once in your '.$type.': ').
2199: &unescape($hash{$key}).'</span><br />'.
2200: &mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
2201: }
2202: }
2203: if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
2204: &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
2205: }
2206: }
2207: &untiehash();
2208: $r->print('<h1>'.&mt('Done').'.</h1>'.'<a href="/adm/coursedocs">'.
2209: &mt('Return to DOCS').'</a>');
2210: }
2211:
2212:
2213: sub devalidateversioncache {
2214: my $src=shift;
2215: &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
2216: &Apache::lonnet::clutter($src));
2217: }
2218:
2219: sub checkversions {
2220: my ($r) = @_;
2221: my $type = &Apache::loncommon::course_type();
2222: $r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
2223: $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
2224: my $header='';
2225: my $startsel='';
2226: my $monthsel='';
2227: my $weeksel='';
2228: my $daysel='';
2229: my $allsel='';
2230: my %changes=();
2231: my $starttime=0;
2232: my $haschanged=0;
2233: my %setversions=&Apache::lonnet::dump('resourceversions',
2234: $env{'course.'.$env{'request.course.id'}.'.domain'},
2235: $env{'course.'.$env{'request.course.id'}.'.num'});
2236:
2237: $hashtied=0;
2238: &tiehash();
2239: my %newsetversions=();
2240: if ($env{'form.setmostrecent'}) {
2241: $haschanged=1;
2242: foreach my $key (keys(%hash)) {
2243: if ($key=~/^ids\_(\/res\/.+)$/) {
2244: $newsetversions{$1}='mostrecent';
2245: &devalidateversioncache($1);
2246: }
2247: }
2248: } elsif ($env{'form.setcurrent'}) {
2249: $haschanged=1;
2250: foreach my $key (keys(%hash)) {
2251: if ($key=~/^ids\_(\/res\/.+)$/) {
2252: my $getvers=&Apache::lonnet::getversion($1);
2253: if ($getvers>0) {
2254: $newsetversions{$1}=$getvers;
2255: &devalidateversioncache($1);
2256: }
2257: }
2258: }
2259: } elsif ($env{'form.setversions'}) {
2260: $haschanged=1;
2261: foreach my $key (keys(%env)) {
2262: if ($key=~/^form\.set_version_(.+)$/) {
2263: my $src=$1;
2264: if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
2265: $newsetversions{$src}=$env{$key};
2266: &devalidateversioncache($src);
2267: }
2268: }
2269: }
2270: }
2271: if ($haschanged) {
2272: if (&Apache::lonnet::put('resourceversions',\%newsetversions,
2273: $env{'course.'.$env{'request.course.id'}.'.domain'},
1.344 bisitz 2274: $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
1.329 droeschl 2275: $r->print('<h1>'.&mt('Your Version Settings have been Saved').'</h1>');
2276: } else {
2277: $r->print('<h1><span class="LC_error">'.&mt('An Error Occured while Attempting to Save your Version Settings').'</span></h1>');
2278: }
2279: &mark_hash_old();
2280: }
2281: &changewarning($r,'');
2282: if ($env{'form.timerange'} eq 'all') {
2283: # show all documents
2284: $header=&mt('All Documents in '.$type);
2285: $allsel=1;
2286: foreach my $key (keys(%hash)) {
2287: if ($key=~/^ids\_(\/res\/.+)$/) {
2288: my $src=$1;
2289: $changes{$src}=1;
2290: }
2291: }
2292: } else {
2293: # show documents which changed
2294: %changes=&Apache::lonnet::dump
2295: ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
2296: $env{'course.'.$env{'request.course.id'}.'.num'});
2297: my $firstkey=(keys(%changes))[0];
2298: unless ($firstkey=~/^error\:/) {
2299: unless ($env{'form.timerange'}) {
2300: $env{'form.timerange'}=604800;
2301: }
2302: my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
2303: .&mt('seconds');
2304: if ($env{'form.timerange'}==-1) {
2305: $seltext='since start of course';
2306: $startsel='selected';
2307: $env{'form.timerange'}=time;
2308: }
2309: $starttime=time-$env{'form.timerange'};
2310: if ($env{'form.timerange'}==2592000) {
2311: $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2312: $monthsel='selected';
2313: } elsif ($env{'form.timerange'}==604800) {
2314: $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2315: $weeksel='selected';
2316: } elsif ($env{'form.timerange'}==86400) {
2317: $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
2318: $daysel='selected';
2319: }
2320: $header=&mt('Content changed').' '.$seltext;
2321: } else {
2322: $header=&mt('No content modifications yet.');
2323: }
2324: }
2325: %setversions=&Apache::lonnet::dump('resourceversions',
2326: $env{'course.'.$env{'request.course.id'}.'.domain'},
2327: $env{'course.'.$env{'request.course.id'}.'.num'});
2328: my %lt=&Apache::lonlocal::texthash
2329: ('st' => 'Version changes since start of '.$type,
2330: 'lm' => 'Version changes since last Month',
2331: 'lw' => 'Version changes since last Week',
2332: 'sy' => 'Version changes since Yesterday',
2333: 'al' => 'All Resources (possibly large output)',
2334: 'sd' => 'Display',
2335: 'fi' => 'File',
2336: 'md' => 'Modification Date',
2337: 'mr' => 'Most recently published Version',
2338: 've' => 'Version used in '.$type,
2339: 'vu' => 'Set Version to be used in '.$type,
2340: 'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
2341: 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
2342: 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
2343: 'di' => 'Differences');
2344: $r->print(<<ENDHEADERS);
2345: <form action="/adm/coursedocs" method="post">
2346: <input type="hidden" name="versions" value="1" />
2347: <input type="submit" name="setmostrecent" value="$lt{'sm'}" />
2348: <input type="submit" name="setcurrent" value="$lt{'sc'}" /><hr />
2349: <select name="timerange">
2350: <option value='all' $allsel>$lt{'al'}</option>
2351: <option value="-1" $startsel>$lt{'st'}</option>
2352: <option value="2592000" $monthsel>$lt{'lm'}</option>
2353: <option value="604800" $weeksel>$lt{'lw'}</option>
2354: <option value="86400" $daysel>$lt{'sy'}</option>
2355: </select>
2356: <input type="submit" name="display" value="$lt{'sd'}" />
2357: <h3>$header</h3>
2358: <input type="submit" name="setversions" value="$lt{'sv'}" />
2359: <table border="0">
2360: ENDHEADERS
2361: foreach my $key (sort(keys(%changes))) {
2362: if ($changes{$key}>$starttime) {
2363: my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
2364: my $currentversion=&Apache::lonnet::getversion($key);
2365: if ($currentversion<0) {
2366: $currentversion=&mt('Could not be determined.');
2367: }
2368: my $linkurl=&Apache::lonnet::clutter($key);
2369: $r->print(
2370: '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
2371: &Apache::lonnet::gettitle($linkurl).
2372: '</b></font></td></tr>'.
2373: '<tr><td> </td>'.
2374: '<td colspan="4">'.
2375: '<a href="'.$linkurl.'" target="cat">'.$linkurl.
2376: '</a></td></tr>'.
2377: '<tr><td></td>'.
2378: '<td title="'.$lt{'md'}.'">'.
2379: &Apache::lonlocal::locallocaltime(
2380: &Apache::lonnet::metadata($root.'.'.$extension,
2381: 'lastrevisiondate')
2382: ).
2383: '</td>'.
2384: '<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
2385: '<font size="+1">'.$currentversion.'</font>'.
2386: '</span></td>'.
2387: '<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
2388: '<font size="+1">');
2389: # Used in course
2390: my $usedversion=$hash{'version_'.$linkurl};
2391: if (($usedversion) && ($usedversion ne 'mostrecent')) {
2392: $r->print($usedversion);
2393: } else {
2394: $r->print($currentversion);
2395: }
2396: $r->print('</font></span></td><td title="'.$lt{'vu'}.'">'.
2397: '<span class="LC_nobreak">Use: ');
2398: # Set version
2399: $r->print(&Apache::loncommon::select_form($setversions{$linkurl},
2400: 'set_version_'.$linkurl,
2401: ('select_form_order' =>
2402: ['',1..$currentversion,'mostrecent'],
2403: '' => '',
2404: 'mostrecent' => 'most recent',
2405: map {$_,$_} (1..$currentversion))));
2406: $r->print('</span></td></tr><tr><td></td>');
2407: my $lastold=1;
2408: for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
2409: my $url=$root.'.'.$prevvers.'.'.$extension;
2410: if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
2411: $starttime) {
2412: $lastold=$prevvers;
2413: }
2414: }
1.364 bisitz 2415: #
1.329 droeschl 2416: # Code to figure out how many version entries should go in
2417: # each of the four columns
2418: my $entries_per_col = 0;
2419: my $num_entries = ($currentversion-$lastold);
2420: if ($num_entries % 4 == 0) {
2421: $entries_per_col = $num_entries/4;
2422: } else {
2423: $entries_per_col = $num_entries/4 + 1;
2424: }
2425: my $entries_count = 0;
1.344 bisitz 2426: $r->print('<td valign="top"><font size="-2">');
1.329 droeschl 2427: my $cols_output = 1;
2428: for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
2429: my $url=$root.'.'.$prevvers.'.'.$extension;
2430: $r->print('<span class="LC_nobreak"><a href="'.&Apache::lonnet::clutter($url).
2431: '">'.&mt('Version').' '.$prevvers.'</a> ('.
2432: &Apache::lonlocal::locallocaltime(
2433: &Apache::lonnet::metadata($url,
2434: 'lastrevisiondate')
2435: ).
2436: ')');
2437: if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
2438: $r->print(' <a href="/adm/diff?filename='.
2439: &Apache::lonnet::clutter($root.'.'.$extension).
2440: '&versionone='.$prevvers.
2441: '">'.&mt('Diffs').'</a>');
2442: }
2443: $r->print('</span><br />');
2444: if (++$entries_count % $entries_per_col == 0) {
2445: $r->print('</font></td>');
2446: if ($cols_output != 4) {
2447: $r->print('<td valign="top"><font size="-2">');
2448: $cols_output++;
2449: }
2450: }
2451: }
2452: while($cols_output++ < 4) {
2453: $r->print('</font></td><td><font>')
2454: }
2455: $r->print('</font></td></tr>'."\n");
2456: }
2457: }
2458: $r->print('</table></form>');
2459: $r->print('<h1>'.&mt('Done').'.</h1>');
2460:
2461: &untiehash();
2462: }
2463:
2464: sub mark_hash_old {
2465: my $retie_hash=0;
2466: if ($hashtied) {
2467: $retie_hash=1;
2468: &untiehash();
2469: }
2470: &tiehash('write');
2471: $hash{'old'}=1;
2472: &untiehash();
2473: if ($retie_hash) { &tiehash(); }
2474: }
2475:
2476: sub is_hash_old {
2477: my $untie_hash=0;
2478: if (!$hashtied) {
2479: $untie_hash=1;
2480: &tiehash();
2481: }
2482: my $return=$hash{'old'};
2483: if ($untie_hash) { &untiehash(); }
2484: return $return;
2485: }
2486:
2487: sub changewarning {
2488: my ($r,$postexec,$message,$url)=@_;
2489: if (!&is_hash_old()) { return; }
2490: my $pathvar='folderpath';
2491: my $path=&escape($env{'form.folderpath'});
2492: if (!defined($url)) {
2493: if (defined($env{'form.pagepath'})) {
2494: $pathvar='pagepath';
2495: $path=&escape($env{'form.pagepath'});
2496: $path.='&pagesymb='.&escape($env{'form.pagesymb'});
2497: }
2498: $url='/adm/coursedocs?'.$pathvar.'='.$path;
2499: }
2500: my $course_type = &Apache::loncommon::course_type();
2501: if (!defined($message)) {
2502: $message='Changes will become active for your current session after [_1], or the next time you log in.';
2503: }
2504: $r->print("\n\n".
1.369 bisitz 2505: '<script type="text/javascript">'.
2506: '// <![CDATA['.
2507: 'function reinit(tf) { tf.submit();'.$postexec.' }'.
2508: '// ]]>'.
2509: '</script>'."\n".
1.329 droeschl 2510: '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
2511: '<input type="hidden" name="orgurl" value="'.$url.
2512: '" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
2513: &mt($message,' <input type="hidden" name="'.
2514: $env{'request.role'}.'" value="1" /><input type="button" value="'.
1.369 bisitz 2515: &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
1.329 droeschl 2516: $help{'Caching'}.'</span></h3></form>'."\n\n");
2517: }
2518:
2519:
2520: sub init_breadcrumbs {
2521: my ($form,$text)=@_;
2522: &Apache::lonhtmlcommon::clear_breadcrumbs();
2523: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
2524: text=>"Edit ".&Apache::loncommon::course_type(),
2525: faq=>273,
2526: bug=>'Instructor Interface',
2527: help => 'Docs_Adding_Course_Doc'});
2528: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs?".$form.'=1',
2529: text=>$text,
2530: faq=>273,
2531: bug=>'Instructor Interface'});
2532: }
2533:
2534:
2535:
2536:
2537: sub handler {
2538: my $r = shift;
2539: &Apache::loncommon::content_type($r,'text/html');
2540: $r->send_http_header;
2541: return OK if $r->header_only;
2542: my $type = &Apache::loncommon::course_type();
2543:
2544:
2545: # --------------------------------------------- Initialize help topics for this
2546: foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
2547: 'Adding_External_Resource','Navigate_Content',
2548: 'Adding_Folders','Docs_Overview', 'Load_Map',
2549: 'Supplemental','Score_Upload_Form','Adding_Pages',
2550: 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
2551: 'Check_Resource_Versions','Verify_Content') {
2552: $help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
2553: }
2554: # Composite help files
2555: $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
2556: 'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
2557: $help{'Simple Page'} = &Apache::loncommon::help_open_topic(
2558: 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages');
2559: $help{'Simple Problem'} = &Apache::loncommon::help_open_topic(
2560: 'Option_Response_Simple');
2561: $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic(
2562: 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages');
1.347 weissno 2563: $help{'My Personal Information Page'} = &Apache::loncommon::help_open_topic(
1.329 droeschl 2564: 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
1.353 weissno 2565: $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
1.329 droeschl 2566: $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
2567:
2568: # does this user have privileges to modify docs
2569: my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
2570: if ($allowed && $env{'form.verify'}) {
2571: &init_breadcrumbs('verify','Verify Content');
2572: &verifycontent($r);
2573: } elsif ($allowed && $env{'form.listsymbs'}) {
2574: &init_breadcrumbs('listsymbs','List Symbs');
2575: &list_symbs($r);
2576: } elsif ($allowed && $env{'form.docslog'}) {
2577: &init_breadcrumbs('docslog','Show Log');
2578: &docs_change_log($r);
2579: } elsif ($allowed && $env{'form.versions'}) {
2580: &init_breadcrumbs('versions','Check/Set Resource Versions');
2581: &checkversions($r);
2582: } elsif ($allowed && $env{'form.dumpcourse'}) {
2583: &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
2584: &dumpcourse($r);
2585: } elsif ($allowed && $env{'form.exportcourse'}) {
2586: &init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
2587: &exportcourse($r);
2588: } else {
2589: # is this a standard course?
2590:
2591: my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
2592: my $forcestandard = 0;
2593: my $forcesupplement;
2594: my $script='';
2595: my $showdoc=0;
2596: my $containertag;
2597: my $uploadtag;
2598:
2599:
2600: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
2601: ['folderpath','pagepath',
2602: 'pagesymb']);
2603: # No folderpath, no pagepath, see if we have something stored
2604: if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
2605: &Apache::loncommon::restore_course_settings('docs_folderpath',
2606: {'folderpath' => 'scalar'});
2607: }
2608: if (!$env{'form.folderpath'}) {
2609: &Apache::loncommon::restore_course_settings('docs_folderpath',
2610: {'pagepath' => 'scalar'});
2611: }
2612: if ($env{'form.pagepath'}) {
2613: $env{'form.folderpath'}='';
2614: }
2615: if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
2616: $env{'form.folderpath'} = 'supplemental&'.
2617: &escape(&mt('Supplemental '.$type.' Documents')).'&'.
2618: $env{'form.folderpath'};
2619: }
2620: &Apache::loncommon::store_course_settings('docs_folderpath',
2621: {'pagepath' => 'scalar',
2622: 'folderpath' => 'scalar'});
2623: if ($env{'form.folderpath'}) {
2624: my (@folderpath)=split('&',$env{'form.folderpath'});
2625: $env{'form.foldername'}=&unescape(pop(@folderpath));
2626: $env{'form.folder'}=pop(@folderpath);
2627: }
2628: if ($env{'form.pagepath'}) {
2629: my (@pagepath)=split('&',$env{'form.pagepath'});
2630: $env{'form.pagename'}=&unescape(pop(@pagepath));
2631: $env{'form.folder'}=pop(@pagepath);
2632: $containertag = '<input type="hidden" name="pagepath" value="" />'.
2633: '<input type="hidden" name="pagesymb" value="" />';
2634: $uploadtag = '<input type="hidden" name="pagepath" value="'.&HTML::Entities::encode($env{'form.pagepath'},'<>&"').'" />'.
2635: '<input type="hidden" name="pagesymb" value="'.&HTML::Entities::encode($env{'form.pagesymb'},'<>&"').'" />';
2636: }
2637: if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
2638: $showdoc='/'.$1;
2639: }
2640: unless ($showdoc) { # got called from remote
1.344 bisitz 2641: if (($env{'form.folder'}=~/^(?:group|default)_/) ||
1.329 droeschl 2642: ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
2643: $forcestandard = 1;
1.364 bisitz 2644: }
1.329 droeschl 2645: $forcesupplement=($env{'form.folder'}=~/^supplemental_/);
2646:
1.344 bisitz 2647: if ($allowed) {
1.329 droeschl 2648: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
1.344 bisitz 2649: $script=&Apache::lonratedt::editscript('simple');
1.329 droeschl 2650: }
2651: } else { # got called in sequence from course
2652: $allowed=0;
2653: }
2654:
2655: # get course data
2656: my $coursenum=$env{'course.'.$env{'request.course.id'}.'.num'};
2657: my $coursedom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2658:
1.344 bisitz 2659: # get personal data
1.329 droeschl 2660: my $uname=$env{'user.name'};
2661: my $udom=$env{'user.domain'};
2662: my $plainname=&escape(&Apache::loncommon::plainname($uname,$udom));
2663:
2664: # graphics settings
2665:
2666: $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
2667:
2668: if ($allowed) {
2669: $script .= &editing_js($udom,$uname);
2670: }
2671: # -------------------------------------------------------------------- Body tag
1.369 bisitz 2672: $script = '<script type="text/javascript">'."\n"
2673: .'// <![CDATA['
2674: .$script
2675: .'// ]]>'
2676: ."\n".'</script>';
1.329 droeschl 2677: my $brcrum = [{href=>"/adm/createuser",text=>"$type Documents"}];
2678: $r->print(&Apache::loncommon::start_page("$type Documents", $script,
2679: {'force_register' => $showdoc,
2680: 'bread_crumbs' => $brcrum}).
2681: &Apache::loncommon::help_open_menu('','',273,'RAT'));
1.364 bisitz 2682:
1.329 droeschl 2683: my %allfiles = ();
2684: my %codebase = ();
2685: my ($upload_result,$upload_output);
2686: if ($allowed) {
2687: if (($env{'form.uploaddoc.filename'}) &&
2688: ($env{'form.cmd'}=~/^upload_(\w+)/)) {
1.344 bisitz 2689: # Process file upload - phase one - upload and parse primary file.
1.329 droeschl 2690: undef($hadchanges);
2691: $upload_result = &process_file_upload(\$upload_output,$coursenum,
2692: $coursedom,\%allfiles,
2693: \%codebase,$1);
2694: if ($hadchanges) {
2695: &mark_hash_old();
2696: }
2697: if ($upload_result eq 'phasetwo') {
2698: $r->print($upload_output);
2699: }
2700: } elsif ($env{'form.phasetwo'}) {
2701: my %newname = ();
2702: my %origname = ();
2703: my %attribs = ();
2704: my $updateflag = 0;
2705: my $residx = $env{'form.newidx'};
2706: my $primary_url = &unescape($env{'form.primaryurl'});
2707: # Process file upload - phase two - gather secondary files.
2708: for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
2709: if ($env{'form.embedded_item_'.$i.'.filename'}) {
2710: my $javacodebase;
2711: $newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
2712: $origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
2713: if (exists($env{'form.embedded_codebase_'.$i})) {
1.344 bisitz 2714: $javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
2715: $origname{$i} =~ s#^\Q$javacodebase\E/##;
1.329 droeschl 2716: }
2717: my @attributes = ();
2718: if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
2719: @attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
2720: } else {
2721: @attributes = ($env{'form.embedded_attrib_'.$i});
2722: }
2723: foreach my $attr (@attributes) {
2724: push(@{$attribs{$i}},&unescape($attr));
2725: }
2726: if ($javacodebase) {
2727: $codebase{$i} = $javacodebase;
2728: $codebase{$i} =~ s#/$##;
2729: $updateflag = 1;
2730: }
2731: }
2732: unless ($newname{$i} eq $origname{$i}) {
2733: $updateflag = 1;
2734: }
2735: }
2736: # Process file upload - phase three - modify primary file
2737: if ($updateflag) {
2738: my ($content,$rtncode);
2739: my $updateflag = 0;
2740: my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
2741: if ($getstatus eq 'ok') {
2742: foreach my $item (keys(%newname)) {
2743: if ($newname{$item} ne $origname{$item}) {
2744: my $attrib_regexp = '';
2745: if (@{$attribs{$item}} > 1) {
2746: $attrib_regexp = join('|',@{$attribs{$item}});
2747: } else {
2748: $attrib_regexp = $attribs{$item}[0];
2749: }
2750: if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
1.364 bisitz 2751: }
1.344 bisitz 2752: $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
1.329 droeschl 2753: }
2754: if (exists($codebase{$item})) {
2755: $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
2756: }
2757: }
2758: # Save edited file.
2759: my $saveresult;
2760: my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
2761: my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
2762: my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
2763: } else {
1.344 bisitz 2764: &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
1.329 droeschl 2765: }
2766: }
2767: }
2768: }
2769:
2770: unless ($showdoc || $upload_result eq 'phasetwo') {
2771: # -----------------------------------------------------------------------------
2772: my %lt=&Apache::lonlocal::texthash(
2773: 'uplm' => 'Upload a new main '.lc($type).' document',
2774: 'upls' => 'Upload a new supplemental '.lc($type).' document',
2775: 'impp' => 'Import a document',
2776: 'pubd' => 'Published Documents',
2777: 'copm' => 'All documents out of a published map into this folder',
2778: 'upld' => 'Upload Document',
2779: 'srch' => 'Search',
2780: 'impo' => 'Import',
2781: 'book' => 'Import Bookmarks',
2782: 'selm' => 'Select Map',
2783: 'load' => 'Load Map',
2784: 'reco' => 'Recover Deleted Resources',
2785: 'newf' => 'New Folder',
2786: 'newp' => 'New Composite Page',
2787: 'extr' => 'External Resource',
2788: 'syll' => 'Syllabus',
2789: 'navc' => 'Navigate Contents',
1.343 biermanm 2790: 'sipa' => 'Simple Course Page',
1.329 droeschl 2791: 'sipr' => 'Simple Problem',
2792: 'drbx' => 'Drop Box',
2793: 'scuf' => 'Score Upload Form',
1.336 schafran 2794: 'bull' => 'Discussion Board',
1.347 weissno 2795: 'mypi' => 'My Personal Information Page',
1.353 weissno 2796: 'grpo' => 'Group Portfolio',
1.329 droeschl 2797: 'rost' => 'Course Roster',
1.348 weissno 2798: 'abou' => 'Personal Information Page for a User',
1.329 droeschl 2799: 'imsf' => 'Import IMS package',
2800: 'file' => 'File',
2801: 'title' => 'Title',
2802: 'comment' => 'Comment',
2803: 'parse' => 'Upload embedded images/multimedia files if HTML file!',
1.368 truskell 2804: 'nd' => 'Upload Document',
1.329 droeschl 2805: 'pm' => 'Published Map',
2806: 'sd' => 'Special Document',
2807: 'mo' => 'More Options',
2808: 'hao' => 'Hide all Options'
2809: );
2810: # -----------------------------------------------------------------------------
2811: my $fileupload=(<<FIUP);
2812: $lt{'file'}:<br />
2813: <input type="file" name="uploaddoc" size="40" />
2814: FIUP
2815:
2816: my $checkbox=(<<CHBO);
2817: <!-- <label>$lt{'parse'}?
2818: <input type="checkbox" name="parserflag" />
2819: </label> -->
2820: <label>
2821: <input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
2822: </label>
2823: CHBO
2824:
2825: my $fileuploadform=(<<FUFORM);
2826: <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.371 ! tempelho 2827: <input type="hidden" name="active" value="aa" />
1.329 droeschl 2828: $fileupload
2829: <br />
2830: $lt{'title'}:<br />
2831: <input type="text" size="50" name="comment" />
2832: $uploadtag
2833: <input type="hidden" name="cmd" value="upload_default" />
2834: <br />
2835: <span class="LC_nobreak">
2836: $checkbox
2837: </span>
2838: <br />
2839: <br />
2840: <span class="LC_nobreak">
2841: <input type="submit" value="$lt{'upld'}" />
2842: $help{'Uploading_From_Harddrive'}
2843: </span>
2844: </form>
2845: FUFORM
2846:
2847: my $simpleeditdefaultform=(<<SEDFFORM);
2848: <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
1.371 ! tempelho 2849: <input type="hidden" name="active" value="bb" />
1.329 droeschl 2850: $lt{'pubd'}<br />
2851: $uploadtag
1.369 bisitz 2852: <input type="button" onclick="javascript:groupsearch()" value="$lt{'srch'}" />
1.329 droeschl 2853: <br />
2854: <span class="LC_nobreak">
1.369 bisitz 2855: <input type="button" onclick="javascript:groupimport();" value="$lt{'impo'}" />
1.329 droeschl 2856: $help{'Importing_LON-CAPA_Resource'}
2857: </span>
2858: <br />
1.369 bisitz 2859: <input type="button" onclick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
1.329 droeschl 2860: <hr />
2861: <p>
2862: $lt{'copm'}<br />
2863: <input type="text" size="40" name="importmap" /><br />
1.344 bisitz 2864: <span class="LC_nobreak"><input type="button"
1.369 bisitz 2865: onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
1.329 droeschl 2866: value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
2867: $help{'Load_Map'}</span>
2868: </p>
2869: </form>
2870: SEDFFORM
2871:
2872: my $extresourcesform=(<<ERFORM);
2873: <form action="/adm/coursedocs" method="post" name="newext">
2874: $uploadtag
2875: <input type="hidden" name="importdetail" value="" />
2876: <span class="LC_nobreak">
1.369 bisitz 2877: <input name="newext" type="button" onclick="javascript:makenewext('newext');"
1.329 droeschl 2878: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
2879: </span>
2880: </form>
2881: ERFORM
2882:
2883: if ($allowed) {
2884: &update_paste_buffer($coursenum,$coursedom);
2885: my %lt=&Apache::lonlocal::texthash(
2886: 'vc' => 'Verify Content',
2887: 'cv' => 'Check/Set Resource Versions',
2888: 'ls' => 'List Symbs',
2889: 'sl' => 'Show Log'
2890: );
2891:
2892: my $folderpath=$env{'form.folderpath'};
2893: if (!$folderpath) {
2894: if ($env{'form.folder'} eq '' ||
2895: $env{'form.folder'} eq 'supplemental') {
2896: $folderpath='default&'.
2897: &escape(&mt('Main '.$type.' Documents'));
2898: }
2899: }
2900: unless ($env{'form.pagepath'}) {
2901: $containertag = '<input type="hidden" name="folderpath" value="" />';
2902: $uploadtag = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
2903: }
1.337 ehlerst 2904: $r->print(<<HIDDENFORM);
2905: <form name="renameform" method="post" action="/adm/coursedocs">
2906: <input type="hidden" name="title" />
2907: <input type="hidden" name="cmd" />
2908: <input type="hidden" name="markcopy" />
2909: <input type="hidden" name="copyfolder" />
2910: $containertag
2911: </form>
2912: <form name="simpleedit" method="post" action="/adm/coursedocs">
2913: <input type="hidden" name="importdetail" value="" />
2914: $uploadtag
2915: </form>
2916: HIDDENFORM
1.329 droeschl 2917: }
1.335 ehlerst 2918: # --------------------------------------------------------- Main tab structure
2919: my $activeClass = 1;
1.355 ehlerst 2920: my $active = '';
1.339 ehlerst 2921: $r->print('<ul class="LC_TabContentBigger" id="mainnav">');
1.362 ehlerst 2922: if (($standard) && ($allowed) && (!$forcesupplement) && (($env{'form.folderpath'}=~/^default/) || ($env{'form.pagepath'}))) {
1.335 ehlerst 2923: if($activeClass == 1){
2924: $active = 'class="active"';
2925: $activeClass = 0;
2926: }
2927: }
1.359 tempelho 2928: $r->print('<li '.$active.'onclick="javascript:showPage(this,\'mainCourseDocuments\',\'mainnav\',\'maincoursedoc\');">'.&mt('Main Course Documents').'</li>');
1.355 ehlerst 2929: $active = '';
1.356 tempelho 2930: if (!$forcestandard || ($env{'form.folderpath'}=~/^supplemental/)) {
1.335 ehlerst 2931: if($activeClass == 1){
2932: $active = 'class="active"';
2933: }
2934: }
1.355 ehlerst 2935: $r->print('<li '.$active.'onclick="javascript:showPage(this,\'Supplemental Course Documents\',\'mainnav\',\'maincoursedoc\');">'.&mt('Supplemental Course Documents').'</li>');
1.370 bisitz 2936: $r->print('</ul><div class="LC_Box" style="margin:0 0;padding:0 0;"><div id="maincoursedoc" style="margin:0 0;padding:0 0;">');
1.329 droeschl 2937: # --------------------------------------------------------- Standard documents
1.356 tempelho 2938: my $savefolderpath;
1.335 ehlerst 2939: my $active = 'style="display: none;"';
2940: if($activeClass == 0){
2941: $active = 'style="display: block;"';
2942: }
1.359 tempelho 2943: $r->print('<div class="LC_ContentBox" id="mainCourseDocuments" '.$active.'>');
1.329 droeschl 2944: my $folder=$env{'form.folder'};
1.356 tempelho 2945: if ($folder eq '' || $folder=~/^supplemental/) {
1.329 droeschl 2946: $folder='default';
1.356 tempelho 2947: $savefolderpath = $env{'form.folderpath'};
1.329 droeschl 2948: $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
2949: $uploadtag = '<input type="hidden" name="folderpath" value="'.
2950: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
2951: }
2952: my $postexec='';
2953: if ($folder eq 'default') {
1.369 bisitz 2954: $r->print('<script type="text/javascript">'
2955: .'// <![CDATA['
2956: .'this.window.name="loncapaclient";'
2957: .'// ]]>'
2958: .'</script>'
2959: );
1.329 droeschl 2960: } else {
2961: #$postexec='self.close();';
2962: }
2963: my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2964: '.sequence';
2965: my $pageseq = '/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
2966: '.page';
2967: my $container='sequence';
2968: if ($env{'form.pagepath'}) {
2969: $container='page';
2970: }
2971: my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
2972:
2973:
2974:
2975: my $recoverform=(<<RFORM);
2976: <form action="/adm/groupsort" method="post" name="recover">
1.369 bisitz 2977: <input type="button" name="recovermap" onclick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
1.329 droeschl 2978: </form>
2979: RFORM
2980:
2981: my $imspform=(<<IMSPFORM);
2982: <form action="/adm/imsimportdocs" method="post" name="ims">
2983: <input type="hidden" name="folder" value="$folder" />
1.369 bisitz 2984: <input name="imsimport" type="button" value="$lt{'imsf'}" onclick="javascript:makeims();" />
1.329 droeschl 2985: </form>
2986: IMSPFORM
2987:
2988: my $newnavform=(<<NNFORM);
2989: <form action="/adm/coursedocs" method="post" name="newnav">
1.371 ! tempelho 2990: <input type="hidden" name="active" value="cc" />
1.329 droeschl 2991: $uploadtag
2992: <input type="hidden" name="importdetail"
2993: value="$lt{'navc'}=/adm/navmaps" />
2994: <span class="LC_nobreak">
2995: <input name="newnav" type="submit" value="$lt{'navc'}" />
2996: $help{'Navigate_Content'}
2997: </span>
2998: </form>
2999: NNFORM
3000: my $newsmppageform=(<<NSPFORM);
3001: <form action="/adm/coursedocs" method="post" name="newsmppg">
1.371 ! tempelho 3002: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3003: $uploadtag
3004: <input type="hidden" name="importdetail" value="" />
3005: <span class="LC_nobreak">
3006: <input name="newsmppg" type="button" value="$lt{'sipa'}"
1.369 bisitz 3007: onclick="javascript:makesmppage();" /> $help{'Simple Page'}
1.329 droeschl 3008: </span>
3009: </form>
3010: NSPFORM
3011:
3012: my $newsmpproblemform=(<<NSPROBFORM);
3013: <form action="/adm/coursedocs" method="post" name="newsmpproblem">
1.371 ! tempelho 3014: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3015: $uploadtag
3016: <input type="hidden" name="importdetail" value="" />
3017: <span class="LC_nobreak">
3018: <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
1.369 bisitz 3019: onclick="javascript:makesmpproblem();" />$help{'Simple Problem'}
1.329 droeschl 3020: </span>
3021: </form>
3022:
3023: NSPROBFORM
3024:
3025: my $newdropboxform=(<<NDBFORM);
3026: <form action="/adm/coursedocs" method="post" name="newdropbox">
1.371 ! tempelho 3027: <input type="hidden" name="active" value="cc" />
1.344 bisitz 3028: $uploadtag
1.329 droeschl 3029: <input type="hidden" name="importdetail" value="" />
1.344 bisitz 3030: <span class="LC_nobreak">
1.329 droeschl 3031: <input name="newdropbox" type="button" value="$lt{'drbx'}"
1.369 bisitz 3032: onclick="javascript:makedropbox();" />
1.344 bisitz 3033: </span>
3034: </form>
1.329 droeschl 3035: NDBFORM
3036:
3037: my $newexuploadform=(<<NEXUFORM);
3038: <form action="/adm/coursedocs" method="post" name="newexamupload">
1.371 ! tempelho 3039: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3040: $uploadtag
3041: <input type="hidden" name="importdetail" value="" />
3042: <span class="LC_nobreak">
3043: <input name="newexamupload" type="button" value="$lt{'scuf'}"
1.369 bisitz 3044: onclick="javascript:makeexamupload();" />
1.329 droeschl 3045: $help{'Score_Upload_Form'}
3046: </span>
3047: </form>
3048: NEXUFORM
3049:
3050: my $newbulform=(<<NBFORM);
3051: <form action="/adm/coursedocs" method="post" name="newbul">
1.371 ! tempelho 3052: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3053: $uploadtag
3054: <input type="hidden" name="importdetail" value="" />
3055: <span class="LC_nobreak">
3056: <input name="newbulletin" type="button" value="$lt{'bull'}"
1.369 bisitz 3057: onclick="javascript:makebulboard();" />
1.329 droeschl 3058: $help{'Bulletin Board'}
3059: </span>
3060: </form>
3061: NBFORM
3062:
3063: my $newaboutmeform=(<<NAMFORM);
3064: <form action="/adm/coursedocs" method="post" name="newaboutme">
1.371 ! tempelho 3065: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3066: $uploadtag
3067: <input type="hidden" name="importdetail"
3068: value="$plainname=/adm/$udom/$uname/aboutme" />
3069: <span class="LC_nobreak">
3070: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.347 weissno 3071: $help{'My Personal Information Page'}
1.329 droeschl 3072: </span>
3073: </form>
3074: NAMFORM
3075:
3076: my $newaboutsomeoneform=(<<NASOFORM);
3077: <form action="/adm/coursedocs" method="post" name="newaboutsomeone">
1.371 ! tempelho 3078: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3079: $uploadtag
3080: <input type="hidden" name="importdetail" value="" />
3081: <span class="LC_nobreak">
3082: <input name="newaboutsomeone" type="button" value="$lt{'abou'}"
1.369 bisitz 3083: onclick="javascript:makeabout();" />
1.329 droeschl 3084: </span>
3085: </form>
3086: NASOFORM
3087:
3088:
3089: my $newrosterform=(<<NROSTFORM);
3090: <form action="/adm/coursedocs" method="post" name="newroster">
1.371 ! tempelho 3091: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3092: $uploadtag
3093: <input type="hidden" name="importdetail"
3094: value="$lt{'rost'}=/adm/viewclasslist" />
3095: <span class="LC_nobreak">
3096: <input name="newroster" type="submit" value="$lt{'rost'}" />
3097: $help{'Course Roster'}
3098: </span>
3099: </form>
3100: NROSTFORM
3101:
1.342 ehlerst 3102: my $specialdocumentsform;
1.351 ehlerst 3103: my $newfolderform;
1.342 ehlerst 3104:
1.329 droeschl 3105: unless ($env{'form.pagepath'}) {
3106: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3107:
3108: my $newpageform=(<<NPFORM);
3109: <form action="/adm/coursedocs" method="post" name="newpage">
3110: <input type="hidden" name="folderpath" value="$path" />
3111: <input type="hidden" name="importdetail" value="" />
1.371 ! tempelho 3112: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3113: <span class="LC_nobreak">
3114: <input name="newpage" type="button"
1.369 bisitz 3115: onclick="javascript:makenewpage(this.form,'$pageseq');"
1.329 droeschl 3116: value="$lt{'newp'}" />$help{'Adding_Pages'}
3117: </span>
3118: </form>
3119: NPFORM
3120:
1.351 ehlerst 3121: $newfolderform=(<<NFFORM);
1.329 droeschl 3122: <form action="/adm/coursedocs" method="post" name="newfolder">
3123: <input type="hidden" name="folderpath" value="$path" />
3124: <input type="hidden" name="importdetail" value="" />
1.371 ! tempelho 3125: <input type="hidden" name="active" value="aa" />
1.329 droeschl 3126: <span class="LC_nobreak">
3127: <input name="newfolder" type="button"
1.369 bisitz 3128: onclick="javascript:makenewfolder(this.form,'$folderseq');"
1.329 droeschl 3129: value="$lt{'newf'}" />$help{'Adding_Folders'}
3130: </span>
3131: </form>
3132: NFFORM
3133:
3134: my $newsylform=(<<NSYLFORM);
3135: <form action="/adm/coursedocs" method="post" name="newsyl">
1.371 ! tempelho 3136: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3137: $uploadtag
3138: <input type="hidden" name="importdetail"
3139: value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
3140: <span class="LC_nobreak">
3141: <input name="newsyl" type="submit" value="$lt{'syll'}" />
3142: $help{'Syllabus'}
3143: </span>
3144: </form>
3145: NSYLFORM
1.364 bisitz 3146:
1.329 droeschl 3147: my $newgroupfileform=(<<NGFFORM);
3148: <form action="/adm/coursedocs" method="post" name="newgroupfiles">
1.371 ! tempelho 3149: <input type="hidden" name="active" value="cc" />
1.329 droeschl 3150: $uploadtag
3151: <input type="hidden" name="importdetail"
3152: value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
3153: <span class="LC_nobreak">
3154: <input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
1.353 weissno 3155: $help{'Group Portfolio'}
1.329 droeschl 3156: </span>
3157: </form>
3158: NGFFORM
3159:
1.351 ehlerst 3160: $specialdocumentsform="<br />$newpageform<br />$newsylform<br />$newgroupfileform";
1.342 ehlerst 3161: }
3162: $specialdocumentsform.="<br />$newnavform<br />$newsmppageform
3163: <br />$newsmpproblemform<br />$newdropboxform
3164: <br />$newexuploadform<br />$newbulform
3165: <br />$newaboutmeform<br />$newaboutsomeoneform
3166: <br />$newrosterform";
3167: if($env{'form.pagepath'}) {
3168: $specialdocumentsform="<br />$newsmpproblemform<br />$newexuploadform";
3169: }
1.331 muellerd 3170:
1.330 tempelho 3171: my %orderhash = (
1.368 truskell 3172: 'aa' => ['Upload Document',$fileuploadform.'<br />'.$newfolderform],
1.363 ehlerst 3173: 'bb' => ['Published Documents',$simpleeditdefaultform],
3174: 'cc' => ['Special Documents',$specialdocumentsform],
3175: 'dd' => ['Tools',$extresourcesform.'<br />'.$imspform.'<br />'.$recoverform.'<br />'.&generate_admin_options($containertag,$uploadtag,\%help,\%env)],
3176: 'zz' => ['Hide all Options'],
1.330 tempelho 3177: );
1.334 muellerd 3178: my $tid='1';
3179: my $varcd = 'Main Course Documents';
1.363 ehlerst 3180: $r->print(&generate_edit_table($tid,$varcd,\%orderhash));
1.341 ehlerst 3181: $hadchanges=0;
3182: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
1.335 ehlerst 3183: if ($error) {
3184: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
3185: }
1.341 ehlerst 3186: if ($hadchanges) {
3187: &mark_hash_old();
3188: }
3189:
3190: &changewarning($r,'');
1.371 ! tempelho 3191: $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
! 3192: &mt('Editing the Table of Contents for your '.$type)));
1.335 ehlerst 3193: $r->print('</div>');
1.329 droeschl 3194: if ($env{'form.pagepath'}) {
3195: }
3196: # ----------------------------------------------------- Supplemental documents
1.335 ehlerst 3197: my $active = 'style="display: none;"';
3198: if($activeClass == 1){
3199: $active = 'style="display: block;"';
3200: }
3201: $r->print('<div class="LC_ContentBox" id="Supplemental Course Documents" '.$active.'>');
1.329 droeschl 3202: my $folder=$env{'form.folder'};
3203: unless ($folder=~/^supplemental/) {
3204: $folder='supplemental';
3205: }
3206: if ($folder =~ /^supplemental$/ &&
3207: (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
3208: $env{'form.folderpath'} = 'supplemental&'.
3209: &escape(&mt('Supplemental '.$type.' Documents'));
1.356 tempelho 3210: }else{
3211: $env{'form.folderpath'} = $savefolderpath;
1.329 droeschl 3212: }
1.362 ehlerst 3213: $env{'form.pagepath'} = '';
1.329 droeschl 3214: if ($allowed) {
3215: my $folderseq=
3216: '/uploaded/'.$coursedom.'/'.$coursenum.'/supplemental_'.time.
3217: '.sequence';
3218:
3219: my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
3220:
3221: my $supupdocform=(<<SUPDOCFORM);
3222: <form action="/adm/coursedocs" method="post" enctype="multipart/form-data">
1.371 ! tempelho 3223: <input type="hidden" name="active" value="ee" />
1.329 droeschl 3224: $fileupload
3225: <br />
3226: <br />
3227: <span class="LC_nobreak">
3228: $checkbox
3229: </span>
3230: <br /><br />
3231: $lt{'comment'}:<br />
1.358 bisitz 3232: <textarea cols="50" rows="4" name="comment">
1.329 droeschl 3233: </textarea>
3234: <br />
3235: <input type="hidden" name="folderpath" value="$path" />
3236: <input type="hidden" name="cmd" value="upload_supplemental" />
3237: <span class="LC_nobreak">
3238: <input type="submit" value="$lt{'upld'}" />
3239: $help{'Uploading_From_Harddrive'}
3240: </span>
3241: </form>
3242: SUPDOCFORM
3243:
3244: my $supnewfolderform=(<<SNFFORM);
3245: <form action="/adm/coursedocs" method="post" name="supnewfolder">
1.371 ! tempelho 3246: <input type="hidden" name="active" value="ee" />
1.329 droeschl 3247: <input type="hidden" name="folderpath" value="$path" />
3248: <input type="hidden" name="importdetail" value="" />
3249: <span class="LC_nobreak">
3250: <input name="newfolder" type="button"
1.369 bisitz 3251: onclick="javascript:makenewfolder(this.form,'$folderseq');"
1.329 droeschl 3252: value="$lt{'newf'}" /> $help{'Adding_Folders'}
3253: </span>
3254: </form>
3255: SNFFORM
3256:
3257:
3258: my $supnewextform=(<<SNEFORM);
3259: <form action="/adm/coursedocs" method="post" name="supnewext">
1.371 ! tempelho 3260: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3261: <input type="hidden" name="folderpath" value="$path" />
3262: <input type="hidden" name="importdetail" value="" />
3263: <span class="LC_nobreak">
3264: <input name="newext" type="button"
1.369 bisitz 3265: onclick="javascript:makenewext('supnewext');"
1.329 droeschl 3266: value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
3267: </span>
3268: </form>
3269: SNEFORM
3270:
3271: my $supnewsylform=(<<SNSFORM);
3272: <form action="/adm/coursedocs" method="post" name="supnewsyl">
1.371 ! tempelho 3273: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3274: <input type="hidden" name="folderpath" value="$path" />
3275: <input type="hidden" name="importdetail"
3276: value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
3277: <span class="LC_nobreak">
3278: <input name="newsyl" type="submit" value="$lt{'syll'}" />
3279: $help{'Syllabus'}
3280: </span>
3281: </form>
3282: SNSFORM
3283:
3284: my $supnewaboutmeform=(<<SNAMFORM);
3285: <form action="/adm/coursedocs" method="post" name="subnewaboutme">
1.371 ! tempelho 3286: <input type="hidden" name="active" value="ff" />
1.329 droeschl 3287: <input type="hidden" name="folderpath" value="$path" />
3288: <input type="hidden" name="importdetail"
3289: value="$plainname=/adm/$udom/$uname/aboutme" />
3290: <span class="LC_nobreak">
3291: <input name="newaboutme" type="submit" value="$lt{'mypi'}" />
1.347 weissno 3292: $help{'My Personal Information Page'}
1.329 droeschl 3293: </span>
3294: </form>
3295: SNAMFORM
3296:
1.333 muellerd 3297:
3298:
3299: my %suporderhash = (
1.368 truskell 3300: 'ee' => ['Upload Document',$supupdocform.'<br />'.$supnewfolderform],
1.363 ehlerst 3301: 'ff' => ['Special Documents',$supnewextform.'<br />'.$supnewsylform.'<br />'.$supnewaboutmeform],
3302: 'zz' => ['Hide all Options'],
1.333 muellerd 3303: );
1.334 muellerd 3304:
1.333 muellerd 3305: my $tid='2';
1.334 muellerd 3306: my $varscd = 'Supplemental Course Documents';
1.333 muellerd 3307:
1.363 ehlerst 3308: $r->print(&generate_edit_table($tid,$varscd,\%suporderhash));
1.335 ehlerst 3309: my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
3310: if ($error) {
3311: $r->print('<p><span class="LC_error">'.$error.'</span></p>');
3312: }
1.337 ehlerst 3313: $r->print('</div>');
1.364 bisitz 3314: }
1.335 ehlerst 3315: $r->print('</div>');
1.329 droeschl 3316: if ($allowed) {
3317: $r->print('
3318: <form method="post" name="extimport" action="/adm/coursedocs">
3319: <input type="hidden" name="title" />
3320: <input type="hidden" name="url" />
3321: <input type="hidden" name="useform" />
3322: <input type="hidden" name="residx" />
3323: </form>');
3324: }
3325: } else {
3326: unless ($upload_result eq 'phasetwo') {
3327: # -------------------------------------------------------- This is showdoc mode
3328: $r->print("<h1>".&mt('Uploaded Document').' - '.
3329: &Apache::lonnet::gettitle($r->uri).'</h1><p>'.
3330: &mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."</p><table>".
3331: &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'</table>');
3332: }
3333: }
3334: }
3335: $r->print(&Apache::loncommon::end_page());
3336: return OK;
1.364 bisitz 3337: }
1.329 droeschl 3338:
3339: sub generate_admin_options {
1.337 ehlerst 3340: my ($containertag,$uploadtag,$help_ref,$env_ref) = @_;
3341: my %lt=&Apache::lonlocal::texthash(
3342: 'vc' => 'Verify Content',
3343: 'cv' => 'Check/Set Resource Versions',
3344: 'ls' => 'List Symbs',
3345: 'sl' => 'Show Log'
3346: );
1.329 droeschl 3347: my %help = %{$help_ref};
3348: my %env = %{$env_ref};
3349: my $dumpbut=&dumpbutton();
3350: my $exportbut=&exportbutton();
3351: return (<<ENDOPTIONFORM);
3352: <form action="/adm/coursedocs" method="post" name="courseverify">
1.354 tempelho 3353: <input type="submit" name="verify" value="$lt{'vc'}" />$help{'Verify_Content'}<br />
1.357 bisitz 3354: <input type="submit" name="versions" value="$lt{'cv'}" />$help{'Check_Resource_Versions'}<br />
1.362 ehlerst 3355: $dumpbut
3356: $exportbut
1.329 droeschl 3357: <input type="submit" name="listsymbs" value="$lt{'ls'}" />
1.354 tempelho 3358: <input type="hidden" name="folder" value="$env{'form.folder'}" /><br />
1.329 droeschl 3359: <input type="submit" name="docslog" value="$lt{'sl'}" />
3360: </form>
3361: ENDOPTIONFORM
1.330 tempelho 3362:
1.329 droeschl 3363: }
3364:
1.330 tempelho 3365:
1.329 droeschl 3366: sub generate_edit_table {
1.363 ehlerst 3367: my ($tid,$varcd,$orderhash_ref) = @_;
1.342 ehlerst 3368: my %orderhash = %{$orderhash_ref};
1.344 bisitz 3369: my $form;
1.371 ! tempelho 3370: my $activetab;
! 3371: my $active;
! 3372: if($env{'form.active'} ne ''){
! 3373: $activetab = $env{'form.active'};
! 3374: }
1.370 bisitz 3375: $form = '<div class="LC_Box"><h4 class="LC_hcell">'.&mt($varcd).'</h4>';
1.359 tempelho 3376: $form .= '<ul id="navigation'.$tid.'" class="LC_TabContent">';
1.329 droeschl 3377: foreach my $name (sort(keys(%orderhash))){
1.332 tempelho 3378: if($name eq 'zz'){
1.371 ! tempelho 3379: if($activetab ne ''){
! 3380: $active = '';
! 3381: }else{
! 3382: $active = 'class="active"';
! 3383: }
! 3384: $form .= '<span class="LC_Right"><li onclick="javascript:hideAll(this, \'navigation'.$tid.'\' ,\'content'.$tid.'\');" '.$active.'>'.&mt(${$orderhash{$name}}[0]).'</li></span>';
1.329 droeschl 3385: }else{
1.371 ! tempelho 3386: if($activetab eq '' || $activetab ne $name){
! 3387: $active = '';
! 3388: }elsif($activetab eq $name){
! 3389: $active = 'class="active"';
! 3390: }
! 3391: $form .= '<li '.$active.' onclick="javascript:showPage(this, \''.substr(${$orderhash{$name}}[0],0,3).$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');">'.&mt(${$orderhash{$name}}[0]).'</li>';
1.329 droeschl 3392: }
3393: }
1.339 ehlerst 3394: $form .= '</ul>';
1.359 tempelho 3395: $form .= '<div id="content'.$tid.'" style="padding: 0 0; margin: 0 0;">';
1.363 ehlerst 3396: foreach my $field (keys(%orderhash)){
3397: if($field ne 'zz'){
1.371 ! tempelho 3398: if($activetab eq '' || $activetab ne $field){
! 3399: $active = 'style="display: none;"';
! 3400: }elsif($activetab eq $field){
! 3401: $active = 'style="display:block;"';
! 3402: }
! 3403: $form .= '<div id="'.substr(${$orderhash{$field}}[0],0,3).$tid.'" class="LC_ContentBox" '.$active.'">'.${$orderhash{$field}}[1].'</div>';
1.363 ehlerst 3404: }
3405: }
1.330 tempelho 3406: $form .= '</div></div>';
1.364 bisitz 3407:
1.329 droeschl 3408: return $form;
3409: }
3410:
3411: sub editing_js {
3412: my ($udom,$uname) = @_;
3413: my $now = time();
3414: my %lt = &Apache::lonlocal::texthash(
3415: p_mnf => 'Name of New Folder',
3416: t_mnf => 'New Folder',
3417: p_mnp => 'Name of New Page',
3418: t_mnp => 'New Page',
3419: p_mxu => 'Title for the Uploaded Score',
1.349 biermanm 3420: p_msp => 'Name of Simple Course Page',
1.329 droeschl 3421: p_msb => 'Title for the Problem',
3422: p_mdb => 'Title for the Drop Box',
1.336 schafran 3423: p_mbb => 'Title for the Discussion Board',
1.348 weissno 3424: p_mab => "Enter user:domain for User's Personal Information Page",
1.352 bisitz 3425: p_mab2 => 'Personal Information Page of ',
1.329 droeschl 3426: p_mab_alrt1 => 'Not a valid user:domain',
3427: p_mab_alrt2 => 'Please enter both user and domain in the format user:domain',
3428: p_chn => 'New Title',
3429: p_rmr1 => 'WARNING: Removing a resource makes associated grades and scores inaccessible!',
3430: p_rmr2a => 'Remove[_99]',
3431: p_rmr2b => '?[_99]',
3432: p_ctr1a => 'WARNING: Cutting a resource makes associated grades and scores inaccessible!',
3433: p_ctr1b => 'Grades remain inaccessible if resource is pasted into another folder.',
3434: p_ctr2a => 'Cut[_98]',
3435: p_ctr2b => '?[_98]'
3436: );
3437:
3438: return <<ENDNEWSCRIPT;
3439: function makenewfolder(targetform,folderseq) {
3440: var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
3441: if (foldername) {
3442: targetform.importdetail.value=escape(foldername)+"="+folderseq;
3443: targetform.submit();
3444: }
3445: }
3446:
3447: function makenewpage(targetform,folderseq) {
3448: var pagename=prompt('$lt{"p_mnp"}','$lt{"t_mnp"}');
3449: if (pagename) {
3450: targetform.importdetail.value=escape(pagename)+"="+folderseq;
3451: targetform.submit();
3452: }
3453: }
3454:
3455: function makenewext(targetname) {
3456: this.document.forms.extimport.useform.value=targetname;
3457: this.document.forms.extimport.title.value='';
3458: this.document.forms.extimport.url.value='';
3459: this.document.forms.extimport.residx.value='';
3460: window.open('/adm/rat/extpickframe.html');
3461: }
3462:
3463: function edittext(targetname,residx,title,url) {
3464: this.document.forms.extimport.useform.value=targetname;
3465: this.document.forms.extimport.residx.value=residx;
3466: this.document.forms.extimport.url.value=url;
3467: this.document.forms.extimport.title.value=title;
3468: window.open('/adm/rat/extpickframe.html');
3469: }
3470:
3471: function makeexamupload() {
3472: var title=prompt('$lt{"p_mxu"}');
1.344 bisitz 3473: if (title) {
1.329 droeschl 3474: this.document.forms.newexamupload.importdetail.value=
3475: escape(title)+'=/res/lib/templates/examupload.problem';
3476: this.document.forms.newexamupload.submit();
3477: }
3478: }
3479:
3480: function makesmppage() {
3481: var title=prompt('$lt{"p_msp"}');
1.344 bisitz 3482: if (title) {
1.329 droeschl 3483: this.document.forms.newsmppg.importdetail.value=
3484: escape(title)+'=/adm/$udom/$uname/$now/smppg';
3485: this.document.forms.newsmppg.submit();
3486: }
3487: }
3488:
3489: function makesmpproblem() {
3490: var title=prompt('$lt{"p_msb"}');
1.344 bisitz 3491: if (title) {
1.329 droeschl 3492: this.document.forms.newsmpproblem.importdetail.value=
3493: escape(title)+'=/res/lib/templates/simpleproblem.problem';
3494: this.document.forms.newsmpproblem.submit();
3495: }
3496: }
3497:
3498: function makedropbox() {
3499: var title=prompt('$lt{"p_mdb"}');
1.344 bisitz 3500: if (title) {
1.329 droeschl 3501: this.document.forms.newdropbox.importdetail.value=
3502: escape(title)+'=/res/lib/templates/DropBox.problem';
3503: this.document.forms.newdropbox.submit();
3504: }
3505: }
3506:
3507: function makebulboard() {
3508: var title=prompt('$lt{"p_mbb"}');
3509: if (title) {
3510: this.document.forms.newbul.importdetail.value=
3511: escape(title)+'=/adm/$udom/$uname/$now/bulletinboard';
3512: this.document.forms.newbul.submit();
3513: }
3514: }
3515:
3516: function makeabout() {
3517: var user=prompt("$lt{'p_mab'}");
3518: if (user) {
3519: var comp=new Array();
3520: comp=user.split(':');
3521: if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
3522: if ((comp[0]) && (comp[1])) {
3523: this.document.forms.newaboutsomeone.importdetail.value=
3524: '$lt{"p_mab2"}'+escape(user)+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
1.335 ehlerst 3525: this.document.forms.newaboutsomeone.submit();
3526: } else {
3527: alert("$lt{'p_mab_alrt1'}");
1.329 droeschl 3528: }
1.335 ehlerst 3529: } else {
3530: alert("$lt{'p_mab_alrt2'}");
3531: }
3532: }
1.329 droeschl 3533: }
3534:
3535: function makeims() {
1.335 ehlerst 3536: var caller = document.forms.ims.folder.value;
3537: var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
3538: newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
3539: newWindow.location.href = newlocation;
1.329 droeschl 3540: }
3541:
3542:
3543: function finishpick() {
1.335 ehlerst 3544: var title=this.document.forms.extimport.title.value;
3545: var url=this.document.forms.extimport.url.value;
3546: var form=this.document.forms.extimport.useform.value;
3547: var residx=this.document.forms.extimport.residx.value;
3548: eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
1.329 droeschl 3549: }
3550:
3551: function changename(folderpath,index,oldtitle,container,pagesymb) {
1.335 ehlerst 3552: var title=prompt('$lt{"p_chn"}',oldtitle);
3553: if (title) {
3554: this.document.forms.renameform.markcopy.value=-1;
3555: this.document.forms.renameform.title.value=title;
3556: this.document.forms.renameform.cmd.value='rename_'+index;
3557: if (container == 'sequence') {
3558: this.document.forms.renameform.folderpath.value=folderpath;
3559: }
3560: if (container == 'page') {
3561: this.document.forms.renameform.pagepath.value=folderpath;
3562: this.document.forms.renameform.pagesymb.value=pagesymb;
3563: }
3564: this.document.forms.renameform.submit();
3565: }
1.329 droeschl 3566: }
3567:
3568: function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
1.335 ehlerst 3569: if (skip_confirm || confirm('$lt{"p_rmr1"}\\n\\n$lt{"p_rmr2a"} "'+oldtitle+'" $lt{"p_rmr2b"}')) {
3570: this.document.forms.renameform.markcopy.value=-1;
3571: this.document.forms.renameform.cmd.value='del_'+index;
3572: if (container == 'sequence') {
3573: this.document.forms.renameform.folderpath.value=folderpath;
3574: }
3575: if (container == 'page') {
3576: this.document.forms.renameform.pagepath.value=folderpath;
3577: this.document.forms.renameform.pagesymb.value=pagesymb;
3578: }
3579: this.document.forms.renameform.submit();
3580: }
1.329 droeschl 3581: }
3582:
3583: function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
1.335 ehlerst 3584: if (skip_confirm || confirm('$lt{"p_ctr1a"}\\n$lt{"p_ctr1b"}\\n\\n$lt{"p_ctr2a"} "'+oldtitle+'" $lt{"p_ctr2b"}')) {
3585: this.document.forms.renameform.cmd.value='cut_'+index;
3586: this.document.forms.renameform.markcopy.value=index;
3587: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3588: if (container == 'sequence') {
3589: this.document.forms.renameform.folderpath.value=folderpath;
3590: }
3591: if (container == 'page') {
3592: this.document.forms.renameform.pagepath.value=folderpath;
3593: this.document.forms.renameform.pagesymb.value=pagesymb;
3594: }
3595: this.document.forms.renameform.submit();
3596: }
1.329 droeschl 3597: }
3598:
3599: function markcopy(folderpath,index,oldtitle,container,pagesymb,folder) {
1.335 ehlerst 3600: this.document.forms.renameform.markcopy.value=index;
3601: this.document.forms.renameform.copyfolder.value=folder+'.'+container;
3602: if (container == 'sequence') {
3603: this.document.forms.renameform.folderpath.value=folderpath;
3604: }
3605: if (container == 'page') {
3606: this.document.forms.renameform.pagepath.value=folderpath;
3607: this.document.forms.renameform.pagesymb.value=pagesymb;
3608: }
3609: this.document.forms.renameform.submit();
1.329 droeschl 3610: }
3611:
1.334 muellerd 3612: function unselectInactive(nav) {
1.335 ehlerst 3613: currentNav = document.getElementById(nav);
3614: currentLis = currentNav.getElementsByTagName('LI');
3615: for (i = 0; i < currentLis.length; i++) {
3616: currentLis[i].className = 'i';
3617: }
1.332 tempelho 3618: }
3619:
1.334 muellerd 3620: function hideAll(current, nav, data) {
1.335 ehlerst 3621: unselectInactive(nav);
3622: current.className = 'active';
3623: currentData = document.getElementById(data);
3624: currentDivs = currentData.getElementsByTagName('DIV');
3625: for (i = 0; i < currentDivs.length; i++) {
3626: if(currentDivs[i].className == 'LC_ContentBox'){
1.333 muellerd 3627: currentDivs[i].style.display = 'none';
1.330 tempelho 3628: }
3629: }
1.335 ehlerst 3630: }
1.330 tempelho 3631:
1.334 muellerd 3632: function showPage(current, pageId, nav, data) {
3633: hideAll(current, nav, data);
3634: unselectInactive(nav);
1.330 tempelho 3635: current.className = 'active';
3636: currentData = document.getElementById(pageId);
3637: currentData.style.display = 'block';
3638: return false;
3639: }
1.329 droeschl 3640:
3641: ENDNEWSCRIPT
3642: }
3643: 1;
3644: __END__
3645:
3646:
3647: =head1 NAME
3648:
3649: Apache::londocs.pm
3650:
3651: =head1 SYNOPSIS
3652:
3653: This is part of the LearningOnline Network with CAPA project
3654: described at http://www.lon-capa.org.
3655:
3656: =head1 SUBROUTINES
3657:
3658: =over
3659:
3660: =item %help=()
3661:
3662: Available help topics
3663:
3664: =item mapread()
3665:
1.344 bisitz 3666: Mapread read maps into LONCAPA::map:: global arrays
1.329 droeschl 3667: @order and @resources, determines status
3668: sets @order - pointer to resources in right order
3669: sets @resources - array with the resources with correct idx
3670:
3671: =item authorhosts()
3672:
3673: Return hash with valid author names
3674:
3675: =item dumpbutton()
3676:
3677: Generate "dump" button
3678:
3679: =item clean()
3680:
3681: =item dumpcourse()
3682:
3683: Actually dump course
3684:
3685:
3686: =item exportbutton()
3687:
3688: Generate "export" button
3689:
3690: =item exportcourse()
3691:
3692: =item create_ims_store()
3693:
3694: =item build_package()
3695:
3696: =item get_dependencies()
3697:
3698: =item process_content()
3699:
3700: =item replicate_content()
3701:
3702: =item extract_media()
3703:
3704: =item store_template()
3705:
3706: =item group_import()
3707:
3708: Imports the given (name, url) resources into the course
3709: coursenum, coursedom, and folder must precede the list
3710:
3711: =item breadcrumbs()
3712:
3713: =item log_docs()
3714:
3715: =item docs_change_log()
3716:
3717: =item update_paste_buffer()
3718:
3719: =item print_paste_buffer()
3720:
3721: =item do_paste_from_buffer()
3722:
3723: =item update_parameter()
3724:
3725: =item handle_edit_cmd()
3726:
3727: =item editor()
3728:
3729: =item process_file_upload()
3730:
3731: =item process_secondary_uploads()
3732:
3733: =item is_supplemental_title()
3734:
3735: =item parse_supplemental_title()
3736:
3737: =item entryline()
3738:
3739: =item tiehash()
3740:
3741: =item untiehash()
3742:
3743: =item checkonthis()
3744:
3745: check on this
3746:
3747: =item verifycontent()
3748:
3749: Verify Content
3750:
3751: =item devalidateversioncache() & checkversions()
3752:
3753: Check Versions
3754:
3755: =item mark_hash_old()
3756:
3757: =item is_hash_old()
3758:
3759: =item changewarning()
3760:
3761: =item init_breadcrumbs()
3762:
3763: Breadcrumbs for special functions
3764:
3765: =back
3766:
3767: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>