--- loncom/interface/londocs.pm 2003/09/15 17:58:21 1.79 +++ loncom/interface/londocs.pm 2007/07/20 00:28:27 1.294 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.79 2003/09/15 17:58:21 www Exp $ +# $Id: londocs.pm,v 1.294 2007/07/20 00:28:27 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,14 +30,19 @@ package Apache::londocs; use strict; use Apache::Constants qw(:common :http); +use Apache::imsexport; use Apache::lonnet; use Apache::loncommon; -use Apache::lonratedt; -use Apache::lonratsrv; +use LONCAPA::map(); +use Apache::lonratedt(); use Apache::lonxml; -use Apache::loncreatecourse; +use Apache::lonclonecourse; +use Apache::lonnavmaps; use HTML::Entities; use GDBM_File; +use Apache::lonlocal; +use Cwd; +use LONCAPA qw(:DEFAULT :match); my $iconpath; @@ -52,7 +57,7 @@ my $hadchanges; my %help=(); -# Mapread read maps into lonratedt::global arrays +# Mapread read maps into LONCAPA::map:: global arrays # @order and @resources, determines status # sets @order - pointer to resources in right order # sets @resources - array with the resources with correct idx @@ -61,16 +66,19 @@ my %help=(); sub mapread { my ($coursenum,$coursedom,$map)=@_; return - &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'. - $map); + &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'. + $map); } sub storemap { my ($coursenum,$coursedom,$map)=@_; + my ($outtext,$errtext)= + &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. + $map,1); + if ($errtext) { return ($errtext,2); } + $hadchanges=1; - return - &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. - $map,1); + return ($errtext,0); } # ----------------------------------------- Return hash with valid author names @@ -79,27 +87,29 @@ sub authorhosts { my %outhash=(); my $home=0; my $other=0; - foreach (keys %ENV) { + foreach (keys %env) { if ($_=~/^user\.role\.(au|ca)\.(.+)$/) { my $role=$1; my $realm=$2; - my ($start,$end)=split(/\./,$ENV{$_}); + my ($start,$end)=split(/\./,$env{$_}); if (($start) && ($start>time)) { next; } if (($end) && (time>$end)) { next; } my $ca; my $cd; if ($1 eq 'au') { - $ca=$ENV{'user.name'}; - $cd=$ENV{'user.domain'}; + $ca=$env{'user.name'}; + $cd=$env{'user.domain'}; } else { - ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); + ($cd,$ca)=($realm=~/^\/($match_domain)\/($match_username)$/); } - if (&Apache::lonnet::homeserver($ca,$cd) eq - $Apache::lonnet::perlvar{'lonHostID'}) { + my $allowed=0; + my $myhome=&Apache::lonnet::homeserver($ca,$cd); + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $myhome) { $allowed=1; } } + if ($allowed) { $home++; $outhash{'home_'.$ca.'@'.$cd}=1; } else { - $outhash{'otherhome_'.$ca.'@'.$cd}= - &Apache::lonnet::homeserver($ca,$cd); + $outhash{'otherhome_'.$ca.'@'.$cd}=$myhome; $other++; } } @@ -110,46 +120,60 @@ sub authorhosts { sub dumpbutton { my ($home,$other,%outhash)=&authorhosts(); + my $type = &Apache::loncommon::course_type(); if ($home+$other==0) { return ''; } - my $output='