[rt-users] show a new ticket tab for a special user group only

Benjamin Weser weser at osp-dd.de
Fri May 23 03:50:09 EDT 2008


Hi Dirk,

thank you, your code works. Almost. ;)
I had to mix it up a little bit with what I've found at the wiki 
(http://wiki.bestpractical.com/view/TestGroupMembership) since 
HasMemberRecursively() expects a Principal as parameter.

For everybody with similar problems: here you can see my working code now:

my $group = new RT::Group($session{'CurrentUser'});
$group->LoadUserDefinedGroup('Members RMB');

my $principal = new RT::Principal($session{'CurrentUser'});
$principal->Load($session{'CurrentUser'}->Id);

if ($group->HasMemberRecursively($principal)) {
$RT::Logger->info("found: ", $group->Name);
        $ticket_page_tabs->{_Ca} = { title => loc('RMB'),
                                     path  => "Ticket/RMB.html?id=" . $id,
                                   };
}


Ben



Dirk Pape schrieb:
> Hello Ben,
>
> --Am 22. Mai 2008 18:39:12 +0200 schrieb Benjamin Weser <weser at osp-dd.de>:
>
>   
>> $RT::Logger->info("User: ", $session{'CurrentUser'}->Name);
>> my $groups = $session{'CurrentUser'}->UserObj->OwnGroups;
>> $RT::Logger->info("Count: ", $groups->Count);
>> while (my $group = $groups->Next){
>>     $RT::Logger->info("test: ", $group->Name);
>>     if ( $group->Name =~ /Members RMB/ ){
>>         $RT::Logger->info("found: ", $group->Name);
>>         $ticket_page_tabs->{_Ca} = { title => loc('RMB'),
>>                                     path  => "Ticket/RMB.html?id=" . $id,
>>                                   };
>>     }
>> }
>>     
>
> I don't know why your code does not work, but I would do it other way 
> round: load the group and look if currentuser is a member.
>
> Without guarantee:
>
> my $group = new RT::Group($session{'CurrentUser'});
> $group->LoadUserDefinedGroup('Members RMB');
> if ($group->HasMemberRecursively($session{'CurrentUser'})) {
>         $ticket_page_tabs->{_Ca} = { title => loc('RMB'),
>                                     path  => "Ticket/RMB.html?id=" . $id,
>                                    };
> }
>
> Dirk.
>   




More information about the rt-users mailing list