clientView.cgi #5

  • //
  • guest/
  • fredric_fredricson/
  • P4DB/
  • main/
  • clientView.cgi
  • View
  • Commits
  • Open Download .zip Download (4 KB)
#!/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!") ;
} ;
$client = &P4CGI::htmlEncode($client) ;

# 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}",
				     "HELP=View user info",
				     $values{"Owner"}) . " ($users{$values{Owner}})" ;  
}
else {
    $values{"Owner"} .= " <font color=red>No such user</font>" ;
} ;

				# Fix up description
{
    my @referenced ;
    $values{"Description"} = &P4CGI::formatDescription($values{"Description"},
						       \@referenced) ;
}

				# Fix Root
if(exists $values{"Root"}) {
    $values{"Root"} = "<tt>$values{Root}</tt>" ;
} ;

				# Fix Options
if(exists $values{"Options"}) {
    $values{"Options"} = "<tt>$values{Options}</tt>" ;
} ;
				# 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("<tt>$d</tt>","<tt>&nbsp;//$c</tt>") ;	    
    } ;	  
    $view .= &P4CGI::end_table() ;
    $values{"View"} = $view ;
}

$| = 1 ;

print "",
    &P4CGI::start_page("",
		       &P4CGI::buttonCell("changeList.cgi",
					  "List changes by client $client",
					  "CLIENT=$client",
					  "FSPC=//...",
					  "List changes")) ;

				# Check that client exist
unless(exists $values{"Client"}) {
    &P4CGI::signalError("Client $client does not exist") ;
}

print
    &P4CGI::start_framedTable("Client $client"),
    &P4CGI::start_table("") ;

my $f ; 
foreach $f (@fields) 
{
    my %xopt ;
    $xopt{"class"} = "Description" if $f eq "Description" ;
    $xopt{"class"} = "Description" if $f eq "View" ;
    print  &P4CGI::table_row({-class => "Prompt",
			      -text  => $f},
			     {%xopt,
			      -text => $values{$f}}) ;
} ;

my @openfiles ;
&P4CGI::p4call(*P4, "opened -a" );
while(<P4>) {
    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+)/ ;
	    if($r ne "add") {
		$f = &P4CGI::ahref(-url => "fileLogView.cgi",
				   "FSPC=$1",
				   "REV=$2",
				   "HELP=View file log",
				   "$f") ;
	    }
	    $u = &P4CGI::ahref(-url => "userView.cgi",
			       "USER=$u",
			       "HELP=View user info",
			       "$u") ;
	    push @openfiles,&P4CGI::table_row({-class=>"ListC",
					       -text => $r},
					      {-class=>"List",
					       -text => $f},
					      {-class=>"ListC",
					       -text => $u}) ;
	} ;
    } ;
} ;

if(@openfiles > 0) {
    print  &P4CGI::table_row({-class  => "Prompt",
			      -text   => "Open&nbsp;files:"},
			     &P4CGI::start_table("").
			     &P4CGI::table_header("Action","File","User") .
			     join("\n",@openfiles) .
			     &P4CGI::end_table()) ;
} ;


print 
    &P4CGI::end_table(),
    &P4CGI::end_framedTable(),
    &P4CGI::end_page() ;

#
# That's all folks
#




# Change User Description Committed
#8 4998 Fredric Fredricson P4DB: cleaned up some code.
Added p4users(), p4client() and p4user2name() to P4CGI.pm and modified
all cgi:s to use these,
#7 4318 Fredric Fredricson P4DB: Bug in client view.
Could not handle spaces in directories in client map
#6 4313 Fredric Fredricson P4DB:
- Removed some error messages (that clobbers the error log for the web server)
- Added a CSS file that works for people with color vision deficiency
- Fixed minor bug in the scripts that creates the tarball and zip-file
#5 4306 Fredric Fredricson P4DB: Hardened P4DB against malicious parameters (cross site scripting),
performed some cleanup and increased version to 3.1.1.
#4 2942 Fredric Fredricson P4DB: Fixed bug: Can now handle spaces in label names etc....
#3 2875 Fredric Fredricson P4DB 3.0 first beta...
#2 1920 Fredric Fredricson P4DB: Mainly some user interface fixes:
* Added a small arrow that points to selection in list of options
* Added tooltip help
* Added user prefereces to turn the above off (or on)
* Some other user interface fixes
And fixed a bug in jobList.cgi and some minor bugs in label and branch
viewers.
#1 1638 Fredric Fredricson P4DB: Added all (I think) files for P4DB