[Rt-commit] rt branch, 4.2/role-roles, updated. rt-4.1.5-276-g3fc5ea1
Alex Vandiver
alexmv at bestpractical.com
Mon Jan 14 18:32:04 EST 2013
The branch, 4.2/role-roles has been updated
via 3fc5ea110fcbbe0f2a4d311a7b480ae9370ffba5 (commit)
via f05713bfd55662994a33d7e407b5c3245f83e22e (commit)
from 4b15643d3a8b94592d9d2c28eb4f6d00c3da0e1e (commit)
Summary of changes:
lib/RT/Role/Record/Roles.pm | 11 ++++++++---
lib/RT/Role/SearchBuilder/Roles.pm | 1 +
2 files changed, 9 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit f05713bfd55662994a33d7e407b5c3245f83e22e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Jan 14 18:16:34 2013 -0500
LoadOrCreateByEmail does not parse non-email-addresses
LoadOrCreateByEmail calls:
($email, $name) = RT::Interface::Email::ParseAddressFromHeader( $email );
$self->LoadByEmail( $email );
$self->Load( $email ) unless $self->Id;
When passed a string with no "@", ParseAddressFromHeader returns an
empty $email and a defined $name; this results in both Load calls
failing, and the later Create failing because of Name is set to $email.
Attempt to load the user with its name if no "@" is present.
diff --git a/lib/RT/Role/Record/Roles.pm b/lib/RT/Role/Record/Roles.pm
index 21efbca..454994f 100644
--- a/lib/RT/Role/Record/Roles.pm
+++ b/lib/RT/Role/Record/Roles.pm
@@ -334,13 +334,18 @@ sub AddRoleMember {
# Create as the SystemUser, not the current user
my $user = RT::User->new(RT->SystemUser);
- my ($pid, $msg) = $user->LoadOrCreateByEmail( $name );
- unless ($pid) {
+ my ($ok, $msg);
+ if ($name =~ /@/) {
+ ($ok, $msg) = $user->LoadOrCreateByEmail( $name );
+ } else {
+ ($ok, $msg) = $user->Load( $name );
+ }
+ unless ($user->Id) {
# If we can't find this watcher, we need to bail.
$RT::Logger->error("Could not load or create a user '$name' to add as a watcher: $msg");
return (0, $self->loc("Could not find or create user '$name'"));
}
- $args{PrincipalId} = $pid;
+ $args{PrincipalId} = $user->PrincipalId;
}
elsif ($args{Group}) {
my $name = delete $args{Group};
commit 3fc5ea110fcbbe0f2a4d311a7b480ae9370ffba5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Jan 14 18:20:24 2013 -0500
Allow ->RoleLimit( VALUE => 12 ) without having to spcify FIELD => "id"
diff --git a/lib/RT/Role/SearchBuilder/Roles.pm b/lib/RT/Role/SearchBuilder/Roles.pm
index 7eb61a9..1f54616 100644
--- a/lib/RT/Role/SearchBuilder/Roles.pm
+++ b/lib/RT/Role/SearchBuilder/Roles.pm
@@ -191,6 +191,7 @@ sub RoleLimit {
my $class = blessed($self->NewItem);
+ $args{FIELD} ||= 'id' if $args{VALUE} =~ /^\d+$/;
my $type = delete $args{TYPE};
if ($type) {
unless ($class->HasRole($type)) {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list