[SOLVED] ACL: Ticket Type based on Selected Queue

Moderator: crythias

Locked
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

[SOLVED] ACL: Ticket Type based on Selected Queue

Post by bitos »

Hello,

I'm trying to set up an ACL using OTRS' 3.3.3 GUI, that will filter the ticket types based on the Queue that has been selected.
I'm guessing that this should be super easy to establish, but I can't for the life of me get it to work.
Access Control Lists (ACL) - Admin - OTRS.jpg
I have been able to select Services based on queue using the above method, and that works just fine.
Is Ticket => Type not supported?

Any ideas? Greatly appreciated!
You do not have the required permissions to view the files attached to this post.
Last edited by bitos on 15 Jan 2014, 16:29, edited 1 time in total.
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
zip
Znuny advanced
Posts: 103
Joined: 02 Jan 2014, 12:32
Znuny Version: 5.0.9

Re: ACL: Ticket Type based on Selected Queue

Post by zip »

Hello!

I wouldn't make a ACL using the GUI, try instead to insert this code into the Config.pm

Code: Select all

   $Self->{TicketAcl}->{'ACL_Name'} = { #Set the Name of the ACL, here its called 'ACL_Name'

        # Match properties
        Properties => {

            Queue => {
                Name => ['Mithras'],
                },

        },
        # Set which Options are not possible (black list)
        PossibleNot => {
            
            Ticket => {
                Service => ['Kalibratie'], #If you have more than one Service, type ['Kalibratie','Service2','Service3'...]
            },

        },

    };
OTRS 5.0.9 - CentOS 7 - MariaDB 5.5
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

Re: ACL: Ticket Type based on Selected Queue

Post by bitos »

Hi, Thanks for your response!

However, I'm really not looking for a way of filtering the services, as I already managed to do that.
I want certain ticket types not to show when specific queues are selected.

Tried the following code after your example, but that doesn't work:

Code: Select all

$Self->{TicketAcl}->{'ACL_Mithras-Kalibratie'} = { #Set the Name of the ACL, here its called 'ACL_Name'

        # Match properties
        Properties => {

            Queue => {
                Name => ['Mithras'],
                },

        },
        # Set which Options are not possible (black list)
        PossibleNot => {
            
            Ticket => {
                Type => ['Kalibratie'], #If you have more than one Service, type ['Kalibratie','Service2','Service3'...]
            },

        },

    };
Also tried, but to no avail.

Code: Select all

...
            Ticket => {
                Type => {
                    Name => ['Kalibratie'], #If you have more than one Service, type ['Kalibratie','Service2','Service3'...]
                },
            },
...
Any other ideas?
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: ACL: Ticket Type based on Selected Queue

Post by reneeb »

AFAIK This has to be developed. The Types list is not refreshed on a change of the selected queue.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

Re: ACL: Ticket Type based on Selected Queue

Post by bitos »

Oh, Really? When I change the queue, I do see a little loading icon next to the type dropdown list as well as next to service, SLA and owner.

In Kernel\Output\HTML\Standard\AgentTicketPhone.dtl, I also found the following code. My guess is that TypeID relates to the type field?

Code: Select all

                    <label class="Mandatory" for="Dest"><span class="Marker">*</span> $Text{"To queue"}:</label>
                    <div class="Field">
                        $Data{"ToStrg"}
                        <div id="DestError" class="TooltipErrorMessage" ><p>$Text{"This field is required."}</p></div>
                        <div id="DestServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div>
<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#Dest').bind('change', function (Event) {
        Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', 'To', 'Cc', 'Bcc', 'StandardTemplateID' $Data{"DynamicFieldNamesStrg"}]);
    });
//]]></script>
Am I looking at the right code here? Any Idea how I could go about refreshing the type field?
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: ACL: Ticket Type based on Selected Queue

Post by reneeb »

I know that spinning wheel next to the Type dropdown, but there is no code to get a new list in Kernel/Modules/AgentTicketEmail.pm .

The best solution would be to change those frontend modules and submit a pull request to the otrs github repository. Then it might become standard in the next releases ;-)

A quick hack would be to create an ArticleComposeModule (see https://github.com/OTRS/otrs/blob/rel-3 ... seCrypt.pm). But that would be cheating.
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

Re: ACL: Ticket Type based on Selected Queue

Post by bitos »

Hi reneeb,

Thanks for the info!

I'm not a programmer really, so it's going to take a lot of trial and error before i figure out how to change those frontend modules. :)
I don't have any experience with github yet, but if I ever manage to figure out how to refresh the ticket type, i'll try to submit the pull request.

Is there any documentation/explanation in regards to the ArticleComposeModule that you posted?
I can only see the code which makes it hard to read "what it does".
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: ACL: Ticket Type based on Selected Queue

Post by reneeb »

You have to add code to the section where the AJAXUpdate is handled (https://github.com/OTRS/otrs/blob/rel-3 ... l.pm#L1384).

First you have to fetch the allowed types

Code: Select all

    my $Types = $Self->_GetTypes(
                    %GetParam,
                    %ACLCompatGetParam,
                    QueueID => $QueueID || 1
                );
put it after this code

Code: Select all

        my $Users = $Self->_GetUsers(
            %GetParam,
            %ACLCompatGetParam,
            QueueID => $QueueID,
            AllUsers => $GetParam{OwnerAll},
        );
Then you have to add

Code: Select all

if ( $Self->{ConfigObject}->Get( 'Ticket::Type' ) ) {
push @ExtendedData ,               {
                    Name => 'TypeID',
                    Data => $Types,
                    SelectedID => $GetParam{TypeID},
                    Translation => 0,
                    PossibleNone => 0,
                    TreeView => $TreeView,
                    Max => 100,
                };
}
just before the call of BuildSelectionJSON (https://github.com/OTRS/otrs/blob/rel-3 ... l.pm#L1645)

(this is untested, but a foundation for you)
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: ACL: Ticket Type based on Selected Queue

Post by reneeb »

bitos wrote:Is there any documentation/explanation in regards to the ArticleComposeModule that you posted?
No
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

Re: ACL: Ticket Type based on Selected Queue

Post by bitos »

Ok great! I'll give that a try! Thanks!!
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

Re: ACL: Ticket Type based on Selected Queue

Post by bitos »

After doing what you said that could work, I got an internal server error.

My apache error log reads the following:

Code: Select all

Global symbol "@ExtendedData" requires explicit package name at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1637.\nCompilation failed in require at /opt/otrs/Kernel/cpan-lib/Apache2/Reload.pm line 179.\n,
So I added
my @ExtendedData;
if ( $Self->{ConfigObject}->Get( 'Ticket::Type' ) ) {
push @ExtendedData , {
Name => 'TypeID',
Data => $Types,
SelectedID => $GetParam{TypeID},
Translation => 0,
PossibleNone => 0,
TreeView => $TreeView,
Max => 100,
};
}

Then when I add a new phone ticket (I did put the code in AgentTicketPhone.pm, not AgentTicketEmail.pm), I get a new server error.

Code: Select all

[Wed Jan 15 13:09:03 2014] -e: Version string '-1, set by base.pm' contains invalid data; ignoring: '-1, set by base.pm' at /opt/otrs//Kernel/System/Log.pm line 203.
ERROR: OTRS-CGI-32 Perl: 5.10.1 OS: linux Time: Wed Jan 15 13:09:03 2014

 Message: Decoding the JSON string failed: unexpected end of string while parsing JSON string, at character offset 250 (before "(end of string)") at /opt/otrs//Kernel/System/JSON.pm line 137


 RemoteAddress: 109.1.1.6
 RequestURI: /otrs/index.pl?Action=AgentDashboard

 Traceback (15000):
   Module: Kernel::System::JSON::Decode (OTRS 3.3.3) Line: 138
   Module: Kernel::Output::HTML::DashboardTicketGeneric::Preferences (OTRS 3.3.3) Line: 321
   Module: Kernel::Modules::AgentDashboardCommon::_Element (OTRS 3.3.3) Line: 775
   Module: Kernel::Modules::AgentDashboardCommon::Run (OTRS 3.3.3) Line: 562
   Module: Kernel::System::Web::InterfaceAgent::Run (OTRS 3.3.3) Line: 863
   Module: ModPerl::ROOT::ModPerl::Registry::opt_otrs_bin_cgi_2dbin_index_2epl::handler (unknown version) Line: 41
   Module: (eval) (v1.99) Line: 204
   Module: ModPerl::RegistryCooker::run (v1.99) Line: 204
   Module: ModPerl::RegistryCooker::default_handler (v1.99) Line: 170
   Module: ModPerl::Registry::handler (v1.99) Line: 31

[Wed Jan 15 13:09:03 2014] -e: Version string '-1, set by base.pm' contains invalid data; ignoring: '-1, set by base.pm' at /opt/otrs//Kernel/System/Log.pm line 203.
[Wed Jan 15 13:09:03 2014] -e: Version string '-1, set by base.pm' contains invalid data; ignoring: '-1, set by base.pm' at /opt/otrs//Kernel/System/Log.pm line 203.
ERROR: OTRS-CGI-32 Perl: 5.10.1 OS: linux Time: Wed Jan 15 13:09:03 2014

 Message: Decoding the JSON string failed: unexpected end of string while parsing JSON string, at character offset 250 (before "(end of string)") at /opt/otrs//Kernel/System/JSON.pm line 137


 RemoteAddress: 109.1.1.6
 RequestURI: /otrs/index.pl?Action=AgentDashboard

 Traceback (15000):
   Module: Kernel::System::JSON::Decode (OTRS 3.3.3) Line: 138
   Module: Kernel::Output::HTML::DashboardTicketGeneric::_SearchParamsGet (OTRS 3.3.3) Line: 1749
   Module: Kernel::Output::HTML::DashboardTicketGeneric::Run (OTRS 3.3.3) Line: 481
   Module: Kernel::Modules::AgentDashboardCommon::_Element (OTRS 3.3.3) Line: 825
   Module: Kernel::Modules::AgentDashboardCommon::Run (OTRS 3.3.3) Line: 562
   Module: Kernel::System::Web::InterfaceAgent::Run (OTRS 3.3.3) Line: 863
   Module: ModPerl::ROOT::ModPerl::Registry::opt_otrs_bin_cgi_2dbin_index_2epl::handler (unknown version) Line: 41
   Module: (eval) (v1.99) Line: 204
   Module: ModPerl::RegistryCooker::run (v1.99) Line: 204
   Module: ModPerl::RegistryCooker::default_handler (v1.99) Line: 170
   Module: ModPerl::Registry::handler (v1.99) Line: 31

[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine new redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 31.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine Run redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 79.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetNextStates redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1734.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetUsers redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1748.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetResponsibles redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1808.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetPriorities redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1868.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetTypes redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1883.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetServices redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1898.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetSLAs redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1929.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetTos redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1946.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetStandardTemplates redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 2011.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _MaskPhoneNew redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 2045.
[Wed Jan 15 13:09:08 2014] AgentTicketPhone.pm: Subroutine _GetFieldsToUpdate redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 2496.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine new redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 31.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine Run redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 79.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetNextStates redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1734.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetUsers redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1748.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetResponsibles redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1808.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetPriorities redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1868.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetTypes redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1883.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetServices redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1898.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetSLAs redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1929.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetTos redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 1946.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetStandardTemplates redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 2011.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _MaskPhoneNew redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 2045.
[Wed Jan 15 13:09:15 2014] AgentTicketPhone.pm: Subroutine _GetFieldsToUpdate redefined at /opt/otrs//Kernel/Modules/AgentTicketPhone.pm line 2496.
[Wed Jan 15 13:09:15 2014] [error] Not an ARRAY reference at /opt/otrs//Kernel/System/Ticket.pm line 7498.\n

line 7498 of /opt/otrs//Kernel/System/Ticket.pm reads:

Code: Select all

for my $New ( @{ $Step{PossibleNot}->{Ticket}->{ $Param{ReturnSubType} } } ) {
Any ideas?
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: ACL: Ticket Type based on Selected Queue

Post by reneeb »

Those changes are enough. It's tested on my dev machine.

https://github.com/OTRS/otrs/pull/204
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

Re: ACL: Ticket Type based on Selected Queue

Post by bitos »

You're right. Your code does work.
I deleted the ACL I created and now I'm not getting an error anymore.

However, When I recreate the ACL, the Ticket Type that I want to filter out, still appears in the list.
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
bitos
Znuny newbie
Posts: 34
Joined: 27 Nov 2013, 17:27
Znuny Version: 3.2.7

Re: ACL: Ticket Type based on Selected Queue

Post by bitos »

I checked out your github post and saw a code change that wasn't mentioned in your post here.

},
@DynamicFieldAJAX,
@TemplateAJAX,
+ @ExtendedData,
],

I Added this to my own AgentTicketPhone.pm page as well and guess what...IT WORKS !

Thank you very much for your time and effort, kind sir!
OTRS 3.3.3 on Cent0S 6.5 using MySQL.
Locked