1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
# --
# Copyright (C) 2001-2021 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::Output::HTML::Article::Invalid;
use strict;
use warnings;
use parent 'Kernel::Output::HTML::Article::Base';
use Kernel::System::VariableCheck qw(:all);
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::Output::HTML::Layout',
'Kernel::System::CommunicationChannel',
'Kernel::System::HTMLUtils',
'Kernel::System::Log',
'Kernel::System::Ticket::Article',
);
=head2 ArticleFields()
Returns common article fields for an invalid article.
my %ArticleFields = $LayoutObject->ArticleFields(
TicketID => 123, # (required)
ArticleID => 123, # (required)
);
Returns:
%ArticleFields = (
Sender => { # mandatory
Label => 'Sender',
Value => 'PackageName',
Prio => 100,
},
Subject => { # mandatory
Label => 'Subject',
Value => 'Invalid article',
Prio => 200,
},
...
);
=cut
sub ArticleFields {
my ( $Self, %Param ) = @_;
for my $Needed (qw(TicketID ArticleID)) {
if ( !$Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Needed!",
);
return;
}
}
my $ArticleBackendObject = $Kernel::OM->Get('Kernel::System::Ticket::Article')->BackendForArticle(%Param);
my %Article = $ArticleBackendObject->ArticleGet(%Param);
# Get communication channel data.
my %CommunicationChannel = $Kernel::OM->Get('Kernel::System::CommunicationChannel')->ChannelGet(
ChannelID => $Article{CommunicationChannelID},
);
my %Result = (
Sender => {
Label => 'Sender',
Value => '-',
Realname => '-',
Prio => 100,
},
Subject => {
Label => 'Subject',
Value => '-',
Prio => 200,
},
);
return %Result;
}
=head2 ArticlePreview()
Returns article preview for an invalid article.
$LayoutObject->ArticlePreview(
TicketID => 123, # (required)
ArticleID => 123, # (required)
ResultType => 'plain', # (optional) plain|HTML. Default HTML.
MaxLength => 50, # (optional) performs trimming (for plain result only)
);
Returns article preview in scalar form:
$ArticlePreview = 'Preview of this article is not possible because...';
=cut
sub ArticlePreview {
my ( $Self, %Param ) = @_;
for my $Needed (qw(TicketID ArticleID)) {
if ( !$Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Needed!",
);
return;
}
}
if ( $Param{MaxLength} && !IsPositiveInteger( $Param{MaxLength} ) ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => 'MaxLength must be positive integer!',
);
return;
}
my $ArticleBackendObject = $Kernel::OM->Get('Kernel::System::Ticket::Article')->BackendForArticle(%Param);
my %Article = $ArticleBackendObject->ArticleGet(%Param);
# Get communication channel data.
my %CommunicationChannel = $Kernel::OM->Get('Kernel::System::CommunicationChannel')->ChannelGet(
ChannelID => $Article{CommunicationChannelID},
);
my $Result = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->Output(
TemplateFile => 'ArticleContent/Invalid',
Data => \%CommunicationChannel,
);
if ( $Param{ResultType} && $Param{ResultType} eq 'plain' ) {
$Result = $Kernel::OM->Get('Kernel::System::HTMLUtils')->ToAscii(
String => $Result,
);
$Result =~ s{\n\s*\n}{\n}g; # Remove extra new lines.
$Result =~ s/[^\S\n]+/ /g; # Remove extra spaces.
# Trim to length.
if ( $Param{MaxLength} ) {
$Result = substr( $Result, 0, $Param{MaxLength} );
}
}
return $Result;
}
=head2 ArticleCustomerRecipientsGet()
Dummy function. Invalid channel always returns no recipients.
=cut
sub ArticleCustomerRecipientsGet {
my ( $Self, %Param ) = @_;
for my $Needed (qw(TicketID ArticleID)) {
if ( !$Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Needed!",
);
return;
}
}
return;
}
1;
|