#!/usr/bin/perl -w
# -*- perl -*-
use P4CGI ;
use strict ;
#
#################################################################
# CONFIGURATION INFORMATION
# All config info should be in P4CGI.pm
#
#################################################################
#
# Search changes for pattern
#
#################################################################
my $FSPC = &P4CGI::cgi()->param("FSPC") ;
$FSPC = "//..." unless defined $FSPC ;
$FSPC= &P4CGI::htmlEncode($FSPC) ; # protect against malicious parameter values
my $COMPLETE= &P4CGI::cgi()->param("COMPLETE") ;
print &P4CGI::start_page("Find changes ($FSPC)","") ;
sub prSelection($$$ )
{
my $title = shift @_ ;
my $cgitarget = shift @_ ;
my $fields = shift @_ ;
my $c = join("\n",
&P4CGI::start_table(),
&P4CGI::table_row(&P4CGI::cgi()->startform(-action => $cgitarget,
-method => "GET"),
{-align=>"left",
-valign=>"top",
-text => $fields},
{-align=>"left",
-text => " "},
{ -valign=>"bottom",
-text => " " . &P4CGI::cgi()->endform()
},
),
&P4CGI::end_table()) ;
print
&P4CGI::framedTable($title,$c) ;
} ;
prSelection("Find change",
"changeView.cgi",
join("\n",(&P4CGI::cgi()->textfield(-name => "CH",
-default => &P4CGI::CURRENT_CHANGE_LEVEL(),
-override => 1,
-size => 10,
-maxlength => 10,
-title => "Change number"),
&P4CGI::cgi()->hidden(-name=>"DP",
-value=>&P4CGI::CURR_DEPOT_NO()),
&P4CGI::cgi()->submit(-name => "0",
-value => "GO!",
-title => "View change")))
) ;
print "
" ;
prSelection("Find changes for file spec",
"changeList.cgi",
join("\n",(&P4CGI::start_table(),
"
",
"File spec: | ",
"",
&P4CGI::cgi()->textfield(-name => "FSPC",
-default => "$FSPC",
-override => 1,
-title =>
"File spec to search",
-size => 50,
-maxlength => 256),
" | ",
&P4CGI::cgi()->hidden(-name=>"DP",
-value=>&P4CGI::CURR_DEPOT_NO()),
&P4CGI::cgi()->submit(-name => "ignore",
-value => "GO!",
-title => "Start search"),
" |
",
""))
) ;
print "
" ;
prSelection("Find changes by description",
"changeList.cgi",
join("\n",(&P4CGI::start_table(),
"",
"File spec: | ",
"",
&P4CGI::cgi()->textfield(-name => "FSPC",
-default => "$FSPC",
-override => 1,
-title =>
"File spec to search",
-size => 50,
-maxlength => 256),
" |
",
"Pattern: | ",
"",
&P4CGI::cgi()->textfield(-name => "SEARCHDESC",
-default => "",
-override => 1,
-title =>
"Search pattern. Wildcards: ?=any character, *=any number of characters.",
-size => 50,
-maxlength => 256),
" | ",
"Invert search: | ",
"",
&P4CGI::cgi()->checkbox(-name => "SEARCH_INVERT",
-value => 1,
-label => " Search descriptions NOT including pattern"),
" | ",
&P4CGI::cgi()->hidden(-name=>"DP",
-value=>&P4CGI::CURR_DEPOT_NO()),
&P4CGI::cgi()->submit(-name => "ignore",
-value => "GO!",
-title => "Start search"),
" | ",
""))
) ;
print "
\n" ;
# Get users
my %userCvt ;
&P4CGI::p4user2name(\%userCvt) ;
map { $userCvt{$_} = "$_ - $userCvt{$_}" } keys %userCvt ;
my @listOfUsers = sort { uc($a) cmp uc ($b) } (keys %userCvt);
if(defined $COMPLETE) {
my %allUsers ;
local *P ;
&P4CGI::p4call(*P,"changes $FSPC") ;
while() {
/.*by (\S+)@/ ;
if(exists $allUsers{$1}) { $allUsers{$1} += 1 ; }
else { $allUsers{$1} = 1 ; }
} ;
foreach (keys %allUsers) {
if(!exists $userCvt{$_}) {
$userCvt{$_} = "Old user: $_ ($allUsers{$_} changes)" ;
push @listOfUsers,$_ ;
} else {
$userCvt{$_} .= " ($allUsers{$_} changes)" ;
}
} ;
}
# Get groups
my @listOfgroups ;
&P4CGI::p4call(\@listOfgroups, "groups" );
my $buttoncell = "" ;
unless(defined $COMPLETE) {
$buttoncell =
join("\n",("
" ,
&P4CGI::buttonCell($ENV{SCRIPT_NAME},
"Include old users in list",
"COMPLETE=Yes",
"FSPC=$FSPC",
"Include old users"),
"
")) ;
} ;
my $ulistSize = @listOfUsers ;
$ulistSize= 15 if $ulistSize > 15 ;
my $glistSize = @listOfgroups ;
$glistSize= 15 if $glistSize > 15 ;
prSelection("Find changes by user and group",
"changeList.cgi",
join("\n",
&P4CGI::start_table(),
$buttoncell,
&P4CGI::table_row({-class=>"Prompt",
-text => "File spec:"},
&P4CGI::cgi()->textfield(-name => "FSPC",
-default => $FSPC,
-override => 1,
-size => 50,
-maxlength => 256)
),
&P4CGI::table_row({-class=>"Prompt",
-text=>"User(s):"},
&P4CGI::cgi()->scrolling_list(-name => "USERS",
-values => \@listOfUsers,
-size => $ulistSize,
-multiple => 'true',
-labels => \%userCvt)
) ,
&P4CGI::table_row({-class=>"Prompt",
-text=>"Group(s):"},
&P4CGI::cgi()->scrolling_list(-name => "GROUPS",
-values => \@listOfgroups,
-size => $glistSize,
-multiple => 'true')
),
&P4CGI::table_row("",
&P4CGI::cgi()->hidden(-name=>"DP",
-value=>&P4CGI::CURR_DEPOT_NO()) .
&P4CGI::cgi()->submit(-name => "ignore",
-value => "GO!",
-title => "Start search")),
&P4CGI::end_table())) ;
print
&P4CGI::end_page() ;
#
# That's all folks
#