diff --git a/Kernel/Config/Files/Insta.xml b/Kernel/Config/Files/Insta.xml new file mode 100644 index 0000000..82f9b4b --- /dev/null +++ b/Kernel/Config/Files/Insta.xml @@ -0,0 +1,77 @@ + + + + InstaClose link in Menu. + InstaClose link in Menu. + Ticket + Frontend::Agent::Ticket::MenuModule + + + Kernel::Output::HTML::TicketMenuGeneric + InstaClose + AgentTicketInsta + Close directly! + Action=AgentTicketInsta&TicketID=$Data{"TicketID"}&Subaction=Close + + + + + InstaSpam link in Menu. + InstaSpam link in Menu. + Ticket + Frontend::Agent::Ticket::MenuModule + + + Kernel::Output::HTML::TicketMenuGeneric + InstaSpam + AgentTicketInsta + Move to Junk directly! + Action=AgentTicketInsta&TicketID=$Data{"TicketID"}&Subaction=Junk + + + + + + InstaClose link in Menu. + InstaClose link in Menu. + Ticket + Frontend::Agent::Ticket::MenuModulePre + + + Kernel::Output::HTML::TicketMenuGeneric + InstaClose + AgentTicketInsta + Close directly! + Action=AgentTicketInsta&TicketID=$Data{"TicketID"}&Subaction=Close + + + + + InstaSpam link in Menu. + InstaSpam link in Menu. + Ticket + Frontend::Agent::Ticket::MenuModulePre + + + Kernel::Output::HTML::TicketMenuGeneric + InstaSpam + AgentTicketInsta + Move to Junk directly! + Action=AgentTicketInsta&TicketID=$Data{"TicketID"}&Subaction=Junk + + + + + + A ticket lock is required. In case the ticket isn't locked, the tickets get locked and the current agent will be set automatically as ticket owner. + Eine Ticket-Sperre wird benötigt bzw. wenn Ticket nicht gesperrt ist, wird das Ticket automatisch gesperrt und der Agent als Besitzer gesetzt. + Ticket + Frontend::Agent::Ticket::ViewInsta + + + + + diff --git a/Kernel/Modules/AgentTicketInsta.pm b/Kernel/Modules/AgentTicketInsta.pm new file mode 100644 index 0000000..a364864 --- /dev/null +++ b/Kernel/Modules/AgentTicketInsta.pm @@ -0,0 +1,151 @@ +# -- +# Kernel/Modules/AgentTicketInsta.pm - instant ticket actions +# -- + +package Kernel::Modules::AgentTicketInsta; + +use strict; +use warnings; + +use Kernel::System::State; + +use vars qw($VERSION); +$VERSION = qw($Revision: 0.00.0.1 $) [1]; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + # check all needed objects + for (qw(ParamObject DBObject TicketObject QueueObject LayoutObject ConfigObject LogObject)) { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + + $Self->{StateObject} = Kernel::System::State->new(%Param); + + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + + my %GetParam; + + # check needed stuff + if ( !$Self->{TicketID} ) { + return $Self->{LayoutObject}->ErrorScreen( + Message => 'No TicketID is given!', + Comment => 'Please contact the admin.', + ); + } + + # check permissions + my $Access = $Self->{TicketObject}->Permission( + Type => [ 'move', 'lock' ], + TicketID => $Self->{TicketID}, + UserID => $Self->{UserID} + ); + + # error screen, don't show ticket + if ( !$Access ) { + return $Self->{LayoutObject}->NoPermission( + Message => "You need $Self->{Config}->{Permission} permissions!", + WithHeader => 'yes', + ); + } + my %Ticket = $Self->{TicketObject}->TicketGet( TicketID => $Self->{TicketID} ); + + # get lock state + if ( !$Self->{TicketObject}->LockIsTicketLocked( TicketID => $Self->{TicketID} ) ) { + $Self->{TicketObject}->LockSet( + TicketID => $Self->{TicketID}, + Lock => 'lock', + UserID => $Self->{UserID} + ); + my $Success = $Self->{TicketObject}->OwnerSet( + TicketID => $Self->{TicketID}, + UserID => $Self->{UserID}, + NewUserID => $Self->{UserID}, + ); + } + else { + my $AccessOk = $Self->{TicketObject}->OwnerCheck( + TicketID => $Self->{TicketID}, + OwnerID => $Self->{UserID}, + ); + if ( !$AccessOk ) { + my $Output = $Self->{LayoutObject}->Header( Value => $Ticket{Number} ); + $Output .= $Self->{LayoutObject}->Warning( + Message => "Sorry, you need to be the owner to do this action!", + Comment => 'Please change the owner first.', + ); + $Output .= $Self->{LayoutObject}->Footer(); + return $Output; + } + + # show back link + $Self->{LayoutObject}->Block( + Name => 'TicketBack', + Data => { %Param, TicketID => $Self->{TicketID} }, + ); + } + + if ( $Self->{Subaction} eq 'Junk' ) { + # move ticket to junk queue + $GetParam{DestQueue} = $Self->{Subaction}; # Junk queue + + # DestQueueID lookup + $GetParam{DestQueueID} = $Self->{QueueObject}->QueueLookup( Queue => $GetParam{DestQueue} ); + + if ( !$GetParam{DestQueueID} ) { + return $Self->{LayoutObject}->ErrorScreen( + Message => 'No valid DestQueue is given!', + Comment => 'Please contact the admin.', + ); + } + + my $Move = $Self->{TicketObject}->MoveTicket( + QueueID => $GetParam{DestQueueID}, + UserID => $Self->{UserID}, + TicketID => $Self->{TicketID}, + ); + + if ( !$Move ) { + return $Self->{LayoutObject}->ErrorScreen(); + } + } + + # close and unlock ticket + if ( $Self->{Subaction} eq 'Close' || $Self->{Subaction} eq 'Junk' ) { + $GetParam{NewStateID} = 2; # closed successfull + + # set state + $Self->{TicketObject}->StateSet( + TicketID => $Self->{TicketID}, + StateID => $GetParam{NewStateID}, + UserID => $Self->{UserID}, + ); + + # unlock the ticket after close + $Self->{TicketObject}->LockSet( + TicketID => $Self->{TicketID}, + Lock => 'unlock', + UserID => $Self->{UserID}, + ); + + # redirect to last screen overview on closed tickets + return $Self->{LayoutObject}->Redirect( OP => $Self->{LastScreenView} ); + } + + return $Self->{LayoutObject}->ErrorScreen( + Message => 'A subaction was missing!', + Comment => 'The requested URL was probably wrong.', + ); +} + +1;