#!/usr/bin/perl -w # -*- perl -*- use P4CGI ; use strict ; use CGI::Carp ; # ################################################################# # CONFIGURATION INFORMATION # All config info should be in P4CGI.pm # ################################################################# # # List open files # ################################################################# # File argument my $FSPC = P4CGI::cgi()->param("FSPC") ; $FSPC = "//..." unless defined $FSPC ; $FSPC = &P4CGI::htmlEncode($FSPC) ; my $fspc=$FSPC ; my @FSPC = split(/\s*\+?\s*(?=\/\/)/,$FSPC) ; $FSPC = "".join(" and ",@FSPC)."" ; my $FSPCcmd = "\"" . join("\" \"",@FSPC) . "\"" ; my $SORTBY = P4CGI::cgi()->param("SORTBY") ; $SORTBY="USER" unless defined $SORTBY and $SORTBY eq "NAME" ; my $err2null = &P4CGI::REDIRECT_ERROR_TO_NULL_DEVICE() ; # Get info about opened status my @opened ; &P4CGI::p4call(\@opened,"opened -a $FSPCcmd $err2null") ; map { /(.*)\#(\d+) - (\S+) (\S+\s\S+) \S+ by (\S+)@(\S+)/ ; $_ = [$1,$2, $3,$4, $5,$6] ; } @opened ; # file status user # rev change client my @options ; my $noFiles=@opened ; if($SORTBY eq "USER") { my @tmp = sort { my @a = @$a ; my @b = @$b ; uc("$a[4] $a[5]").$a[0] cmp uc("$b[4] $b[5]").$b[0] ; } @opened ; @opened = @tmp ; push @options, &P4CGI::buttonCell($ENV{SCRIPT_NAME}, "Sort list by file name", "FSPC=$fspc", "SORTBY=NAME", "Sort by file") ; } else { push @options, &P4CGI::buttonCell($ENV{SCRIPT_NAME}, "Sort list by user", "FSPC=$fspc", "SORTBY=USER", "Sort by user") ; } ; @options = () if $noFiles == 0 ; print &P4CGI::start_page("List open files for
$FSPC",@options) ; # Create conversion hash for user -> fullname my %userCvt ; &P4CGI::p4user2name(\%userCvt ); my $filet = "$noFiles files" ; $filet = "No files found" if $noFiles == 0 ; $filet = "One file" if $noFiles == 1 ; print &P4CGI::start_framedTable($filet) ; my ($lastFile,$lastRev,$lastUser,$lastClient) = ("","","","") ; sub printLine(@) { my ($file,$rev,$status,$change,$user,$client) = @_ ; $change =~ s/\s*change\s*// ; my $Puser = &P4CGI::ahref(-url => "userView.cgi", -title=> "\"View user $userCvt{$user}\"", "USER=$user", "$user") . "/" ; my $Pclient = &P4CGI::ahref(-url => "clientView.cgi", -title =>"\"View client\"", "CLIENT=$client", "$client") ; my $Pfile = &P4CGI::ahref(-url => "fileLogView.cgi", -title => "\"View file log\"", "FSPC=$file", "$file") ; my $Prev = &P4CGI::ahref(-url => "fileViewer.cgi", -title => "\"View file\"", "FSPC=$file", "REV=$rev", "#$rev") ; if($change =~ /^\d+$/) { $change = &P4CGI::ahref(-url => "changeView.cgi", -title => "\"View change $change\"", "CH=$change", "$change") ; } if($SORTBY eq "NAME") { if($file eq $lastFile) { $Pfile = "" ; if($rev eq $lastRev) { $Prev = "" ; } } print &P4CGI::table_row("${Pfile}$Prev",$status,$change,"$Puser$Pclient") ; } elsif ($SORTBY eq "USER") { if($user eq $lastUser) { $Puser = "" ; if($client eq $lastClient) { $Pclient = "" ; } } print &P4CGI::table_row("$Puser$Pclient",$status,$change,"${Pfile}$Prev") ; } ; ($lastFile,$lastRev,$lastUser,$lastClient) = ($file,$rev,$user,$client) ; } ; print &P4CGI::start_table("") ; if($SORTBY eq "NAME") { print &P4CGI::table_header("File","Status","Change","User/Client") ; } elsif($SORTBY eq "USER") { print &P4CGI::table_header("User/Client","Status","Change","File") ; } ; map { printLine(@$_) ; } @opened ; print &P4CGI::end_table() ; print &P4CGI::end_framedTable() ; print &P4CGI::end_page() ; # # That's all folks #