diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2015-01-19 00:50:43 +0100 |
---|---|---|
committer | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2015-01-19 00:50:43 +0100 |
commit | 80e9d9da6ec5a16d222910a97ca5b79d30a1da8f (patch) | |
tree | 8ee8f5378e17bb2bca4fa02729126ef55f205b75 | |
download | DefaultRecipient-80e9d9da6ec5a16d222910a97ca5b79d30a1da8f.tar.gz DefaultRecipient-80e9d9da6ec5a16d222910a97ca5b79d30a1da8f.tar.bz2 DefaultRecipient-80e9d9da6ec5a16d222910a97ca5b79d30a1da8f.zip |
Inital commit
-rw-r--r-- | Kernel/Config/Files/ResponseChangeDefaultTo.xml | 18 | ||||
-rw-r--r-- | Kernel/Output/HTML/ResponseChangeDefaultTo.pm | 75 | ||||
-rw-r--r-- | Kernel/System/ResponseChangeDefaultTo.pm | 25 | ||||
-rw-r--r-- | ResponseChangeDefaultTo.sopm | 54 |
4 files changed, 172 insertions, 0 deletions
diff --git a/Kernel/Config/Files/ResponseChangeDefaultTo.xml b/Kernel/Config/Files/ResponseChangeDefaultTo.xml new file mode 100644 index 0000000..0018b85 --- /dev/null +++ b/Kernel/Config/Files/ResponseChangeDefaultTo.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<otrs_config version="1.0" init="Config"> + <ConfigItem Name="Frontend::Output::FilterElementPre###ResponseChangeDefaultTo" Required="0" Valid="1"> + <Description Translatable="1">Change the default To address, based on the response template.</Description> + <Group>Ticket</Group> + <SubGroup>Frontend::Agent::Ticket::ViewCompose</SubGroup> + <Setting> + <Hash> + <Item Key="Module">Kernel::Output::HTML::ResponseChangeDefaultTo</Item> + <Item Key="Templates"> + <Hash> + <Item Key="AgentTicketCompose">1</Item> + </Hash> + </Item> + </Hash> + </Setting> + </ConfigItem> +</otrs_config> diff --git a/Kernel/Output/HTML/ResponseChangeDefaultTo.pm b/Kernel/Output/HTML/ResponseChangeDefaultTo.pm new file mode 100644 index 0000000..df583fe --- /dev/null +++ b/Kernel/Output/HTML/ResponseChangeDefaultTo.pm @@ -0,0 +1,75 @@ +# -- +# Kernel/Output/HTML/ResponseChangeDefaultTo.pm +# Copyright (C) 2015 Alexander Sulfrian <alex@spline.inf.fu-berlin.de> +# -- + +package Kernel::Output::HTML::ResponseChangeDefaultTo; + +use strict; +use warnings; + +our @ObjectDependencies = qw( + Kernel::Config + Kernel::System::DB + Kernel::System::Encode + Kernel::System::Log + Kernel::System::Main + Kernel::System::ResponseChangeDefaultTo +); + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {}; + $Self->{LayoutObject} = $Param{$_} || die "Got no $_!"; + $Self->{ConfigObject} = $Kernel::OM->Get('Kernel::Config'); + $Self->{DBObject} = $Kernel::OM->Get('Kernel::System::DB'); + $Self->{EncodeObject} = $Kernel::OM->Get('Kernel::System::Encode'); + $Self->{LogObject} = $Kernel::OM->Get('Kernel::System::Log'); + $Self->{MainObject} = $Kernel::OM->Get('Kernel::System::Main'); + $Self->{ResponseChangeDefaultToObject} = + $Kernel::OM->Get('Kernel::System::ResponseChangeDefaultTo'); + bless( $Self, $Type ); + + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + return if !$Self->{LayoutObject}; + + for (qw(DBObject EncodeObject ConfigObject LogObject MainObject + LayoutObject ResponseChangeDefaultToObject)) { + return if !$Self->{$_}; + } + + # check needed stuff + if ( !defined $Param{Data} ) { + $Self->{LogObject}->Log( + Priority => 'error', + Message => 'Need Data!' + ); + $Self->{LayoutObject}->FatalDie(); + } + + my @BlockData = $Self->{LayoutObject}->{BlockData}; + + # get ticket data + my %Ticket = (); + BLOCK: + for my $block ( @BlockData ) { + if ( $block->{Name} eq 'TicketBack' ) { + %Ticket = $block->{Data}; + last BLOCK; + } + } + + # remove preselected "To" address + $Self->{LayoutObject}->{BlockData} = + grep { $_->{Name} ne 'PreFilledToRow' } @BlockData; + + return $Param{Data}; +} + +1; diff --git a/Kernel/System/ResponseChangeDefaultTo.pm b/Kernel/System/ResponseChangeDefaultTo.pm new file mode 100644 index 0000000..7ba02a9 --- /dev/null +++ b/Kernel/System/ResponseChangeDefaultTo.pm @@ -0,0 +1,25 @@ +# -- +# Kernel/System/ResponseChangeDefaultTo.pm - core module +# Copyright (C) 2015 Alexander Sulfrian <alex@spline.inf.fu-berlin.de> +# -- +# 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::System::ResponseChangeDefaultTo; + +use strict; +use warnings; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {}; + bless ($Self, $Type); + + return $Self; +} + +1; diff --git a/ResponseChangeDefaultTo.sopm b/ResponseChangeDefaultTo.sopm new file mode 100644 index 0000000..9fc48dc --- /dev/null +++ b/ResponseChangeDefaultTo.sopm @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8" ?> +<otrs_package version="1.0"> + <Name></Name> + <Version>1.0.0</Version> + <Framework>4.0.x</Framework> + <Vendor>spline.de</Vendor> + <URL>http://www.spline.de/</URL> + <License>GNU AFFERO GENERAL PUBLIC LICENSE Version 3, November 2007</License> + <Description Lang="en"></Description> + <Description Lang="de"></Description> + <BuildDate>?</BuildDate> + <BuildHost>?</BuildHost> + <Filelist> + <File Permission="644" Location="Kernel/Output/HTML/ResponseChangeDefaultTo.pm"/> + <File Permission="644" Location="Kernel/Config/Files/ResponseChangeDefaultTo.xml"/> + <File Permission="644" Location="Kernel/System/ResponseChangeDefaultTo.pm"/> + </Filelist> + <DatabaseInstall> + <TableCreate Name="response_change_default_to"> + <Column Name="id" Required="true" PrimaryKey="true" AutoIncrement="true" Type="BIGINT"/> + <Column Name="title" Required="true" Size="250" Type="VARCHAR"/> + <Column Name="remove_default" Required="true" Type="SMALLINT"/> + <Column Name="add_new" Required="true" Type="SMALLINT"/> + <Column Name="new_address" Required="true" Size="255" Type="VARCHAR"/> + <Index Name="response_change_default_to_title"> + <IndexColumn Name="title"/> + </Index> + <Unique Name="response_change_default_to_title"> + <UniqueColumn Name="title"/> + </Unique> + </TableCreate> + <TableCreate Name="response_change_default_to_response"> + <Column Name="id" Required="true" PrimaryKey="true" AutoIncrement="true" Type="BIGINT"/> + <Column Name="response_change_default_to_id" Required="true" Type="BIGINT"/> + <Column Name="response_id" Required="true" Type="BIGINT"/> + <Index Name="response_change_default_to_response_response_change_default_to_id"> + <IndexColumn Name="response_change_default_to_id"/> + </Index> + <Index Name="response_change_default_to_response_response_id"> + <IndexColumn Name="response_id"/> + </Index> + <ForeignKey ForeignTable="response_change_default_to"> + <Reference Local="response_change_default_to_id" Foreign="id"/> + </ForeignKey> + <ForeignKey ForeignTable="standard_template"> + <Reference Local="response_id" Foreign="id"/> + </ForeignKey> + </TableCreate> + </DatabaseInstall> + <DatabaseUninstall> + <TableDrop Name="response_change_default_to"/> + <TableDrop Name="response_change_default_to_response"/> + </DatabaseUninstall> +</otrs_package> |