[Rt-commit] rtir branch, 2.5-trunk, updated. fba3ace1720994ade5922a9feaa0e7831dd92d1b

Ruslan Zakirov ruz at bestpractical.com
Mon Jul 13 18:19:04 EDT 2009


The branch, 2.5-trunk has been updated
       via  fba3ace1720994ade5922a9feaa0e7831dd92d1b (commit)
      from  59846a36cc3a265d19ccd5486fe74b12dacc2656 (commit)

Summary of changes:
 lib/RT/Action/RTIR_FindIP.pm |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

- Log -----------------------------------------------------------------
commit fba3ace1720994ade5922a9feaa0e7831dd92d1b
Author: Ruslan Zakirov <Ruslan.Zakirov at gmail.com>
Date:   Tue Jul 14 02:18:13 2009 +0400

    * handle case when max values on IP CF is limitted

diff --git a/lib/RT/Action/RTIR_FindIP.pm b/lib/RT/Action/RTIR_FindIP.pm
index d6804d8..fcde0bd 100644
--- a/lib/RT/Action/RTIR_FindIP.pm
+++ b/lib/RT/Action/RTIR_FindIP.pm
@@ -30,6 +30,8 @@ sub Commit {
     my $cf = $ticket->LoadCustomFieldByIdentifier('IP');
     return 1 unless $cf && $cf->id;
 
+    my $can_many = $cf->MaxValues;
+
     my $attach = $self->TransactionObj->ContentObj;
     return 1 unless $attach && $attach->id;
 
@@ -37,6 +39,12 @@ sub Commit {
     for( @{$cf->ValuesForObject( $ticket )->ItemsArrayRef} ) {
         $existing{ $_->Content } =  1;
     }
+
+    if ( $how_many_can && $how_many_can >= keys %existing ) {
+        $RT::Logger->debug("Ticket #". $ticket->id ." already has maximum number of IPs, skipping" );
+        return 1;
+    }
+
     my $content = $attach->Content || '';
     my @IPs = ( $content =~ /(?<!\d)($RE{net}{IPv4})(?!\d)(?!\/(?:3[0-2]|[1-2]?[0-9])(?:\D|\z))/go );
     $self->AddIP(

-----------------------------------------------------------------------


More information about the Rt-commit mailing list