--- loncom/interface/londocs.pm 2002/09/06 15:18:23 1.21 +++ loncom/interface/londocs.pm 2004/08/29 06:35:41 1.139 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.21 2002/09/06 15:18:23 www Exp $ +# $Id: londocs.pm,v 1.139 2004/08/29 06:35:41 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,15 +29,31 @@ package Apache::londocs; use strict; -use Apache::Constants qw(:common); +use Apache::Constants qw(:common :http); use Apache::lonnet; use Apache::loncommon; use Apache::lonratedt; use Apache::lonratsrv; use Apache::lonxml; +use Apache::loncreatecourse; +use Apache::lonnavmaps; +use HTML::Entities; +use GDBM_File; +use Apache::lonlocal; my $iconpath; +my %hash; + +my $hashtied; +my %alreadyseen=(); + +my $hadchanges; + +# Available help topics + +my %help=(); + # Mapread read maps into lonratedt::global arrays # @order and @resources, determines status # sets @order - pointer to resources in right order @@ -53,16 +69,423 @@ sub mapread { sub storemap { my ($coursenum,$coursedom,$map)=@_; - return + my ($outtext,$errtext)= &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'. $map,1); + if ($errtext) { return ($errtext,2); } + + $hadchanges=1; + return ($errtext,0); +} + +# ----------------------------------------- Return hash with valid author names + +sub authorhosts { + my %outhash=(); + my $home=0; + my $other=0; + foreach (keys %ENV) { + if ($_=~/^user\.role\.(au|ca)\.(.+)$/) { + my $role=$1; + my $realm=$2; + 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'}; + } else { + ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); + } + 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}=$myhome; + $other++; + } + } + } + return ($home,$other,%outhash); +} +# ------------------------------------------------------ Generate "dump" button + +sub dumpbutton { + my ($home,$other,%outhash)=&authorhosts(); + if ($home+$other==0) { return ''; } + my $output='