This commit is contained in:
2024-10-14 00:08:40 +02:00
parent dbfba56f66
commit 1462d52e13
4572 changed files with 2658864 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
# --
# Copyright (C) 2001-2019 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::System::Queue::Event::TicketAcceleratorUpdate;
use strict;
use warnings;
use Kernel::System::VariableCheck qw(:all);
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Log',
'Kernel::System::Ticket::IndexAccelerator::StaticDB',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# check needed stuff
for my $Needed (qw( Data Event Config UserID )) {
if ( !$Param{$Needed} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $Needed!"
);
return;
}
}
# Only run for StaticDB IndexModule.
my $IndexModule = $Kernel::OM->Get('Kernel::Config')->Get('Ticket::IndexModule');
return 1 if $IndexModule ne 'Kernel::System::Ticket::IndexAccelerator::StaticDB';
# only run if we have the correct data
for my $Needed (qw(Queue OldQueue)) {
if ( !IsHashRefWithData( $Param{Data}->{$Needed} ) ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "$Needed in Data is missing or invalid!"
);
return;
}
}
# only update if Queue has really changed
return 1 if $Param{Data}->{Queue}->{Name} eq $Param{Data}->{OldQueue}->{Name};
# update ticket_index
return $Kernel::OM->Get('Kernel::System::Ticket::IndexAccelerator::StaticDB')->TicketAcceleratorUpdateOnQueueUpdate(
NewQueueName => $Param{Data}->{Queue}->{Name},
OldQueueName => $Param{Data}->{OldQueue}->{Name},
);
}
1;

View File

@@ -0,0 +1,138 @@
# --
# Copyright (C) 2001-2019 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::System::Queue::PreferencesDB;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::Config',
'Kernel::System::Cache',
'Kernel::System::DB',
'Kernel::System::Log',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {};
bless( $Self, $Type );
# preferences table data
$Self->{PreferencesTable} = 'queue_preferences';
$Self->{PreferencesTableKey} = 'preferences_key';
$Self->{PreferencesTableValue} = 'preferences_value';
$Self->{PreferencesTableQueueID} = 'queue_id';
# create cache prefix
$Self->{CachePrefix} = 'QueuePreferencesDB'
. $Self->{PreferencesTable}
. $Self->{PreferencesTableKey}
. $Self->{PreferencesTableValue}
. $Self->{PreferencesTableQueueID};
$Self->{CacheType} = 'Queue';
$Self->{CacheTTL} = 60 * 60 * 24 * 20;
return $Self;
}
sub QueuePreferencesSet {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(QueueID Key Value)) {
if ( !defined $Param{$_} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $_!",
);
return;
}
}
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
# delete old data
return if !$DBObject->Do(
SQL => "DELETE FROM $Self->{PreferencesTable} WHERE "
. "$Self->{PreferencesTableQueueID} = ? AND $Self->{PreferencesTableKey} = ?",
Bind => [ \$Param{QueueID}, \$Param{Key} ],
);
# insert new data
return if !$DBObject->Do(
SQL => "INSERT INTO $Self->{PreferencesTable} ($Self->{PreferencesTableQueueID}, "
. " $Self->{PreferencesTableKey}, $Self->{PreferencesTableValue}) "
. " VALUES (?, ?, ?)",
Bind => [ \$Param{QueueID}, \$Param{Key}, \$Param{Value} ],
);
# delete cache
$Kernel::OM->Get('Kernel::System::Cache')->Delete(
Type => $Self->{CacheType},
Key => $Self->{CachePrefix} . $Param{QueueID},
);
return 1;
}
sub QueuePreferencesGet {
my ( $Self, %Param ) = @_;
# check needed stuff
for (qw(QueueID)) {
if ( !$Param{$_} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need $_!",
);
return;
}
}
# check if queue preferences are available
return if !$Kernel::OM->Get('Kernel::Config')->Get('QueuePreferences');
# read cache
my $Cache = $Kernel::OM->Get('Kernel::System::Cache')->Get(
Type => $Self->{CacheType},
Key => $Self->{CachePrefix} . $Param{QueueID},
);
return %{$Cache} if $Cache;
# get database object
my $DBObject = $Kernel::OM->Get('Kernel::System::DB');
# get preferences
return if !$DBObject->Prepare(
SQL => "SELECT $Self->{PreferencesTableKey}, $Self->{PreferencesTableValue} "
. " FROM $Self->{PreferencesTable} WHERE $Self->{PreferencesTableQueueID} = ?",
Bind => [ \$Param{QueueID} ],
);
my %Data;
while ( my @Row = $DBObject->FetchrowArray() ) {
$Data{ $Row[0] } = $Row[1];
}
# set cache
$Kernel::OM->Get('Kernel::System::Cache')->Set(
Type => $Self->{CacheType},
TTL => $Self->{CacheTTL},
Key => $Self->{CachePrefix} . $Param{QueueID},
Value => \%Data,
);
return %Data;
}
1;