是的,票证可以通过 GUI 链接到 configItem,并且可以通过 Web 服务完成。
首先,您应该编写一个新的通用接口连接器操作,它将处理方法LinkAdd from 链接对象班级 (APIdoc https://github.com/OTRS/otrs/blob/1e908159a5dbdcfb94cc35d13bf15b04ac3e6a24/Kernel/System/LinkObject.pm )
然后通过新的 XML 文件创建并注册新操作,如下所示:
文件名:GenericInterfaceLinkObjectConnector.xml
<?xml version="1.0" encoding="utf-8"?>
<otrs_config version="1.0" init="Application">
<ConfigItem Name="GenericInterface::Operation::Module###LinkObject::LinkAdd" Required="0" Valid="1">
<Description Translatable="1">GenericInterface module registration for the operation layer.</Description>
<Group>GenericInterface</Group>
<SubGroup>GenericInterface::Operation::ModuleRegistration</SubGroup>
<Setting>
<Hash>
<Item Key="Name">LinkAdd</Item>
<Item Key="Controller">LinkObject</Item>
<Item Key="ConfigDialog">AdminGenericInterfaceOperationDefault</Item>
</Hash>
</Setting>
</ConfigItem>
</otrs_config>
之后,您可以从 OTRS GUI 发布新的提供程序 WebService,其中使用新创建的连接器。
确保传递该方法所需的所有参数!
$True = $LinkObject->LinkAdd(
SourceObject => 'Ticket',
SourceKey => '321',
TargetObject => 'FAQ',
TargetKey => '5',
Type => 'ParentChild',
State => 'Valid',
UserID => 1,
);
UPDATE:
请阅读这个Document https://otrs.github.io/doc/manual/admin/3.2/en/html/genericinterface.html要了解通用接口是如何构建的,然后请添加一个新的连接器( LinkObject )
要注册连接器及其操作 - 将 XML 文件放入 /Kernel/Config/Files/...
然后转到 Sysconfig -> GenericInterface -> GenericInterface::Operation::ModuleRegistration 并在 GenericInterface::Operation::Module###LinkObject::LinkAdd 旁边设置一个勾号并保存更改
然后将此连接器文件添加到 /Custom/Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm
# --
# Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm - GenericInterface LinkAdd operation backend
# Copyright (C) 2016 ArtyCo (Artjoms Petrovs), http://artjoms.lv/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::GenericInterface::Operation::LinkObject::LinkAdd;
use strict;
use warnings;
use Kernel::GenericInterface::Operation::Common;
use Kernel::System::LinkObject;
use Kernel::System::VariableCheck qw(IsStringWithData IsHashRefWithData);
=head1 NAME
Kernel::GenericInterface::Operation::LinkObject::LinkAdd - GenericInterface Link Create Operation backend
=head1 SYNOPSIS
=head1 PUBLIC INTERFACE
=over 4
=cut
=item new()
usually, you want to create an instance of this
by using Kernel::GenericInterface::Operation->new();
=cut
sub new {
my ( $Type, %Param ) = @_;
my $Self = {};
bless( $Self, $Type );
# check needed objects
for my $Needed (
qw(DebuggerObject ConfigObject MainObject LogObject TimeObject DBObject EncodeObject WebserviceID)
)
{
if ( !$Param{$Needed} ) {
return {
Success => 0,
ErrorMessage => "Got no $Needed!"
};
}
$Self->{$Needed} = $Param{$Needed};
}
# create additional objects
$Self->{CommonObject} = Kernel::GenericInterface::Operation::Common->new( %{$Self} );
$Self->{LinkObject}
= Kernel::System->LinkObject->new( %{$Self} );
return $Self;
}
=item Run()
Create a new link.
my $Result = $OperationObject->Run(
Data => {
SourceObject => 'Ticket',
SourceKey => '321',
TargetObject => 'Ticket',
TargetKey => '12345',
Type => 'ParentChild',
State => 'Valid',
UserID => 1,
},
);
$Result = {
Success => 1, # 0 or 1
ErrorMessage => '', # In case of an error
Data => {
Result => 1, # 0 or 1
},
};
=cut
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !IsHashRefWithData( $Param{Data} ) ) {
return $Self->{CommonObject}->ReturnError(
ErrorCode => 'LinkAdd.MissingParameter',
ErrorMessage => "LinkAdd: The request is empty!",
);
}
my $LinkID = $Self->{LinkObject}->LinkAdd(
%Param,
);
if ( !$LinkID ) {
return $Self->{CommonObject}->ReturnError(
ErrorCode => 'LinkAdd.AuthFail',
ErrorMessage => "LinkAdd: Authorization failing!",
);
}
return {
Success => 1,
Data => {
Result => $LinkID,
},
};
}
1;
=back
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<http://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L<http://www.gnu.org/licenses/agpl.txt>.
=cut
然后它应该出现并可以从管理 -> Web 服务 -> 可用操作下拉列表中使用,当然也可以用作 Web 服务。
PHP 使用示例如下:
#### Initialize new client session ####
$client = new SoapClient(
null,
array(
'location' => $url,
'uri' => "Core",
'trace' => 1,
'login' => $username,
'password' => $password,
'style' => SOAP_RPC,
'use' => SOAP_ENCODED
)
);
#### Create and send the SOAP Function Call ####
$success = $client->__soapCall("Dispatch",
array($username, $password,
"LinkObject", "LinkAdd",
"SourceObject", 'Ticket',
"SourceKey", $ticket_id1,
"TargetObject", 'Ticket',
"TargetKey", $ticket_id2,
"Type", 'ParentChild',
"State", 'Valid',
"UserID", '1'
));
如果出现错误 - 启用调试、查看系统日志并检查 OTRS 的所有初始设置
祝你好运!
更新#2
要注册 Web 服务 - 按添加新 Web 服务按钮,根据需要命名并设置以下设置(选择 LinkAdd 操作)并保存
更新#3
这是 OTRS 5 的更新模块文件
# --
# Kernel/GenericInterface/Operation/LinkObject/LinkAdd.pm - GenericInterface LinkAdd operation backend
# Copyright (C) 2016 ArtyCo (Artjoms Petrovs), http://artjoms.lv/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
package Kernel::GenericInterface::Operation::LinkObject::LinkAdd;
use strict;
use warnings;
use Kernel::GenericInterface::Operation::Common;
use Kernel::System::LinkObject;
use Kernel::System::VariableCheck qw(IsStringWithData IsHashRefWithData);
=head1 NAME
Kernel::GenericInterface::Operation::LinkObject::LinkAdd - GenericInterface Link Create Operation backend
=head1 SYNOPSIS
=head1 PUBLIC INTERFACE
=over 4
=cut
=item new()
usually, you want to create an instance of this
by using Kernel::GenericInterface::Operation->new();
=cut
sub new {
my ( $Type, %Param ) = @_;
my $Self = {};
bless( $Self, $Type );
# check needed objects
for my $Needed (
qw( DebuggerObject WebserviceID )
)
{
if ( !$Param{$Needed} ) {
return {
Success => 0,
ErrorMessage => "Got no $Needed!"
};
}
$Self->{$Needed} = $Param{$Needed};
}
# create additional objects
$Self->{CommonObject} = Kernel::GenericInterface::Operation::Common->new( %{$Self} );
$Self->{LinkObject}
= $Kernel::OM->Get('Kernel::System::LinkObject');
return $Self;
}
=item Run()
Create a new link.
my $Result = $OperationObject->Run(
Data => {
SourceObject => 'Ticket',
SourceKey => '321',
TargetObject => 'Ticket',
TargetKey => '12345',
Type => 'ParentChild',
State => 'Valid',
UserID => 1,
},
);
$Result = {
Success => 1, # 0 or 1
ErrorMessage => '', # In case of an error
Data => {
Result => 1, # 0 or 1
},
};
=cut
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !IsHashRefWithData( $Param{Data} ) ) {
return $Self->{CommonObject}->ReturnError(
ErrorCode => 'LinkAdd.MissingParameter',
ErrorMessage => "LinkAdd: The request is empty!",
);
}
my $LinkID = $Self->{LinkObject}->LinkAdd(
%Param,
);
if ( !$LinkID ) {
return $Self->{CommonObject}->ReturnError(
ErrorCode => 'LinkAdd.AuthFail',
ErrorMessage => "LinkAdd: Authorization failing!",
);
}
return {
Success => 1,
Data => {
Result => $LinkID,
},
};
}
1;
=back
=head1 TERMS AND CONDITIONS
This software is part of the OTRS project (L<http://otrs.org/>).
This software comes with ABSOLUTELY NO WARRANTY. For details, see
the enclosed file COPYING for license information (AGPL). If you
did not receive this file, see L<http://www.gnu.org/licenses/agpl.txt>.
=cut