[rt-users] Custom Condition for "Is A Member Of A Group"
Todd Chapman
todd at chaka.net
Thu Oct 20 23:37:14 EDT 2005
On Thu, Oct 20, 2005 at 11:12:54PM -0400, Barry L. Kline wrote:
> I'm trying to create a custom condition that will execute a scrip when a
> new ticket is created, but only if the submitter is not a part of a
> group. Specifically, we want to be notified if someone who is not a
> member of our group creates a new ticket. We typically create tickets
> via the web interface, so we're signed in when the ticket it created.
> It'd be nice if this would work using rt-mailgate, too.
>
> I created the following custom condition (based on one of the
> contributed wiki scrips), but the scrip fails to fire whether the ticket
> is created by a group member or not. Any suggestions would be greatly
> appreciated.
>
>
> My custom condition is:
>
> if ($self->TransactionObj->Type eq 'Create') {
> my $GroupObj = RT::Group->new( $session{ 'CurrentUser' } );
> my $PrincipalObj = RT::Principal->new( $session{ 'CurrentUser' } );
> $PrincipalObj->Load( $session{ 'CurrentUser' }->id );
> $GroupObj->LoadUserDefinedGroup( 'IT_dept' );
> my $HasMember = $GroupObj->HasMemberRecursively( $PrincipalObj );
> return 0 if $HasMember;
> return 1;
> } else {
> return 0;
> }
Does the CurrentUser have SeeGroup rights on IT_dept?
Also, I don't think $session{CurrentUser} is defined for
transactions created by an incoming e-mail. I could be wrong though.
Try this:
if ($self->TransactionObj->Type eq 'Create') {
my $GroupObj = RT::Group->new( $RT::SystemUser );
$GroupObj->LoadUserDefinedGroup( 'IT_dept' );
return $GroupObj->HasMemberRecursively( $self->CurrentUser->PrincipalObj );
}
More information about the rt-users
mailing list