[Rt-commit] r19588 - rt/3.8/branches/notify_group/lib/RT/Action
ruz at bestpractical.com
ruz at bestpractical.com
Thu May 7 20:36:05 EDT 2009
Author: ruz
Date: Thu May 7 20:36:05 2009
New Revision: 19588
Modified:
rt/3.8/branches/notify_group/lib/RT/Action/NotifyGroup.pm
Log:
* add support for group name, user name, user's email address
and just an email address in NotifyGroup action.
This will make easier to use it in crontool
Modified: rt/3.8/branches/notify_group/lib/RT/Action/NotifyGroup.pm
==============================================================================
--- rt/3.8/branches/notify_group/lib/RT/Action/NotifyGroup.pm (original)
+++ rt/3.8/branches/notify_group/lib/RT/Action/NotifyGroup.pm Thu May 7 20:36:05 2009
@@ -97,9 +97,43 @@
sub _HandleArgument {
my $self = shift;
my $instance = shift;
-
- my $obj = RT::Principal->new( $RT::SystemUser );
- $obj->Load( $instance );
+
+ if ( $instance !~ /\D/ ) {
+ my $obj = RT::Principal->new( $self->CurrentUser );
+ $obj->Load( $instance );
+ return $self->_HandlePrincipal( $obj );
+ }
+
+ my $group = RT::Group->new( $self->CurrentUser );
+ $group->LoadUserDefinedGroup( $instance );
+ # to check disabled and so on
+ return $self->_HandlePrincipal( $group->PrincipalObj )
+ if $group->id;
+
+ require Email::Address;
+
+ my $user = RT::User->new( $self->CurrentUser );
+ if ( $instance =~ /^$Email::Address::addr_spec$/ ) {
+ $user->LoadByEmail( $instance );
+ return $self->__PushUserAddress( $instance )
+ unless $user->id;
+ } else {
+ $user->Load( $instance );
+ }
+ return $self->_HandlePrincipal( $user->PrincipalObj )
+ if $user->id;
+
+ $RT::Logger->error(
+ "'$instance' is not principal id, group name, user name,"
+ ." user email address or any email address"
+ );
+
+ return;
+}
+
+sub _HandlePrincipal {
+ my $self = shift;
+ my $obj = shift;
unless( $obj->id ) {
$RT::Logger->error( "Couldn't load principal #$instance" );
return;
More information about the Rt-commit
mailing list