[Rt-commit] rt branch, 4.4/include-people-by-username, created. rt-4.4.2-57-g8c7965e
Craig Kaiser
craig at bestpractical.com
Fri Jan 5 14:50:57 EST 2018
The branch, 4.4/include-people-by-username has been created
at 8c7965ebd8dcea300f0bff0bba666ed530d11d31 (commit)
- Log -----------------------------------------------------------------
commit 8c7965ebd8dcea300f0bff0bba666ed530d11d31
Author: Craig Kaiser <craig at bestpractical.com>
Date: Fri Jan 5 13:53:16 2018 -0500
Accept usernames for roles on ticket create
In addition to being able to add a person to a ticket with an email, now
a username is an acceptable argument on ticket create. It is possible that a user exist and
should be attached to a ticket as a person, but that user account may
not have an associated email. Then the username can be used in place of
the email.
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 7b89d21..64708cb 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -531,7 +531,7 @@ sub LoadOrCreateByEmail {
@create{'EmailAddress','RealName'} = $addr ? ($addr->address, $addr->phrase) : (undef, undef);
}
- $self->LoadByEmail( $create{EmailAddress} );
+ $self->Load( $create{EmailAddress} || $create{RealName} );
$self->Load( $create{EmailAddress} ) unless $self->Id;
return wantarray ? ($self->Id, $self->loc("User loaded")) : $self->Id
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 26dc216..afccb31 100644
--- a/share/html/Ticket/Create.html
+++ b/share/html/Ticket/Create.html
@@ -488,6 +488,9 @@ if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
my $value = $ARGS{ $field };
next unless defined $value && length $value;
+ # Preserve non-email username inputs
+ my @usernames = grep {!/\@/} split /,/, $value;
+
my @emails = Email::Address->parse( $value );
foreach my $email ( grep RT::EmailParser->IsRTAddress($_->address), @emails ) {
push @results, loc("[_1] is an address RT receives mail at. Adding it as a '[_2]' would create a mail loop", $email->format, loc($field =~ /^(.*?)s?$/) );
@@ -495,6 +498,7 @@ if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
$email = undef;
}
$ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
+ $ARGS{ $field } .= join ', ', @usernames;
}
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list