--- loncom/interface/londocs.pm 2003/09/05 18:11:26 1.73 +++ loncom/interface/londocs.pm 2003/09/08 18:56:09 1.74 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.73 2003/09/05 18:11:26 bowersj2 Exp $ +# $Id: londocs.pm,v 1.74 2003/09/08 18:56:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::loncommon; use Apache::lonratedt; use Apache::lonratsrv; use Apache::lonxml; +use Apache::loncreatecourse; use HTML::Entities; use GDBM_File; @@ -72,6 +73,63 @@ sub storemap { $map,1); } +# ----------------------------------------- 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+)$/); + } + if (&Apache::lonnet::homeserver($ca,$cd) eq + $Apache::lonnet::perlvar{'lonHostID'}) { + $home++; + $outhash{'home_'.$ca.'@'.$cd}=1; + } else { + $outhash{'otherhome_'.$ca.'@'.$cd}= + &Apache::lonnet::homeserver($ca,$cd); + $other++; + } + } + } + return ($home,$other,%outhash); +} +# ------------------------------------------------------ Generate "dump" button + +sub dumpbutton { + my ($home,$other,%outhash)=&authorhosts(); + if ($home+$other==0) { return ''; } + my $output=''; + if ($home) { + return ''. + ''; + } else { + return''. + 'Dump Course DOCS to Construction Space: available on other servers'; + } +} + +# -------------------------------------------------------- Actually dump course + +sub dumpcourse { + my ($home,$other,%outhash)=&authorhosts(); + unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; } + my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'}); + +} + # Imports the given (name, url) resources into the course # coursenum, coursedom, and folder must precede the list sub group_import { @@ -664,8 +722,7 @@ ENDNEWSCRIPT '','',$showdoc)); unless ($showdoc) { if ($allowed) { - $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', - 'Editing the Table of Contents for your Course')); + my $dumpbut=&dumpbutton(); $r->print(< @@ -677,10 +734,17 @@ ENDNEWSCRIPT
+ +
+ +$dumpbut +
ENDCOURSEVERIFY + $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', + 'Editing the Table of Contents for your Course')); } # --------------------------------------------------------- Standard documents $r->print('');