[Rt-commit] rt branch, 4.4/include-people-by-username, created. rt-4.4.2-57-g2357ce83a
Craig Kaiser
craig at bestpractical.com
Mon Jan 8 17:26:31 EST 2018
The branch, 4.4/include-people-by-username has been created
at 2357ce83a18ebce481e121805afb46696f66d78c (commit)
- Log -----------------------------------------------------------------
commit 2357ce83a18ebce481e121805afb46696f66d78c
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 an RT user to a role
with an email address, also accept a valid RT username via the
web UI on create or update.
diff --git a/lib/RT/Record/Role/Roles.pm b/lib/RT/Record/Role/Roles.pm
index a1d49104e..bcca48784 100644
--- a/lib/RT/Record/Role/Roles.pm
+++ b/lib/RT/Record/Role/Roles.pm
@@ -620,8 +620,20 @@ sub _ResolveRoles {
push @errors,
$self->loc("Couldn't load principal: [_1]", $msg);
}
- } else {
- my @addresses = RT::EmailParser->ParseEmailAddress( $value );
+ }
+ else {
+ # Check for username as input
+ for my $person ( grep {!/\@/} split /,\s*/, $value ) {
+ my $user = RT::User->new( RT->SystemUser );
+ my ($id, $msg) = $user->Load( $person );
+ if ( $id ) {
+ push @{ $roles->{$role} }, $user->PrincipalObj;
+ } else {
+ push @errors,
+ $self->loc("Couldn't load or create user from username: [_1]", $msg);
+ }
+ }
+ my @addresses = RT::EmailParser->ParseEmailAddress( grep {/\@/} split /,/, $value );
for my $address ( @addresses ) {
my $user = RT::User->new( RT->SystemUser );
my ($id, $msg) = $user->LoadOrCreateByEmail( $address );
diff --git a/share/html/Ticket/Create.html b/share/html/Ticket/Create.html
index 26dc216b0..5b299f093 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,8 @@ if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
$email = undef;
}
$ARGS{ $field } = join ', ', map $_->format, grep defined, @emails;
+ $ARGS{ $field } .= ', ';
+ $ARGS{ $field } .= join ', ', grep defined, @usernames;
}
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list