#!/usr/local/bin/perl5
# -*- perl -*-
use P4CGI ;
use strict ;
#
#####################################################################
##
## CONFIGURATION INFORMATION:
## All config info should be in $configFile (see init() in P4CGI.pm)
##
#####################################################################
##
## Changes By User
##
#####################################################################
# Set back references
my $homepage="index.cgi";
my $backtohome="Back to Home" ;
# Vars for columnizing
my $totalUsers ;
my $usersPerColumn ;
my $usersRemainder ;
my $usersColumn1 ;
my $usersColumn2 ;
my $usersColumn3 ;
my $users1 ;
my $users2 ;
my $users3 ;
# Get users
my @tmp;
&P4CGI::p4call(\@tmp, "users" );
my $user ;
my @users ;
foreach $user (sort { uc($a) cmp uc($b) } @tmp)
{
my ( $uid, $name, $listuser ) ;
$user =~ /^(\w+)\s+<.*>\s+(\(.*\))\s+accessed.*/ and do {
$uid = $1 ;
$name= $2 ;
$listuser = &P4CGI::ahref(-url => &P4CGI::CHB_URL(), "FSPC=//...",
"USER=$uid", $uid),
$listuser .= " " . $name . "
";
++$totalUsers ; push ( @users, $listuser ) ;
}
}
$usersPerColumn = $totalUsers / 3 ;
$usersRemainder = $totalUsers % 3 ;
if ( $usersRemainder ) {
$usersColumn1 = $usersPerColumn + 1 ;
$usersColumn2 = $usersPerColumn + 1 ;
$usersColumn3 = $usersPerColumn ;
}
else {
$usersColumn1 = $usersPerColumn ;
$usersColumn2 = $usersPerColumn ;
$usersColumn3 = $usersPerColumn ;
}
# Split users into 3 columns
my @tmpusers1 ;
my @tmpusers2 ;
my @tmpusers3 ;
if(@users) {
@tmpusers1 = splice(@users,0,$usersColumn1) ;
@tmpusers2 = splice(@users,0,$usersColumn2) ;
@tmpusers3 = splice(@users,0,$usersColumn3) ;
}
if( @tmpusers1 ) {
$users1 = join("\n", @tmpusers1) ;
}
else {
$users1 = "No users!\n" ;
}
if( @tmpusers2 ) {
$users2 = join("\n", @tmpusers2) ;
}
if( @tmpusers3 ) {
$users3 = join("\n", @tmpusers3) ;
}
# Print title and legend
print
"",
&P4CGI::start_page("Changes by User",
&P4CGI::ul_list(
"User: to see list of changes for that user"),
$homepage,$backtohome) ;
# Print user in 3 columns
print
"",
"
", "$users1", " | ", " | ", "$users2", " | ", " | ", "$users3", " |