Create a new Ticket via RT Web Interface - behavior ofspecifying Cc's

I hacked Ticket_Overlay.pm to do the following and it seems to work:

Before the loop in which LoadOrCreateByEmail() is called, I added
a loop that calls LoadByEmail to check each Cc and AdminCc values; if
the value is not an existing email address in the Users table, I set
the value in @{$args{$type}} to ‘’ so that when it gets to the LoadOrCreateEmail()
loop, those blanked out email addresses won’t get created as RT users
and won’t get added to the Watcher lists for the ticket.

If anyone sees something wrong with my hack pls let me know.

thanks!

Pei

diff -C 10 Ticket_Overlay.pm …/…/…/lib/RT/Ticket_Overlay.pm
*** Ticket_Overlay.pm Thu Jan 13 18:42:20 2005
— …/…/…/lib/RT/Ticket_Overlay.pm Thu Sep 23 22:21:43 2004
*** 525,582 ****
}

  #If we haven't been handed a valid owner, make it nobody.
  unless ( defined($Owner) && $Owner->Id ) {
      $Owner = new RT::User( $self->CurrentUser );
      $Owner->Load( $RT::Nobody->Id );
  }

  # }}}
  • {{{

  • hack

  • Eliminate CCs and AdminCCs that are not existing

  • users in RT.

  •  foreach my $type ( "Cc", "AdminCc" ) {
    
  •    next unless ( defined $args{$type}  );
    
  •    # It appears CC and AdminCC are always a ref (
    
  •    # even if it's empty or contains only one element).
    
  •    # So bail out if the data structure is not a ref
    
  •    # (lazy coding ;-)
    
  •    #
    
  •    next unless ( ref( $args{$type} ) ) ;
    
  •    for (my $i = 0; $i < scalar( @{$args{$type}} ) ; $i++) {
    
  •        my $user = RT::User->new($RT::SystemUser);
    
  •        $user->LoadByEmail( ${$args{$type}}[$i] ) ;
    
  •      if ( ! $user->Id ) { 
    
  •          push( @non_fatal_errors,
    
  •              $self->loc("Not adding " . ${$args{$type}}[$i] 
    
  •                 . " to Cc watcher list because it is not an existing RT user." ) ); 
    
  •        ${$args{$type}}[$i] = '' ; 
    
  •        }
    
  •    } 
    
  •  }
    
  • end of hack

  • }}}

    We attempt to load or create each of the people who might have a role for this ticket

    outside the transaction, so we don’t get into ticket creation races

    foreach my $type ( "Cc", "AdminCc", "Requestor" ) {
        next unless ( defined $args{$type} );
        foreach my $watcher (
            ref( $args{$type} ) ? @{ $args{$type} } : ( $args{$type} ) )
        {
            my $user = RT::User->new($RT::SystemUser);
            $user->LoadOrCreateByEmail($watcher)
              if ( $watcher && $watcher !~ /^\d+$/ );
    

— 525,544 ----