--- loncom/interface/loncommon.pm 2002/08/22 21:02:49 1.57 +++ loncom/interface/loncommon.pm 2002/08/28 14:11:27 1.62 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.57 2002/08/22 21:02:49 albertel Exp $ +# $Id: loncommon.pm,v 1.62 2002/08/28 14:11:27 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -755,6 +755,8 @@ sub authform_kerberos{ Kerberos authenticated with domain +Version 4 +Version 5 END return $result; } @@ -930,6 +932,51 @@ sub get_related_words { ## End Thesaurus Functions ## ############################################################### +# -------------------------------------------------------------- Plaintext name + +sub plainname { + my ($uname,$udom)=@_; + my %names=&Apache::lonnet::get('environment', + ['firstname','middlename','lastname','generation'], + $udom,$uname); + my $name=$names{'firstname'}.' '.$names{'middlename'}.' '. + $names{'lastname'}.' '.$names{'generation'}; + $name=~s/\s+$//; + $name=~s/\s+/ /g; + return $name; +} + +# ------------------------------------------------------------------ Screenname + +sub screenname { + my ($uname,$udom)=@_; + my %names= + &Apache::lonnet::get('environment',['screenname'],$udom,$uname); + return $names{'screenname'}; +} + +# ------------------------------------------------------------- Message Wrapper + +sub messagewrapper { + my ($link,$un,$do)=@_; + return +"$link"; +} +# ------------------------------------------------------------- Aboutme Wrapper + +sub aboutmewrapper { + my ($link,$un,$do)=@_; + return "$link"; +} + +# ------------------------------------------------------------ Syllabus Wrapper + + +sub syllabuswrapper { + my ($link,$un,$do)=@_; + return "$link"; +} + # ---------------------------------------------------------------- Language IDs sub languageids { return sort(keys(%language)); @@ -1146,9 +1193,69 @@ sub findallcourses { } ############################################### +############################################### + +=pod +=item &domainlogo() + +Inputs: $domain (usually will be undef) + +Returns: A link to a domain logo, if the domain logo exists. +If the domain logo does not exist, a description of the domain. + +=cut + +############################################### +############################################### +sub domainlogo { + my ($domain) = @_; + if (! $domain) { + # Determine domain if we have not been given one + $domain = $Apache::lonnet::perlvar{'lonDefDomain'}; + if ($ENV{'user.domain'}) { $domain=$ENV{'user.domain'}; } + if ($ENV{'request.role.domain'}) { + $domain=$ENV{'request.role.domain'}; + } + } + # See if there is a logo + if (-e '/home/httpd/html/adm/lonDomLogos/'.$domain.'.gif') { + return ''; + } elsif(exists($Apache::lonnet::domaindescription{$domain})) { + return $Apache::lonnet::domaindescription{$domain}; + } else { + return ''; + } +} + +############################################### +############################################### + +=pod + +=item &bodytag() + +Returns a uniform header for LON-CAPA web pages. + +Inputs: + + $title, A title to be displayed on the page. + $function, the current role (can be undef). + $addentries, extra parameters for the tag. + $bodyonly, if defined, only return the tag. + $domain, if defined, force a given domain. + +Returns: A uniform header for LON-CAPA web pages. +If $bodyonly is nonzero, a string containing a tag will be returned. +If $bodyonly is undef or zero, an html string containing a tag and +other decorations will be returned. + +=cut + +############################################### +############################################### sub bodytag { - my ($title,$function,$addentries)=@_; + my ($title,$function,$addentries,$bodyonly,$domain)=@_; unless ($function) { $function='student'; if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { @@ -1208,11 +1315,17 @@ sub bodytag { } unless ($realm) { $realm=' '; } # Set messages - my $messages=localtime(); + my $messages=&domainlogo($domain); # Output - return(< +END + if ($bodyonly) { + return $bodytag; + } else { + return(< @@ -1237,6 +1350,7 @@ $addentries> $realm 
ENDBODY + } } ###############################################