Skip to content

Instantly share code, notes, and snippets.

@reneeb
Last active July 4, 2018 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reneeb/0ab3f7aa6d0f9e55f9bb32ab25c9d138 to your computer and use it in GitHub Desktop.
Save reneeb/0ab3f7aa6d0f9e55f9bb32ab25c9d138 to your computer and use it in GitHub Desktop.
Sample Hook
# --
# Copyright (C) 2018 Perl-Services.de, http://perl-services.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::TicketOverview::Hooks::Age;
use strict;
use warnings;
our @ObjectDependencies = qw(
Kernel::Config
Kernel::System::Time
);
=head1 NAME
Kernel::System::TicketOverview::Hooks::Age
=head1 PUBLIC INTERFACE
=over 4
=cut
=item new()
create an object
=cut
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
=item Run()
Returns a color when the ticket belongs to the Junk-Queue
my $JunkColor = $JunkObject->Run(
TicketID => 123,
);
=cut
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{Created} && !$Param{CreateTimeUnix} ) {
$Self->{LogObject}->Log(
Priority => 'error',
Message => "Need Created or CreateTimeUnix!",
);
return;
}
my $TimeObject = $Kernel::OM->Get('Kernel::System::Time');
my $Age = $TimeObject->SystemTime() - ( $Param{CreateTimeUnix} || $Param{Created} );
my @Colors = qw( ffff66 ff3300 ); # yellow => older than 7 days, red => older than 10 days
my $Color;
if ( $Age > 7 * 24 * 60 * 60 ) { # older than 7 days
$Color = $Colors[0];
}
if ( $Age > 10 * 24 * 60 * 60 ) { # older than 10 days
$Color = $Colors[1];
}
return $Color;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment