Re: [rt-users] Match isWatcher and part of subjectline

2016-10-06 Thread Jeffrey Pilant
Joel Bergmark Writes:
>Could anyone assist with this scrip?
>
>This matches $match2 at every time, regardless if both $match1 and $match2 is 
>present in the subject-line. Hence the If(index part is not working, any good 
>perl-people that can correct it? Both matches must be present to not return 0;
>
>my $match1 = "InformationX";
>my $match2 = "[Y]";
>my $subject = $self->TicketObj->Subject;
>if (index(lc($subject), ($match1 && $match2)) eq -1)

The "&&" operator is a logical short-circuit AND.  If the first op ($match1) is 
false it returns false without evaluating the second op ($match2).
Neither $match1 nor $match2 is a logical, so it makes no sense.

Try this instead:
   if ((index(lc($subject), $match1) >= 0) && (index(lc($subject), $match2) >= 
0))
reference:
   http://perldoc.perl.org/perlop.html#C-style-Logical-And
   http://perldoc.perl.org/functions/index.html

Another consideration: you are testing against a lower case version of the 
subject, yet both strings have upper case characters.  You will never find 
either string.

You need to AND the result of both index functions, to verify both are found.

/jeff


The information contained in this e-mail is for the exclusive use of the 
intended recipient(s) and may be confidential, proprietary, and/or 
legally privileged.  Inadvertent disclosure of this message does not 
constitute a waiver of any privilege.  If you receive this message in 
error, please do not directly or indirectly use, print, copy, forward,
or disclose any part of this message.  Please also delete this e-mail 
and all copies and notify the sender.  Thank you. 

-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017


Re: [rt-users] Match isWatcher and part of subjectline

2016-10-06 Thread Joel Bergmark
Could anyone assist with this scrip?

This matches $match2 at every time, regardless if both $match1 and $match2 is 
present in the subject-line. Hence the If(index part is not working, any good 
perl-people that can correct it? Both matches must be present to not return 0;

my $match1 = "InformationX";
my $match2 = "[Y]";
my $subject = $self->TicketObj->Subject;
if (index(lc($subject), ($match1 && $match2)) eq -1)
{
return 0;
}
else {
return 1 if $self->TicketObj->IsWatcher(
Type => 'Requestor', Email => 'email-adr...@se.se'
);
return 0;
}

Regards,


Från: rt-users [mailto:rt-users-boun...@lists.bestpractical.com] För Joel 
Bergmark
Skickat: den 5 oktober 2016 15:25
Till: rt-users@lists.bestpractical.com
Ämne: [rt-users] Match isWatcher and part of subjectline

Anyone has some cool code to match something like this: If iswatcher is  then check if subject contains  return 1;  else return 0;

I cant get this simple stuff to work, perl isn't my thing :-)

Regards
-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017

Re: [rt-users] Adding an Action link to Ticket/Display.html/BeforeActionList

2016-10-06 Thread David Schmidt

I'll answer myself:
if an action is not a ref it is rendered in the result box. bit 
unexpected but im sure there is a reason. (code in 
share/html/Elements/ListActions)


https://github.com/bestpractical/rt/blob/stable/share/html/Elements/ListActions#L49


On 06.10.2016 13:53, David Schmidt wrote:

When/Where are the actions added to @Actions?

1) for some reason the \@Actions ArrayRef is empty when I access it in
the callback. Where do the Actions come from? I am talking about the
links "Reply", "Comment", "Forward", "Stall", ...

2) If I push a simple string to \@Actions they end up in a yellow
"Results" Widget. see attached screenshot


#local/plugins/RT-Extension-OneClickClose/html/Callbacks/RT-Extension-OneClickClose/Ticket/Display.html/BeforeActionList
<%init>
use Data::Dumper;
$RT::Logger->debug("\n\n###\n".Dumper($Actions)."\n\n###\n");
push @$Actions, "foo";


<%args>
$Actions => undef
$TicketObj   => undef



Output:
###
$VAR1 = [];


###
(/opt/rt4/local/plugins/RT-Extension-OneClickClose/html/Callbacks/RT-Extension-OneClickClose/Ticket/Display.html/BeforeActionList:3)

-
RT 4.4 and RTIR training sessions, and a new workshop day!
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017

-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017


[rt-users] Adding an Action link to Ticket/Display.html/BeforeActionList

2016-10-06 Thread David Schmidt

When/Where are the actions added to @Actions?

1) for some reason the \@Actions ArrayRef is empty when I access it in 
the callback. Where do the Actions come from? I am talking about the 
links "Reply", "Comment", "Forward", "Stall", ...


2) If I push a simple string to \@Actions they end up in a yellow 
"Results" Widget. see attached screenshot



#local/plugins/RT-Extension-OneClickClose/html/Callbacks/RT-Extension-OneClickClose/Ticket/Display.html/BeforeActionList
<%init>
use Data::Dumper;
$RT::Logger->debug("\n\n###\n".Dumper($Actions)."\n\n###\n");
push @$Actions, "foo";


<%args>
$Actions => undef
$TicketObj   => undef



Output:
###
$VAR1 = [];


### 
(/opt/rt4/local/plugins/RT-Extension-OneClickClose/html/Callbacks/RT-Extension-OneClickClose/Ticket/Display.html/BeforeActionList:3)
-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Boston - October 24-26
* Los Angeles - Q1 2017