[Rt-commit] rtir branch, rt-3.9, created. 4f3a8869f2adc89e4c7ee99c624acb8f495b95cd
? sunnavy
sunnavy at bestpractical.com
Fri Sep 24 07:05:36 EDT 2010
The branch, rt-3.9 has been created
at 4f3a8869f2adc89e4c7ee99c624acb8f495b95cd (commit)
- Log -----------------------------------------------------------------
commit 17cd91c61f3f679c4dfa79eb87052167ba134e9b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 21 21:03:23 2010 +0800
no ::Generic module any more
diff --git a/lib/RT/Action/RTIR.pm b/lib/RT/Action/RTIR.pm
index 58bd3a0..e19b1dc 100644
--- a/lib/RT/Action/RTIR.pm
+++ b/lib/RT/Action/RTIR.pm
@@ -4,7 +4,7 @@ use strict;
use RT::IR;
package RT::Action::RTIR;
-use base 'RT::Action::Generic';
+use base 'RT::Action';
sub CreatorCurrentUser {
my $self = shift;
diff --git a/lib/RT/Condition/RTIR.pm b/lib/RT/Condition/RTIR.pm
index 21363d4..9d0d5f7 100644
--- a/lib/RT/Condition/RTIR.pm
+++ b/lib/RT/Condition/RTIR.pm
@@ -4,7 +4,7 @@ use strict;
use RT::IR;
package RT::Condition::RTIR;
-use base 'RT::Condition::Generic';
+use base 'RT::Condition';
=head1 NAME
commit 29f73d54b997922f7a5d7e7737ead646ca91d6f6
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 21 21:03:51 2010 +0800
no ActiveStatus or alike in config any more
diff --git a/lib/RT/Action/RTIR_ResolveChildren.pm b/lib/RT/Action/RTIR_ResolveChildren.pm
index ada2064..1533666 100644
--- a/lib/RT/Action/RTIR_ResolveChildren.pm
+++ b/lib/RT/Action/RTIR_ResolveChildren.pm
@@ -84,7 +84,8 @@ sub Commit {
.") AND MemberOf = " . $id
." AND ("
# TODO: move to per queue statuses lists
- . join(" AND ", map "Status != '$_'", RT->Config->Get('InactiveStatus') )
+ . join(" AND ", map "Status != '$_'",
+ RT::Queue->InactiveStatusArray )
.")";
my $members = new RT::Tickets( $self->TransactionObj->CurrentUser );
diff --git a/lib/RT/Action/RTIR_SetDueIncident.pm b/lib/RT/Action/RTIR_SetDueIncident.pm
index 1208ae3..400936e 100644
--- a/lib/RT/Action/RTIR_SetDueIncident.pm
+++ b/lib/RT/Action/RTIR_SetDueIncident.pm
@@ -102,7 +102,8 @@ sub UpdateDue {
." OR Queue = 'Blocks'"
.") AND MemberOf = " . $incident->Id
." AND ("
- . join( " OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') )
+ . join( " OR ", map "Status = '$_'",
+ RT::Queue->ActiveStatusArray )
.")";
my $children = new RT::Tickets($self->CurrentUser);
$children->FromSQL( $query );
diff --git a/lib/RT/IR/Ticket.pm b/lib/RT/IR/Ticket.pm
index 693e6e6..b6cc906 100644
--- a/lib/RT/IR/Ticket.pm
+++ b/lib/RT/IR/Ticket.pm
@@ -41,7 +41,8 @@ sub IsLinkedToActiveIncidents {
my $query = "Queue = 'Incidents'"
." AND HasMember = ". $child->id
- ." AND ( ". join(" OR ", map "Status = '$_'", RT->Config->Get('ActiveStatus') ) ." ) ";
+ ." AND ( ". join(" OR ", map "Status = '$_'",
+ RT::Queue->ActiveStatusArray ) ." ) ";
$query .= " AND id != ". $parent->Id if $parent;
commit 764d4ce59b6897fde4406cb59f33a42e0bd9f9fc
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 21 22:00:55 2010 +0800
we have IPAddressRange in rt 3.9
diff --git a/etc/initialdata b/etc/initialdata
index 49121c4..f8018e9 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -31,9 +31,9 @@
},
);
-use Regexp::Common qw(net);
-use Regexp::Common::net::CIDR();
-my $ip_pattern = qr{(?#IP/IP-IP/CIDR)^(?:|\s*$RE{net}{IPv4}(?:\s*-\s*$RE{net}{IPv4})?\s*|$RE{net}{CIDR}{IPv4})$};
+#use Regexp::Common qw(net);
+#use Regexp::Common::net::CIDR();
+#my $ip_pattern = qr{(?#IP/IP-IP/CIDR)^(?:|\s*$RE{net}{IPv4}(?:\s*-\s*$RE{net}{IPv4})?\s*|$RE{net}{CIDR}{IPv4})$};
@CustomFields = (
@@ -184,8 +184,7 @@ my $ip_pattern = qr{(?#IP/IP-IP/CIDR)^(?:|\s*$RE{net}{IPv4}(?:\s*-\s*$RE{net}{IP
},
{
Name => 'IP',
- Type => 'FreeformMultiple',
- Pattern => "$ip_pattern",
+ Type => 'IPAddressRangeMultiple',
Queue => ['Incidents', 'Incident Reports', 'Investigations', 'Blocks'],
Disabled => 0,
Description => 'IP address for RTIR queues',
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 5a9b246..1ecdb79 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -307,171 +307,7 @@ sub DefaultConstituency {
}
-# IPs processing hooks
-# in order too implement searches by IP ranges we
-# store IPs in "%03d.%03d.%03d.%03d" format so ops
-# like > and < make sense.
use Hook::LexWrap;
-use Regexp::Common qw(RE_net_IPv4);
-use Regexp::Common::net::CIDR;
-require Net::CIDR;
-
-sub ParseIPRange {
- my $arg = shift or return ();
-
- if ( $arg =~ /^\s*$RE{net}{CIDR}{IPv4}{-keep}\s*$/go ) {
- my $cidr = join( '.', map $_||0, (split /\./, $1)[0..3] ) ."/$2";
- $arg = (Net::CIDR::cidr2range( $cidr ))[0] || $arg;
- }
-
- my ($sIP, $eIP);
- if ( $arg =~ /^\s*($RE{net}{IPv4})\s*$/o ) {
- $sIP = $eIP = sprintf "%03d.%03d.%03d.%03d", split /\./, $1;
- }
- elsif ( $arg =~ /^\s*($RE{net}{IPv4})-($RE{net}{IPv4})\s*$/o ) {
- $sIP = sprintf "%03d.%03d.%03d.%03d", split /\./, $1;
- $eIP = sprintf "%03d.%03d.%03d.%03d", split /\./, $2;
- }
- else {
- return ();
- }
- ($sIP, $eIP) = ($eIP, $sIP) if $sIP gt $eIP;
-
- return $sIP, $eIP;
-}
-
-
-# limit formatting "%03d.%03d.%03d.%03d"
-# "= 'sIP-eIP'" => "( >=sIP AND <=eIP)"
-# "!= 'sIP-eIP'" => "( <sIP OR >eIP)"
-# two ranges intercect when ( eIP1 >= sIP2 AND sIP1 <= eIP2 )
-require RT::Tickets;
-wrap 'RT::Tickets::_CustomFieldLimit',
- pre => sub {
- return if $_[2] && $_[2] =~ /^[<>]=?$/;
- return unless $_[3] =~ /^\s*($RE{net}{IPv4})\s*(?:-\s*($RE{net}{IPv4})\s*)?$/o;
- my ($start_ip, $end_ip) = ($1, ($2 || $1));
- $_ = sprintf "%03d.%03d.%03d.%03d", split /\./, $_
- for $start_ip, $end_ip;
- ($start_ip, $end_ip) = ($end_ip, $start_ip) if $start_ip gt $end_ip;
-
- my ($tickets, $field, $op, $value, %rest) = @_[0..($#_-1)];
- $tickets->_OpenParen;
- unless ( $op =~ /NOT|!=|<>/i ) { # positive equation
- $tickets->_CustomFieldLimit(
- $field, '<=', $end_ip, %rest,
- SUBKEY => $rest{'SUBKEY'}. '.Content',
- );
- $tickets->_CustomFieldLimit(
- $field, '>=', $start_ip, %rest,
- SUBKEY => $rest{'SUBKEY'}. '.LargeContent',
- ENTRYAGGREGATOR => 'AND',
- );
- # as well limit borders so DB optimizers can use better
- # estimations and scan less rows
- $tickets->_CustomFieldLimit(
- $field, '>=', '000.000.000.000', %rest,
- SUBKEY => $rest{'SUBKEY'}. '.Content',
- ENTRYAGGREGATOR => 'AND',
- );
- $tickets->_CustomFieldLimit(
- $field, '<=', '255.255.255.255', %rest,
- SUBKEY => $rest{'SUBKEY'}. '.LargeContent',
- ENTRYAGGREGATOR => 'AND',
- );
- }
- else { # negative equation
- $tickets->_CustomFieldLimit($field, '>', $end_ip, %rest);
- $tickets->_CustomFieldLimit(
- $field, '<', $start_ip, %rest,
- SUBKEY => $rest{'SUBKEY'}. '.LargeContent',
- ENTRYAGGREGATOR => 'OR',
- );
- # TODO: as well limit borders so DB optimizers can use better
- # estimations and scan less rows, but it's harder to do
- # as we have OR aggregator
- }
- $tickets->_CloseParen;
- # return right now as we did everything
- $_[-1] = ref $_[-1]? [1]: 1;
- };
-
-# "[!]= 'CIDR'" => "op 'sIP-eIP'"
-wrap 'RT::Tickets::_CustomFieldLimit',
- pre => sub {
- return unless $_[3] =~ /^\s*$RE{net}{CIDR}{IPv4}{-keep}\s*$/o;
- # convert incomplete 192.168/24 to 192.168.0.0/24 format
- my $cidr = join( '.', map $_||0, (split /\./, $1)[0..3] ) ."/$2";
- # convert to range and continue, it will be catched by next wrapper
- $_[3] = (Net::CIDR::cidr2range( $cidr ))[0] || $_[3];
- };
-$RT::Tickets::dispatch{'CUSTOMFIELD'} = \&RT::Tickets::_CustomFieldLimit;
-
-# on OCFV create format storage
-require RT::ObjectCustomFieldValue;
-wrap 'RT::ObjectCustomFieldValue::Create',
- pre => sub {
- my %args = @_[1.. at _-2];
- my $cf = GetCustomField( 'IP' );
- unless ( $cf && $cf->id ) {
- $RT::Logger->crit("Couldn't load IP CF");
- return;
- }
- return unless $cf->id == $args{'CustomField'};
-
- for ( my $i = 1; $i < @_; $i += 2 ) {
- next unless $_[$i] && $_[$i] eq 'Content';
-
- my ($sIP, $eIP) = ParseIPRange( $_[++$i] );
- unless ( $sIP && $eIP ) {
- $_[-1] = 0;
- return;
- }
- $_[$i] = $sIP;
-
- my $flag = 0;
- for ( my $j = 1; $j < @_; $j += 2 ) {
- next unless $_[$j] && $_[$j] eq 'LargeContent';
- $flag = $_[++$j] = $eIP;
- last;
- }
- splice @_, -1, 0, LargeContent => $eIP unless $flag;
- return;
- }
- };
-
-# strip zero chars(deserialize)
-{
-my $re_ip_sunit = qr/[0-1][0-9][0-9]|2[0-4][0-9]|25[0-5]/;
-my $re_ip_serialized = qr/$re_ip_sunit(?:\.$re_ip_sunit){3}/;
-my $obj;
-wrap 'RT::ObjectCustomFieldValue::Content',
- pre => sub { $obj = $_[0] },
- post => sub {
- return unless $_[-1];
- my $val = ref $_[-1]? \$_[-1][0]: \$_[-1];
- return unless $$val =~ /^\s*($re_ip_serialized)\s*$/o;
- $$val = sprintf "%d.%d.%d.%d", split /\./, $1;
-
- my $large_content = $obj->__Value('LargeContent');
- return if !$large_content
- || $large_content !~ /^\s*($re_ip_serialized)\s*$/o;
- my $eIP = sprintf "%d.%d.%d.%d", split /\./, $1;
- $$val .= '-'. $eIP unless $$val eq $eIP;
- return;
- };
-}
-
-# don't return LargeContent to avoid making angry RT's AddCFV logic
-wrap 'RT::ObjectCustomFieldValue::LargeContent',
- pre => sub {
- my $obj = $_[0];
- my $cf = GetCustomField( 'IP' );
- return unless $cf && $cf->id;
- return unless $obj->CustomField == $cf->id;
- $_[-1] = undef;
- };
-
if ( RT::IR->HasConstituency ) {
# ACL checks for multiple constituencies
@@ -658,31 +494,4 @@ die $@ if ($@ && $@ !~ qr{^Can't locate RT/IR_Vendor.pm});
eval "require RT::IR_Local";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/IR_Local.pm});
-package RT::ObjectCustomFieldValue;
-
-use strict;
-use warnings;
-
-sub LoadByCols {
- my $self = shift;
- my %args = @_;
- return $self->SUPER::LoadByCols( %args )
- unless $args{'CustomField'} && $args{'Content'};
-
- my $cf = RT::IR::GetCustomField( 'IP' );
- unless ( $cf && $cf->id ) {
- $RT::Logger->crit("Couldn't load IP CF");
- return $self->SUPER::LoadByCols( %args )
- }
- return $self->SUPER::LoadByCols( %args )
- unless $cf->id == $args{'CustomField'};
-
- my ($sIP, $eIP) = RT::IR::ParseIPRange( $args{'Content'} );
- return $self->SUPER::LoadByCols( %args )
- unless $sIP && $eIP;
-
- return $self->SUPER::LoadByCols( %args, Content => $sIP, LargeContent => $eIP );
-}
-
-
1;
diff --git a/t/custom-fields/ip.t b/t/custom-fields/ip.t
index 8bfb2cf..6c09d25 100644
--- a/t/custom-fields/ip.t
+++ b/t/custom-fields/ip.t
@@ -18,7 +18,7 @@ diag "load and check basic properties of the IP CF" if $ENV{'TEST_VERBOSE'};
is( $cfs->Count, 1, "found one CF with name 'IP'" );
$cf = $cfs->First;
- is( $cf->Type, 'Freeform', 'type check' );
+ is( $cf->Type, 'IPAddressRange', 'type check' );
is( $cf->LookupType, 'RT::Queue-RT::Ticket', 'lookup type check' );
ok( !$cf->MaxValues, "unlimited number of values" );
ok( !$cf->Disabled, "not disabled" );
commit 4f3a8869f2adc89e4c7ee99c624acb8f495b95cd
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Sep 23 00:14:21 2010 +0800
typo fix
diff --git a/t/custom-fields/defaults-on-linking.t b/t/custom-fields/defaults-on-linking.t
index e41fef0..ea41ee0 100644
--- a/t/custom-fields/defaults-on-linking.t
+++ b/t/custom-fields/defaults-on-linking.t
@@ -14,7 +14,7 @@ my $cf_name = 'test';
Type => 'FreeformSingle',
);
- for my $q ('Incident Reports', 'Investigation', 'Incidents', 'Blocks') {
+ for my $q ('Incident Reports', 'Investigations', 'Incidents', 'Blocks') {
my $q_obj = RT::Queue->new($RT::SystemUser);
$q_obj->Load($q);
unless ( $q_obj->Id ) {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list