#!/usr/bin/perl -w
# -*- perl -*-
use P4CGI ;
use strict ;
#
#################################################################
# CONFIGURATION INFORMATION
# All config info should be in P4CGI.pm
#
#################################################################
#
# View a p4 client
#
#################################################################
# Get parameter
my $client = P4CGI::cgi()->param("CLIENT") ;
unless(defined $client) {
&P4CGI::bail("No client specified!") ;
} ;
# Get list of users and full names
my @users ;
&P4CGI::p4call(\@users, "users" );
my %users ;
map { s/^(\S+).* \((.*)\).*$/$1/ ; $users{$_}=$2 ; } @users ;
# Get client info
my %values ;
my @fields = &P4CGI::p4readform("client -o $client",\%values);
# Fix owner field
if(exists $users{$values{"Owner"}}) {
$values{"Owner"} = &P4CGI::ahref(-url => "userView.cgi" ,
"USER=$values{Owner}",
$values{"Owner"}) . " ($users{$values{Owner}})" ;
}
else {
$values{"Owner"} .= " No such user" ;
} ;
# Fix up description
{
my $d = &P4CGI::fixSpecChar($values{"Description"}) ;
$d =~ s/\n/
/g ;
$values{"Description"} = $d ;
}
# Fix Root
if(exists $values{"Root"}) {
$values{"Root"} = "$values{Root}" ;
} ;
# Fix Options
if(exists $values{"Options"}) {
$values{"Options"} = "$values{Options}" ;
} ;
# Fix view
{
my $view = &P4CGI::start_table("border=0 cellspacing=0 cellpadding=0") ;
foreach (split("\n",$values{"View"})) {
last if /^\s*$/ ;
my ($d,$c) = split(/\s+\/\//,$_) ;
$view .= &P4CGI::table_row("$d"," //$c") ;
} ;
$view .= &P4CGI::end_table() ;
$values{"View"} = $view ;
}
$| = 1 ;
print "",
&P4CGI::start_page("Client
$client",
&P4CGI::ul_list("user -- view user info",
"open file -- view file log",
&P4CGI::ahref(-url => "changeList.cgi",
"CLIENT=$client",
"FSPC=//...",
"List changes by client") .
" -- List changes made by client $client")) ;
# Check that client exist
unless(exists $values{"Client"}) {
&P4CGI::signalError("Client $client does not exist") ;
}
print
&P4CGI::start_table("") ;
my $f ;
foreach $f (@fields)
{
print &P4CGI::table_row({-align => "right",
-valign => "top",
-type => "th",
-text => $f},
$values{$f}) ;
} ;
my $openfiles ;
&P4CGI::p4call(*P4, "opened -a" );
while() {
chomp ;
/^(.+\#\d+) - (\S+) .* by (\S+)\@(\S+)/ and do {
my $f = $1 ;
my $u = $3 ;
my $r = "$2" ;
my $c = $4 ;
if($c eq $client) {
$f =~ /(.*)\#(\d+)/ ;
$f = &P4CGI::ahref(-url => "fileLogView.cgi",
"FSPC=$1",
"REV=$2",
"$f") ;
if(defined $openfiles) {
$openfiles .= "
$f - $r" ;
} else {
$openfiles = "$f - $r" ;
} ;
if($u ne $values{"Owner"}) {
$openfiles .= " by user $u" ;
}
} ;
} ;
} ;
if(defined $openfiles) {
print &P4CGI::table_row({-align => "right",
-type => "th",
-valign => "top",
-text => "Open files:"},
"$openfiles") ;
} ;
print
&P4CGI::end_table(),
&P4CGI::end_page() ;
#
# That's all folks
#