Restrict visibility of E-mail icon for certain groups

Moderator: crythias

Post Reply
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Restrict visibility of E-mail icon for certain groups

Post by aph »

How can I make the e-mail icon in toolbar visible only to a certain group in OTRS. If I add the group restriction under Frontend::Module###AgentTicketEmail
in Ticket -> Frontend::Agent::ModuleRegistration, the icon is still visible but a user not in group gets an error. I also tried adding group parameter to Frontend::ToolBarModule###5-Ticket::AgentTicketEmail under Ticket -> Frontend::Agent::ToolBarModule, but it doesn't work. How can I hide the e-mail ticket icon for specific groups?
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
root
Administrator
Posts: 4011
Joined: 18 Dec 2007, 12:23
Znuny Version: Znuny and Znuny LTS
Real Name: Roy Kaldung
Company: Znuny
Contact:

Re: Restrict visibility of E-mail icon for certain groups

Post by root »

That's excatly the right way. Did you double checked your settings?
Znuny and Znuny LTS running on CentOS / RHEL / Debian / SLES / MySQL / PostgreSQL / Oracle / OpenLDAP / Active Directory / SSO

Use a test system - always.

Do you need professional services? Check out https://www.znuny.com/

Do you want to contribute or want to know where it goes ?
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Restrict visibility of E-mail icon for certain groups

Post by aph »

Yes I did double check my settings
Unbenannt_180.PNG
I added 'Group' parameter to Frontend::ToolBarModule###5-Ticket::AgentTicketEmail under Ticket -> Frontend::Agent::ToolBarModule. It still doesn't work.

I don't want to block the email ticket functionality alltogether for the group, just the icon. But even when I add group restriction under Frontend::Module###AgentTicketEmail in Ticket -> Frontend::Agent::ModuleRegistration, the icon is still visible.
Unbenannt_182.PNG
I also double-checked the group name
You do not have the required permissions to view the files attached to this post.
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
wagnersp
Znuny newbie
Posts: 1
Joined: 20 Dec 2014, 19:13
Znuny Version: OTRS 4
Real Name: Wagner

Re: Restrict visibility of E-mail icon for certain groups

Post by wagnersp »

In fact, the Permission is not being verified for the ToolBar Modules.
See this older post: viewtopic.php?t=18370
And this bug record: http://bugs.otrs.org/show_bug.cgi?id=8971
I solved this by adding the code bellow on the file /Kernel/Output/HTML/Layout.pm (remember to copy to the Custom folder). I wish someone could modularize that and commit to the repository.

Code: Select all

   # run tool bar item modules
    if ( $Self->{UserID} && $Self->{UserType} eq 'User' ) {
        my $ToolBarModule = $Self->{ConfigObject}->Get('Frontend::ToolBarModule');

        if ( $Param{ShowToolbarItems} && ref $ToolBarModule eq 'HASH' ) {

            $Self->Block(
                Name => 'ToolBar',
                Data => \%Param,
            );

            my %Modules;
            my %Jobs = %{$ToolBarModule};

            MODULE:
            for my $Job ( sort keys %Jobs ) {

                #-------------- Check Permissions ------------------
                # group check (Copied from TicketMenuGeneric)
                if ( $Jobs{$Job}->{Group} ) {
                        my @Items = split /;/, $Jobs{$Job}->{Group};
                        my $AccessOk;
                        ITEM:
                        for my $Item (@Items) {
                                my ( $Permission, $Name ) = split /:/, $Item;
                                if ( !$Permission || !$Name ) {
                                        $Self->{LogObject}->Log(
                                                Priority => 'error',
                                                Message  => "Invalid config for Key Group: '$Item'! "
                                                        . "Need something like '\$Permission:\$Group;'",
                                        );
                                }
                                my @Groups = $Self->{GroupObject}->GroupMemberList(
                                        UserID => $Self->{UserID},
                                        Type   => $Permission,
                                        Result => 'Name',
                                );
                                next ITEM if !@Groups;

                                GROUP:
                                for my $Group (@Groups) {
                                        if ( $Group eq $Name ) {
                                                $AccessOk = 1;
                                                last GROUP;
                                        }
                                }
                        }
                                next MODULE if !$AccessOk;
                }
                #-------------- End Check Permissions ------------------
                # load and run module
                next MODULE if !$Self->{MainObject}->Require( $Jobs{$Job}->{Module} );
                ...
 
aph
Znuny superhero
Posts: 646
Joined: 20 Jun 2014, 12:11
Znuny Version: 3.3.9, 4.x, 5.x

Re: Restrict visibility of E-mail icon for certain groups

Post by aph »

thanks Wagner for the hint
OTRS 3.3.x (private/testing) on Windows Server 2008 with MSSQL database.
OTRS 3.3.x (private/testing) on CentOS with MySQL database and apache
Post Reply