Annotation of loncom/imspackages/imsimportdocs.pm, revision 1.2
1.1 raeburn 1: package Apache::imsimportdocs;
2:
1.2 ! raeburn 3: use Apache::Constants qw(:common :http :methods);
1.1 raeburn 4: use Apache::lonnet;
1.2 ! raeburn 5: use Apache::londocs;
1.1 raeburn 6: use Apache::loncommon;
7: use Apache::lonlocal;
8: use Apache::imsprocessor;
9: use LONCAPA::Configuration;
1.2 ! raeburn 10: use strict;
1.1 raeburn 11:
12: sub jscript_one {
13: my $javascript = shift;
14: $$javascript = qq#
15: function verify() {
16: if ((document.forms.pickcms.uploadname.value == '') || (!document.forms.pickcms.uploadname.value)) {
17: alert("You must provide the name of the IMS package to be imported")
18: return false
19: }
20: if (document.forms.pickcms.source.selectedIndex == 0) {
21: alert("You must choose the Course Management System from which the IMS package was exported");
22: return false
23: }
24: return true
25: }
26:
27: function nextPage() {
28: if (verify()) {
29: document.forms.pickcms.submit()
30: }
31: }
32: #;
33:
34: }
35:
36: sub jscript_two {
37: my $javascript = shift;
38: $$javascript = qq#
39: function setOptions(caller,itemnum) {
40: var opForm = document.forms.pickoptions
41: var menu = 1 + itemnum*2
42: opForm.elements[menu].length = 0
43: if (opForm.elements[itemnum*2].checked == true) {
44: if (caller == "board") {
45: opForm.elements[menu].options[0] = new Option("Select","-1",true,true)
46: opForm.elements[menu].options[1] = new Option("Import topics only","topics",true,true)
47: opForm.elements[menu].options[2] = new Option("Import topics & posts (with author)","allpost",true,true)
48: opForm.elements[menu].options[3] = new Option("Import topics & posts (no author)","allanon",true,true)
49: }
50: else {
51: if (caller == "users") {
52: opForm.elements[menu].length = 0
53: opForm.elements[menu].options[0] = new Option("Select","-1",true,true)
54: opForm.elements[menu].options[1] = new Option("Enroll students only","students",true,true)
55: opForm.elements[menu].options[2] = new Option("Enroll all users","all",true,true)
56: }
57: }
58: }
59: else {
60: opForm.elements[menu].options[0] = new Option("Not required","0",true,true)
61: }
62: opForm.elements[menu].selectedIndex = 0
63: }
64:
65: function verify(caller) {
66: var opForm = document.forms.pickoptions
67: var totcheck = 0;
68: for (var i=0; i<caller; i++) {
69: if (opForm.elements[2*i].checked == true) {
70: totcheck ++
71: if (opForm.elements[2*i].name == "board") {
72: if (opForm.elements[2*i+1].selectedIndex == 0) {
73: alert("You must select one of the additional options when importing Discussion Boards ")
74: return false
75: }
76: }
77: if (opForm.elements[2*i].name == "users") {
78: if (opForm.elements[2*i+1].selectedIndex == 0) {
79: alert("You must select one of the additional options when importing Enrollment")
80: return false
81: }
82: }
83: }
84: }
85: if (totcheck == 0) {
86: alert("You must check the Checkbox for at least one Content Type");
87: return false
88: }
89: return true
90: }
91:
92: function nextPage(caller) {
93: if (verify(caller)) {
94: document.forms.pickoptions.submit()
95: }
96: }
97: #;
98: }
99:
1.2 ! raeburn 100: sub jscript_three {
! 101: my $javascript = shift;
! 102: $$javascript = qq|
! 103: function init(tf) {
! 104: setTimeout("self.close()",3000)
! 105: tf.submit();
! 106: }
! 107: |;
! 108: }
! 109:
1.1 raeburn 110: sub handler {
111: my $r = shift;
112: my $javascript = '';
113: &Apache::loncommon::content_type($r,'text/html');
114: $r->send_http_header;
115: return OK if $r->header_only;
116:
117: my @areas = ("doc","extlink","announce","staff","board","quiz","survey","pool","users");
118: my %cmsmap = ();
119: %{$cmsmap{bb5}} = (
120: announce => 'resource/x-bb-announcement',
121: board => 'resource/x-bb-discussionboard',
122: doc => 'resource/x-bb-document',
123: extlink => 'resource/x-bb-externallink',
124: pool => 'assessment/x-bb-pool',
125: quiz => 'assessment/x-bb-quiz',
126: staff => 'resource/x-bb-staffinfo',
127: survey => 'assessment/x-bb-survey',
128: users => 'course/x-bb-user',
129: );
130:
131: %{$cmsmap{angel}} = (
132: board => 'BOARD',
133: extlink => 'LINK',
134: msg => 'MESSAGE',
135: quiz => 'QUIZ',
136: survey => 'FORM',
137: );
138:
139: @{$cmsmap{angel}{doc}} = ('FILE','PAGE');
140:
141: # get course data
142: my $coursenum=$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
143: my $coursedom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
144: my $coursehome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'};
145:
146: # get personal data
147:
148: my $uname=$ENV{'user.name'};
149: my $udom=$ENV{'user.domain'};
150: my $plainname=&Apache::lonnet::escape(
151: &Apache::loncommon::plainname($uname,$udom));
152:
153: # does this user have privileges to post, etc?
154: my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
155: unless ($allowed) {
156: $r->print("<html><head><title>The LearningOnline Network with CAPA</title></head>");
157: $r->print(&Apache::loncommon::bodytag('Import IMS package'));
158: $r->print('<h3>'.&mt('Modification of Course Contents Disallowed').'</h3>'.&mt('Your current role does not grant you the right to modify course content in this course.').'</body></html>');
159: return OK;
160: }
161:
162: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
163: ['phase']);
164:
165: if ($ENV{'form.phase'} eq 'one') {
166: &jscript_one(\$javascript);
167: } elsif ($ENV{'form.phase'} eq 'two') {
168: &jscript_two(\$javascript);
1.2 ! raeburn 169: } elsif ($ENV{'form.phase'} eq 'three') {
! 170: &jscript_three(\$javascript);
1.1 raeburn 171: }
172:
173: # print screen
174: $r->print(<<ENDHEAD);
175: <html>
176: <head>
177: <title>The LearningOnline Network with CAPA</title>
178: <script type="text/javascript">
179: <!--
180: $javascript
181: -->
182: </script>
183: </head>
184: ENDHEAD
185: # -------------------------------------------------------------------- Body tag
186: $r->print(&Apache::loncommon::bodytag('Import IMS package'));
187: if ($ENV{'form.phase'} eq 'one') {
188: &display_one($r);
189: } elsif ($ENV{'form.phase'} eq 'two') {
190: &display_two($r,$coursenum,\@areas,%cmsmap);
191: } elsif ($ENV{'form.phase'} eq 'three') {
1.2 ! raeburn 192: &display_three($r,$coursenum,$coursedom,$coursehome,$uname,$udom,\@areas,%cmsmap);
1.1 raeburn 193: }
194: $r->print("</body><html>");
1.2 ! raeburn 195: return OK;
1.1 raeburn 196: }
197:
198: sub uploadzip {
199: my $tempdir = shift;
200: my $fname=$ENV{'form.uploadname.filename'};
201: # Replace Windows backslashes by forward slashes
202: $fname=~s/\\/\//g;
203: # Get rid of everything but the actual filename
204: $fname=~s/^.*\/([^\/]+)$/$1/;
205: # Replace spaces by underscores
206: $fname=~s/\s+/\_/g;
207: # Replace all other weird characters by nothing
208: $fname=~s/[^\w\.\-]//g;
209: # See if there is anything left
210: unless ($fname) { return 'error: no uploaded file'; }
211:
212: # Save the file
213: chomp($ENV{'form.uploadname'});
214: open(my $fh,'>'.$tempdir.'/'.$fname);
215: print $fh $ENV{'form.uploadname'};
216: close($fh);
217: return $fname;
218: }
219:
220: sub display_one {
1.2 ! raeburn 221: my ($r) = @_;
1.1 raeburn 222: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder']);
223:
224: $r->print(<<ENDBLOCK);
225: <form action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" name="pickcms">
226: <table border='0' bgcolor='#F6F6F6' cellspacing='0' cellpadding ='0' width='100%'>
227: <tr>
228: <td colspan='2'>
229: <table border='0' cellspacing='0' cellpadding='0'>
230: <tr>
231: <td colspan='2' align='left'>
232: </td>
233: </tr>
234: <tr bgcolor='#CCCCFF'>
235: <td valign='middle'><img src='/res/adm/pages/bl_step1.gif'>
236: </td>
237: <td width='100%' align='left'>
238: <font face='arial,helvetica,sans-serif'><b>Specify the Course Management system used to create the package.</b>
239: </font>
240: </td>
241: </tr>
242: <tr>
243: <td colspan='2'> </td>
244: </tr>
245: <tr>
246: <td> </td>
247: <td>
248: <font face='Arial,Helvetica,sans-serif'>
249: Please choose the CMS used to create your IMS content package.
250: <select name="source">
251: <option value='-1' selected="true">Please select
252: <option value='bb5'>Blackboard 5
253: <option value='angel'>ANGEL
254: </select>
255: </font>
256: </td>
257: </tr>
258: <tr>
259: <td colspan='2'> </td>
260: </tr>
261: <tr>
262: <td colspan='2'> </td>
263: </tr>
264: <tr bgcolor='#CCCCFF'>
265: <td valign='middle'><img src='/res/adm/pages/bl_step2.gif'>
266: </td>
267: <td width='100%' align='left'>
268: <font face='arial,helvetica,sans-serif'><b>Locate the IMS content package you wish to upload.</b>
269: </font>
270: </td>
271: </tr>
272: <tr>
273: <td colspan='2'> </td>
274: </tr>
275: <tr>
276: <td colspan='2'>
277: <input type="hidden" name="folder" value="$ENV{'form.folder'}" />
278: <input type="hidden" name="phase" value="two" />
279: <input type="file" name="uploadname" size="40" />
280: </td>
281: </tr>
282: <tr>
283: <td colspan='2'> </td>
284: </tr>
285: <tr>
286: <td> </td>
287: <td><font face='arial,helvetica,sans-serif'>If you have selected the CMS, and located the IMS package, you should click the 'Upload IMS package' button to upload the file to the server.</font></td>
288: </tr>
289: <tr>
290: <td colspan='2'> </td>
291: </tr>
292: <tr
293: <td colspan='2'>
294: <table border='0' cellspacing='0' cellpadding='0' width="100%">
295: <tr>
296: <td align='left'>
297: <input type="button" name="exitpage" value="Exit now" onClick="javascript:self.close()">
298: </td>
299: <td align='right'>
300: <input type="button" name="nextpage" value="Upload IMS package" onClick="javascript:nextPage()">
301: </td>
302: </tr>
303: </table>
304: </td>
305: </tr>
306: </table>
307: </td>
308: </tr>
309: </table>
310: </form>
311: ENDBLOCK
312: }
313:
314:
315: sub display_two {
316: my ($r,$crs,$areasref,%cmsmap) = @_;
317: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folder','source']);
318: my $cms = $ENV{'form.source'};
1.2 ! raeburn 319: my $timenow = time;
! 320: my $tempdir = &Apache::imsprocessor::create_tempdir('DOCS',$crs,$timenow);
1.1 raeburn 321: my $fname = &uploadzip($tempdir);
322: my $unzip_result = '';
323: my $manifest_result = '';
324: unless ($tempdir eq '') {
325: $unzip_result = &Apache::imsprocessor::expand_zip($tempdir,$fname);
326: }
327: my %resources = ();
328: my %items = ();
329: my %hrefs = ();
1.2 ! raeburn 330: my %resinfo = ();
1.1 raeburn 331: my %count = ();
332: my @bgcolors = ("#eeeeee","#dddddd");
333:
334: my $counter = 0;
335: my $iter = 0;
336: my %count = (
337: announce => 0,
338: board => 0,
339: doc => 0,
340: extlink => 0,
341: msg => 0,
342: pool => 0,
343: quiz => 0,
344: staff => 0,
345: survey => 0,
346: users => 0,
347: );
348:
349: my %areaname = (
350: announce => 'Announcements',
351: board => 'Discussion Boards',
352: doc => 'Documents, pages & folders',
353: extlink => 'Links to external sites',
354: pool => 'Question pools',
355: quiz => 'Quizzes',
356: staff => 'Staff information',
357: survey => 'Surveys',
358: users => 'Enrollment',
359: );
360:
361: if ($unzip_result eq 'ok') {
1.2 ! raeburn 362: $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo);
1.1 raeburn 363: if ($manifest_result eq 'ok') {
364: foreach my $res (sort keys %resources) {
365: if ($cms eq 'bb5') {
366: foreach my $area (keys %{$cmsmap{$cms}}) {
367: if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) {
368: $count{$area} ++;
369: }
370: }
371: } elsif ($cms eq 'angel') {
372: foreach my $area (keys %{$cmsmap{$cms}}) {
373: if ($area eq 'doc') {
374: if (grep/^$resources{$res}{type}$/,@{$cmsmap{$cms}{doc}}) {
375: $count{$area} ++;
376: }
377: } elsif ($resources{$res}{type} eq $cmsmap{$cms}{$area}) {
378: $count{$area} ++;
379: }
380: }
381: }
382: }
383: $r->print(<<ENDBLOCK);
384: <form name="pickoptions" method="post">
385: <table border='0' bgcolor='#F6F6F6'' cellspacing='0' cellpadding ='0' width='100%'>
386: <tr>
387: <td colspan='2'>
388: <table border='0' cellspacing='0' cellpadding='0'>
389: <tr>
390: <td colspan='2' align='left'>
391: </td>
392: </tr>
393: <tr bgcolor='#CCCCFF'>
394: <td valign='middle'><img src='/res/adm/pages/bl_step3.gif'>
395: </td>
396: <td width='100%' align='left'>
397: <font face='arial,helvetica,sans-serif'><b>Choose which content types you wish to import</b></font>
398: </td>
399: </tr>
400: <tr>
401: <td colspan='2'> </td>
402: </tr>
403: <tr>
404: <td> </td>
405: <td>
406: <table border='0' cellspacing='0' cellpadding='1' bgcolor='#000000'>
407: <tr>
408: <td>
409: <table border='0' cellspacing='0' cellpadding='0' bgcolor='#ffffff' width='100%'>
410: <tr>
411: <td>
412: <table border='0' cellspacing='1' cellpadding='1' bgcolor='#ffffff' width='100%'>
413: <tr bgcolor='#CCCCFF'>
414: <td align='center'><font face='arial,helvetica,sans-serif'><b>Import?</b></font></td>
415: <td align='center'><font face='arial,helvetica,sans-serif'><b>Content type</b></font></td>
416: <td align='center'><font face='arial,helvetica,sans-serif'><b>Additional options</b></font></td>
417: </tr>
418: ENDBLOCK
419: foreach my $area (@{$areasref}) {
420: if ($count{$area} > 0) {
421: my $count_tag = 'flag_'.$counter;
422: $r->print(" <tr bgcolor='@bgcolors[$iter]'>
423: <td align='left'><font face='arial,helvetica,sans-serif'><input name='$area' type='checkbox' ");
424: if ($area eq 'board' || $area eq 'users') {
425: $r->print(qq|onClick='javascript:setOptions("$area","$counter")'|);
426: }
427: $r->print("/></font></td>
428: <td align='left'><font face='arial,helvetica,sans-serif'> $areaname{$area} - $count{$area} item(s)</font></td>");
429: if ($area eq 'board') {
430: $r->print(" <td align='left'><font face='arial,helvetica,sans-serif'>
1.2 ! raeburn 431: <select name='db_handling'>
1.1 raeburn 432: <option value='-2'><-- Check Import first
433: </select></font>
434: </td>");
435: } elsif ($area eq 'users') {
436: $r->print(" <td align='left'><font face='arial,helvetica,sans-serif'>
437: <select name='user_handling'>
438: <option value='-2'><-- Check Import first
439: </select>
440: </font>
441: </td>");
442: } else {
443: $r->print(" <td align='left'><font face='arial,helvetica,sans-serif'> None<input type='hidden' name='$count_tag' /></font></td>");
444: }
445: $counter ++;
446: $iter = $counter%2;
447: }
448: }
449: $r->print(<<ENDDOCUMENT);
450: </tr>
451: </table>
452: </td>
453: </tr>
454: </table>
455: </td>
456: </tr>
457: </table>
458: </td>
459: </tr>
460: <tr>
461: <td colspan='2'> <br /><br /></td>
462: </tr>
1.2 ! raeburn 463: <tr bgcolor='#CCCCFF'>
! 464: <td valign='middle'><img src='/res/adm/pages/bl_step4.gif'>
! 465: </td>
! 466: <td width='100%' align='left'>
! 467: <font face='arial,helvetica,sans-serif'><b>Choose display options for listing of contents of top level of package.</b></font>
! 468: </td>
! 469: </tr>
! 470: <tr>
! 471: <td colspan='2'> </td>
! 472: </tr>
1.1 raeburn 473: <tr>
474: <td> </td>
1.2 ! raeburn 475: <td>
! 476: <table border='0'>
! 477: <tr>
! 478: <td><font face='arial,helvetica,sans-serif'><input type="radio" name="toplevel" value="newfolder" />Display listing of contents in a new folder, with folder name: <input type="text" name="foldername" size="15" value="Type Name Here" /></font></td>
! 479: </tr>
! 480: <tr>
! 481: <td><font face='arial,helvetica,sans-serif'><input type="radio" name="toplevel" value="oldfolder" />Append listing of contents of top level of package to contents list for the current folder.</font></td>
! 482: </tr>
! 483: </table>
! 484: </td>
! 485: </tr>
! 486: <tr>
! 487: <td colspan='2'> </td>
! 488: </tr>
! 489: <tr>
! 490: <td> </td>
! 491: <td><font face='arial,helvetica,sans-serif'>Once you have checked the checkboxes for all areas you wish to import from the IMS package, selected options (if available), and selected a display option for the package contents you should click the 'Complete Import' button.</font></td>
1.1 raeburn 492: </tr>
493: <tr>
494: <td colspan='2'>
495: <input type="hidden" name="folder" value="$ENV{'form.folder'}" />
496: <input type="hidden" name="source" value="$cms" />
497: <input type="hidden" name="tempdir" value="$tempdir" />
498: <input type="hidden" name="phase" value="three" />
499: </td>
500: </tr>
501: <tr>
502: <td colspan='2'>
503: <table border='0' cellspacing='0' cellpadding='0' width="100%">
504: <tr>
505: <td align='left'>
506: <input type='button' name='exitpage' value='Exit now' onClick="javascript:self.close()">
507: </td>
508: <td align='right'>
509: <input type="button" name="nextpage" value="Complete Import" onClick="javascript:nextPage($counter)">
510: </td>
511: </tr>
512: </table>
513: </td>
514: </tr>
515: </table>
516: </td>
517: </tr>
518: </table>
519: ENDDOCUMENT
520: } else {
521: $r->print("Unpacking of your IMS package failed because an IMS manifest file was not located in the package\n");
522: }
523: } else {
524: $r->print("Processing of your IMS package failed because the file you uploaded could not be unzipped\n");
525: }
526: }
527:
528:
529: sub display_three {
1.2 ! raeburn 530: my ($r,$crs,$cdom,$chome,$uname,$udom,$areas,%cmsmap) = @_;
! 531: my $folder = $ENV{'form.folder'};
! 532: my $cms = $ENV{'form.source'};
! 533: my $tempdir = $ENV{'form.tempdir'};
! 534: my $longcrs = '';
! 535: if ($crs =~ m/^(\d)(\d)(\d)/) {
! 536: $longcrs = $1.'/'.$2.'/'.$3.'/'.$crs;
! 537: }
! 538: my %imports = ();
! 539: my @targets = ();
! 540: my %resources = ();
! 541: my %items = ();
! 542: my %hrefs = ();
! 543: my %urls = ();
! 544: my %resinfo = ();
! 545: my %total = (
! 546: page => 0,
! 547: prob => 0,
! 548: seq => 0,
! 549: board => 0,
! 550: quiz => 0,
! 551: surv => 0,
! 552: );
! 553: my @pages = ();
! 554: my @sequences = ();
! 555: my @resrcfiles = ();
! 556:
! 557: my $timenow = time;
! 558:
! 559: my $destdir = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$cdom.'/'.$crs.'/'.$timenow;
! 560: my $dirname = $cdom.'/'.$crs.'/'.$timenow;
! 561: my $seqstem = "/uploaded/$cdom/$crs/$timenow";
! 562: my $db_handling = '';
! 563: my $user_handling = '';
! 564:
! 565: my $toplevel = '';
! 566: my $foldername = '';
! 567: my %topitems = ();
! 568: if (defined($ENV{'form.toplevel'}) ) {
! 569: $toplevel = $ENV{'form.toplevel'};
! 570: }
! 571: if (defined($ENV{'form.foldername'}) ) {
! 572: $foldername = $ENV{'form.foldername'};
! 573: }
! 574:
! 575: foreach my $area (@{$areas}) {
! 576: if (defined($ENV{"form.$area"}) ) {
! 577: if ($cms eq 'angel' && $area eq 'doc') {
! 578: foreach (@{$cmsmap{$cms}{$area}}) {
! 579: $imports{$_} = 1;
! 580: }
! 581: } else {
! 582: $imports{$cmsmap{$cms}{$area}} = 1;
! 583: }
! 584: if ($area eq 'board') {
! 585: $db_handling = $ENV{'form.db_handling'};
! 586: } elsif ($area eq 'users') {
! 587: $user_handling = $ENV{'form.user_handling'};
! 588: }
! 589: }
! 590: }
1.1 raeburn 591:
1.2 ! raeburn 592: my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo);
! 593: if ($manifest_result eq 'ok') {
! 594: &Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets);
! 595: my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow);
! 596:
! 597: my @boards = ();
! 598: my @announcements = ();
! 599: my @quizzes = ();
! 600: my @surveys = ();
! 601: my @groups = ();
! 602: my %messages = ();
! 603: my @timestamp = ();
! 604: my %boardnum = ();
! 605: my @topurls = ();
! 606: my @topnames = ();
! 607:
! 608: &Apache::imsprocessor::process_resinfo($cms,$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$dirname,$seqstem,\@resrcfiles);
! 609:
! 610: &Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%resinfo,\%items,\%resources,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames);
! 611:
! 612: foreach my $item (@pages) {
! 613: my $path = $timenow.'/pages/';
! 614: ©_items($item,$path,$cdom,$chome,$crs);
! 615: }
! 616: foreach my $item (@sequences) {
! 617: unless ($item eq 'Top.sequence' && $toplevel eq 'oldfolder') {
! 618: my $path = $timenow.'/sequences/';
! 619: ©_items($item,$path,$cdom,$chome,$crs);
! 620: }
! 621: }
! 622: foreach my $item (@resrcfiles) {
! 623: my $path = $timenow.'/resfiles/';
! 624: ©_items($item,$path,$cdom,$chome,$crs);
! 625: }
! 626:
! 627: my @imports = ();
! 628: if ($toplevel eq 'oldfolder') {
! 629: for (my $i=0; $i<@topurls; $i++) {
! 630: my $url = &Apache::lonnet::unescape($topurls[$i]);
! 631: my $name = &Apache::lonnet::unescape($topnames[$i]);
! 632: push @imports, $name, $url;
! 633: }
! 634: } elsif ($toplevel eq 'newfolder') {
! 635: my $url = &Apache::lonnet::unescape("/uploaded/$cdom/$crs/$timenow/sequences/Top.sequence");
! 636: my $name = &Apache::lonnet::unescape("$ENV{'form.foldername'}");
! 637: push @imports, $name, $url;
! 638: }
! 639: my $errtext='';
! 640: my $fatal=0;
! 641: ($errtext,$fatal)= &Apache::londocs::mapread($crs,$cdom,$folder.'.sequence');
! 642: if ($#Apache::lonratedt::order<1) {
! 643: $Apache::lonratedt::order[0]=1;
! 644: $Apache::lonratedt::resources[1]='';
! 645: }
! 646: my ($errtext,$fatal)=&Apache::londocs::group_import($crs, $cdom, $folder,@imports);
! 647: if ($fatal) {
! 648: print STDERR "Fatal error during group_import\n";
! 649: }
! 650: }
! 651: $r->print(<<ENDBLOCK);
! 652: <table border='0' bgcolor='#F6F6F6'' cellspacing='0' cellpadding ='0' width='100%'>
! 653: <tr>
! 654: <td colspan='2'>
! 655: <table border='0' cellspacing='0' cellpadding='0'>
! 656: <tr>
! 657: <td colspan='2' align='left'>
! 658: </td>
! 659: </tr>
! 660: <tr bgcolor='#CCCCFF'>
! 661: <td valign='middle'><img src='/res/adm/pages/bl_step5.gif'>
! 662: </td>
! 663: <td width='100%' align='left'>
! 664: <font face='arial,helvetica,sans-serif'><b>Your import is complete</b></font>
! 665: </td>
! 666: </tr>
! 667: <tr>
! 668: <td colspan='2'> </td>
! 669: </tr>
! 670: <tr>
! 671: <td> </td>
! 672: <td>
! 673: ENDBLOCK
! 674: my $initblock = qq|
! 675: <form method="post" action="/adm/roles" target="loncapaclient" name="importDone">
! 676: <input type="hidden" name="orgurl" value="/adm/coursedocs" />
! 677: <input type="hidden" name="selectrole" value="1" />
! 678: <h3><font color="red">Changes will become active for your current session after
! 679: <input type="hidden" name="$ENV{'request.role'}" value="1" />
! 680: <input type="button" value="|;
! 681: $initblock .= &mt('re-initializing course');
! 682: $initblock .= qq|" onClick="javascript:init(this.form)"/>|;
! 683: $initblock .= &mt('or the next time you log in.');
! 684: $initblock .= qq|</font></h3></form>|;
! 685: $r->print($initblock);
! 686: $r->print(<<ENDBLOCKTWO);
! 687: </table>
! 688: </td>
! 689: </tr>
! 690: </table>
! 691: ENDBLOCKTWO
! 692: }
! 693:
! 694: sub copy_items {
! 695: my ($filename,$fpath,$cdom,$chome,$crs) = @_;
! 696: my $fetchresult= &Apache::lonnet::reply('fetchuserfile:'.$cdom.'/'.$crs.'/'.$filename.':'.$fpath,$chome);
1.1 raeburn 697: }
698:
699: 1;
700: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>