#!/usr/bin/perl -w # -*- perl -*- use P4CGI ; use strict ; # ################################################################# # CONFIGURATION INFORMATION # All config info should be in P4CGI.pm # ################################################################# # # List p4 clients # ################################################################# sub weeksago($$$ ) { # Take Year, month and day of month as parameter and return the number # of week that has passed since that date my ($y,$m,$d) = @_ ; $y -= 1900 ; $m-- ; my $_now = time() ; my $_then = $_now ; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($_then); if(($y > $year) or (($y == $year) and ($m > $mon)) or (($y == $year) and ($m == $mon) and ($d > $mday))) { return 0 ; } # The algorithm is not very robust, take current date and # remove one day at the time until the date match the requested # date. Can fail miserably for a number of combinations of # illegal input.... while(1) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($_then); if(($y == $year) and ($m == $mon) and ($d == $mday)) { return int(( $_now - $_then)/(3600*24*7)) ; } $_then -= 3600*24 ; } ; } my $user = P4CGI::cgi()->param("USER") ; my $mode = P4CGI::cgi()->param("MODE") ; $mode = "Brief" unless (defined $mode) and ($mode eq "Complete") ; if (defined $user) { $mode = "Complete" ; $user = &P4CGI::htmlEncode($user) ; } ; my $WARNING_LEVEL = &P4CGI::UNUSEDCLIWL() ; $WARNING_LEVEL = 10 unless $WARNING_LEVEL =~ /^\d+$/ ; # Get clients my %clientInfo = &P4CGI::p4clients(); my @clients = keys %clientInfo ; my $clients = @clients ; my $warnings = 0 ; my $title = "P4 clients" ; if(defined $user) { $title .= "<br>for user $user" ; } $| = 1 ; my @legend ; my $lastaccess = undef ; my $owner = undef ; if($mode eq "Brief") { push @legend,&P4CGI::buttonCell("", "Show owner and access info in table (slow)", "MODE=Complete", "Show owner and access info") ; } else { $lastaccess = "Last access" ; $owner = "Owner" ; } ; if(defined $user) { push @legend,&P4CGI::buttonCell("clientList.cgi", "Show all clients on depot", "Show all clients") ; } print "", &P4CGI::start_page("List clients", @legend) ; unless(defined $user) { print &P4CGI::start_framedTable("$clients clients") ; } else { print &P4CGI::start_framedTable("$title") ; } print "", &P4CGI::start_table(" cellpadding=1"), &P4CGI::table_header("Client","",$owner, "Updated",$lastaccess); # Get users my %users ; &P4CGI::p4user2name(\%users); &P4CGI::ERRLOG("Mode: $mode" ); if($mode ne "Brief") { my $client ; foreach $client (sort { uc($a) cmp uc($b) } @clients) { my %values ; my @fields = &P4CGI::p4readform("client -o '$client'",\%values) ; my $warning = "" ; if(exists $values{"Date"}) { $values{"Update"} = $values{"Date"} ; $values{"Access"} = "---" ; delete $values{"Date"} ; } else { if($values{"Access"} =~ /(\d\d\d\d)\/(\d\d)\/(\d\d)/) { my $weeksOld = weeksago($1,$2,$3) ; if($weeksOld >= $WARNING_LEVEL) { if($warning ne "") { $warning .= "<br>\n" ; } ; $warning .= "Not used for $weeksOld weeks!" ; } } } if(exists $values{"Owner"}) { $owner = $values{"Owner"} ; $values{"OwnerName"} = $owner ; if(exists $users{$owner}) { $values{"Owner"} = &P4CGI::ahref(-url => "userView.cgi" , "USER=$owner", "HELP=View user info", $owner), } else { if($warning ne "") { $warning .= "<br>\n" ; } ; $warning .= "Owner does not exist!" ; } } ; unless((defined $user) and ( uc($user) ne uc($owner))) { $values{"Warnings"} = $warning ; $clientInfo{$client} = { %{$clientInfo{$client}},%values} ; if($warning ne "") { $warnings++ ; } ; } } ; } my $client ; foreach $client (sort { uc($a) cmp uc($b) } @clients) { my %info = %{$clientInfo{$client}} ; $info{"Warnings"} = "" unless defined $info{"Warnings"} ; if((!defined $user) or (uc($user) eq uc($info{"OwnerName"}))) { print join("\n",(&P4CGI::table_row(-valign=>"top", undef, &P4CGI::ahref(-url => "clientView.cgi", "CLIENT=$client", "HELP=View client info", $client), $info{"Owner"}, $info{"Update"}, $info{"Access"}, "<font color=red><b>$info{Warnings}</b></font>"). &P4CGI::table_row({-text=>"", -style=>"width: 30pt"}, undef, undef, undef, undef, { -class=>"Description", -text => &P4CGI::formatDescription($info{"Description"}), }))) ; } } print &P4CGI::end_table(), &P4CGI::end_framedTable() ; if($warnings > 0) { my $s = "" ; $s = "s" if $warnings != 1 ; $warnings = "<font color=red>($warnings warning$s)</font>" ; } else { $warnings = "" ; } print " $warnings<br>", &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 | 4973 | Fredric Fredricson |
P4DB: Worked around some IE CSS-bugs. Improved page layout for branch, client and job lists. |
||
#6 | 4306 | Fredric Fredricson |
P4DB: Hardened P4DB against malicious parameters (cross site scripting), performed some cleanup and increased version to 3.1.1. |
||
#5 | 4046 | Fredric Fredricson |
P4DB: First submit for 3.1. * Removed frame-stuff and some related files * Added new page header * Started update of documentation * Changed a lot of CGI:s to conform to new "look and feel" Still a lot to do: - clean up stuff (especially the javascript) - Fix the file list to use new annotate-command - Clean up and document css-file - and more....... |
||
#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 |