--- loncom/interface/loncommon.pm 2002/07/22 14:25:40 1.47 +++ loncom/interface/loncommon.pm 2002/08/20 21:29:34 1.54 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.47 2002/07/22 14:25:40 bowersj2 Exp $ +# $Id: loncommon.pm,v 1.54 2002/08/20 21:29:34 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -80,7 +80,7 @@ package Apache::loncommon; use strict; use Apache::lonnet(); use GDBM_File; -use POSIX qw(strftime); +use POSIX qw(strftime mktime); use Apache::Constants qw(:common); use Apache::lonmsg(); my $readit; @@ -242,7 +242,7 @@ of the element the selection from the se ############################################################### sub browser_and_searcher_javascript { return <(Help: $topic) -ENDTEMPLATE + $link = "javascript:void(open('/adm/help/${filename}.hlp', 'Help_for_$topic', 'menubar=0,toolbar=1,scrollbars=1,width=$width,height=$height'))"; } else { - $template = <<"ENDTEMPLATE"; -(Help: $topic) -ENDTEMPLATE + $link = "/adm/help/${filename}.hlp"; + } + + # Add the text + if ($text ne "") + { + $template .= "$text "; } + # Add the graphic + $template .= <<"ENDTEMPLATE"; +(Help: $topic) +ENDTEMPLATE + return $template; } @@ -552,7 +558,7 @@ sub select_dom_form { =pod -=item get_home_servers($domain) +=item get_library_servers($domain) Returns a hash which contains keys like '103l3' and values like 'kirk.lite.msu.edu'. All of the keys will be for machines in the @@ -561,15 +567,15 @@ given $domain. =cut #------------------------------------------- -sub get_home_servers { +sub get_library_servers { my $domain = shift; - my %home_servers; + my %library_servers; foreach (keys(%Apache::lonnet::libserv)) { if ($Apache::lonnet::hostdom{$_} eq $domain) { - $home_servers{$_} = $Apache::lonnet::hostname{$_}; + $library_servers{$_} = $Apache::lonnet::hostname{$_}; } } - return %home_servers; + return %library_servers; } #------------------------------------------- @@ -586,7 +592,7 @@ returns a string which contains an '; } $prevattempts.=''; @@ -1145,6 +1151,115 @@ sub get_student_answers { ############################################### + +sub timehash { + my @ltime=localtime(shift); + return ( 'seconds' => $ltime[0], + 'minutes' => $ltime[1], + 'hours' => $ltime[2], + 'day' => $ltime[3], + 'month' => $ltime[4]+1, + 'year' => $ltime[5]+1900, + 'weekday' => $ltime[6], + 'dayyear' => $ltime[7]+1, + 'dlsav' => $ltime[8] ); +} + +sub maketime { + my %th=@_; + return POSIX::mktime( + ($th{'seconds'},$th{'minutes'},$th{'hours'}, + $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,$th{'dlsav'})); +} + + +sub findallcourses { + my %courses=(); + my $now=time; + foreach (keys %ENV) { + if ($_=~/^user\.role\.\w+\.\/(\w+)\/(\w+)/) { + my ($starttime,$endtime)=$ENV{$_}; + my $active=1; + if ($starttime) { + if ($now<$starttime) { $active=0; } + } + if ($endtime) { + if ($now>$endtime) { $active=0; } + } + if ($active) { $courses{$1.'_'.$2}=1; } + } + } + return keys %courses; +} + +############################################### + +sub bodytag { + my ($function,$title,$addentries)=@_; + my $img=''; + my $pgbg=''; + my $tabbg=''; + my $font=''; + my $link=''; + my $alink='#CC0000'; + my $vlink=''; + if ($function eq 'admin') { + $img='admin'; + $pgbg='#FFFFCC'; + $tabbg='#CCCC99'; + $font='#772200'; + $link='#663300'; + $vlink='#666600'; + } elsif ($function eq 'coordinator') { + $img='coordinator'; + $pgbg='#CCFFFF'; + $tabbg='#CCCCFF'; + $font='#000033'; + $link='#003333'; + $vlink='#006633'; + } elsif ($function eq 'author') { + $img='author'; + $pgbg='#CCFFFF'; + $tabbg='#CCFFCC'; + $font='#003300'; + $link='#003333'; + $vlink='#006666'; + } else { + $img='student'; + $pgbg='#FFFF99'; + $tabbg='#FF9900'; + $font='#991100'; + $link='#993300'; + $vlink='#996600'; + } + my $role=&Apache::lonnet::plaintext((split(/\./,$ENV{'request.role'}))[0]); + if ($ENV{'request.course.id'}) { + $role.='
'.$ENV{'course.'.$ENV{'request.course.id'}.'.description'}; + } + return(< + + + + + + +
+
+$title + + + $ENV{'environment.firstname'} + $ENV{'environment.middlename'} + $ENV{'environment.lastname'} + $ENV{'environment.generation'} + +
+$role +

+ENDBODY +} ############################################### sub get_unprocessed_cgi {