ACL working for agent only

Moderator: crythias

Locked
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

ACL working for agent only

Post by StefanoBoccanera »

Hi
I wrote two ACL to solve following issue:

Depending on Ticket type I have to select a subset of a dropdown dynamic field, both for Customer and Agent (User).

After reading manual and some post into the forum i supposed i need to write two different ACl: one to match agnet criteria and another one to match customer criteria. Following the two ACL:

Code: Select all

 $Self->{TicketAcl}->{'1010-ACL-SEBC-Cust'} = {
     Properties => {
        Type => {
           Name  => ['RfC::SEBC'],
           },
        CustomerUser => {
        Group_rw => ['SEBC'],
        },
      },   
    Possible => {
        Ticket => {
          DynamicField_TicketFreeText3  => ['9 - Sistemi Europei','9.1 - ESCB-Net','9.2 - CoreNet','9.3 - ESCBMail','9.4 - EXDI (ex ENO)','9.5 - Teleconference','9.6 - Altri servizi SEBC'],
           },
        },   
      };

     $Self->{TicketAcl}->{'1000-ACL-SEBC-dom'} = {
     Properties => {
        Type => {
            Name  => ['RfC::SEBC'],
           },
      },   
    Possible => {
        Ticket => {
          DynamicField_TicketFreeText3  => ['9 - Sistemi Europei','9.1 - ESCB-Net','9.2 - CoreNet','9.3 - ESCBMail','9.4 - EXDI (ex ENO)','9.5 - Teleconference','9.6 - Altri servizi SEBC'],
           },
        },   
      };
The first one ( '1010-ACL-SEBC-Cust ) would match the criteria :
When the ticket type is RfC::SEBC and the customer has the SEBC group rw permission, then the DynamicField_TicketFreeText3 would make available only the value ......
The second one ('1000-ACL-SEBC-dom) is the ACL matching agent criteria:
When the ticket type is RfC::SEBC then the DynamicField_TicketFreeText3 would make available only the value ......
After some test I found the agent criteria is correctly matched and the behaviour is right, but the customer's acl never matching also with customer matching both criteria.

Any suggestion to solve the problem ?

I'm using OTRS 3.1.5.
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: ACL working for agent only

Post by crythias »

1000 < 1010, so it wins.

But if it does win, it would apply to customers, too.

If I'm reading it properly, *any* customer choosing Type Rfc::SEBC will have those options.

Also, imo, you're using Type where it probably should be a queue or service.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: ACL working for agent only

Post by StefanoBoccanera »

crythias wrote:1000 < 1010, so it wins.

But if it does win, it would apply to customers, too.

If I'm reading it properly, *any* customer choosing Type Rfc::SEBC will have those options.

Also, imo, you're using Type where it probably should be a queue or service.
Hi crythias

Yes you are right about criteria, I want to hide the queue to customer, setting the right queue for evry ticket type within the dtl.
So probbaly using Type or Queue would be the same, because when the ticket's type is selected, the queue is set ......

I'll try to change the number ......

thanks
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: ACL working for agent only

Post by crythias »

StefanoBoccanera wrote:setting the right queue for evry ticket type within the dtl.
That sounds complicated. Queues should be what agents can do, services should be what customers want the agents to fix.
Type should probably be ignored for the most part, because everything *most* people want with regard to type can be handled with Queue::SubQueue
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: ACL working for agent only

Post by StefanoBoccanera »

crythias wrote:1000 < 1010, so it wins.

But if it does win, it would apply to customers, too.

If I'm reading it properly, *any* customer choosing Type Rfc::SEBC will have those options.

Also, imo, you're using Type where it probably should be a queue or service.
Hi crythias

I made a mistake: Customer or Agent selects the queue and on this selection jscript code set the right type id.

So I changed the numeric label, and I substitute Type with queue but it doesn't work, but I saw a funny behaviour on the CustomerTicketMessage dtl:

Assuming i have queue A, B and SEBC-RfC-Auth (queue used into the acl criteria)

step 1 selected A the acl has no effect (Right)

step 2 selected SEBC-RfC-Auth the acl has no effect (Wrong)

step 3 selected A (or B) the acl has effect (Wrong again)

It seems has the acl action is delayed on the next refresh of the form, I'll try two or three times the same sequence and I took always the same result.

I use the same approach, but based on queue selection switching, on the AgentTicketPhone form (same jscript funtion, same calling sequence, same 'logic') but there is a basic difference:

In CustomerTicketMessage the main logic is at the bottom of dtl

Code: Select all

<script type="text/javascript">
    Core.Customer.InitFocus();
         clearMandatory();
         clearOptField();
         unsetMandatory();   
switch ($('#Dest').val() ){
         case "1\|\|Postmaster":
         alert("Attenzione! Utente non autorizzato a questa richiesta !");
         document.getElementById('TypeID').value = '1';
         break;
         case "2\|\|Raw":
         alert("Attenzione! Utente non autorizzato a questa richiesta !");
         document.getElementById('TypeID').value = '1';
         break;
         case "3\|\|Junk":
         alert("Attenzione! Utente non autorizzato a questa richiesta !");
         document.getElementById('TypeID').value = '1';
         break;
         case "4\|\|Misc":
         alert("Attenzione! Utente non autorizzato a questa richiesta !");
         document.getElementById('TypeID').value = '1';
         break;
         case "5\|\|S1-Richiesta-Disponibilità":
         document.getElementById('TypeID').value = '16';
         showColField();
         setColField();
         document.getElementById('DynamicField_TicketFreeText3').value = '11 - Richiesta Collegamento';
         break;
         case "6\|\|S2-Interventi-Centrali":
         document.getElementById('TypeID').value = '17';
         showDgsaOpField();
         setDgsaOpField();
         break;
         case "7\|\|S3-Interventi-Intermedi":
         document.getElementById('TypeID').value = '18';
         showDgsaOpField();
         setDgsaOpField();
         break;
         case "8\|\|RfC-1-Non-Standard":
         document.getElementById('TypeID').value = '20';
         showRfCField();
         setRfCField();
         break;
         case "9\|\|RfC-2-Standard":
         document.getElementById('TypeID').value = '19';
         document.getElementById('DynamicField_TicketFreeText2').style.display = 'block';
         document.getElementById('LabelDynamicField_TicketFreeText2').style.display = 'block';
         document.getElementById('LabelDynamicField_TicketFreeText2').style.color = "red";
         document.getElementById('LabelDynamicField_TicketFreeText2').style.fontWeight= "bold";
         showRfCField();
         setRfCStdField();
         break;         
         case "10\|\|RfC-3-Hot-Fix":
         document.getElementById('TypeID').value = '21';
         showRfCField();
         setRfCField();
         break;
         case "11\|\|RfC-4-Emergency":
         alert("Attenzione! Utente non autorizzato a questa richiesta !");
         document.getElementById('TypeID').value = '1';
         break;
        case "12\|\|DSVAI-AUTH-RfC-1-Non-Standard":
         document.getElementById('TypeID').value = '20';
         showRfCField();
         setRfCField();
         break;
         case "13\|\|DSVAI-AUTH-RfC-2-Standard":
         document.getElementById('TypeID').value = '19';
         document.getElementById('DynamicField_TicketFreeText2').style.display = 'block';
         document.getElementById('LabelDynamicField_TicketFreeText2').style.display = 'block';
         document.getElementById('LabelDynamicField_TicketFreeText2').style.color = "red";
         document.getElementById('LabelDynamicField_TicketFreeText2').style.fontWeight= "bold";
         showRfCField();
         setRfCStdField();
         break;         
         case "24\|\|SEBC-RfC-Auth":
         document.getElementById('TypeID').value = '23';
         document.getElementById('DynamicField_TicketFreeText2').style.display = 'block';
         document.getElementById('LabelDynamicField_TicketFreeText2').style.display = 'block';
         document.getElementById('LabelDynamicField_TicketFreeText2').style.color = "red";
         document.getElementById('LabelDynamicField_TicketFreeText2').style.fontWeight= "bold";
         showRfCField();
         setRfCStdField();
         break;         
         default:         
        alert("Attenzione! Richiesta errata. Selezionare una richiesta tra quelle disponibili");
        }
</script>
<!-- dtl:js_on_document_complete -->
But in AgentTicketPhone is after the Queue field declaration
<label class="Mandatory" for="Dest"><span class="Marker" style="color:red">*</span> <b style="color:red">$Text{"Seleziona richiesta"}:</b></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) {
# alert("Attenzione! Evento Modifica coda");
clearMandatory();
clearOptField();
unsetMandatory();
switch ($('#Dest').val() ){
case "1\|\|Postmaster":
document.getElementById('TypeID').value = '1';
break;
case "2\|\|Raw":
document.getElementById('TypeID').value = '1';
break;
case "3\|\|Junk":
document.getElementById('TypeID').value = '1';
break;
case "4\|\|Misc":
document.getElementById('TypeID').value = '1';
break;
case "5\|\|S1-Richiesta-Disponibilità":
document.getElementById('TypeID').value = '16';
showColField();
setColField();
document.getElementById('DynamicField_TicketFreeText3').value = '11 - Richiesta Collegamento';
break;
case "6\|\|S2-Interventi-Centrali":
document.getElementById('TypeID').value = '17';
showDgsaOpField();
setDgsaOpField();
document.getElementById('TicketFreeText3').value = '';
break;
case "7\|\|S3-Interventi-Intermedi":
document.getElementById('TypeID').value = '18';
showDgsaOpField();
setDgsaOpField();
document.getElementById('TicketFreeText3').value = '';
break;
case "8\|\|RfC-1-Non-Standard":
document.getElementById('TypeID').value = '20';
showRfCField();
setRfCField();
break;
case "9\|\|RfC-2-Standard":
document.getElementById('TypeID').value = '19';
document.getElementById('DynamicField_TicketFreeText2').style.display = 'block';
document.getElementById('LabelDynamicField_TicketFreeText2').style.display = 'block';
document.getElementById('LabelDynamicField_TicketFreeText2').style.color = "red";
document.getElementById('LabelDynamicField_TicketFreeText2').style.fontWeight= "bold";
showRfCField();
setRfCStdField();
break;
case "10\|\|RfC-3-Hot-Fix":
document.getElementById('TypeID').value = '21';
showRfCField();
setRfCField();
break;
case "11\|\|RfC-4-Emergency":
document.getElementById('TypeID').value = '22';
showRfCField();
setRfCField();
break;
case "24\|\|SEBC-RfC-Auth":
document.getElementById('TypeID').value = '23';
document.getElementById('DynamicField_TicketFreeText2').style.display = 'block';
document.getElementById('LabelDynamicField_TicketFreeText2').style.display = 'block';
document.getElementById('LabelDynamicField_TicketFreeText2').style.color = "red";
document.getElementById('LabelDynamicField_TicketFreeText2').style.fontWeight= "bold";
showRfCField();
setRfCStdField();
break;
default:
alert("Attenzione! Richiesta errata. Selezionare una richiesta tra quelle disponibili");
}
Core.AJAX.FormUpdate($('#NewPhoneTicket'), 'AJAXUpdate', 'Dest', ['TypeID', 'NewUserID', 'NewResponsibleID', 'NextStateID', 'PriorityID', 'ServiceID', 'SLAID', 'SignKeyID', 'CryptKeyID', $Data{"DynamicFieldNamesStrg"}, 'To', 'Cc', 'Bcc']);
});
//]]></script>
<!--dtl:js_on_document_complete-->
in this case the acl always works correctly.

So I'wonder if the problem is not on the acl but on the different code position leading to a different behaviour of the form.

regards
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: ACL working for agent only

Post by crythias »

code position matters. If you need to apply a script to something that's not yet rendered/loaded, the script needs to run last. Functions in head, actions at the end.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: ACL working for agent only

Post by StefanoBoccanera »

crythias wrote:code position matters. If you need to apply a script to something that's not yet rendered/loaded, the script needs to run last. Functions in head, actions at the end.
Hi crythias

I put function in head
For customer's dtl the code is at the end and it's not working.
For agent's dtl the code is appendend to jscript section of dest defintion and it's working.

Probably it's depend when acl management is perfomed and, I suspect, on different behaviour between Core.Customer.InitFocus() and Core.Agent.TicketAction.Init();

regards
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: ACL working for agent only

Post by crythias »

For customer you may want to check out per-field .binds

Code: Select all

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#TypeID').bind('change', function (Event) {
        // make sure the ticket is not yet created on queue change
        $('input#Expand').val(1);
        Core.Form.Validate.DisableValidation($(this).closest('form'));
        $(this).closest('form').submit();
    });
//]]></script>
<!--dtl:js_on_document_complete-->
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
StefanoBoccanera
Znuny newbie
Posts: 76
Joined: 23 Feb 2011, 15:43
Znuny Version: 3.1.5
Real Name: Stefano Boccanera
Company: I.Conseils (self-employee)
Location: Rome (Italy)

Re: ACL working for agent only

Post by StefanoBoccanera »

crythias wrote:For customer you may want to check out per-field .binds

Code: Select all

<!--dtl:js_on_document_complete-->
<script type="text/javascript">//<![CDATA[
    $('#TypeID').bind('change', function (Event) {
        // make sure the ticket is not yet created on queue change
        $('input#Expand').val(1);
        Core.Form.Validate.DisableValidation($(this).closest('form'));
        $(this).closest('form').submit();
    });
//]]></script>
<!--dtl:js_on_document_complete-->
Hi crythias

sorry but my jscript's knowledge isn't so good.
Despite talking of #TypeID and #Dest how I can modify the jscript section getting acl execution immediately ? (Actually I'm getting the acl execution output after another queue is selected ...)

thanks for help !
Stefano Boccanera

OTRS : 3.1.5
ITSM : 3.1
S.O : RH
RDBMS : Postgres
Locked