#!/usr/bin/perl -w
# -*- perl -*-
use P4CGI ;
use strict ;
#
#################################################################
# CONFIGURATION INFORMATION
# All config info should be in P4CGI.pm
#
#################################################################
#
# P4 view a group
#
#
#################################################################
$| = 1 ; # turn off output buffering
# Get parameter
my $group = P4CGI::cgi()->param("GROUP") ;
unless(defined $group) {
&P4CGI::bail("No group specified!") ;
} ;
$group = &P4CGI::htmlEncode($group) ;
# Get real user names...
my %userCvt ;
&P4CGI::p4user2name(\%userCvt );
my %groups ;
{
my @groups ;
&P4CGI::p4call(\@groups, "groups" );
%groups = map { ($_,1) ; } @groups ;
}
# Get user info
my %values ;
my @fields = &P4CGI::p4readform("group -o '$group'",\%values);
print "",
&P4CGI::start_page("View group $group",
(&P4CGI::buttonCell("changeList.cgi",
"List changes by group $group",
"GROUP=$group",
"FSPC=//...",
"List changes"))) ;
unless(exists $groups{$group}) {
&P4CGI::signalError("No such group \"$group\"") ;
}
print
&P4CGI::start_framedTable("Group $group"),
&P4CGI::start_table("") ;
my @emailUsers ;
if(exists $values{"Users"}) {
my @users ;
foreach (split( /\s+/,$values{"Users"})) {
my $fullname ;
if(exists $userCvt{$_}) {
$fullname = "($userCvt{$_})" ;
push @emailUsers,$_ ;
push @users, &P4CGI::ahref(-url => "userView.cgi",
"USER=$_",
"HELP=View user info",
"$_ $fullname") ;
}
else {
$fullname = "(No such user)" ;
push @users, "$_ $fullname" ;
} ;
} ;
$values{"Users"} = join("
\n",@users) ;
} ;
if(exists $values{"Subgroups"}) {
my @subgroups ;
foreach (split( /\s+/,$values{"Subgroups"})) {
my $sg ;
if(exists $groups{$_}) {
push @subgroups, &P4CGI::ahref(-url => "groupView.cgi", #
"GROUP=$_",
"HELP=View group info",
$_) ;
}
else {
push @subgroups, "$_ (No such group)" ;
} ;
} ;
$values{"Subgroups"} = join("
\n",@subgroups) ;
} ;
my $f ;
foreach $f (@fields) {
print &P4CGI::table_row({-class => "Prompt",
-text => "$f"},
$values{$f}) ;
} ;
print
&P4CGI::end_table(),
&P4CGI::end_framedTable() ;
if(@emailUsers > 0) {
my @email ;
foreach (@emailUsers) {
my %data ;
&P4CGI::p4readform("user -o '$_'",\%data) ;
if(exists $data{"Email"}) {
push @email,$data{"Email"} ;
}
}
my $email = join(",",@email) ;
my $emailbutton = &P4CGI::buttonCell("mailto:$email",
"Send an email to all group members",
"Subject=To members in group $group",
"Email group") ;
print &P4CGI::buttonHMenuTable(($emailbutton)) ;
}
print &P4CGI::end_page() ;
#
# That's all folks
#