Expansão Interna do Sistema Central OTOBO
Neste artigo, você aprenderá como personalizar o OTOBO diretamente no núcleo – através de configuração XML, módulos Perl e templates. Mostramos passo a passo como integrar um módulo "HelloWorld" próprio ao sistema.
1. Estrutura de Diretórios
Todas as personalizações ficam abaixo do seu clone OTOBO no diretório Kernel/:
Kernel/
├─ Config/Files/ # Registros XML
│ └─ XML/
├─ System/ # Módulos de lógica de negócios (Core)
├─ Modules/ # Controladores Frontend (Agente/Cliente)
├─ Output/HTML/Standard/ # Templates Template Toolkit (TT)
└─ Language/ # Traduções2. Configuração XML
Novos módulos e rotas são registrados via XML. Crie um arquivo HelloWorld.xml em Kernel/Config/Files/XML/:
<?xml version="1.0" encoding="UTF-8"?>
<otobo_config version="2.0" init="Application">
<!-- 1. Registrar módulo Frontend -->
<Setting Name="Frontend::Module###AgentHelloWorld" Required="1" Valid="1">
<Navigation>Frontend::Agent::ModuleRegistration</Navigation>
<Value>
<Item ValueType="FrontendRegistration">
<Hash>
<Item Key="Group"><Array><Item>users</Item></Array></Item>
<Item Key="Description" Translatable="1">Módulo HelloWorld</Item>
<Item Key="Title" Translatable="1">HelloWorld</Item>
<Item Key="NavBarName">HelloWorld</Item>
</Hash>
</Item>
</Value>
</Setting>
</otobo_config>3. Módulo Core (Lógica de Negócios)
Crie sua lógica em Kernel/System/HelloWorld.pm:
package Kernel::System::HelloWorld;
use strict;
use warnings;
our @ObjectDependencies = ();
sub new {
my ($Type, %Param) = @_;
return bless {}, $Type;
}
sub GetHelloWorldText {
my ($Self, %Param) = @_;
return $Self->_FormatText(String => 'Hello World');
}
sub _FormatText {
my ($Self, %Param) = @_;
return uc $Param{String};
}
1;4. Módulo Frontend (Controlador)
Em Kernel/Modules/AgentHelloWorld.pm, integre sua lógica ao frontend do Agente:
package Kernel::Modules::AgentHelloWorld;
use strict;
use warnings;
sub new { bless {}, shift }
sub Run {
my ($Self, %Param) = @_;
my $HelloObj = $Kernel::OM->Get('Kernel::System::HelloWorld');
my $LayoutObj = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
my %Data;
$Data{Text} = $HelloObj->GetHelloWorldText();
return
$LayoutObj->Header(Title => 'HelloWorld')
. $LayoutObj->NavigationBar()
. $LayoutObj->Output(
TemplateFile => 'AgentHelloWorld',
Data => \%Data,
)
. $LayoutObj->Footer();
}
1;5. Templates (TT)
Crie o seguinte template em Kernel/Output/HTML/Standard/AgentHelloWorld.tt:
[% Data.Text %]
<p>Este é o seu módulo HelloWorld criado!</p>6. Fluxo de Trabalho de Exemplo
Recarregar:
bashbin/otobo.Console.pl Maint::Config::RebuildLimpar Cache:
bashbin/otobo.Console.pl Maint::Cache::DeleteAbrir Navegador: Interface do Agente → Menu → "HelloWorld"
7. Dicas e Melhores Práticas
- Declare ObjectDependencies corretamente (por exemplo, DB, Layout).
- Não se esqueça da documentação POD em módulos Perl.
- Mantenha as traduções em
Kernel/Language/de_*.pm. - Configure unit tests com Mojolicious (opcional).
- Após cada alteração, execute rebuild de configuração e limpe o cache.
Com isso, você tem um modelo sólido para realizar outras extensões do núcleo no OTOBO. Feliz desenvolvimento!