[Rt-commit] r5174 - in RT-Extension-TimeWorked: . html
html/Callbacks html/Callbacks/TimeWorked
html/Callbacks/TimeWorked/Elements html/Callbacks/TimeWorked/NoAuth
html/Callbacks/TimeWorked/NoAuth/webrt.css
html/Callbacks/TimeWorked/Search
html/Callbacks/TimeWorked/Search/Results.html html/Reports
html/Reports/TimeWorked html/Reports/TimeWorked/Elements inc
inc/Module inc/Module/Install lib lib/RT lib/RT/Extension
alexmv at bestpractical.com
alexmv at bestpractical.com
Mon May 8 02:12:06 EDT 2006
Author: alexmv
Date: Mon May 8 02:12:04 2006
New Revision: 5174
Added:
RT-Extension-TimeWorked/MANIFEST
RT-Extension-TimeWorked/META.yml
RT-Extension-TimeWorked/Makefile.PL
RT-Extension-TimeWorked/README
RT-Extension-TimeWorked/html/
RT-Extension-TimeWorked/html/Callbacks/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Elements/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Elements/Tabs/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Elements/Tabs/Default
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/NoAuth/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/NoAuth/webrt.css/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/NoAuth/webrt.css/Default
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Search/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Search/Results.html/
RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Search/Results.html/SearchActions
RT-Extension-TimeWorked/html/Reports/
RT-Extension-TimeWorked/html/Reports/TimeWorked/
RT-Extension-TimeWorked/html/Reports/TimeWorked/Elements/
RT-Extension-TimeWorked/html/Reports/TimeWorked/Elements/MiniPlot
RT-Extension-TimeWorked/html/Reports/TimeWorked/Elements/Tabs
RT-Extension-TimeWorked/html/Reports/TimeWorked/index.html
RT-Extension-TimeWorked/inc/
RT-Extension-TimeWorked/inc/Module/
RT-Extension-TimeWorked/inc/Module/Install/
RT-Extension-TimeWorked/inc/Module/Install.pm
RT-Extension-TimeWorked/inc/Module/Install/Base.pm
RT-Extension-TimeWorked/inc/Module/Install/Can.pm
RT-Extension-TimeWorked/inc/Module/Install/Fetch.pm
RT-Extension-TimeWorked/inc/Module/Install/Makefile.pm
RT-Extension-TimeWorked/inc/Module/Install/Metadata.pm
RT-Extension-TimeWorked/inc/Module/Install/RTx.pm
RT-Extension-TimeWorked/inc/Module/Install/Win32.pm
RT-Extension-TimeWorked/inc/Module/Install/WriteAll.pm
RT-Extension-TimeWorked/lib/
RT-Extension-TimeWorked/lib/RT/
RT-Extension-TimeWorked/lib/RT/Extension/
RT-Extension-TimeWorked/lib/RT/Extension/TimeWorked.pm
Log:
* Initial import
Added: RT-Extension-TimeWorked/MANIFEST
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/MANIFEST Mon May 8 02:12:04 2006
@@ -0,0 +1,20 @@
+html/Callbacks/TimeWorked/Elements/Tabs/Default
+html/Callbacks/TimeWorked/NoAuth/webrt.css/Default
+html/Callbacks/TimeWorked/Search/Results.html/SearchActions
+html/Reports/TimeWorked/Elements/MiniPlot
+html/Reports/TimeWorked/Elements/Tabs
+html/Reports/TimeWorked/index.html
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/RTx.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+lib/RT/Extension/TimeWorked.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
Added: RT-Extension-TimeWorked/META.yml
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/META.yml Mon May 8 02:12:04 2006
@@ -0,0 +1,14 @@
+abstract: RT Extension-TimeWorked Extension
+author: Alex Vandiver <alexmv at bestpractical.com>
+distribution_type: module
+generated_by: Module::Install version 0.61
+license: perl
+name: RT-Extension-TimeWorked
+no_index:
+ directory:
+ - html
+ - inc
+ - t
+requires:
+ Time::Duration: 0
+version: 0.4
Added: RT-Extension-TimeWorked/Makefile.PL
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/Makefile.PL Mon May 8 02:12:04 2006
@@ -0,0 +1,7 @@
+use inc::Module::Install;
+
+RTx('RT-Extension-TimeWorked');
+license('perl');
+requires('Time::Duration');
+author('Alex Vandiver <alexmv at bestpractical.com>');
+&WriteAll;
Added: RT-Extension-TimeWorked/README
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/README Mon May 8 02:12:04 2006
@@ -0,0 +1,21 @@
+This extension is Copyright (C) 2005 Best Practical Solutions, LLC.
+
+It is freely redistributable under the terms of version 2 of the GNU GPL.
+
+SUMMARY ---
+
+RT-Extension-TimeWorked provides a number of simple reporting
+tools to analyze the amount of time spent in various states.
+
+INSTALLATION ---
+
+To install the extension:
+
+$ perl Makefile.PL
+
+(it may prompt you for the path to your RT.pm, if it can't
+automatically detect it.)
+
+$ make
+$ make install
+
Added: RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Elements/Tabs/Default
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Elements/Tabs/Default Mon May 8 02:12:04 2006
@@ -0,0 +1,7 @@
+<%init>
+if ($ARGS{current_toptab} eq "Tools/Offline.html") {
+ $ARGS{tabs}{r} ||= { path => 'Reports/TimeWorked/index.html',
+ title => 'Reports',
+ };
+}
+</%init>
\ No newline at end of file
Added: RT-Extension-TimeWorked/html/Callbacks/TimeWorked/NoAuth/webrt.css/Default
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/html/Callbacks/TimeWorked/NoAuth/webrt.css/Default Mon May 8 02:12:04 2006
@@ -0,0 +1,70 @@
+table.miniplot {
+ width: 100%;
+ border-collapse: collapse;
+}
+table.miniplot td {
+ margin: 0;
+ padding: 0;
+ border-bottom: 1px solid black;
+}
+table.miniplot .graph {
+ margin-left: auto;
+ margin-right: auto;
+ position: relative;
+ width: 60px;
+}
+table.miniplot .graph ul {
+ height: 100px;
+ margin: 0;
+ padding: 0;
+}
+table.miniplot .graph ul li {
+ list-style: none;
+ position: absolute;
+ bottom: 0px;
+ padding: 0 !important;
+ margin: 0 !important;
+ border-bottom: none;
+}
+table.miniplot .graph ul li .data {
+ display: none;
+}
+
+.miniplot .demoblock { margin: 0 10px; padding: 0 30px; }
+
+.miniplot .c1 { border: 2px solid #990000; background: #ff0000; }
+.miniplot .c2 { border: 2px solid #996600; background: #ff9900; }
+.miniplot .c3 { border: 2px solid #009900; background: #00ff00; }
+.miniplot .c4 { border: 2px solid #009999; background: #00ffff; }
+.miniplot .c5 { border: 2px solid #000099; background: #0000ff; }
+.miniplot .c6 { border: 2px solid #990099; background: #ff00ff; }
+graph .c5 { border: 2px solid #000099; background: #0000ff; }
+.graph .c6 { border: 2px solid #990099; background: #ff00ff; }
+
+tr.titlerow th {
+ border-bottom: solid black 1px;
+ margin: 0;
+ font-size:80%;
+ text-wrap: none;
+}
+
+tr.grandtotal td, tr.grandtotal th{
+ border-top: 1px solid black;
+}
+
+th.label {
+ align: left;
+}
+
+table.miniplot th.legend {
+ font-style: normal;
+ font-size: 80%;
+}
+
+table.numberreport {
+ width: 100%;
+}
+table.numberreport td {
+ padding: 0 1em;
+ text-align: right;
+}
Added: RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Search/Results.html/SearchActions
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/html/Callbacks/TimeWorked/Search/Results.html/SearchActions Mon May 8 02:12:04 2006
@@ -0,0 +1,13 @@
+<a href="<% $RT::WebPath %>/Reports/TimeWorked/index.html?queue=<% $Query %>">Generate reports</a>
+<%init>
+use YAML;
+my %args = $m->caller_args(2);
+
+my $Queue;
+if ($args{Query} =~ m|Queue\s*=\s*'([^']+)'|) {
+ $Queue = RT::Queue->new();
+ $Queue->Load($1);
+ $Queue = $Queue->Id;
+}
+
+</%init>
\ No newline at end of file
Added: RT-Extension-TimeWorked/html/Reports/TimeWorked/Elements/MiniPlot
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/html/Reports/TimeWorked/Elements/MiniPlot Mon May 8 02:12:04 2006
@@ -0,0 +1,57 @@
+<table class="miniplot"><tr>
+% for my $major (@major) {
+<td><div class="graph">
+ <ul>
+% my $i = 0;
+% for my $minor (@minor) {
+% my $percent = int( 100 * ($data->{$major}{$minor} || 0) / ($max || 1) );
+ <li class="c<% ($i % 6) + 1%>" style="width: <% $barwidth %>%;
+ left: <% $baroffset + $each * $i %>%;
+ height: <% $percent %>%;"><div class="data"><% $minor %>: <% $percent %>%</div></li>
+% $i++;
+% }
+ </ul>
+</div></td>
+% }
+</tr><tr>
+% for my $major (@major) {
+<th class="legend"><% $major %></th>
+% }
+</tr>
+</table>
+
+<table class="miniplot"><tr>
+% my $i = 0;
+% for my $minor (@minor) {
+<th><span class="demoblock c<% ($i++ % 6) + 1 %>"></span> <% $minor %></th>
+% }
+</tr>
+</table>
+
+<%args>
+$data
+$major => undef
+$minor => undef
+</%args>
+<%init>
+
+my $max = 1;
+
+my %minor;
+for my $major (keys %{$data}) {
+ for (keys %{$data->{$major}}) {
+ $minor{$_}++;
+ $max = $data->{$major}{$_} if $data->{$major}{$_} > $max;
+ }
+}
+
+my @major = $major ? @{$major} : sort keys %{$data};
+my @minor = $minor ? @{$minor} : sort keys %minor;
+
+return unless @minor and @major;
+
+my $each = int( (100 / @minor) );
+my $barwidth = int( (100 / @minor) * (3/4) );
+my $baroffset = int( (100 / @minor) * (1/8) );
+
+</%init>
Added: RT-Extension-TimeWorked/html/Reports/TimeWorked/Elements/Tabs
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/html/Reports/TimeWorked/Elements/Tabs Mon May 8 02:12:04 2006
@@ -0,0 +1,52 @@
+<& /Elements/Tabs,
+ tabs => $tabs,
+ subtabs => $subtabs,
+ current_toptab => 'Tools/Offline.html',
+ current_tab => 'Reports/TimeWorked/index.html'.$args,
+ Title => $Title &>
+
+<%INIT>
+my $subtabs = {};
+
+my $top = $m->caller_args(-1);
+if (defined $m->caller_args(-1)->{'queue'}) {
+ my $args = "?" . $m->comp( '/Elements/QueryString',
+ start => $top->{start},
+ end => $top->{end});
+ $current_subtab .= "$args&queue=".$top->{queue};
+
+ my $order = 'a';
+ $subtabs->{$order++} = { title => 'All queues', path => "Reports/TimeWorked/index.html$args&queue=" };
+ $subtabs->{$order++} = { separator => 1 };
+ my $queues=new RT::Queues($session{'CurrentUser'});
+ $queues->UnLimit;
+
+ while (my $q = $queues->Next) {
+ $subtabs->{$order++} = { title => $q->Name, path => "Reports/TimeWorked/index.html$args&queue=".$q->Id };
+ }
+}
+
+my $args = "?" . $m->comp( '/Elements/QueryString',
+ queue => $top->{queue},
+ start => $top->{start},
+ end => $top->{end});
+
+my $tabs = {
+ a => { title => loc('Offline'),
+ path => 'Tools/Offline.html',
+ },
+ r => { title => loc('Reports'),
+ path => 'Reports/TimeWorked/index.html'.$args,
+ subtabs => $subtabs,
+ current_subtab => $current_subtab,
+ }
+ };
+
+</%INIT>
+
+
+<%ARGS>
+$current_tab => undef
+$current_subtab => undef
+$Title => undef
+</%ARGS>
Added: RT-Extension-TimeWorked/html/Reports/TimeWorked/index.html
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/html/Reports/TimeWorked/index.html Mon May 8 02:12:04 2006
@@ -0,0 +1,309 @@
+<& /Elements/Header, Title => loc("Time worked reports") &>
+<& Elements/Tabs,
+ current_subtab => "Reports/TimeWorked/index.html",
+ Title => loc("Time worked reports") &>
+
+% if (defined $queue and defined $start and defined $end) {
+
+<& Elements/MiniPlot, data => \%plot, minor => ["< 24h","24-48h","> 48h"] &>
+
+<br />
+<table class="numberreport">
+<tr class="titlerow">
+<th rowspan="2">Queue</th>
+<th colspan="6">Created in date range</th>
+<th colspan="6">Resolved in date range</th>
+<th rowspan="2">Total tickets still open</th>
+</tr>
+<tr class="titlerow">
+<th>Total tickets</th>
+<th>Total resolutions</th>
+<th>Resolved within 24h</th>
+<th>Resolved within 24-48h</th>
+<th>Resolved in more than 48h</th>
+<th>Tickets currently open</th>
+
+<th>Total tickets</th>
+<th>Total resolutions</th>
+<th>Resolved within 24h</th>
+<th>Resolved within 24-48h</th>
+<th>Resolved in more than 48h</th>
+<th>Tickets currently open</th>
+</tr>
+
+% my @totals;
+% for my $queue (sort {lc $queue{$a}{name} cmp lc $queue{$b}{name}} keys %queue) {
+% my @row; my $i = 0;
+<tr>
+<th><% $queue{$queue}{name} || $queue %></th>
+% for my $bin (qw/created resolved/) {
+<td><% $row[$i++] = $queue{$queue}{$bin}{tickets} || 0%></td>
+<td><% $row[$i++] = $queue{$queue}{$bin}{resolves} || 0%></td>
+<td><% $row[$i++] = $queue{$queue}{$bin}{24} || 0 %></td>
+<td><% $row[$i++] = $queue{$queue}{$bin}{48} || 0 %></td>
+<td><% $row[$i++] = $queue{$queue}{$bin}{more} || 0 %></td>
+<td><% $row[$i++] = $queue{$queue}{$bin}{open} || 0 %></td>
+% }
+
+<td><% $row[$i++] = $queue{$queue}{total_open} %></td>
+</tr>
+% $totals[$_] += $row[$_] for 0..$#row;
+% }
+<tr class="grandtotal">
+<th>Total</th>
+% for (@totals) {
+<td><% $_ %></td>
+% }
+</tr>
+</table>
+
+<br />
+<table class="numberreport">
+<tr class="titlerow">
+<th>Username</th>
+<th>Queue</th>
+<th>Resolved within 24h</th>
+<th>Resolved within 24-28h</th>
+<th>Resolved in more than 48h</th>
+<th>Time worked</th>
+<th>Average time per ticket</th>
+<th>Average resolutions per hour</th>
+</tr>
+% for my $user (sort keys %user) {
+% for my $queue (sort {lc $queue{$a}{name} cmp lc $queue{$b}{name}} keys %{$user{$user}}) {
+<tr>
+<th><% $user %></th>
+<th><% $queue{$queue}{name} %></th>
+<td><% $user{$user}{$queue}{24} || 0 %></td>
+<td><% $user{$user}{$queue}{48} || 0 %></td>
+<td><% $user{$user}{$queue}{more} || 0 %></td>
+<td><% sprintf("%.02f",$user{$user}{$queue}{time}/60 || 0) %></td>
+<td><% sprintf("%.02f",$user{$user}{$queue}{time}/($user{$user}{$queue}{tickets} || 1) || 0) %></td>
+<td><% $user{$user}{$queue}{time} ? sprintf("%.02f",$user{$user}{$queue}{resolves}/($user{$user}{$queue}{time}/60) || 0) : "-" %></td>
+</tr>
+% }
+% }
+</table>
+
+<br />
+<h3>Still open tickets created in date range</h3>
+<& /Elements/TicketList,
+ Query => join(" AND ", map {"($_)"} grep {/\S/} ($query, qq{ ( Created >= '$start' AND Created <= '$end' ) AND ( Status = 'new' OR Status = 'open' ) })),
+ OrderBy => 'Created',
+ Order => 'ASC',
+ Format => q{' <b><a href="/Ticket/Display.html?id=__id__">__id__</a></b>/TITLE:#','<a href="/Ticket/Display.html?id=__id__">__Subject__</a>/TITLE:Subject','__QueueName__','__Created__'},
+ Rows => 0,
+ BaseURL => $RT::WebPath."/Search/Results.html?",
+ AllowSorting => 1,
+&>
+<br />
+
+
+% }
+
+<form action="index.html" method="POST" enctype="multipart/form-data">
+Queue: <& /Elements/SelectQueue, Name => "queue", Default => $queue &> <br />
+Start date: <input type="text" name="start" value="<% $start %>" /><br />
+End date: <input type="text" name="end" value="<% $end %>" /><br />
+<& /Elements/Submit, Label => loc('Report') &>
+</form>
+
+<%args>
+$queue => undef
+$start => undef
+$end => undef
+</%args>
+<%init>
+unless ($start) {
+ my $then = RT::Date->new($session{'CurrentUser'});
+ $then->Set(Format => 'Unix', Value => time - (86400*7));
+ $start = substr($then->ISO,0,10);
+}
+
+unless ($end) {
+ my $now = RT::Date->new($session{'CurrentUser'});
+ $now->SetToNow();
+ $end = substr($now->ISO,0,10);
+}
+
+my $query = "GROUP BY Tickets.Queue";
+$query = "AND Tickets.Queue = '$queue'" if $queue;
+
+my $startDate = RT::Date->new($session{'CurrentUser'});
+$startDate->Set(Format => 'unknown', Value => $start);
+my $endDate = RT::Date->new($session{'CurrentUser'});
+$endDate->Set(Format => 'unknown', Value => $end);
+
+my(%queue, %user);
+my $Queues = RT::Queues->new($session{'CurrentUser'});
+if ($queue) {
+ $Queues->Limit(FIELD => 'Id', VALUE => $queue);
+} else {
+ $Queues->UnLimit();
+}
+
+while (my $q = $Queues->Next) {
+ my $tix = RT::Tickets->new($session{'CurrentUser'});
+ $tix->FromSQL("Queue = '@{[$q->Name]}' AND (Status = 'open' OR Status = 'new')");
+ $queue{$q->Id}{name} = $q->Name;
+ $queue{$q->Id}{total_open} = $tix->Count();
+}
+
+
+# ..and here we start doing hand SQL queries. These walk around ACLs,
+# and are scary!
+
+my $sth = $RT::Handle->SimpleQuery(<<"EOSQL");
+SELECT Tickets.Queue as queue,
+ COUNT(*) as created
+ FROM Tickets
+ JOIN Queues ON Tickets.Queue = Queues.id
+ WHERE Tickets.Created >= '$start'
+ AND Tickets.Created <= '$end'
+ AND Tickets.Status != 'deleted'
+ AND Queues.Disabled = 0
+ $query
+EOSQL
+$queue{$_->{queue}}{created}{tickets} = $_->{created} while $_ = $sth->fetchrow_hashref;
+
+$sth = $RT::Handle->SimpleQuery(<<"EOSQL");
+SELECT Tickets.Queue as queue,
+ COUNT(*) as resolves,
+ SUM(TIME_TO_SEC(TIMEDIFF(Transactions.Created,Tickets.Created)) < 24*60*60) as one_day,
+ SUM(TIME_TO_SEC(TIMEDIFF(Transactions.Created,Tickets.Created)) < 48*60*60) as two_day
+ FROM Tickets
+ JOIN Transactions ON Tickets.id = Transactions.ObjectId
+ AND Transactions.ObjectType = 'RT::Ticket'
+ JOIN Queues ON Tickets.Queue = Queues.id
+ WHERE Transactions.Type = 'Status'
+ AND Transactions.NewValue = 'resolved'
+ AND Transactions.Created >= '$start'
+ AND Transactions.Created <= '$end'
+ AND Tickets.Created >= '$start'
+ AND Tickets.Created <= '$end'
+ AND Queues.Disabled = 0
+ $query
+EOSQL
+while ($_ = $sth->fetchrow_hashref) {
+ $queue{$_->{queue}}{created}{resolves} = $_->{resolves};
+ $queue{$_->{queue}}{created}{24} = $_->{one_day};
+ $queue{$_->{queue}}{created}{48} = $_->{two_day} - $_->{one_day};
+ $queue{$_->{queue}}{created}{more} = $_->{resolves} - $_->{two_day};
+}
+
+$sth = $RT::Handle->SimpleQuery(<<"EOSQL");
+SELECT Tickets.Queue as queue,
+ COUNT(*) as open
+ FROM Tickets
+ JOIN Queues ON Tickets.Queue = Queues.id
+ WHERE Tickets.Created >= '$start'
+ AND Tickets.Created <= '$end'
+ AND (Tickets.Status = 'new'
+ OR Tickets.Status = 'open')
+ AND Queues.Disabled = 0
+ $query
+EOSQL
+$queue{$_->{queue}}{created}{open} = $_->{open} while $_ = $sth->fetchrow_hashref;
+
+
+$sth = $RT::Handle->SimpleQuery(<<"EOSQL");
+SELECT Tickets.Queue as queue,
+ COUNT(DISTINCT Tickets.id) as all_tickets,
+ COUNT(*) as resolves,
+ SUM(TIME_TO_SEC(TIMEDIFF(Transactions.Created,Tickets.Created)) < 24*60*60) as one_day,
+ SUM(TIME_TO_SEC(TIMEDIFF(Transactions.Created,Tickets.Created)) < 48*60*60) as two_day
+ FROM Tickets
+ JOIN Transactions ON Tickets.id = Transactions.ObjectId
+ AND Transactions.ObjectType = 'RT::Ticket'
+ JOIN Queues ON Tickets.Queue = Queues.id
+ WHERE Transactions.Type = 'Status'
+ AND Transactions.NewValue = 'resolved'
+ AND Transactions.Created >= '$start'
+ AND Transactions.Created <= '$end'
+ AND Queues.Disabled = 0
+ $query
+EOSQL
+while ($_ = $sth->fetchrow_hashref) {
+ $queue{$_->{queue}}{resolved}{tickets} = $_->{all_tickets};
+ $queue{$_->{queue}}{resolved}{resolves} = $_->{resolves};
+ $queue{$_->{queue}}{resolved}{24} = $_->{one_day};
+ $queue{$_->{queue}}{resolved}{48} = $_->{two_day} - $_->{one_day};
+ $queue{$_->{queue}}{resolved}{more} = $_->{resolves} - $_->{two_day};
+}
+
+$sth = $RT::Handle->SimpleQuery(<<"EOSQL");
+SELECT Tickets.Queue as queue,
+ COUNT(DISTINCT Tickets.id) as open
+ FROM Tickets
+ JOIN Transactions ON Tickets.id = Transactions.ObjectId
+ AND Transactions.ObjectType = 'RT::Ticket'
+ JOIN Queues ON Tickets.Queue = Queues.id
+ WHERE Transactions.Type = 'Status'
+ AND Transactions.NewValue = 'resolved'
+ AND Transactions.Created >= '$start'
+ AND Transactions.Created <= '$end'
+ AND (Tickets.Status = 'new'
+ OR Tickets.Status = 'open')
+ AND Queues.Disabled = 0
+ $query
+EOSQL
+$queue{$_->{queue}}{resolved}{open} = $_->{open} while $_ = $sth->fetchrow_hashref;
+
+$query = "" unless $queue;
+
+$sth = $RT::Handle->SimpleQuery(<<"EOSQL");
+SELECT Users.Name as name,
+ Tickets.Queue as queue,
+ SUM(TIME_TO_SEC(TIMEDIFF(Transactions.Created,Tickets.Created)) < 24*60*60) as one_day,
+ SUM(TIME_TO_SEC(TIMEDIFF(Transactions.Created,Tickets.Created)) < 48*60*60) as two_day,
+ COUNT(*) as more,
+ COUNT(DISTINCT Tickets.id) as tickets
+ FROM Tickets
+ JOIN Transactions ON Tickets.id = Transactions.ObjectId
+ AND Transactions.ObjectType = 'RT::Ticket'
+ JOIN Users ON Transactions.Creator = Users.id
+ JOIN Queues ON Tickets.Queue = Queues.id
+ WHERE Transactions.Type = 'Status'
+ AND Transactions.NewValue = 'resolved'
+ AND Transactions.Created >= '$start'
+ AND Transactions.Created <= '$end'
+ AND Queues.Disabled = 0
+ $query
+GROUP BY Users.Name, Tickets.Queue;
+EOSQL
+while ($_ = $sth->fetchrow_hashref) {
+ $user{$_->{name}}{$_->{queue}}{tickets} = $_->{tickets};
+ $user{$_->{name}}{$_->{queue}}{resolves} = $_->{more};
+ $user{$_->{name}}{$_->{queue}}{24} = $_->{one_day};
+ $user{$_->{name}}{$_->{queue}}{48} = $_->{two_day} - $_->{one_day};
+ $user{$_->{name}}{$_->{queue}}{more} = $_->{more} - $_->{two_day};
+}
+
+$sth = $RT::Handle->SimpleQuery(<<"EOSQL");
+SELECT Users.Name as name,
+ Tickets.Queue as queue,
+ SUM(Transactions.TimeTaken) as worked
+ FROM Tickets
+ JOIN Transactions ON Tickets.id = Transactions.ObjectId
+ AND Transactions.ObjectType = 'RT::Ticket'
+ JOIN Users ON Transactions.Creator = Users.id
+ JOIN Queues ON Tickets.Queue = Queues.id
+ WHERE Transactions.Created >= '$start'
+ AND Transactions.Created <= '$end'
+ AND Transactions.TimeTaken > 0
+ AND Queues.Disabled = 0
+ $query
+GROUP BY Users.Name, Tickets.Queue;
+EOSQL
+$user{$_->{name}}{$_->{queue}}{time} = $_->{worked} while $_ = $sth->fetchrow_hashref;
+
+# Set up miniplots
+my %plot;
+for (keys %queue) {
+ $plot{$queue{$_}{name}} = {
+ "< 24h" => $queue{$_}{resolved}{24} || 0,
+ "24-48h" => $queue{$_}{resolved}{48} || 0,
+ "> 48h" => $queue{$_}{resolved}{more} || 0,
+ };
+}
+</%init>
Added: RT-Extension-TimeWorked/inc/Module/Install.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,265 @@
+#line 1
+package Module::Install;
+
+# For any maintainers:
+# The load order for Module::Install is a bit magic.
+# It goes something like this...
+#
+# IF ( host has Module::Install installed, creating author mode ) {
+# 1. Makefile.PL calls "use inc::Module::Install"
+# 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install
+# 3. The installed version of inc::Module::Install loads
+# 4. inc::Module::Install calls "require Module::Install"
+# 5. The ./inc/ version of Module::Install loads
+# } ELSE {
+# 1. Makefile.PL calls "use inc::Module::Install"
+# 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install
+# 3. The ./inc/ version of Module::Install loads
+# }
+
+use 5.004;
+use strict 'vars';
+
+use vars qw{$VERSION};
+BEGIN {
+ # All Module::Install core packages now require synchronised versions.
+ # This will be used to ensure we don't accidentally load old or
+ # different versions of modules.
+ # This is not enforced yet, but will be some time in the next few
+ # releases once we can make sure it won't clash with custom
+ # Module::Install extensions.
+ $VERSION = '0.61';
+}
+
+# Whether or not inc::Module::Install is actually loaded, the
+# $INC{inc/Module/Install.pm} is what will still get set as long as
+# the caller loaded module this in the documented manner.
+# If not set, the caller may NOT have loaded the bundled version, and thus
+# they may not have a MI version that works with the Makefile.PL. This would
+# result in false errors or unexpected behaviour. And we don't want that.
+my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
+unless ( $INC{$file} ) {
+ die <<"END_DIE";
+Please invoke ${\__PACKAGE__} with:
+
+ use inc::${\__PACKAGE__};
+
+not:
+
+ use ${\__PACKAGE__};
+
+END_DIE
+}
+
+use Cwd ();
+use File::Find ();
+use File::Path ();
+use FindBin;
+
+*inc::Module::Install::VERSION = *VERSION;
+ at inc::Module::Install::ISA = __PACKAGE__;
+
+sub autoload {
+ my $self = shift;
+ my $who = $self->_caller;
+ my $cwd = Cwd::cwd();
+ my $sym = "${who}::AUTOLOAD";
+ $sym->{$cwd} = sub {
+ my $pwd = Cwd::cwd();
+ if ( my $code = $sym->{$pwd} ) {
+ # delegate back to parent dirs
+ goto &$code unless $cwd eq $pwd;
+ }
+ $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
+ unshift @_, ($self, $1);
+ goto &{$self->can('call')} unless uc($1) eq $1;
+ };
+}
+
+sub import {
+ my $class = shift;
+ my $self = $class->new(@_);
+ my $who = $self->_caller;
+
+ unless ( -f $self->{file} ) {
+ require "$self->{path}/$self->{dispatch}.pm";
+ File::Path::mkpath("$self->{prefix}/$self->{author}");
+ $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self );
+ $self->{admin}->init;
+ @_ = ($class, _self => $self);
+ goto &{"$self->{name}::import"};
+ }
+
+ *{"${who}::AUTOLOAD"} = $self->autoload;
+ $self->preload;
+
+ # Unregister loader and worker packages so subdirs can use them again
+ delete $INC{"$self->{file}"};
+ delete $INC{"$self->{path}.pm"};
+}
+
+sub preload {
+ my ($self) = @_;
+
+ unless ( $self->{extensions} ) {
+ $self->load_extensions(
+ "$self->{prefix}/$self->{path}", $self
+ );
+ }
+
+ my @exts = @{$self->{extensions}};
+ unless ( @exts ) {
+ my $admin = $self->{admin};
+ @exts = $admin->load_all_extensions;
+ }
+
+ my %seen;
+ foreach my $obj ( @exts ) {
+ while (my ($method, $glob) = each %{ref($obj) . '::'}) {
+ next unless exists &{ref($obj).'::'.$method};
+ next if $method =~ /^_/;
+ next if $method eq uc($method);
+ $seen{$method}++;
+ }
+ }
+
+ my $who = $self->_caller;
+ foreach my $name ( sort keys %seen ) {
+ *{"${who}::$name"} = sub {
+ ${"${who}::AUTOLOAD"} = "${who}::$name";
+ goto &{"${who}::AUTOLOAD"};
+ };
+ }
+}
+
+sub new {
+ my ($class, %args) = @_;
+
+ # ignore the prefix on extension modules built from top level.
+ my $base_path = Cwd::abs_path($FindBin::Bin);
+ unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) {
+ delete $args{prefix};
+ }
+
+ return $args{_self} if $args{_self};
+
+ $args{dispatch} ||= 'Admin';
+ $args{prefix} ||= 'inc';
+ $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
+ $args{bundle} ||= 'inc/BUNDLES';
+ $args{base} ||= $base_path;
+ $class =~ s/^\Q$args{prefix}\E:://;
+ $args{name} ||= $class;
+ $args{version} ||= $class->VERSION;
+ unless ( $args{path} ) {
+ $args{path} = $args{name};
+ $args{path} =~ s!::!/!g;
+ }
+ $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
+
+ bless( \%args, $class );
+}
+
+sub call {
+ my ($self, $method) = @_;
+ my $obj = $self->load($method) or return;
+ splice(@_, 0, 2, $obj);
+ goto &{$obj->can($method)};
+}
+
+sub load {
+ my ($self, $method) = @_;
+
+ $self->load_extensions(
+ "$self->{prefix}/$self->{path}", $self
+ ) unless $self->{extensions};
+
+ foreach my $obj (@{$self->{extensions}}) {
+ return $obj if $obj->can($method);
+ }
+
+ my $admin = $self->{admin} or die <<"END_DIE";
+The '$method' method does not exist in the '$self->{prefix}' path!
+Please remove the '$self->{prefix}' directory and run $0 again to load it.
+END_DIE
+
+ my $obj = $admin->load($method, 1);
+ push @{$self->{extensions}}, $obj;
+
+ $obj;
+}
+
+sub load_extensions {
+ my ($self, $path, $top) = @_;
+
+ unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) {
+ unshift @INC, $self->{prefix};
+ }
+
+ foreach my $rv ( $self->find_extensions($path) ) {
+ my ($file, $pkg) = @{$rv};
+ next if $self->{pathnames}{$pkg};
+
+ local $@;
+ my $new = eval { require $file; $pkg->can('new') };
+ unless ( $new ) {
+ warn $@ if $@;
+ next;
+ }
+ $self->{pathnames}{$pkg} = delete $INC{$file};
+ push @{$self->{extensions}}, &{$new}($pkg, _top => $top );
+ }
+
+ $self->{extensions} ||= [];
+}
+
+sub find_extensions {
+ my ($self, $path) = @_;
+
+ my @found;
+ File::Find::find( sub {
+ my $file = $File::Find::name;
+ return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
+ my $subpath = $1;
+ return if lc($subpath) eq lc($self->{dispatch});
+
+ $file = "$self->{path}/$subpath.pm";
+ my $pkg = "$self->{name}::$subpath";
+ $pkg =~ s!/!::!g;
+
+ # If we have a mixed-case package name, assume case has been preserved
+ # correctly. Otherwise, root through the file to locate the case-preserved
+ # version of the package name.
+ if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
+ open PKGFILE, "<$subpath.pm" or die "find_extensions: Can't open $subpath.pm: $!";
+ my $in_pod = 0;
+ while ( <PKGFILE> ) {
+ $in_pod = 1 if /^=\w/;
+ $in_pod = 0 if /^=cut/;
+ next if ($in_pod || /^=cut/); # skip pod text
+ next if /^\s*#/; # and comments
+ if ( m/^\s*package\s+($pkg)\s*;/i ) {
+ $pkg = $1;
+ last;
+ }
+ }
+ close PKGFILE;
+ }
+
+ push @found, [ $file, $pkg ];
+ }, $path ) if -d $path;
+
+ @found;
+}
+
+sub _caller {
+ my $depth = 0;
+ my $call = caller($depth);
+ while ( $call eq __PACKAGE__ ) {
+ $depth++;
+ $call = caller($depth);
+ }
+ return $call;
+}
+
+1;
Added: RT-Extension-TimeWorked/inc/Module/Install/Base.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/Base.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,70 @@
+#line 1
+package Module::Install::Base;
+
+$VERSION = '0.61';
+
+# Suspend handler for "redefined" warnings
+BEGIN {
+ my $w = $SIG{__WARN__};
+ $SIG{__WARN__} = sub { $w };
+}
+
+### This is the ONLY module that shouldn't have strict on
+# use strict;
+
+#line 41
+
+sub new {
+ my ($class, %args) = @_;
+
+ foreach my $method ( qw(call load) ) {
+ *{"$class\::$method"} = sub {
+ shift()->_top->$method(@_);
+ } unless defined &{"$class\::$method"};
+ }
+
+ bless( \%args, $class );
+}
+
+#line 61
+
+sub AUTOLOAD {
+ my $self = shift;
+ local $@;
+ my $autoload = eval { $self->_top->autoload } or return;
+ goto &$autoload;
+}
+
+#line 76
+
+sub _top { $_[0]->{_top} }
+
+#line 89
+
+sub admin {
+ $_[0]->_top->{admin} or Module::Install::Base::FakeAdmin->new;
+}
+
+sub is_admin {
+ $_[0]->admin->VERSION;
+}
+
+sub DESTROY {}
+
+package Module::Install::Base::FakeAdmin;
+
+my $Fake;
+sub new { $Fake ||= bless(\@_, $_[0]) }
+
+sub AUTOLOAD {}
+
+sub DESTROY {}
+
+# Restore warning handler
+BEGIN {
+ $SIG{__WARN__} = $SIG{__WARN__}->();
+}
+
+1;
+
+#line 138
Added: RT-Extension-TimeWorked/inc/Module/Install/Can.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/Can.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,82 @@
+#line 1
+package Module::Install::Can;
+
+use strict;
+use Module::Install::Base;
+use Config ();
+### This adds a 5.005 Perl version dependency.
+### This is a bug and will be fixed.
+use File::Spec ();
+use ExtUtils::MakeMaker ();
+
+use vars qw{$VERSION @ISA};
+BEGIN {
+ $VERSION = '0.61';
+ @ISA = qw{Module::Install::Base};
+}
+
+
+# check if we can load some module
+### Upgrade this to not have to load the module if possible
+sub can_use {
+ my ($self, $mod, $ver) = @_;
+ $mod =~ s{::|\\}{/}g;
+ $mod .= '.pm' unless $mod =~ /\.pm$/i;
+
+ my $pkg = $mod;
+ $pkg =~ s{/}{::}g;
+ $pkg =~ s{\.pm$}{}i;
+
+ local $@;
+ eval { require $mod; $pkg->VERSION($ver || 0); 1 };
+}
+
+# check if we can run some command
+sub can_run {
+ my ($self, $cmd) = @_;
+
+ my $_cmd = $cmd;
+ return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
+
+ for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
+ my $abs = File::Spec->catfile($dir, $_[1]);
+ return $abs if (-x $abs or $abs = MM->maybe_command($abs));
+ }
+
+ return;
+}
+
+# can we locate a (the) C compiler
+sub can_cc {
+ my $self = shift;
+ my @chunks = split(/ /, $Config::Config{cc}) or return;
+
+ # $Config{cc} may contain args; try to find out the program part
+ while (@chunks) {
+ return $self->can_run("@chunks") || (pop(@chunks), next);
+ }
+
+ return;
+}
+
+# Fix Cygwin bug on maybe_command();
+if ( $^O eq 'cygwin' ) {
+ require ExtUtils::MM_Cygwin;
+ require ExtUtils::MM_Win32;
+ if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) {
+ *ExtUtils::MM_Cygwin::maybe_command = sub {
+ my ($self, $file) = @_;
+ if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) {
+ ExtUtils::MM_Win32->maybe_command($file);
+ } else {
+ ExtUtils::MM_Unix->maybe_command($file);
+ }
+ }
+ }
+}
+
+1;
+
+__END__
+
+#line 157
Added: RT-Extension-TimeWorked/inc/Module/Install/Fetch.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/Fetch.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,92 @@
+#line 1
+package Module::Install::Fetch;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION @ISA};
+BEGIN {
+ $VERSION = '0.61';
+ @ISA = qw{Module::Install::Base};
+}
+
+sub get_file {
+ my ($self, %args) = @_;
+ my ($scheme, $host, $path, $file) =
+ $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+
+ if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) {
+ $args{url} = $args{ftp_url}
+ or (warn("LWP support unavailable!\n"), return);
+ ($scheme, $host, $path, $file) =
+ $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+ }
+
+ $|++;
+ print "Fetching '$file' from $host... ";
+
+ unless (eval { require Socket; Socket::inet_aton($host) }) {
+ warn "'$host' resolve failed!\n";
+ return;
+ }
+
+ return unless $scheme eq 'ftp' or $scheme eq 'http';
+
+ require Cwd;
+ my $dir = Cwd::getcwd();
+ chdir $args{local_dir} or return if exists $args{local_dir};
+
+ if (eval { require LWP::Simple; 1 }) {
+ LWP::Simple::mirror($args{url}, $file);
+ }
+ elsif (eval { require Net::FTP; 1 }) { eval {
+ # use Net::FTP to get past firewall
+ my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600);
+ $ftp->login("anonymous", 'anonymous at example.com');
+ $ftp->cwd($path);
+ $ftp->binary;
+ $ftp->get($file) or (warn("$!\n"), return);
+ $ftp->quit;
+ } }
+ elsif (my $ftp = $self->can_run('ftp')) { eval {
+ # no Net::FTP, fallback to ftp.exe
+ require FileHandle;
+ my $fh = FileHandle->new;
+
+ local $SIG{CHLD} = 'IGNORE';
+ unless ($fh->open("|$ftp -n")) {
+ warn "Couldn't open ftp: $!\n";
+ chdir $dir; return;
+ }
+
+ my @dialog = split(/\n/, <<"END_FTP");
+open $host
+user anonymous anonymous\@example.com
+cd $path
+binary
+get $file $file
+quit
+END_FTP
+ foreach (@dialog) { $fh->print("$_\n") }
+ $fh->close;
+ } }
+ else {
+ warn "No working 'ftp' program available!\n";
+ chdir $dir; return;
+ }
+
+ unless (-f $file) {
+ warn "Fetching failed: $@\n";
+ chdir $dir; return;
+ }
+
+ return if exists $args{size} and -s $file != $args{size};
+ system($args{run}) if exists $args{run};
+ unlink($file) if $args{remove};
+
+ print(((!exists $args{check_for} or -e $args{check_for})
+ ? "done!" : "failed! ($!)"), "\n");
+ chdir $dir; return !$?;
+}
+
+1;
Added: RT-Extension-TimeWorked/inc/Module/Install/Makefile.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/Makefile.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,198 @@
+#line 1
+package Module::Install::Makefile;
+
+use strict 'vars';
+use Module::Install::Base;
+use ExtUtils::MakeMaker ();
+
+use vars qw{$VERSION @ISA};
+BEGIN {
+ $VERSION = '0.61';
+ @ISA = qw{Module::Install::Base};
+}
+
+sub Makefile { $_[0] }
+
+my %seen = ();
+
+sub prompt {
+ shift;
+
+ # Infinite loop protection
+ my @c = caller();
+ if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) {
+ die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
+ }
+
+ # In automated testing, always use defaults
+ if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
+ local $ENV{PERL_MM_USE_DEFAULT} = 1;
+ goto &ExtUtils::MakeMaker::prompt;
+ } else {
+ goto &ExtUtils::MakeMaker::prompt;
+ }
+}
+
+sub makemaker_args {
+ my $self = shift;
+ my $args = ($self->{makemaker_args} ||= {});
+ %$args = ( %$args, @_ ) if @_;
+ $args;
+}
+
+# For mm args that take multiple space-seperated args,
+# append an argument to the current list.
+sub makemaker_append {
+ my $self = shift;
+ my $name = shift;
+ my $args = $self->makemaker_args;
+ $args->{name} = defined $args->{$name}
+ ? join( ' ', $args->{name}, @_ )
+ : join( ' ', @_ );
+}
+
+sub build_subdirs {
+ my $self = shift;
+ my $subdirs = $self->makemaker_args->{DIR} ||= [];
+ for my $subdir (@_) {
+ push @$subdirs, $subdir;
+ }
+}
+
+sub clean_files {
+ my $self = shift;
+ my $clean = $self->makemaker_args->{clean} ||= {};
+ %$clean = (
+ %$clean,
+ FILES => join(' ', grep length, $clean->{FILES}, @_),
+ );
+}
+
+sub realclean_files {
+ my $self = shift;
+ my $realclean = $self->makemaker_args->{realclean} ||= {};
+ %$realclean = (
+ %$realclean,
+ FILES => join(' ', grep length, $realclean->{FILES}, @_),
+ );
+}
+
+sub libs {
+ my $self = shift;
+ my $libs = ref $_[0] ? shift : [ shift ];
+ $self->makemaker_args( LIBS => $libs );
+}
+
+sub inc {
+ my $self = shift;
+ $self->makemaker_args( INC => shift );
+}
+
+sub write {
+ my $self = shift;
+ die "&Makefile->write() takes no arguments\n" if @_;
+
+ my $args = $self->makemaker_args;
+ $args->{DISTNAME} = $self->name;
+ $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
+ $args->{VERSION} = $self->version || $self->determine_VERSION($args);
+ $args->{NAME} =~ s/-/::/g;
+ if ( $self->tests ) {
+ $args->{test} = { TESTS => $self->tests };
+ }
+ if ($] >= 5.005) {
+ $args->{ABSTRACT} = $self->abstract;
+ $args->{AUTHOR} = $self->author;
+ }
+ if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
+ $args->{NO_META} = 1;
+ }
+ if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 and $self->sign ) {
+ $args->{SIGN} = 1;
+ }
+ unless ( $self->is_admin ) {
+ delete $args->{SIGN};
+ }
+
+ # merge both kinds of requires into prereq_pm
+ my $prereq = ($args->{PREREQ_PM} ||= {});
+ %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_,
+ ($self->build_requires, $self->requires) );
+
+ # merge both kinds of requires into prereq_pm
+ my $subdirs = ($args->{DIR} ||= []);
+ if ($self->bundles) {
+ foreach my $bundle (@{ $self->bundles }) {
+ my ($file, $dir) = @$bundle;
+ push @$subdirs, $dir if -d $dir;
+ delete $prereq->{$file};
+ }
+ }
+
+ if ( my $perl_version = $self->perl_version ) {
+ eval "use $perl_version; 1"
+ or die "ERROR: perl: Version $] is installed, "
+ . "but we need version >= $perl_version";
+ }
+
+ my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_})} keys %$args;
+ if ($self->admin->preop) {
+ $args{dist} = $self->admin->preop;
+ }
+
+ my $mm = ExtUtils::MakeMaker::WriteMakefile(%args);
+ $self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile');
+}
+
+sub fix_up_makefile {
+ my $self = shift;
+ my $makefile_name = shift;
+ my $top_class = ref($self->_top) || '';
+ my $top_version = $self->_top->VERSION || '';
+
+ my $preamble = $self->preamble
+ ? "# Preamble by $top_class $top_version\n"
+ . $self->preamble
+ : '';
+ my $postamble = "# Postamble by $top_class $top_version\n"
+ . ($self->postamble || '');
+
+ local *MAKEFILE;
+ open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
+ my $makefile = do { local $/; <MAKEFILE> };
+ close MAKEFILE or die $!;
+
+ $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
+ $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
+ $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
+ $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
+ $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
+
+ # XXX - This is currently unused; not sure if it breaks other MM-users
+ # $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
+
+ open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
+ print MAKEFILE "$preamble$makefile$postamble" or die $!;
+ close MAKEFILE or die $!;
+
+ 1;
+}
+
+sub preamble {
+ my ($self, $text) = @_;
+ $self->{preamble} = $text . $self->{preamble} if defined $text;
+ $self->{preamble};
+}
+
+sub postamble {
+ my ($self, $text) = @_;
+ $self->{postamble} ||= $self->admin->postamble;
+ $self->{postamble} .= $text if defined $text;
+ $self->{postamble}
+}
+
+1;
+
+__END__
+
+#line 324
Added: RT-Extension-TimeWorked/inc/Module/Install/Metadata.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/Metadata.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,310 @@
+#line 1
+package Module::Install::Metadata;
+
+use Module::Install::Base;
+ at ISA = qw{Module::Install::Base};
+
+$VERSION = '0.61';
+
+use strict 'vars';
+
+my @scalar_keys = qw{
+ name module_name abstract author version license
+ distribution_type perl_version tests
+};
+
+my @tuple_keys = qw{
+ build_requires requires recommends bundles
+};
+
+sub Meta { shift }
+sub Meta_ScalarKeys { @scalar_keys }
+sub Meta_TupleKeys { @tuple_keys }
+
+foreach my $key (@scalar_keys) {
+ *$key = sub {
+ my $self = shift;
+ return $self->{values}{$key} if defined wantarray and !@_;
+ $self->{values}{$key} = shift;
+ return $self;
+ };
+}
+
+foreach my $key (@tuple_keys) {
+ *$key = sub {
+ my $self = shift;
+ return $self->{values}{$key} unless @_;
+
+ my @rv;
+ while (@_) {
+ my $module = shift or last;
+ my $version = shift || 0;
+ if ( $module eq 'perl' ) {
+ $version =~ s{^(\d+)\.(\d+)\.(\d+)}
+ {$1 + $2/1_000 + $3/1_000_000}e;
+ $self->perl_version($version);
+ next;
+ }
+ my $rv = [ $module, $version ];
+ push @rv, $rv;
+ }
+ push @{ $self->{values}{$key} }, @rv;
+ @rv;
+ };
+}
+
+sub sign {
+ my $self = shift;
+ return $self->{'values'}{'sign'} if defined wantarray and !@_;
+ $self->{'values'}{'sign'} = ( @_ ? $_[0] : 1 );
+ return $self;
+}
+
+sub dynamic_config {
+ my $self = shift;
+ unless ( @_ ) {
+ warn "You MUST provide an explicit true/false value to dynamic_config, skipping\n";
+ return $self;
+ }
+ $self->{'values'}{'dynamic_config'} = $_[0] ? 1 : 0;
+ return $self;
+}
+
+sub all_from {
+ my ( $self, $file ) = @_;
+
+ unless ( defined($file) ) {
+ my $name = $self->name
+ or die "all_from called with no args without setting name() first";
+ $file = join('/', 'lib', split(/-/, $name)) . '.pm';
+ $file =~ s{.*/}{} unless -e $file;
+ die "all_from: cannot find $file from $name" unless -e $file;
+ }
+
+ $self->version_from($file) unless $self->version;
+ $self->perl_version_from($file) unless $self->perl_version;
+
+ # The remaining probes read from POD sections; if the file
+ # has an accompanying .pod, use that instead
+ my $pod = $file;
+ if ( $pod =~ s/\.pm$/.pod/i and -e $pod ) {
+ $file = $pod;
+ }
+
+ $self->author_from($file) unless $self->author;
+ $self->license_from($file) unless $self->license;
+ $self->abstract_from($file) unless $self->abstract;
+}
+
+sub provides {
+ my $self = shift;
+ my $provides = ( $self->{values}{provides} ||= {} );
+ %$provides = (%$provides, @_) if @_;
+ return $provides;
+}
+
+sub auto_provides {
+ my $self = shift;
+ return $self unless $self->is_admin;
+
+ unless (-e 'MANIFEST') {
+ warn "Cannot deduce auto_provides without a MANIFEST, skipping\n";
+ return $self;
+ }
+
+ # Avoid spurious warnings as we are not checking manifest here.
+
+ local $SIG{__WARN__} = sub {1};
+ require ExtUtils::Manifest;
+ local *ExtUtils::Manifest::manicheck = sub { return };
+
+ require Module::Build;
+ my $build = Module::Build->new(
+ dist_name => $self->{name},
+ dist_version => $self->{version},
+ license => $self->{license},
+ );
+ $self->provides(%{ $build->find_dist_packages || {} });
+}
+
+sub feature {
+ my $self = shift;
+ my $name = shift;
+ my $features = ( $self->{values}{features} ||= [] );
+
+ my $mods;
+
+ if ( @_ == 1 and ref( $_[0] ) ) {
+ # The user used ->feature like ->features by passing in the second
+ # argument as a reference. Accomodate for that.
+ $mods = $_[0];
+ } else {
+ $mods = \@_;
+ }
+
+ my $count = 0;
+ push @$features, (
+ $name => [
+ map {
+ ref($_) ? ( ref($_) eq 'HASH' ) ? %$_
+ : @$_
+ : $_
+ } @$mods
+ ]
+ );
+
+ return @$features;
+}
+
+sub features {
+ my $self = shift;
+ while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
+ $self->feature( $name, @$mods );
+ }
+ return $self->{values}->{features}
+ ? @{ $self->{values}->{features} }
+ : ();
+}
+
+sub no_index {
+ my $self = shift;
+ my $type = shift;
+ push @{ $self->{values}{no_index}{$type} }, @_ if $type;
+ return $self->{values}{no_index};
+}
+
+sub read {
+ my $self = shift;
+ $self->include_deps( 'YAML', 0 );
+
+ require YAML;
+ my $data = YAML::LoadFile('META.yml');
+
+ # Call methods explicitly in case user has already set some values.
+ while ( my ( $key, $value ) = each %$data ) {
+ next unless $self->can($key);
+ if ( ref $value eq 'HASH' ) {
+ while ( my ( $module, $version ) = each %$value ) {
+ $self->can($key)->($self, $module => $version );
+ }
+ }
+ else {
+ $self->can($key)->($self, $value);
+ }
+ }
+ return $self;
+}
+
+sub write {
+ my $self = shift;
+ return $self unless $self->is_admin;
+ $self->admin->write_meta;
+ return $self;
+}
+
+sub version_from {
+ my ( $self, $file ) = @_;
+ require ExtUtils::MM_Unix;
+ $self->version( ExtUtils::MM_Unix->parse_version($file) );
+}
+
+sub abstract_from {
+ my ( $self, $file ) = @_;
+ require ExtUtils::MM_Unix;
+ $self->abstract(
+ bless(
+ { DISTNAME => $self->name },
+ 'ExtUtils::MM_Unix'
+ )->parse_abstract($file)
+ );
+}
+
+sub _slurp {
+ my ( $self, $file ) = @_;
+
+ local *FH;
+ open FH, "< $file" or die "Cannot open $file.pod: $!";
+ do { local $/; <FH> };
+}
+
+sub perl_version_from {
+ my ( $self, $file ) = @_;
+
+ if (
+ $self->_slurp($file) =~ m/
+ ^
+ use \s*
+ v?
+ ([\d\.]+)
+ \s* ;
+ /ixms
+ )
+ {
+ $self->perl_version($1);
+ }
+ else {
+ warn "Cannot determine perl version info from $file\n";
+ return;
+ }
+}
+
+sub author_from {
+ my ( $self, $file ) = @_;
+ my $content = $self->_slurp($file);
+ if ($content =~ m/
+ =head \d \s+ (?:authors?)\b \s*
+ ([^\n]*)
+ |
+ =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s*
+ .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s*
+ ([^\n]*)
+ /ixms) {
+ my $author = $1 || $2;
+ $author =~ s{E<lt>}{<}g;
+ $author =~ s{E<gt>}{>}g;
+ $self->author($author);
+ }
+ else {
+ warn "Cannot determine author info from $file\n";
+ }
+}
+
+sub license_from {
+ my ( $self, $file ) = @_;
+
+ if (
+ $self->_slurp($file) =~ m/
+ =head \d \s+
+ (?:licen[cs]e|licensing|copyright|legal)\b
+ (.*?)
+ (=head\\d.*|=cut.*|)
+ \z
+ /ixms
+ )
+ {
+ my $license_text = $1;
+ my @phrases = (
+ 'under the same (?:terms|license) as perl itself' => 'perl',
+ 'GNU public license' => 'gpl',
+ 'GNU lesser public license' => 'gpl',
+ 'BSD license' => 'bsd',
+ 'Artistic license' => 'artistic',
+ 'GPL' => 'gpl',
+ 'LGPL' => 'lgpl',
+ 'BSD' => 'bsd',
+ 'Artistic' => 'artistic',
+ );
+ while ( my ( $pattern, $license ) = splice( @phrases, 0, 2 ) ) {
+ $pattern =~ s{\s+}{\\s+}g;
+ if ( $license_text =~ /\b$pattern\b/i ) {
+ $self->license($license);
+ return 1;
+ }
+ }
+ }
+
+ warn "Cannot determine license info from $file\n";
+ return 'unknown';
+}
+
+1;
Added: RT-Extension-TimeWorked/inc/Module/Install/RTx.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/RTx.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,158 @@
+#line 1
+package Module::Install::RTx;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$Module::Install::RTx::VERSION = '0.11';
+
+use strict;
+use FindBin;
+use File::Glob ();
+use File::Basename ();
+
+sub RTx {
+ my ($self, $name) = @_;
+ my $RTx = 'RTx';
+ $RTx = $1 if $name =~ s/^(\w+)-//;
+ my $fname = $name;
+ $fname =~ s!-!/!g;
+
+ $self->name("$RTx-$name")
+ unless $self->name;
+ $self->abstract("RT $name Extension")
+ unless $self->abstract;
+ $self->version_from (-e "$name.pm" ? "$name.pm" : "lib/$RTx/$fname.pm")
+ unless $self->version;
+
+ my @prefixes = (qw(/opt /usr/local /home /usr /sw ));
+ my $prefix = $ENV{PREFIX};
+ @ARGV = grep { /PREFIX=(.*)/ ? (($prefix = $1), 0) : 1 } @ARGV;
+
+ if ($prefix) {
+ $RT::LocalPath = $prefix;
+ $INC{'RT.pm'} = "$RT::LocalPath/lib/RT.pm";
+ }
+ else {
+ local @INC = (
+ @INC,
+ $ENV{RTHOME} ? ($ENV{RTHOME}, "$ENV{RTHOME}/lib") : (),
+ map {( "$_/rt3/lib", "$_/lib/rt3", "$_/lib" )} grep $_, @prefixes
+ );
+ until ( eval { require RT; $RT::LocalPath } ) {
+ warn "Cannot find the location of RT.pm that defines \$RT::LocalPath in: @INC\n";
+ $_ = $self->prompt("Path to your RT.pm:") or exit;
+ push @INC, $_, "$_/rt3/lib", "$_/lib/rt3";
+ }
+ }
+
+ my $lib_path = File::Basename::dirname($INC{'RT.pm'});
+ print "Using RT configurations from $INC{'RT.pm'}:\n";
+
+ $RT::LocalVarPath ||= $RT::VarPath;
+ $RT::LocalPoPath ||= $RT::LocalLexiconPath;
+ $RT::LocalHtmlPath ||= $RT::MasonComponentRoot;
+
+ my %path;
+ my $with_subdirs = $ENV{WITH_SUBDIRS};
+ @ARGV = grep { /WITH_SUBDIRS=(.*)/ ? (($with_subdirs = $1), 0) : 1 } @ARGV;
+ my %subdirs = map { $_ => 1 } split(/\s*,\s*/, $with_subdirs);
+
+ foreach (qw(bin etc html po sbin var)) {
+ next unless -d "$FindBin::Bin/$_";
+ next if %subdirs and !$subdirs{$_};
+ $self->no_index( directory => $_ );
+
+ no strict 'refs';
+ my $varname = "RT::Local" . ucfirst($_) . "Path";
+ $path{$_} = ${$varname} || "$RT::LocalPath/$_";
+ }
+
+ $path{$_} .= "/$name" for grep $path{$_}, qw(etc po var);
+ my $args = join(', ', map "q($_)", %path);
+ $path{lib} = "$RT::LocalPath/lib" unless %subdirs and !$subdirs{'lib'};
+ print "./$_\t=> $path{$_}\n" for sort keys %path;
+
+ if (my @dirs = map { (-D => $_) } grep $path{$_}, qw(bin html sbin)) {
+ my @po = map { (-o => $_) } grep -f, File::Glob::bsd_glob("po/*.po");
+ $self->postamble(<< ".") if @po;
+lexicons ::
+\t\$(NOECHO) \$(PERL) -MLocale::Maketext::Extract::Run=xgettext -e \"xgettext(qw(@dirs @po))\"
+.
+ }
+
+ my $postamble = << ".";
+install ::
+\t\$(NOECHO) \$(PERL) -MExtUtils::Install -e \"install({$args})\"
+.
+
+ if ($path{var} and -d $RT::MasonDataDir) {
+ my ($uid, $gid) = (stat($RT::MasonDataDir))[4, 5];
+ $postamble .= << ".";
+\t\$(NOECHO) chown -R $uid:$gid $path{var}
+.
+ }
+
+ my %has_etc;
+ if (File::Glob::bsd_glob("$FindBin::Bin/etc/schema.*")) {
+ # got schema, load factory module
+ $has_etc{schema}++;
+ $self->load('RTxFactory');
+ $self->postamble(<< ".");
+factory ::
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name))"
+
+dropdb ::
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name drop))"
+
+.
+ }
+ if (File::Glob::bsd_glob("$FindBin::Bin/etc/acl.*")) {
+ $has_etc{acl}++;
+ }
+ if (-e 'etc/initialdata') {
+ $has_etc{initialdata}++;
+ }
+
+ $self->postamble("$postamble\n");
+ if (%subdirs and !$subdirs{'lib'}) {
+ $self->makemaker_args(
+ PM => { "" => "" },
+ )
+ }
+ else {
+ $self->makemaker_args( INSTALLSITELIB => "$RT::LocalPath/lib" );
+ }
+
+ if (%has_etc) {
+ $self->load('RTxInitDB');
+ print "For first-time installation, type 'make initdb'.\n";
+ my $initdb = '';
+ $initdb .= <<"." if $has_etc{schema};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(schema))"
+.
+ $initdb .= <<"." if $has_etc{acl};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(acl))"
+.
+ $initdb .= <<"." if $has_etc{initialdata};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(insert))"
+.
+ $self->postamble("initdb ::\n$initdb\n");
+ $self->postamble("initialize-database ::\n$initdb\n");
+ }
+}
+
+sub RTxInit {
+ unshift @INC, substr(delete($INC{'RT.pm'}), 0, -5) if $INC{'RT.pm'};
+ require RT;
+ RT::LoadConfig();
+ RT::ConnectToDatabase();
+
+ die "Cannot load RT" unless $RT::Handle and $RT::DatabaseType;
+}
+
+1;
+
+__END__
+
+#line 220
+
+#line 241
Added: RT-Extension-TimeWorked/inc/Module/Install/Win32.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/Win32.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,64 @@
+#line 1
+package Module::Install::Win32;
+
+use strict;
+use Module::Install::Base;
+
+use vars qw{$VERSION @ISA};
+BEGIN {
+ $VERSION = '0.61';
+ @ISA = qw{Module::Install::Base};
+}
+
+# determine if the user needs nmake, and download it if needed
+sub check_nmake {
+ my $self = shift;
+ $self->load('can_run');
+ $self->load('get_file');
+
+ require Config;
+ return unless (
+ $^O eq 'MSWin32' and
+ $Config::Config{make} and
+ $Config::Config{make} =~ /^nmake\b/i and
+ ! $self->can_run('nmake')
+ );
+
+ print "The required 'nmake' executable not found, fetching it...\n";
+
+ require File::Basename;
+ my $rv = $self->get_file(
+ url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
+ ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
+ local_dir => File::Basename::dirname($^X),
+ size => 51928,
+ run => 'Nmake15.exe /o > nul',
+ check_for => 'Nmake.exe',
+ remove => 1,
+ );
+
+ if (!$rv) {
+ die <<'END_MESSAGE';
+
+-------------------------------------------------------------------------------
+
+Since you are using Microsoft Windows, you will need the 'nmake' utility
+before installation. It's available at:
+
+ http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
+ or
+ ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe
+
+Please download the file manually, save it to a directory in %PATH% (e.g.
+C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to
+that directory, and run "Nmake15.exe" from there; that will create the
+'nmake.exe' file needed by this module.
+
+You may then resume the installation process described in README.
+
+-------------------------------------------------------------------------------
+END_MESSAGE
+ }
+}
+
+1;
Added: RT-Extension-TimeWorked/inc/Module/Install/WriteAll.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/inc/Module/Install/WriteAll.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,40 @@
+#line 1
+package Module::Install::WriteAll;
+
+use Module::Install::Base;
+ at ISA = qw(Module::Install::Base);
+
+$VERSION = '0.61';
+
+use strict;
+
+sub WriteAll {
+ my $self = shift;
+ my %args = (
+ meta => 1,
+ sign => 0,
+ inline => 0,
+ check_nmake => 1,
+ @_
+ );
+
+ $self->sign(1) if $args{sign};
+ $self->Meta->write if $args{meta};
+ $self->admin->WriteAll(%args) if $self->is_admin;
+
+ if ( $0 =~ /Build.PL$/i ) {
+ $self->Build->write;
+ } else {
+ $self->check_nmake if $args{check_nmake};
+ unless ( $self->makemaker_args->{'PL_FILES'} ) {
+ $self->makemaker_args( PL_FILES => {} );
+ }
+ if ($args{inline}) {
+ $self->Inline->write;
+ } else {
+ $self->Makefile->write;
+ }
+ }
+}
+
+1;
Added: RT-Extension-TimeWorked/lib/RT/Extension/TimeWorked.pm
==============================================================================
--- (empty file)
+++ RT-Extension-TimeWorked/lib/RT/Extension/TimeWorked.pm Mon May 8 02:12:04 2006
@@ -0,0 +1,3 @@
+package RT::Extension::TimeWorked;
+
+our $VERSION = '0.1';
More information about the Rt-commit
mailing list