Re: [rt-users] Overriding files in lib/RT?

2016-11-01 Thread Martin Wheldon

Hi Alex,

You may need to add the following to the end of your Email_Local.pm 
file:


1;

Best Regards

Martin

On 2016-10-31 20:17, Alex Hall wrote:

Hi all,
Thanks for the responses, it's partially working. When I use my
Email_Local.pm, the server refuses to start, yet I have no errors.
Running it through Perl's checker reveals only:

Name "RT::Logger" used only once: possible typo at Email_Local.pm at
line 31

Perl says everything else is fine. I pulled the single function I
wanted to modify out of the original Email.pm (ParseTicketId) and left
it alone, except for changing \s+ to \s* in the "if (my $@captures"
line. As usual, any errors that might be generated are going who knows
where, so I'm not sure where to start looking. As I said, Perl thinks
this is fine save that warning, but RT definitely doesn't. Any
thoughts? Here's the file:

use strict;
use warnings;
no warnings qw(redefine);

package RT::Interface::Email;

#Takes a string and searches for [subjecttag #id]

#Returns the id if a match is found.  Otherwise returns undef.

sub ParseTicketId {
my $Subject = shift;

my $rtname = RT->Config->Get('rtname');
my $test_name = RT->Config->Get('EmailSubjectTagRegex') ||
qr/\Q$rtname\E/i;

# We use @captures and pull out the last capture value to guard
against
# someone using (...) instead of (?:...) in $EmailSubjectTagRegex.
my $id;
if ( my @captures = $Subject =~ /\[$test_name\s*\#(\d+)\s*\]/i ) {
$id = $captures[-1];
} else {
foreach my $tag ( RT->System->SubjectTag ) {
next unless my @captures = $Subject =~
/\[\Q$tag\E\s+\#(\d+)\s*\]/i;
$id = $captures[-1];
last;
}
}
return undef unless $id;

$RT::Logger->debug("Found a ticket ID. It's $id");
return $id;
}

On Mon, Oct 31, 2016 at 12:18 PM, Nilesh  wrote:


To extend you should either add code in Email_Local.pm or
Email_Overlay.pm. If you name it as Email.pm then you have to copy
all code from existing module and modify it.

I'm not sure about differences between Overlay and Local but I think
that difference is for OO vs adding some functionality.

--
Nilesh

On 31-Oct-2016 9:45 PM, "Matt Zagrabelny" 
wrote:


Hi Alex,

On Mon, Oct 31, 2016 at 11:09 AM, Alex Hall 
wrote:

Hey list,
How would I override /opt/rt4/lib/RT/Interface/Email.pm [1]?


Overlays.





https://docs.bestpractical.com/rt/4.4.1/RT/StyleGuide.html#EXTENDING-RT-CLASSES

[2]

It looks like there is also an outdated wiki article:

https://rt-wiki.bestpractical.com/wiki/ObjectModel [3]

-m
-
RT 4.4 and RTIR training sessions, and a new workshop day!
https://bestpractical.com/training [4]
* Los Angeles - Q1 2017


-
RT 4.4 and RTIR training sessions, and a new workshop day!
https://bestpractical.com/training [4]
* Los Angeles - Q1 2017


--

Alex Hall
Automatic Distributors, IT department
ah...@autodist.com


Links:
--
[1] http://l.pm
[2]
https://docs.bestpractical.com/rt/4.4.1/RT/StyleGuide.html#EXTENDING-RT-CLASSES
[3] https://rt-wiki.bestpractical.com/wiki/ObjectModel
[4] https://bestpractical.com/training

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

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


Re: [rt-users] Overriding files in lib/RT?

2016-10-31 Thread Alex Hall
Sorry, but can you clarify "run FCGI by hand"? Currently, I run spawn-fcgi
to specify the address, port, and location of the RT FCGI server. All that
gives me is a success or error message on initial start, but any subsequent
errors don't seem to be logged anywhere. This is the only way I know to get
the FCGI server running. How do you do it? I'd love a way that would give
me more information. Thanks.

On Mon, Oct 31, 2016 at 4:29 PM, Kenneth Marshall  wrote:

> On Mon, Oct 31, 2016 at 04:17:11PM -0400, Alex Hall wrote:
> > Hi all,
> > Thanks for the responses, it's partially working. When I use my
> > Email_Local.pm, the server refuses to start, yet I have no errors.
> Running
> > it through Perl's checker reveals only:
> >
> > Name "RT::Logger" used only once: possible typo at Email_Local.pm at
> line 31
> >
> > Perl says everything else is fine. I pulled the single function I wanted
> to
> > modify out of the original Email.pm (ParseTicketId) and left it alone,
> > except for changing \s+ to \s* in the "if (my $@captures" line. As usual,
> > any errors that might be generated are going who knows where, so I'm not
> > sure where to start looking. As I said, Perl thinks this is fine save
> that
> > warning, but RT definitely doesn't. Any thoughts? Here's the file:
> >
>
> Hi Alex,
>
> Try running the fcgi process by hand and look for any errors. Sometimes,
> the one function you pull has dependencies on other function in the file
> which means that they would need to be in the new file as well. Running
> it by hand gave a useful error for me.
>
> Regards,
> Ken
>



-- 
Alex Hall
Automatic Distributors, IT department
ah...@autodist.com
-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Los Angeles - Q1 2017

Re: [rt-users] Overriding files in lib/RT?

2016-10-31 Thread Kenneth Marshall
On Mon, Oct 31, 2016 at 04:17:11PM -0400, Alex Hall wrote:
> Hi all,
> Thanks for the responses, it's partially working. When I use my
> Email_Local.pm, the server refuses to start, yet I have no errors. Running
> it through Perl's checker reveals only:
> 
> Name "RT::Logger" used only once: possible typo at Email_Local.pm at line 31
> 
> Perl says everything else is fine. I pulled the single function I wanted to
> modify out of the original Email.pm (ParseTicketId) and left it alone,
> except for changing \s+ to \s* in the "if (my $@captures" line. As usual,
> any errors that might be generated are going who knows where, so I'm not
> sure where to start looking. As I said, Perl thinks this is fine save that
> warning, but RT definitely doesn't. Any thoughts? Here's the file:
> 

Hi Alex,

Try running the fcgi process by hand and look for any errors. Sometimes,
the one function you pull has dependencies on other function in the file
which means that they would need to be in the new file as well. Running
it by hand gave a useful error for me.

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


Re: [rt-users] Overriding files in lib/RT?

2016-10-31 Thread Alex Hall
Hi all,
Thanks for the responses, it's partially working. When I use my
Email_Local.pm, the server refuses to start, yet I have no errors. Running
it through Perl's checker reveals only:

Name "RT::Logger" used only once: possible typo at Email_Local.pm at line 31

Perl says everything else is fine. I pulled the single function I wanted to
modify out of the original Email.pm (ParseTicketId) and left it alone,
except for changing \s+ to \s* in the "if (my $@captures" line. As usual,
any errors that might be generated are going who knows where, so I'm not
sure where to start looking. As I said, Perl thinks this is fine save that
warning, but RT definitely doesn't. Any thoughts? Here's the file:


use strict;
use warnings;
no warnings qw(redefine);

package RT::Interface::Email;

#Takes a string and searches for [subjecttag #id]

#Returns the id if a match is found.  Otherwise returns undef.

sub ParseTicketId {
my $Subject = shift;

my $rtname = RT->Config->Get('rtname');
my $test_name = RT->Config->Get('EmailSubjectTagRegex') ||
qr/\Q$rtname\E/i;

# We use @captures and pull out the last capture value to guard against
# someone using (...) instead of (?:...) in $EmailSubjectTagRegex.
my $id;
if ( my @captures = $Subject =~ /\[$test_name\s*\#(\d+)\s*\]/i ) {
$id = $captures[-1];
} else {
foreach my $tag ( RT->System->SubjectTag ) {
next unless my @captures = $Subject =~
/\[\Q$tag\E\s+\#(\d+)\s*\]/i;
$id = $captures[-1];
last;
}
}
return undef unless $id;

$RT::Logger->debug("Found a ticket ID. It's $id");
return $id;
}



On Mon, Oct 31, 2016 at 12:18 PM, Nilesh  wrote:

> To extend you should either add code in Email_Local.pm or
> Email_Overlay.pm. If you name it as Email.pm then you have to copy all code
> from existing module and modify it.
>
> I'm not sure about differences between Overlay and Local but I think that
> difference is for OO vs adding some functionality.
>
> --
> Nilesh
>
> On 31-Oct-2016 9:45 PM, "Matt Zagrabelny"  wrote:
>
>> Hi Alex,
>>
>> On Mon, Oct 31, 2016 at 11:09 AM, Alex Hall  wrote:
>> > Hey list,
>> > How would I override /opt/rt4/lib/RT/Interface/Email.pm?
>>
>> Overlays.
>>
>> https://docs.bestpractical.com/rt/4.4.1/RT/StyleGuide.html#
>> EXTENDING-RT-CLASSES
>>
>> It looks like there is also an outdated wiki article:
>>
>> https://rt-wiki.bestpractical.com/wiki/ObjectModel
>>
>> -m
>> -
>> RT 4.4 and RTIR training sessions, and a new workshop day!
>> https://bestpractical.com/training
>> * Los Angeles - Q1 2017
>>
>
> -
> RT 4.4 and RTIR training sessions, and a new workshop day!
> https://bestpractical.com/training
> * Los Angeles - Q1 2017
>



-- 
Alex Hall
Automatic Distributors, IT department
ah...@autodist.com
-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Los Angeles - Q1 2017

Re: [rt-users] Overriding files in lib/RT?

2016-10-31 Thread Nilesh
To extend you should either add code in Email_Local.pm or Email_Overlay.pm.
If you name it as Email.pm then you have to copy all code from existing
module and modify it.

I'm not sure about differences between Overlay and Local but I think that
difference is for OO vs adding some functionality.

--
Nilesh

On 31-Oct-2016 9:45 PM, "Matt Zagrabelny"  wrote:

> Hi Alex,
>
> On Mon, Oct 31, 2016 at 11:09 AM, Alex Hall  wrote:
> > Hey list,
> > How would I override /opt/rt4/lib/RT/Interface/Email.pm?
>
> Overlays.
>
> https://docs.bestpractical.com/rt/4.4.1/RT/StyleGuide.
> html#EXTENDING-RT-CLASSES
>
> It looks like there is also an outdated wiki article:
>
> https://rt-wiki.bestpractical.com/wiki/ObjectModel
>
> -m
> -
> RT 4.4 and RTIR training sessions, and a new workshop day!
> https://bestpractical.com/training
> * Los Angeles - Q1 2017
>
-
RT 4.4 and RTIR training sessions, and a new workshop day! 
https://bestpractical.com/training
* Los Angeles - Q1 2017

Re: [rt-users] Overriding files in lib/RT?

2016-10-31 Thread Matt Zagrabelny
Hi Alex,

On Mon, Oct 31, 2016 at 11:09 AM, Alex Hall  wrote:
> Hey list,
> How would I override /opt/rt4/lib/RT/Interface/Email.pm?

Overlays.

https://docs.bestpractical.com/rt/4.4.1/RT/StyleGuide.html#EXTENDING-RT-CLASSES

It looks like there is also an outdated wiki article:

https://rt-wiki.bestpractical.com/wiki/ObjectModel

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