--- loncom/imspackages/imsimportdocs.pm 2004/03/16 19:20:58 1.3 +++ loncom/imspackages/imsimportdocs.pm 2004/08/05 23:21:49 1.7 @@ -1,3 +1,26 @@ +# Copyright Michigan State University Board of Trustees +# +# This file is part of the LearningOnline Network with CAPA (LON-CAPA). +# +# LON-CAPA is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LON-CAPA is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LON-CAPA; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# /home/httpd/html/adm/gpl.txt +# +# http://www.lon-capa.org/ +# + package Apache::imsimportdocs; use Apache::Constants qw(:common :http :methods); @@ -44,8 +67,8 @@ function setOptions(caller,itemnum) { if (caller == "board") { opForm.elements[menu].options[0] = new Option("Select","-1",true,true) opForm.elements[menu].options[1] = new Option("Import topics only","topics",true,true) - opForm.elements[menu].options[2] = new Option("Import topics & posts (with author)","allpost",true,true) - opForm.elements[menu].options[3] = new Option("Import topics & posts (no author)","allanon",true,true) + opForm.elements[menu].options[2] = new Option("Import topics + posts (with author)","allpost",true,true) + opForm.elements[menu].options[3] = new Option("Import topics + posts (no author)","allanon",true,true) } else { if (caller == "users") { @@ -210,6 +233,7 @@ Please choose the CMS used to create you @@ -310,7 +334,7 @@ sub display_two { $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo); if ($manifest_result eq 'ok') { foreach my $res (sort keys %resources) { - if ($cms eq 'bb5') { + if ($cms eq 'bb5' || $cms eq 'bb6') { foreach my $area (keys %{$cmsmap{$cms}}) { if ($resources{$res}{type} eq $cmsmap{$cms}{$area}) { $count{$area} ++; @@ -505,7 +529,6 @@ sub display_three { my $timenow = time; my $destdir = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$cdom.'/'.$crs.'/'.$timenow; - my $dirname = $cdom.'/'.$crs.'/'.$timenow; my $seqstem = "/uploaded/$cdom/$crs/$timenow"; my $db_handling = ''; my $user_handling = ''; @@ -539,8 +562,21 @@ sub display_three { my $manifest_result = &Apache::imsprocessor::process_manifest($cms,$tempdir,\%resources,\%items,\%hrefs,\%resinfo); if ($manifest_result eq 'ok') { + my @path = ($cdom,$crs,$timenow); + my $fullpath = $Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles'; + foreach my $item (@path) { + $fullpath .= '/'.$item; + if (!-e "$fullpath") { + mkdir("$fullpath",0770); + } + } + my @namedirs = ("resfiles","sequences","pages","problems"); + foreach my $name (@namedirs) { + if (!-e "$fullpath/$name") { + mkdir("$fullpath/$name",0770); + } + } &Apache::imsprocessor::target_resources(\%resources,\%imports,\@targets); - my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow); my @boards = (); my @announcements = (); @@ -552,10 +588,13 @@ sub display_three { my %boardnum = (); my @topurls = (); my @topnames = (); + my @packages = (); - &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); + &Apache::imsprocessor::process_resinfo($cms,'DOCS',$tempdir,$destdir,\%items,\%resources,\@boards,\@announcements,\@quizzes,\@surveys,\@groups,\%messages,\@timestamp,\%boardnum,\%resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,\%total,$seqstem,$seqstem,\@resrcfiles,\@packages,\%hrefs); + + my $copy_result = &Apache::imsprocessor::copy_resources('DOCS',$cms,\%hrefs,$tempdir,\@targets,\%urls,$crs,$cdom,$chome,$destdir,$timenow); - &Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames); + &Apache::imsprocessor::build_structure($cms,'DOCS',$destdir,\%items,\%resinfo,\%resources,\%hrefs,$udom,$uname,'',$timenow,$cdom,$crs,\@timestamp,\%total,\@boards,\@announcements,\@quizzes,\@surveys,\%boardnum,\@pages,\@sequences,\@topurls,\@topnames,\@packages); foreach my $item (@pages) { my $filename = $timenow.'/pages/'.$item;