--- loncom/cgi/userstatus.pl 2006/06/02 21:36:21 1.13 +++ loncom/cgi/userstatus.pl 2006/09/01 10:54:08 1.14 @@ -1,7 +1,7 @@ #!/usr/bin/perl $|=1; # User Status -# $Id: userstatus.pl,v 1.13 2006/06/02 21:36:21 albertel Exp $ +# $Id: userstatus.pl,v 1.14 2006/09/01 10:54:08 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,9 +48,9 @@ sub analyze_time { my ($since)=@_; my $color="#000000"; my $userclass=$actl[0]; - if ($since>300) { $color="#222222"; } + if ($since>300) { $color="#222222"; $userclass=$actl[1]; } if ($since>600) { $color="#444444"; } - if ($since>1800) { $color="#666666"; $userclass=$actl[1]; } + if ($since>1800) { $color="#666666"; } if ($since>7200) { $color="#888888"; } if ($since>21600) { $color="#AAAAAA"; $userclass=$actl[2]; } return ($color,$userclass); @@ -78,6 +78,7 @@ sub main { opendir(DIR,$$perlvar{'lonIDsDir'}); my @allfiles=(sort(readdir(DIR))); + my %users; foreach my $filename (@allfiles) { if ($filename=~/^\./) { next; } if ($filename=~/^publicuser_/) { next; } @@ -88,7 +89,7 @@ sub main { my $now=time; my $since=$now-$mtime; my $sinceacc=$now-$atime; - unless ($oneline || $justsummary) { print ("\n\n
"); } + #unless ($oneline || $justsummary) { print ("\n\n
"); } my %userinfo; ($userinfo{'user.name'},undef,$userinfo{'user.domain'})= split('_',$filename); @@ -107,8 +108,9 @@ sub main { } $fh->close(); if (!$justsummary) { - print ''; - print '

'.$userinfo{'environment.lastname'}.', '. + $users{$userclass}{$filename} .= + ''. + '

'.$userinfo{'environment.lastname'}.', '. $userinfo{'environment.firstname'}.' '. $userinfo{'environment.middlename'}.' '. $userinfo{'environment.generation'}." (". @@ -126,20 +128,36 @@ sub main { my $cid=$userinfo{'request.course.id'}; my $coursename= $userinfo{'course.'.$cid.'.description'}. ' ('.$cid.')'; - if (!$justsummary) { print "Course: ".$coursename; } + if (!$justsummary) { + $users{$userclass}{$filename} .= + "Course: ".$coursename; + } &add_count('Course',$coursename,$userclass); } else { - if (!$justsummary) { print "Not in a course."; } + if (!$justsummary) { + $users{$userclass}{$filename} .= + "Not in a course."; + } &add_count('Course','No Course',$userclass); } if (!$justsummary) { - print "
Last Transaction: ".localtime($mtime). + $users{$userclass}{$filename} .= + "
Last Transaction: ".localtime($mtime). " (".$since." secs ago)
Last Access: ". - localtime($atime)." (".$sinceacc." secs ago)"; - print ("
"); + localtime($atime)." (".$sinceacc." secs ago)". + "
"; } } } + if (!$oneline && !$justsummary) { + foreach my $class (@actl) { + print("\n\n

$class

"); + foreach my $filename (sort(keys(%{$users{$class}}))) { + print("\n\n".$users{$class}{$filename}."\n\n
"); + } + } + } + closedir(DIR); open (LOADAVGH,"/proc/loadavg"); my $loadavg=;