Commit fc96bff19a6aebfedbd24fa2bbc58eb34af58cb1

Authored by Rodrigo Gonçalves
1 parent 058af795
Exists in master

Detecção e reencaminhamento automático para modo autenticado.

Mensagem customizada para interface pública, para sugerir o idUFSC.
Kernel/Config/Files/NewTicketWizard.xml
... ... @@ -522,6 +522,17 @@
522 522 <String Regex="">Escolha o local para o qual deseja atendimento</String>
523 523 </Setting>
524 524 </ConfigItem>
  525 +
  526 + <ConfigItem Name="Ticket::Frontend::Customer::QueuesPanel###MessageChooseQueue"
  527 + Required="0" Valid="1">
  528 + <Description Lang="en">Message to let the user choose a queue.</Description>
  529 + <Description Lang="pt_BR">Mensagem para o usuário selecionar uma fila.</Description>
  530 + <Group>Ticket</Group>
  531 + <SubGroup>Frontend::Customer::QueuesPanel</SubGroup>
  532 + <Setting>
  533 + <String Regex="">Escolha o local para o qual deseja atendimento</String>
  534 + </Setting>
  535 + </ConfigItem>
525 536  
526 537  
527 538 </otrs_config>
528 539 \ No newline at end of file
... ...
Kernel/Modules/NewTicketWizard.pm
... ... @@ -109,7 +109,7 @@ sub BuildServices {
109 109 Max => 200
110 110 );
111 111  
112   - print STDERR "\n\n\n Combo " . $retorno . "\n\n\n";
  112 + $Self->Debug( "\n\n\n Combo " . $retorno . "\n\n\n" );
113 113 return $retorno;
114 114  
115 115 }
... ... @@ -298,7 +298,7 @@ sub GetFormJSON {
298 298  
299 299 my ( $schema, $fields, $introduction ) = $Self->GetForm( ServiceForm => \%serviceForm, QueueID => $QueueID );
300 300  
301   - print STDERR "[{" . $schema . "}, {" . $fields . "}, \"" . $introduction . "\"]";
  301 + $Self->Debug( "[{" . $schema . "}, {" . $fields . "}, \"" . $introduction . "\"]" );
302 302  
303 303 return $Self->{LayoutObject}->Attachment(
304 304 ContentType => 'application/json; charset=' . $Self->{LayoutObject}->{Charset},
... ... @@ -358,10 +358,10 @@ sub GetQueueID() {
358 358  
359 359 # Check if queueID was sent
360 360 my $QueueID = $Self->{ParamObject}->GetParam( Param => "QueueID" );
361   - print STDERR "\n\nBSUCANDO $QueueID FILA\n\n";
  361 + $Self->Debug( "\n\nBSUCANDO $QueueID FILA\n\n");
362 362  
363 363 if ($QueueID) {
364   - print STDERR "\n\nRecebida fila $QueueID\n\n";
  364 + $Self->Debug( "\n\nRecebida fila $QueueID\n\n" );
365 365 my %Queue = $Self->{QueueObject}->QueueGet( ID => $QueueID );
366 366 return ( $Queue{"Name"}, $QueueID );
367 367 }
... ... @@ -373,7 +373,7 @@ sub GetQueueID() {
373 373 my $QueueDefault = $ConfigTicket->{"QueueDefault"};
374 374  
375 375 # Checks if there is a field for the queue
376   - print STDERR Dumper($ConfigTicketWizard);
  376 + $Self->Debug( Dumper($ConfigTicketWizard) );
377 377  
378 378 my $QueuePrefix = $ConfigTicketWizard->{"QueuePrefix"};
379 379 my $QueueField = $ConfigTicketWizard->{"QueueField"};
... ... @@ -409,7 +409,7 @@ sub CreateTicket {
409 409 my ( $Queue, $QueueID ) = $Self->GetQueueID(%Param);
410 410 $Data{QueueID} = $QueueID;
411 411  
412   - print STDERR "\n\nFila achada: " . $Queue . "\n\n";
  412 + $Self->Debug( "\n\nFila achada: " . $Queue . "\n\n" );
413 413  
414 414 $Self->{Config} = $Self->{ConfigObject}->Get("Ticket::Frontend::CustomerTicketMessage");
415 415  
... ... @@ -510,7 +510,7 @@ sub Debug {
510 510 my $Self = shift;
511 511 my $msg = shift;
512 512  
513   - print STDERR "\n\nDEBUG => \n$msg\n\n";
  513 + #print STDERR "\n\nDEBUG => \n$msg\n\n";
514 514 }
515 515  
516 516 1;
... ...
Kernel/Modules/NewTicketWizardPublic.pm
... ... @@ -265,10 +265,10 @@ sub GetQueueID() {
265 265  
266 266 # Check if queueID was sent
267 267 my $QueueID = $Self->{ParamObject}->GetParam(Param => "QueueID");
268   - print STDERR "\n\nBSUCANDO $QueueID FILA\n\n";
  268 + $Self->Debug( "\n\nBSUCANDO $QueueID FILA\n\n");
269 269  
270 270 if ($QueueID) {
271   - print STDERR "\n\nRecebida fila $QueueID\n\n";
  271 + $Self->Debug( "\n\nRecebida fila $QueueID\n\n" );
272 272 my %Queue = $Self->{QueueObject}->QueueGet(ID => $QueueID);
273 273 return ($Queue{"Name"}, $QueueID);
274 274 }
... ... @@ -284,7 +284,7 @@ sub GetQueueID() {
284 284  
285 285 my $QueuePrefix = $ConfigTicketWizard->{"QueuePrefix"};
286 286 my $QueueField = $ConfigTicketWizard->{"QueueField"};
287   - $Self->{LogObject}->Log( Priority => 'info', Message => "Searching queue for - $QueuePrefix ($QueueField)!" );
  287 + $Self->Debug( "Searching queue for - $QueuePrefix ($QueueField)!" );
288 288  
289 289 my %QueueListID = $Self->{QueueObject}->QueueList( Valid => 1 );
290 290 my %QueueList = reverse $Self->{QueueObject}->QueueList( Valid => 1 );
... ... @@ -294,13 +294,12 @@ sub GetQueueID() {
294 294 if ( $QueuePrefix && $QueueField ) {
295 295 my $QueueSelected = $Self->{ParamObject}->GetParam( Param => $QueueField );
296 296 my $QueueName = "$QueuePrefix $QueueSelected";
297   - $Self->{LogObject}
298   - ->Log( Priority => 'info', Message => "Searching queue for - $QueuePrefix ($QueueField) - [$QueueName]!" );
  297 + $Self->Debug( "Searching queue for - $QueuePrefix ($QueueField) - [$QueueName]!" );
299 298  
300 299 if ( $QueueList{$QueueName} ) {
301 300 $QueueID = $QueueList{$QueueName};
302 301 $Queue = $QueueName;
303   - $Self->{LogObject}->Log( Priority => 'info', Message => "Custom queue found - $QueueName ($QueueID)!" );
  302 + $Self->Debug( "Custom queue found - $QueueName ($QueueID)!" );
304 303 }
305 304  
306 305 }
... ... @@ -452,4 +451,11 @@ sub CreateTicket {
452 451  
453 452 }
454 453  
  454 +sub Debug {
  455 + my $Self = shift;
  456 + my $msg = shift;
  457 +
  458 + #print STDERR "\n\nDEBUG => \n$msg\n\n";
  459 +}
  460 +
455 461 1;
... ...
Kernel/Modules/QueuesPanel.pm
... ... @@ -17,8 +17,6 @@ use Data::Dumper;
17 17  
18 18 sub new {
19 19 my ( $Type, %Param ) = @_;
20   -
21   -
22 20  
23 21 # allocate new hash for object
24 22 my $Self = {%Param};
... ... @@ -42,122 +40,146 @@ sub new {
42 40 sub Run {
43 41 my ( $Self, %Param ) = @_;
44 42 my %Data = ();
45   -
  43 +
46 44 $Self->{UrlAtendimento} = '/otrs/customer.pl?Action=NewTicketWizard;QueueID=';
47 45  
48 46 $Data{"QueueJS"} = $Self->BuildQueuesJS();
49   -
50   - $Self->Debug($Data{"QueueJS"});
  47 +
  48 + $Self->Debug( $Data{"QueueJS"} );
51 49  
52 50 $Self->{Config} = $Self->{ConfigObject}->Get("Ticket::Frontend::Customer::QueuesPanel");
53   - my $msgChooseService = $Self->{Config}->{"MessageChooseQueuePublic"};
  51 + my $msgChooseService = $Self->{Config}->{"MessageChooseQueue"};
54 52 $Data{MsgChooseQueue} = $msgChooseService;
55 53  
56   - if ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) ) {
57   - if ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) eq "CreateTicket" ) {
58   - }
59   - elsif ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) eq "GetFormJSON" ) {
60   - }
61   - }
62   - else {
63   -
64   - # build output
65   - my $Output =
66   - $Self->{LayoutObject}
67   - ->CustomerHeader( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Queues panel") );
68   -
69   - $Output .= $Self->{LayoutObject}->Output(
70   - Data => \%Data,
71   - TemplateFile => 'QueuesPanel',
72   - );
73   - $Output .= $Self->{LayoutObject}->CustomerFooter();
74   - return $Output;
75   - }
  54 + # build output
  55 + my $Output =
  56 + $Self->{LayoutObject}->CustomerHeader( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Queues panel") );
  57 +
  58 + $Output .= $Self->{LayoutObject}->Output(
  59 + Data => \%Data,
  60 + TemplateFile => 'QueuesPanel',
  61 + );
  62 + $Output .= $Self->{LayoutObject}->CustomerFooter();
  63 + return $Output;
76 64 }
77 65  
78 66 sub BuildQueuesJS {
79 67 my ( $Self, %Param ) = @_;
80   -
  68 +
81 69 # Get queues
82 70 my %Queues = ();
83   -
  71 +
84 72 $Self->{DBObject}->Prepare( SQL => "SELECT id, name FROM queue WHERE valid_id = 1 ORDER BY name ASC", );
85 73 while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
86   - $Queues{$Row[0]} = $Row[1];
  74 + $Queues{ $Row[0] } = $Row[1];
87 75 }
88 76  
89   - my $result = '$(document).ready(function() {' . "\n\t". ' $("#columns").hColumns({' . "\n\t\t" . ' nodeSource: function(node_id, callback) {' . "\n";
90   -
91   - for my $queue (keys %Queues) {
92   - $result = $result . $Self->BuildQueueJS(Queues => \%Queues, Queue => $Queues{$queue}, QueueID => $queue);
  77 + my $result =
  78 + '$(document).ready(function() {' . "\n\t"
  79 + . ' $("#columns").hColumns({'
  80 + . "\n\t\t"
  81 + . ' nodeSource: function(node_id, callback) {' . "\n";
  82 +
  83 + for my $queue ( keys %Queues ) {
  84 + $result = $result . $Self->BuildQueueJS( Queues => \%Queues, Queue => $Queues{$queue}, QueueID => $queue );
93 85 }
94   -
95   - $result = $result . $Self->BuildTopQueuesJS(Queues => \%Queues);
96   -
  86 +
  87 + $result = $result . $Self->BuildTopQueuesJS( Queues => \%Queues );
  88 +
97 89 $result = $result . "\n\t}});\n});";
98   -
99   - return $result;
  90 +
  91 + return $result;
100 92 }
101 93  
102 94 sub BuildTopQueuesJS {
103 95 my ( $Self, %Param ) = @_;
104   - my %Queues = %{$Param{"Queues"}};
  96 + my %Queues = %{ $Param{"Queues"} };
105 97  
106   - my @topQueues = grep { index($Queues{$_},'::') == -1 } keys %Queues;
  98 + my @topQueues = grep { index( $Queues{$_}, '::' ) == -1 } keys %Queues;
107 99  
108 100 my $result = "\t\tif (node_id === null) { \n\t\t\treturn callback(null, [\n";
109 101 for my $queue (@topQueues) {
110   -
111   - if (grep { index($Queues{$_}, $Queues{$queue} . "::") >= 0} keys %Queues) {
112   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "folder" },' . "\n";
113   - } else {
114   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "link", url: "' . $Self->{UrlAtendimento} . $queue . '" },' . "\n";
  102 +
  103 + if ( grep { index( $Queues{$_}, $Queues{$queue} . "::" ) >= 0 } keys %Queues ) {
  104 + $result = $result
  105 + . "\t\t\t\t"
  106 + . '{ id: '
  107 + . $queue
  108 + . ', label: "'
  109 + . $Self->LastQueue( $Queues{$queue} )
  110 + . '", type: "folder" },' . "\n";
  111 + }
  112 + else {
  113 + $result = $result
  114 + . "\t\t\t\t"
  115 + . '{ id: '
  116 + . $queue
  117 + . ', label: "'
  118 + . $Self->LastQueue( $Queues{$queue} )
  119 + . '", type: "link", url: "'
  120 + . $Self->{UrlAtendimento}
  121 + . $queue . '" },' . "\n";
115 122 }
116 123 }
117   -
  124 +
118 125 $result = $result . "\t\t\t]);\n\t\t}\n";
119   -
120   - return $result;
  126 +
  127 + return $result;
121 128 }
122 129  
123 130 sub BuildQueueJS {
124 131 my ( $Self, %Param ) = @_;
125   - my %Queues = %{$Param{"Queues"}};
126   - my $BaseQueue = $Param{"Queue"};
  132 + my %Queues = %{ $Param{"Queues"} };
  133 + my $BaseQueue = $Param{"Queue"};
127 134 my $BaseQueueID = $Param{"QueueID"};
128 135  
129 136 # Get subqueues
130   - my @subqueues = grep { index($Queues{$_}, $BaseQueue . "::") >= 0} keys %Queues;
  137 + my @subqueues = grep { index( $Queues{$_}, $BaseQueue . "::" ) >= 0 } keys %Queues;
131 138 my $level = () = $BaseQueue =~ /::/g;
132 139 $level = $level + 1;
133   -
  140 +
134 141 # Remove subsubqueues
135   - @subqueues = grep { (() = $Queues{$_} =~ /::/g) == $level} @subqueues;
136   -
  142 + @subqueues = grep { ( () = $Queues{$_} =~ /::/g ) == $level } @subqueues;
  143 +
137 144 # When there are no subqueues, there is no need to create a JS
138   - if (! @subqueues) {
  145 + if ( !@subqueues ) {
139 146 return;
140 147 }
141   -
  148 +
142 149 my $result = "\t\tif (node_id === " . $BaseQueueID . ") { \n\t\t\treturn callback(null, [\n";
143   -
144   - for my $queue (@subqueues) {
145   - if (grep {index($Queues{$_}, $Queues{$queue} . "::") >= 0} keys %Queues) {
146   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "folder" }, ' . "\n";
147   - } else {
148   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "link", url: "' . $Self->{UrlAtendimento} . $queue . '" }, ' . "\n";
149   - }
  150 +
  151 + for my $queue (@subqueues) {
  152 + if ( grep { index( $Queues{$_}, $Queues{$queue} . "::" ) >= 0 } keys %Queues ) {
  153 + $result = $result
  154 + . "\t\t\t\t"
  155 + . '{ id: '
  156 + . $queue
  157 + . ', label: "'
  158 + . $Self->LastQueue( $Queues{$queue} )
  159 + . '", type: "folder" }, ' . "\n";
  160 + }
  161 + else {
  162 + $result = $result
  163 + . "\t\t\t\t"
  164 + . '{ id: '
  165 + . $queue
  166 + . ', label: "'
  167 + . $Self->LastQueue( $Queues{$queue} )
  168 + . '", type: "link", url: "'
  169 + . $Self->{UrlAtendimento}
  170 + . $queue . '" }, ' . "\n";
  171 + }
150 172 }
151   -
  173 +
152 174 $result = $result . "\t\t\t]);\n\t\t}\n";
153   -
154   - return $result;
  175 +
  176 + return $result;
155 177 }
156 178  
157 179 sub LastQueue {
158   - my $Self = shift;
  180 + my $Self = shift;
159 181 my $queue = shift;
160   - my @parts = split("::", $queue);
  182 + my @parts = split( "::", $queue );
161 183 return $parts[-1];
162 184 }
163 185  
... ... @@ -165,7 +187,7 @@ sub Debug {
165 187 my $Self = shift;
166 188 my $msg = shift;
167 189  
168   - print STDERR "\n\nDEBUG => \n$msg\n\n";
  190 + #print STDERR "\n\nDEBUG => \n$msg\n\n";
169 191 }
170 192  
171 193 1;
... ...
Kernel/Modules/QueuesPanelPublic.pm
... ... @@ -17,8 +17,6 @@ use Data::Dumper;
17 17  
18 18 sub new {
19 19 my ( $Type, %Param ) = @_;
20   -
21   -
22 20  
23 21 # allocate new hash for object
24 22 my $Self = {%Param};
... ... @@ -42,122 +40,169 @@ sub new {
42 40 sub Run {
43 41 my ( $Self, %Param ) = @_;
44 42 my %Data = ();
45   -
  43 +
  44 + ## Se recebeu o ticket, significa que usuario já está autenticado
  45 + if ( $Self->{ParamObject}->GetParam( Param => "ticket" ) ) {
  46 + $Self->Debug("Recebida URL com ticket");
  47 + my $retorno = $Self->{LayoutObject}->Redirect( OP => "Action=QueuesPanel", );
  48 + $retorno =~ s/public/customer/g;
  49 + $Self->Debug( "Redirect feito: " . $retorno );
  50 + return $retorno;
  51 + }
  52 +
  53 + ## Se tiver parametro para tentar autenticar, repassa ao CAS com gateway
  54 + if ( $Self->{ParamObject}->GetParam( Param => "autenticar" ) ) {
  55 + my $url =
  56 + $Self->{ConfigObject}->Get('Customer::AuthModule::CAS::CASUrl')
  57 + . "/login?gateway=true&service="
  58 + . "https://"
  59 + . $ENV{SERVER_NAME}
  60 + . $ENV{SCRIPT_NAME}
  61 + . "?Action=QueuesPanelPublic";
  62 + $Self->Debug("Recebida tentativa de autenticar via url $url");
  63 + return $Self->{LayoutObject}->Redirect( ExtURL => $url, );
  64 + }
  65 + ##
  66 +
46 67 $Self->{UrlAtendimento} = '/otrs/public.pl?Action=NewTicketWizardPublic;QueueID=';
47 68  
48 69 $Data{"QueueJS"} = $Self->BuildQueuesJS();
49   -
50   - $Self->Debug($Data{"QueueJS"});
  70 +
  71 + $Self->Debug( $Data{"QueueJS"} );
51 72  
52 73 $Self->{Config} = $Self->{ConfigObject}->Get("Ticket::Frontend::Customer::QueuesPanel");
53 74 my $msgChooseService = $Self->{Config}->{"MessageChooseQueuePublic"};
54 75 $Data{MsgChooseQueue} = $msgChooseService;
55 76  
56   - if ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) ) {
57   - if ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) eq "CreateTicket" ) {
58   - }
59   - elsif ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) eq "GetFormJSON" ) {
60   - }
61   - }
62   - else {
63   -
64   - # build output
65   - my $Output =
66   - $Self->{LayoutObject}
67   - ->CustomerHeader( Title => $Self->{LayoutObject}->{LanguageObject}->Get("New ticket") );
68   -
69   - $Output .= $Self->{LayoutObject}->Output(
70   - Data => \%Data,
71   - TemplateFile => 'QueuesPanel',
72   - );
73   - $Output .= $Self->{LayoutObject}->CustomerFooter();
74   - return $Output;
75   - }
  77 + # build output
  78 + my $Output =
  79 + $Self->{LayoutObject}->CustomerHeader( Title => $Self->{LayoutObject}->{LanguageObject}->Get("New ticket") );
  80 +
  81 + $Output .= $Self->{LayoutObject}->Output(
  82 + Data => \%Data,
  83 + TemplateFile => 'QueuesPanel',
  84 + );
  85 + $Output .= $Self->{LayoutObject}->CustomerFooter();
  86 + return $Output;
76 87 }
77 88  
78 89 sub BuildQueuesJS {
79 90 my ( $Self, %Param ) = @_;
80   -
  91 +
81 92 # Get queues
82 93 my %Queues = ();
83   -
  94 +
84 95 $Self->{DBObject}->Prepare( SQL => "SELECT id, name FROM queue WHERE valid_id = 1 ORDER BY name ASC", );
85 96 while ( my @Row = $Self->{DBObject}->FetchrowArray() ) {
86   - $Queues{$Row[0]} = $Row[1];
  97 + $Queues{ $Row[0] } = $Row[1];
87 98 }
88 99  
89   - my $result = '$(document).ready(function() {' . "\n\t". ' $("#columns").hColumns({' . "\n\t\t" . ' nodeSource: function(node_id, callback) {' . "\n";
90   -
91   - for my $queue (keys %Queues) {
92   - $result = $result . $Self->BuildQueueJS(Queues => \%Queues, Queue => $Queues{$queue}, QueueID => $queue);
  100 + my $result =
  101 + '$(document).ready(function() {' . "\n\t"
  102 + . ' $("#columns").hColumns({'
  103 + . "\n\t\t"
  104 + . ' nodeSource: function(node_id, callback) {' . "\n";
  105 +
  106 + for my $queue ( keys %Queues ) {
  107 + $result = $result . $Self->BuildQueueJS( Queues => \%Queues, Queue => $Queues{$queue}, QueueID => $queue );
93 108 }
94   -
95   - $result = $result . $Self->BuildTopQueuesJS(Queues => \%Queues);
96   -
  109 +
  110 + $result = $result . $Self->BuildTopQueuesJS( Queues => \%Queues );
  111 +
97 112 $result = $result . "\n\t}});\n});";
98   -
99   - return $result;
  113 +
  114 + return $result;
100 115 }
101 116  
102 117 sub BuildTopQueuesJS {
103 118 my ( $Self, %Param ) = @_;
104   - my %Queues = %{$Param{"Queues"}};
  119 + my %Queues = %{ $Param{"Queues"} };
105 120  
106   - my @topQueues = grep { index($Queues{$_},'::') == -1 } keys %Queues;
  121 + my @topQueues = grep { index( $Queues{$_}, '::' ) == -1 } keys %Queues;
107 122  
108 123 my $result = "\t\tif (node_id === null) { \n\t\t\treturn callback(null, [\n";
109 124 for my $queue (@topQueues) {
110   -
111   - if (grep { index($Queues{$_}, $Queues{$queue} . "::") >= 0} keys %Queues) {
112   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "folder" },' . "\n";
113   - } else {
114   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "link", url: "' . $Self->{UrlAtendimento} . $queue . '" },' . "\n";
  125 +
  126 + if ( grep { index( $Queues{$_}, $Queues{$queue} . "::" ) >= 0 } keys %Queues ) {
  127 + $result = $result
  128 + . "\t\t\t\t"
  129 + . '{ id: '
  130 + . $queue
  131 + . ', label: "'
  132 + . $Self->LastQueue( $Queues{$queue} )
  133 + . '", type: "folder" },' . "\n";
  134 + }
  135 + else {
  136 + $result = $result
  137 + . "\t\t\t\t"
  138 + . '{ id: '
  139 + . $queue
  140 + . ', label: "'
  141 + . $Self->LastQueue( $Queues{$queue} )
  142 + . '", type: "link", url: "'
  143 + . $Self->{UrlAtendimento}
  144 + . $queue . '" },' . "\n";
115 145 }
116 146 }
117   -
  147 +
118 148 $result = $result . "\t\t\t]);\n\t\t}\n";
119   -
120   - return $result;
  149 +
  150 + return $result;
121 151 }
122 152  
123 153 sub BuildQueueJS {
124 154 my ( $Self, %Param ) = @_;
125   - my %Queues = %{$Param{"Queues"}};
126   - my $BaseQueue = $Param{"Queue"};
  155 + my %Queues = %{ $Param{"Queues"} };
  156 + my $BaseQueue = $Param{"Queue"};
127 157 my $BaseQueueID = $Param{"QueueID"};
128 158  
129 159 # Get subqueues
130   - my @subqueues = grep { index($Queues{$_}, $BaseQueue . "::") >= 0} keys %Queues;
  160 + my @subqueues = grep { index( $Queues{$_}, $BaseQueue . "::" ) >= 0 } keys %Queues;
131 161 my $level = () = $BaseQueue =~ /::/g;
132 162 $level = $level + 1;
133   -
  163 +
134 164 # Remove subsubqueues
135   - @subqueues = grep { (() = $Queues{$_} =~ /::/g) == $level} @subqueues;
136   -
  165 + @subqueues = grep { ( () = $Queues{$_} =~ /::/g ) == $level } @subqueues;
  166 +
137 167 # When there are no subqueues, there is no need to create a JS
138   - if (! @subqueues) {
  168 + if ( !@subqueues ) {
139 169 return;
140 170 }
141   -
  171 +
142 172 my $result = "\t\tif (node_id === " . $BaseQueueID . ") { \n\t\t\treturn callback(null, [\n";
143   -
144   - for my $queue (@subqueues) {
145   - if (grep {index($Queues{$_}, $Queues{$queue} . "::") >= 0} keys %Queues) {
146   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "folder" }, ' . "\n";
147   - } else {
148   - $result = $result . "\t\t\t\t" . '{ id: ' . $queue . ', label: "' . $Self->LastQueue($Queues{$queue}) . '", type: "link", url: "' . $Self->{UrlAtendimento} . $queue . '" }, ' . "\n";
149   - }
  173 +
  174 + for my $queue (@subqueues) {
  175 + if ( grep { index( $Queues{$_}, $Queues{$queue} . "::" ) >= 0 } keys %Queues ) {
  176 + $result = $result
  177 + . "\t\t\t\t"
  178 + . '{ id: '
  179 + . $queue
  180 + . ', label: "'
  181 + . $Self->LastQueue( $Queues{$queue} )
  182 + . '", type: "folder" }, ' . "\n";
  183 + }
  184 + else {
  185 + $result = $result
  186 + . "\t\t\t\t"
  187 + . '{ id: '
  188 + . $queue
  189 + . ', label: "'
  190 + . $Self->LastQueue( $Queues{$queue} )
  191 + . '", type: "link", url: "'
  192 + . $Self->{UrlAtendimento}
  193 + . $queue . '" }, ' . "\n";
  194 + }
150 195 }
151   -
  196 +
152 197 $result = $result . "\t\t\t]);\n\t\t}\n";
153   -
154   - return $result;
  198 +
  199 + return $result;
155 200 }
156 201  
157 202 sub LastQueue {
158   - my $Self = shift;
  203 + my $Self = shift;
159 204 my $queue = shift;
160   - my @parts = split("::", $queue);
  205 + my @parts = split( "::", $queue );
161 206 return $parts[-1];
162 207 }
163 208  
... ... @@ -165,7 +210,7 @@ sub Debug {
165 210 my $Self = shift;
166 211 my $msg = shift;
167 212  
168   - print STDERR "\n\nDEBUG => \n$msg\n\n";
  213 + #print STDERR "\n\nDEBUG => \n$msg\n\n";
169 214 }
170 215  
171 216 1;
... ...
NewTicketWizard.sopm
1 1 <?xml version="1.0" encoding="utf-8" ?>
2 2 <otrs_package version="1.0">
3 3 <Name>NewTicketWizard</Name>
4   - <Version>1.2.10</Version>
  4 + <Version>1.3.0</Version>
5 5 <Framework>3.x.x</Framework>
6 6 <Vendor>SeTIC</Vendor>
7 7 <URL>http://www.setic.ufsc.br</URL>
... ... @@ -17,7 +17,8 @@
17 17 Versão 1.1.3 - Link para abrir segundo chamado na tela de finalização da abertura
18 18 Versão 1.1.4 - Aumento na fonte do botao de enviar
19 19 Versão 1.2.6 - Painel de navegação de filas
20   - Versão 1.2.9 - Publicacao de manutencoes em progresso
  20 + Versão 1.2.9 - Publicacao de manutencoes em progresso
  21 + Versão 1.3.0 - Suporte para detecção e auto-encaminhamento em modo autenticado/não autenticado
21 22  
22 23 </Description>
23 24 <IntroInstall Type="post" Lang="pt-br" Title="Obrigado">Módulo instalado com sucesso!</IntroInstall>
... ...