Integrating OTRS modifications nicely

English! place to talk about development, programming and coding
Post Reply
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Integrating OTRS modifications nicely

Post by MichaelR »

Yo,

I've just developed 'ArticleFreeTime' fields (3 of them) that you can enter. I've done all the development and have got it working on our dev OTRS. I want to 'nicely' integrate it into our live OTRS instead of having to copy+paste code into a few Kernel/System/* Kernel/Modules/* Kernel/Output/HTML/* etc.

So I have a few questions, since I cannot find the answers in the dev handbook for OTRS 3!

1. I have created a new file Kernel/System/Ticket/ArticleFreeTimeFunctions.pm that holds a few functions. How can I get OTRS to see these?

"package Kernel::System::Ticket::ArticleFreeTimeFunction;"

I have included the line "use Kernel::System::Ticket::ArticleFreeTimeFunctions;" into Kernel/System/Ticket.pm, but when I call the functions from within AgentTicketActionCommon.pm like "$Self->{TicketObject}->ArticleFreeTimeSet" it doesn't seem to find the functions correctly! Do I need to include the reference to ArticleFreeTimeFunctions.pm somewhere else?

2. Is there a way I can easily change each of the Modules? I know ArticleFreeTime like the rest is a 'core function' as such, as is not simply an 'addon'. My end goal will be to install it with a package, then go and paste the extra code in as required. I would prefer to make it as automated as I can!

I've also built an .XML file that holds all the eg.ArticleFreeTimeKey1 values it's init ="Application". Do I need another one for ArticleFreeTimeFunctions.pm? Confused slightly :S
If anyone has any insight that would be awesome! As when I get it all nicely wrapped up I will release it!

- Michael
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: Integrating OTRS modifications nicely

Post by MichaelR »

Ok, so I figured out how to 'activate' the custom module, with this piece of code in my Kernel/Config.pm

$Self->{'ArticleFreeTimeFunctions'} = 'Kernel::System::Ticket::ArticleFreeTimeFunctions';

Is there a way I can do this from within the Kernel/Config/Files/ArticleFreeTime.xml? Or do custom modules like need to be 'activated' from within Config.pm?

I also need to name my functions like this: "sub Kernel::System::Ticket::ArticleFreeTimeSet{}"

Why cannot I just use: "sub ArticleFreeTimeSet{}"?

- Michael
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: Integrating OTRS modifications nicely

Post by MichaelR »

Obviously the above post was too stupid a question to ask about Perl, or no one knows anything about it :lol:

I've managed to integrate it to the best I can, and it works pretty dam good! If anyone would like any more info about it, shoot me a PM or something.

- Michael
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
Daniel Obee
Moderator
Posts: 644
Joined: 19 Jun 2007, 17:11
Znuny Version: various
Real Name: Daniel Obée
Location: Berlin

Re: Integrating OTRS modifications nicely

Post by Daniel Obee »

Hi Michael,

nicely done! Would be cool if you could drop a line if the module is of public interest - or even upload it to opar.perl-services.de, the official community repository.

For other people starting OTRS programming I strongly recommend to once go through the hello world module - seems stupid but it really helps with the mechanism of the system.

One thing that's not in there: every time you change config settings run the rebuildconfig.pl. Thus you make sure the changes really were applied before testing.

Greets
Dan
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: Integrating OTRS modifications nicely

Post by MichaelR »

Thanks tisar!

Only reason I probably won't upload it as it requires manually patching a heap of .pm/.dtl files. I'm not sure how to build packages that can patch an existing file.
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
Daniel Obee
Moderator
Posts: 644
Joined: 19 Jun 2007, 17:11
Znuny Version: various
Real Name: Daniel Obée
Location: Berlin

Re: Integrating OTRS modifications nicely

Post by Daniel Obee »

MichaelR wrote:Thanks tisar!

Only reason I probably won't upload it as it requires manually patching a heap of .pm/.dtl files. I'm not sure how to build packages that can patch an existing file.
If you replace an existing file via package it will automatically be back-uped to a .save file and restored with uninstall. You just have to make sure the file is located in the correct path of your development enviroment.

A known limitation is that once a file is replaced by an installed package it cannot be altered or replaced by another package. What's sure a good way to prevent incompatibilities but should be consindered if very common files are altered.

Greets
Dan
MichaelR
Znuny expert
Posts: 250
Joined: 12 Oct 2010, 01:35
Znuny Version: 3.0.9
Company: LRS Health

Re: Integrating OTRS modifications nicely

Post by MichaelR »

Hmm... well I've had to patch AgentTicketCommon, AgentTicketPhoneNew etc, which are all used by the ITSM package etc. So they will all most likely have .save files.
I guess that's the downside of adding a 'core' feature, it's hard to separate it out. Anywho, when I get around to documenting it all and cleaning up the code I'll post it.
OTRS: 3.0.9 & ITSM 3.0.4 - OS: Windows 7 - DB: MySQL - Heaps of random/useful hacks :)
[Major Code Changes]
ArticleFreeTime1-3
Ability to search ArticleFreeText
Post Reply