[rt-users] How to avoid RT::GroupMember?

Todd Chapman rt at chaka.net
Wed Mar 10 09:24:41 EST 2004


The documentation for RT::GroupMember says:

>RT::GroupMember should never be called directly. It should ONLY
>only be accessed through the helper functions in RT::Group;
>
>If you're operating on an RT::GroupMember object yourself, you B<ARE>
>doing something wrong.

So if that is the case, how do I avoid using the MemberObj
function in the code below?

# Get an RT::Group object
my $group = $self->TicketObj->AdminCc;

# Get an RT::GroupMembers object
my $members = $group->MembersObj;

# Loop through the RT::GroupMember
while(my $member = $members->Next) {

    # Now I have an RT::GroupMember but I can't do this?
    # How do I get around it?
    my $principal = $member->MemberObj;

    # do something with $principal

}


My code based on the above works but I don't want
to abuse the API.


And another question. If I call:

$principal = $member->MemberObj;
$truth = $principal->IsGroup;  #Sometimes true, sometimes false

If I call:

$principal = $member->GroupObj;
$truth = $principal->IsGroup;  #Always true

Why does GroupObj always return a group (even when it is
a member) while MemberObj sometimes returns a group and
sometiems a member?

Once I get this figured out I'll be sharing an ugly
hack with the RT community. :)

Thanks!

-Todd




More information about the rt-users mailing list