#!/usr/bin/perl -w # -*- perl -*- use P4CGI ; use strict ; # ################################################################# # CONFIGURATION INFORMATION # All config info should be in the config file # ################################################################# # # P4 view job # View a job # ################################################################# # Get file spec argument my $job = P4CGI::cgi()->param("JOB") ; &P4CGI::bail("No job specified") unless defined $job ; $job = &P4CGI::htmlEncode($job) ; # protect against malicious values # Get jobspec my %jobspec ; &P4CGI::p4readform("jobspec -o",\%jobspec) ; # Get field types: my %fieldTypes = map { /\d+ (\S+) (\S+)/ ; ($1,$2) ; } split("\n",$jobspec{"Fields"}) ; # Create title print &P4CGI::start_page("",(&P4CGI::buttonCell("jobList.cgi", "Select new list of jobs to view", "View job list"))) ; my @fields ; my %fieldData ; @fields = &P4CGI::p4readform("job -o '$job'",\%fieldData); # Check that job exist if($fieldData{"Description"} =~ //) { &P4CGI::signalError("Job $job does not exist") ; } # Fix user field if(exists $fieldData{"User"}) { $fieldData{"User"} = &P4CGI::ahref(-url => "userView.cgi", "USER=$fieldData{User}", "HELP=View user info", $fieldData{"User"}) ; } # Fix text fields my $fld ; foreach $fld (keys %fieldData) { if($fieldTypes{$fld} eq "text") { my $d = &P4CGI::formatDescription($fieldData{$fld}) ; $fieldData{$fld} = {-text=>"$d", -class=>"Description"} ; } } ; my @fixes ; &P4CGI::p4call(\@fixes,"fixes -j $job") ; if(@fixes > 0) { push @fields,"Fixed by" ; $fieldData{"Fixed by"} = join("
\n", map {/change (\d+) on (\S+) by (\S+)\@(\S+)/ ; my ($ch,$date,$user,$client) = ($1,$2,$3,$4) ; $ch = &P4CGI::ahref(-url => "changeView.cgi", "CH=$ch", "HELP=View change", $ch) ; $user = &P4CGI::ahref(-url => "userView.cgi", "USER=$user", "HELP=View user info", $user) ; $client = &P4CGI::ahref(-url => "clientView.cgi", "CLIENT=$client", "HELP=View client info", $client) ; "Change $ch on $date by $user\@$client" ; } @fixes ) ; } print &P4CGI::start_framedTable("Job $job") ; my $f ; foreach $f (@fields) { print &P4CGI::table_row({-class=>"\"Prompt\"", -text => $f}, $fieldData{$f}) ; } ; print &P4CGI::end_framedTable() ; print &P4CGI::end_page(); # # That's all folks #