--- loncom/imspackages/imsimport.pm 2004/12/13 20:01:09 1.8 +++ loncom/imspackages/imsimport.pm 2005/02/14 22:46:12 1.9 @@ -374,6 +374,8 @@ sub display_two { $unzip_result = &Apache::imsprocessor::expand_zip($tempdir,$fname); } my %resources = (); + my %includedres = (); + my %includeditems = (); my %items = (); my %hrefs = (); my %resinfo = (); @@ -397,7 +399,7 @@ sub display_two { my $conditions; if ($unzip_result eq 'ok') { - $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo); + $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'choose',\%includedres,\%includeditems); if ($manifest_result eq 'ok') { foreach my $res (sort keys %resources) { if ($cms eq 'bb5' || $cms eq 'bb6') { @@ -612,20 +614,16 @@ sub display_three { ($cdom,$crs) = split/\//,$ENV{'form.bb_crs'}; $chome = &Apache::lonnet::homeserver($crs,$cdom); } - if ( defined($ENV{'form.bb_handling'}) ) { - $db_handling = $ENV{'form.bb_handling'}; - } my $user_crs = ''; my $user_cdom = ''; my $user_handling = ''; if ( defined($ENV{'form.user_crs'}) ) { ($user_cdom,$user_crs) = split/\//,$ENV{'form.user_crs'}; } - if ( defined($ENV{'form.user_handling'}) ) { - $user_handling = $ENV{'form.user_handling'}; - } my $seqstem = "/res/$udom/$uname/$newdir"; - my %imports = (); + my %importareas = (); + my %includedres = (); + my %includeditems = (); my @targets = (); my %resources = (); my %items = (); @@ -648,13 +646,13 @@ sub display_three { my $tempdir = $ENV{'form.tempdir'}; foreach my $area (@{$areas}) { - if (defined($ENV{"form.$area"}) ) { + if (defined($ENV{"form.$area"}) ) { if ($cms eq 'angel' && $area eq 'doc') { foreach (@{$$cmsmap{$cms}{$area}}) { - $imports{$_} = 1; + $importareas{$_} = 1; } } else { - $imports{$$cmsmap{$cms}{$area}} = 1; + $importareas{$$cmsmap{$cms}{$area}} = 1; } if ($area eq 'board') { $db_handling = $ENV{'form.db_handling'}; @@ -663,14 +661,32 @@ sub display_three { } } } - my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo); + + my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'prepare',\%includedres); + if ($manifest_result eq 'ok') { + foreach my $res (sort keys %resources) { + if ($importareas{$resources{$res}{type}}) { + $includedres{$res} = 1; + } + } + foreach my $itm (sort keys %items) { + &Apache::imsprocessor::get_imports(\%includeditems,\%items,\%resources,\%importareas,$itm); + } + } + + foreach my $itm (sort keys %includeditems) { + &Apache::imsprocessor::get_parents(\%includeditems,\%items,$itm); + } + + $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo,'build',\%includedres,\%includeditems); if ($manifest_result eq 'ok') { - &Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets); + &Apache::imsprocessor::target_resources(\%resources,\%importareas,\@targets); my @boards = (); my @announcements = (); my @quizzes = (); my @surveys = (); + my @pools = (); my @groups = (); my %messages = (); my @timestamp = (); @@ -679,22 +695,25 @@ sub display_three { my @topnames = (); my @packages = (); - &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$newdir,$seqstem,\@resrcfiles,\@packages,\%hrefs,\@pages,\@sequences); + &Apache::imsprocessor::process_resinfo($cms,'CSTR',$tempdir,$destdir,\%items,\%resources,\@targets,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs,\@pages,\@sequences); - my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow); + my $copy_result = &Apache::imsprocessor::copy_resources('CSTR',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow,\%importareas); - &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages); + &Apache::imsprocessor::build_structure($cms,'CSTR',$destdir,\%items,\%resinfo,\%resources,\@targets,\%hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\@pools,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages,\%includeditems); - $r->print("