init III
This commit is contained in:
148
Perl OTRS/Kernel/Output/HTML/ToolBar/ChangeManager.pm
Normal file
148
Perl OTRS/Kernel/Output/HTML/ToolBar/ChangeManager.pm
Normal file
@@ -0,0 +1,148 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::ChangeManager;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Cache',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::ITSMChange',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# get UserID param
|
||||
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# define action, group, label, image and prio
|
||||
my $Action = 'AgentITSMChangeManager';
|
||||
my $Group = 'itsm-change-manager';
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# do not show icon if frontend module is not registered
|
||||
return if !$ConfigObject->Get('Frontend::Module')->{$Action};
|
||||
|
||||
# get config of frontend module
|
||||
my $Config = $ConfigObject->Get("ITSMChange::Frontend::$Action");
|
||||
|
||||
# get group object
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
|
||||
# get the group id
|
||||
my $GroupID = $GroupObject->GroupLookup( Group => $Group );
|
||||
|
||||
# deny access, when the group is not found
|
||||
return if !$GroupID;
|
||||
|
||||
# get user groups, where the user has the appropriate privilege
|
||||
my %Groups = $GroupObject->GroupMemberList(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Config->{Permission},
|
||||
Result => 'HASH',
|
||||
);
|
||||
|
||||
# deny access if the agent doesn't have the appropriate type in the appropriate group
|
||||
return if !$Groups{$GroupID};
|
||||
|
||||
# get the number of viewable changes
|
||||
my $Count = 0;
|
||||
if ( $Config->{'Filter::ChangeStates'} && @{ $Config->{'Filter::ChangeStates'} } ) {
|
||||
|
||||
# remove empty change states
|
||||
my @ChangeStates;
|
||||
CHANGESTATE:
|
||||
for my $ChangeState ( @{ $Config->{'Filter::ChangeStates'} } ) {
|
||||
next CHANGESTATE if !$ChangeState;
|
||||
push @ChangeStates, $ChangeState;
|
||||
}
|
||||
|
||||
# get the cache type and TTL (in seconds)
|
||||
$Self->{CacheType} = 'ITSMChangeManagementToolBarChangeManager' . $Self->{UserID};
|
||||
$Self->{CacheTTL} = $ConfigObject->Get('ITSMChange::ToolBar::CacheTTL') * 60;
|
||||
|
||||
# get cache object
|
||||
my $CacheObject = $Kernel::OM->Get('Kernel::System::Cache');
|
||||
|
||||
# check cache
|
||||
my $CacheKey = join ',', sort ChangeStates;
|
||||
my $Cache = $CacheObject->Get(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
);
|
||||
|
||||
if ( defined $Cache ) {
|
||||
$Count = $Cache;
|
||||
}
|
||||
else {
|
||||
|
||||
# count the number of viewable changes
|
||||
$Count = $Kernel::OM->Get('Kernel::System::ITSMChange')->ChangeSearch(
|
||||
ChangeManagerIDs => [ $Self->{UserID} ],
|
||||
ChangeStates => \@ChangeStates,
|
||||
Limit => 1000,
|
||||
Result => 'COUNT',
|
||||
MirrorDB => 1,
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
# set cache
|
||||
$CacheObject->Set(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
Value => $Count,
|
||||
TTL => $Self->{CacheTTL},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# get ToolBar object parameters
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $Text = $LayoutObject->{LanguageObject}->Translate('Change Manager');
|
||||
|
||||
# set ToolBar object
|
||||
my $URL = $LayoutObject->{Baselink};
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
my %Return;
|
||||
if ($Count) {
|
||||
$Return{$Priority} = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => $Text,
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=' . $Action,
|
||||
AccessKey => '',
|
||||
};
|
||||
}
|
||||
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
41
Perl OTRS/Kernel/Output/HTML/ToolBar/Generic.pm
Normal file
41
Perl OTRS/Kernel/Output/HTML/ToolBar/Generic.pm
Normal file
@@ -0,0 +1,41 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::Generic;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Priority = $Param{Config}->{'Priority'};
|
||||
my %Return = ();
|
||||
|
||||
# check if there is extended data available
|
||||
my %Data;
|
||||
if ( $Param{Config}->{Data} && %{ $Param{Config}->{Data} } ) {
|
||||
%Data = %{ $Param{Config}->{Data} };
|
||||
}
|
||||
|
||||
$Return{ $Priority++ } = {
|
||||
Block => $Param{Config}->{Block},
|
||||
Description => $Param{Config}->{Description},
|
||||
Name => $Param{Config}->{Name},
|
||||
Size => $Param{Config}->{Size},
|
||||
Fulltext => '',
|
||||
Image => '',
|
||||
AccessKey => '',
|
||||
%Data,
|
||||
};
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
161
Perl OTRS/Kernel/Output/HTML/ToolBar/IncompleteWorkingDays.pm
Normal file
161
Perl OTRS/Kernel/Output/HTML/ToolBar/IncompleteWorkingDays.pm
Normal file
@@ -0,0 +1,161 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::IncompleteWorkingDays;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::TimeAccounting',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# Define action and get its frontend module registration.
|
||||
my $Action = 'AgentTimeAccountingEdit';
|
||||
my $Config = $Kernel::OM->Get('Kernel::Config')->Get('Frontend::Module')->{$Action};
|
||||
|
||||
# Do not show icon if frontend module is not registered.
|
||||
return if !$Config;
|
||||
|
||||
# Get group names from config.
|
||||
my @GroupNames = @{ $Config->{Group} || [] };
|
||||
|
||||
# If access is restricted, allow access only if user has appropriate permissions in configured group(s).
|
||||
if (@GroupNames) {
|
||||
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
|
||||
# Get user groups, where the user has the appropriate permissions.
|
||||
my %GroupList = $GroupObject->GroupMemberList(
|
||||
UserID => $Self->{UserID},
|
||||
Type => 'rw',
|
||||
Result => 'HASH',
|
||||
);
|
||||
|
||||
my $Permission = 0;
|
||||
|
||||
GROUP:
|
||||
for my $GroupName (@GroupNames) {
|
||||
next GROUP if !$GroupName;
|
||||
|
||||
# Get the group ID.
|
||||
my $GroupID = $GroupObject->GroupLookup(
|
||||
Group => $GroupName,
|
||||
);
|
||||
next GROUP if !$GroupID;
|
||||
|
||||
# Stop checking if membership in at least one group is found.
|
||||
if ( $GroupList{$GroupID} ) {
|
||||
$Permission = 1;
|
||||
last GROUP;
|
||||
}
|
||||
}
|
||||
|
||||
# Deny access if the agent doesn't have the appropriate permissions.
|
||||
return if !$Permission;
|
||||
}
|
||||
|
||||
my $DateTimeObject = $Kernel::OM->Create('Kernel::System::DateTime');
|
||||
my $DateTimeSettings = $DateTimeObject->Get();
|
||||
|
||||
my $TimeAccountingObject = $Kernel::OM->Get('Kernel::System::TimeAccounting');
|
||||
|
||||
my %UserCurrentPeriod = $TimeAccountingObject->UserCurrentPeriodGet(
|
||||
Year => $DateTimeSettings->{Year},
|
||||
Month => $DateTimeSettings->{Month},
|
||||
Day => $DateTimeSettings->{Day},
|
||||
);
|
||||
|
||||
# Deny access, if user has no valid period.
|
||||
return if !$UserCurrentPeriod{ $Self->{UserID} };
|
||||
|
||||
# Get the number of incomplete working days.
|
||||
my $Count = 0;
|
||||
my %IncompleteWorkingDays = $TimeAccountingObject->WorkingUnitsCompletnessCheck(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
YEARID:
|
||||
for my $YearID ( sort keys %{ $IncompleteWorkingDays{Incomplete} } ) {
|
||||
|
||||
next YEARID if !$YearID;
|
||||
next YEARID if !$IncompleteWorkingDays{Incomplete}{$YearID};
|
||||
next YEARID if ref $IncompleteWorkingDays{Incomplete}{$YearID} ne 'HASH';
|
||||
|
||||
# Extract year.
|
||||
my %Year = %{ $IncompleteWorkingDays{Incomplete}{$YearID} };
|
||||
|
||||
MONTH:
|
||||
for my $MonthID ( sort keys %Year ) {
|
||||
|
||||
next MONTH if !$MonthID;
|
||||
next MONTH if !$Year{$MonthID};
|
||||
next MONTH if ref $Year{$MonthID} ne 'HASH';
|
||||
|
||||
# extract month
|
||||
my %Month = %{ $Year{$MonthID} };
|
||||
|
||||
$Count += scalar keys %Month;
|
||||
|
||||
# Remove current day because it makes no sense to show the current day as incomplete.
|
||||
if (
|
||||
$DateTimeSettings->{Year} eq $YearID
|
||||
&& $MonthID eq sprintf( '%02d', $DateTimeSettings->{Month} )
|
||||
&& defined $Month{ sprintf( '%02d', $DateTimeSettings->{Day} ) }
|
||||
)
|
||||
{
|
||||
$Count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# Get toolbar object parameters.
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $Text = Translatable('Incomplete working days');
|
||||
my $URL = $LayoutObject->{Baselink};
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
|
||||
return () if !$Count;
|
||||
|
||||
my %Return = (
|
||||
1000810 => {
|
||||
Block => 'ToolBarItem',
|
||||
Description => $Text,
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=' . $Action,
|
||||
AccessKey => '',
|
||||
},
|
||||
);
|
||||
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
65
Perl OTRS/Kernel/Output/HTML/ToolBar/Link.pm
Normal file
65
Perl OTRS/Kernel/Output/HTML/ToolBar/Link.pm
Normal file
@@ -0,0 +1,65 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::Link;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
for (qw(Config)) {
|
||||
if ( !$Param{$_} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => "Need $_!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# check if frontend module is used
|
||||
my $Action = $Param{Config}->{Action};
|
||||
if ($Action) {
|
||||
return if !$Kernel::OM->Get('Kernel::Config')->Get('Frontend::Module')->{$Action};
|
||||
}
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# get item definition
|
||||
my $Text = $LayoutObject->{LanguageObject}->Translate( $Param{Config}->{Name} );
|
||||
my $URL = $LayoutObject->{Baselink} . $Param{Config}->{Link};
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
my $AccessKey = $Param{Config}->{AccessKey};
|
||||
my $CssClass = $Param{Config}->{CssClass};
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
|
||||
my %Return;
|
||||
$Return{$Priority} = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => $Text,
|
||||
Class => $CssClass,
|
||||
Icon => $Icon,
|
||||
Link => $URL,
|
||||
AccessKey => $AccessKey,
|
||||
};
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
148
Perl OTRS/Kernel/Output/HTML/ToolBar/MyCAB.pm
Normal file
148
Perl OTRS/Kernel/Output/HTML/ToolBar/MyCAB.pm
Normal file
@@ -0,0 +1,148 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::MyCAB;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Cache',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::ITSMChange',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# get UserID param
|
||||
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# define action, group, label, image and prio
|
||||
my $Action = 'AgentITSMChangeMyCAB';
|
||||
my $Group = 'itsm-change';
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# do not show icon if frontend module is not registered
|
||||
return if !$ConfigObject->Get('Frontend::Module')->{$Action};
|
||||
|
||||
# get config of frontend module
|
||||
my $Config = $ConfigObject->Get("ITSMChange::Frontend::$Action");
|
||||
|
||||
# get group object
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
|
||||
# get the group id
|
||||
my $GroupID = $GroupObject->GroupLookup( Group => $Group );
|
||||
|
||||
# deny access, when the group is not found
|
||||
return if !$GroupID;
|
||||
|
||||
# get user groups, where the user has the appropriate privilege
|
||||
my %Groups = $GroupObject->GroupMemberList(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Config->{Permission},
|
||||
Result => 'HASH',
|
||||
);
|
||||
|
||||
# deny access if the agent doesn't have the appropriate type in the appropriate group
|
||||
return if !$Groups{$GroupID};
|
||||
|
||||
# get the number of viewable changes
|
||||
my $Count = 0;
|
||||
if ( $Config->{'Filter::ChangeStates'} && @{ $Config->{'Filter::ChangeStates'} } ) {
|
||||
|
||||
# remove empty change states
|
||||
my @ChangeStates;
|
||||
CHANGESTATE:
|
||||
for my $ChangeState ( @{ $Config->{'Filter::ChangeStates'} } ) {
|
||||
next CHANGESTATE if !$ChangeState;
|
||||
push @ChangeStates, $ChangeState;
|
||||
}
|
||||
|
||||
# get the cache type and TTL (in seconds)
|
||||
$Self->{CacheType} = 'ITSMChangeManagementToolBarMyCAB' . $Self->{UserID};
|
||||
$Self->{CacheTTL} = $ConfigObject->Get('ITSMChange::ToolBar::CacheTTL') * 60;
|
||||
|
||||
# get cache object
|
||||
my $CacheObject = $Kernel::OM->Get('Kernel::System::Cache');
|
||||
|
||||
# check cache
|
||||
my $CacheKey = join ',', sort @ChangeStates;
|
||||
my $Cache = $CacheObject->Get(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
);
|
||||
|
||||
if ( defined $Cache ) {
|
||||
$Count = $Cache;
|
||||
}
|
||||
else {
|
||||
|
||||
# count the number of viewable changes
|
||||
$Count = $Kernel::OM->Get('Kernel::System::ITSMChange')->ChangeSearch(
|
||||
CABAgents => [ $Self->{UserID} ],
|
||||
ChangeStates => \@ChangeStates,
|
||||
Limit => 1000,
|
||||
Result => 'COUNT',
|
||||
MirrorDB => 1,
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
# set cache
|
||||
$CacheObject->Set(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
Value => $Count || 0,
|
||||
TTL => $Self->{CacheTTL},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# get ToolBar object parameters
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $Text = $LayoutObject->{LanguageObject}->Translate('My CABs');
|
||||
|
||||
# set ToolBar object
|
||||
my $URL = $LayoutObject->{Baselink};
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
my %Return;
|
||||
if ($Count) {
|
||||
$Return{$Priority} = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => $Text,
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=' . $Action,
|
||||
AccessKey => '',
|
||||
};
|
||||
}
|
||||
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
148
Perl OTRS/Kernel/Output/HTML/ToolBar/MyChanges.pm
Normal file
148
Perl OTRS/Kernel/Output/HTML/ToolBar/MyChanges.pm
Normal file
@@ -0,0 +1,148 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::MyChanges;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Cache',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::ITSMChange',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# get UserID param
|
||||
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# define action, group, label, image and prio
|
||||
my $Action = 'AgentITSMChangeMyChanges';
|
||||
my $Group = 'itsm-change-builder';
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# do not show icon if frontend module is not registered
|
||||
return if !$ConfigObject->Get('Frontend::Module')->{$Action};
|
||||
|
||||
# get config of frontend module
|
||||
my $Config = $ConfigObject->Get("ITSMChange::Frontend::$Action");
|
||||
|
||||
# get group object
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
|
||||
# get the group id
|
||||
my $GroupID = $GroupObject->GroupLookup( Group => $Group );
|
||||
|
||||
# deny access, when the group is not found
|
||||
return if !$GroupID;
|
||||
|
||||
# get user groups, where the user has the appropriate privilege
|
||||
my %Groups = $GroupObject->GroupMemberList(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Config->{Permission},
|
||||
Result => 'HASH',
|
||||
);
|
||||
|
||||
# deny access if the agent doesn't have the appropriate type in the appropriate group
|
||||
return if !$Groups{$GroupID};
|
||||
|
||||
# get the number of viewable changes
|
||||
my $Count = 0;
|
||||
if ( $Config->{'Filter::ChangeStates'} && @{ $Config->{'Filter::ChangeStates'} } ) {
|
||||
|
||||
# remove empty change states
|
||||
my @ChangeStates;
|
||||
CHANGESTATE:
|
||||
for my $ChangeState ( @{ $Config->{'Filter::ChangeStates'} } ) {
|
||||
next CHANGESTATE if !$ChangeState;
|
||||
push @ChangeStates, $ChangeState;
|
||||
}
|
||||
|
||||
# get the cache type and TTL (in seconds)
|
||||
$Self->{CacheType} = 'ITSMChangeManagementToolBarMyChanges' . $Self->{UserID};
|
||||
$Self->{CacheTTL} = $ConfigObject->Get('ITSMChange::ToolBar::CacheTTL') * 60;
|
||||
|
||||
# get cache object
|
||||
my $CacheObject = $Kernel::OM->Get('Kernel::System::Cache');
|
||||
|
||||
# check cache
|
||||
my $CacheKey = join ',', sort @ChangeStates;
|
||||
my $Cache = $CacheObject->Get(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
);
|
||||
|
||||
if ( defined $Cache ) {
|
||||
$Count = $Cache;
|
||||
}
|
||||
else {
|
||||
|
||||
# count the number of viewable changes
|
||||
$Count = $Kernel::OM->Get('Kernel::System::ITSMChange')->ChangeSearch(
|
||||
ChangeBuilderIDs => [ $Self->{UserID} ],
|
||||
ChangeStates => \@ChangeStates,
|
||||
Limit => 1000,
|
||||
Result => 'COUNT',
|
||||
MirrorDB => 1,
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
# set cache
|
||||
$CacheObject->Set(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
Value => $Count,
|
||||
TTL => $Self->{CacheTTL},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# get ToolBar object parameters
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $Text = $LayoutObject->{LanguageObject}->Translate('My Changes');
|
||||
|
||||
# set ToolBar object
|
||||
my $URL = $LayoutObject->{Baselink};
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
my %Return;
|
||||
if ($Count) {
|
||||
$Return{$Priority} = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => $Text,
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=' . $Action,
|
||||
AccessKey => '',
|
||||
};
|
||||
}
|
||||
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
146
Perl OTRS/Kernel/Output/HTML/ToolBar/MyWorkOrders.pm
Normal file
146
Perl OTRS/Kernel/Output/HTML/ToolBar/MyWorkOrders.pm
Normal file
@@ -0,0 +1,146 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::MyWorkOrders;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Cache',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::ITSMChange::ITSMWorkOrder',
|
||||
);
|
||||
|
||||
sub new {
|
||||
my ( $Type, %Param ) = @_;
|
||||
|
||||
# allocate new hash for object
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
# get UserID param
|
||||
$Self->{UserID} = $Param{UserID} || die "Got no UserID!";
|
||||
|
||||
return $Self;
|
||||
}
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# define action
|
||||
my $Action = 'AgentITSMChangeMyWorkOrders';
|
||||
my $Group = 'itsm-change';
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# do not show icon if frontend module is not registered
|
||||
return if !$ConfigObject->Get('Frontend::Module')->{$Action};
|
||||
|
||||
# get config of frontend module
|
||||
my $Config = $ConfigObject->Get("ITSMChange::Frontend::$Action");
|
||||
|
||||
# get group object
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
|
||||
# get the group id
|
||||
my $GroupID = $GroupObject->GroupLookup( Group => $Group );
|
||||
|
||||
# deny access, when the group is not found
|
||||
return if !$GroupID;
|
||||
|
||||
# get user groups, where the user has the appropriate privilege
|
||||
my %Groups = $GroupObject->GroupMemberList(
|
||||
UserID => $Self->{UserID},
|
||||
Type => $Config->{Permission},
|
||||
Result => 'HASH',
|
||||
);
|
||||
|
||||
# deny access if the agent doesn't have the appropriate type in the appropriate group
|
||||
return if !$Groups{$GroupID};
|
||||
|
||||
# get the number of viewable changes
|
||||
my $Count = 0;
|
||||
if ( $Config->{'Filter::WorkOrderStates'} && @{ $Config->{'Filter::WorkOrderStates'} } ) {
|
||||
|
||||
# remove empty workorder states
|
||||
my @WorkOrderStates;
|
||||
WORKORDERSTATE:
|
||||
for my $WorkOrderState ( @{ $Config->{'Filter::WorkOrderStates'} } ) {
|
||||
next WORKORDERSTATE if !$WorkOrderState;
|
||||
push @WorkOrderStates, $WorkOrderState;
|
||||
}
|
||||
|
||||
# get the cache type and TTL (in seconds)
|
||||
$Self->{CacheType} = 'ITSMChangeManagementToolBarMyWorkOrders' . $Self->{UserID};
|
||||
$Self->{CacheTTL} = $ConfigObject->Get('ITSMChange::ToolBar::CacheTTL') * 60;
|
||||
|
||||
# check cache
|
||||
my $CacheKey = join ',', sort @WorkOrderStates;
|
||||
|
||||
my $Cache = $Kernel::OM->Get('Kernel::System::Cache')->Get(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
);
|
||||
|
||||
if ( defined $Cache ) {
|
||||
$Count = $Cache;
|
||||
}
|
||||
else {
|
||||
|
||||
# count the number of viewable workorders
|
||||
$Count = $Kernel::OM->Get('Kernel::System::ITSMChange::ITSMWorkOrder')->WorkOrderSearch(
|
||||
WorkOrderAgentIDs => [ $Self->{UserID} ],
|
||||
WorkOrderStates => \@WorkOrderStates,
|
||||
Limit => 1000,
|
||||
Result => 'COUNT',
|
||||
MirrorDB => 1,
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
# set cache
|
||||
$Kernel::OM->Get('Kernel::System::Cache')->Set(
|
||||
Type => $Self->{CacheType},
|
||||
Key => $CacheKey,
|
||||
Value => $Count,
|
||||
TTL => $Self->{CacheTTL},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# get ToolBar object parameters
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $Text = $LayoutObject->{LanguageObject}->Translate('My Work Orders');
|
||||
|
||||
# set ToolBar object
|
||||
my $URL = $LayoutObject->{Baselink};
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
my %Return;
|
||||
if ($Count) {
|
||||
$Return{$Priority} = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => $Text,
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=' . $Action,
|
||||
AccessKey => '',
|
||||
};
|
||||
}
|
||||
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
121
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketLocked.pm
Normal file
121
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketLocked.pm
Normal file
@@ -0,0 +1,121 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::TicketLocked;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Ticket',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# check needed stuff
|
||||
for (qw(Config)) {
|
||||
if ( !$Param{$_} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => "Need $_!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return if !$Kernel::OM->Get('Kernel::Config')->Get('Frontend::Module')->{AgentTicketLockedView};
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
# get user lock data
|
||||
my $Count = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
Locks => [ 'lock', 'tmp_lock' ],
|
||||
OwnerIDs => [ $Self->{UserID} ],
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
my $CountNew = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
Locks => [ 'lock', 'tmp_lock' ],
|
||||
OwnerIDs => [ $Self->{UserID} ],
|
||||
TicketFlag => {
|
||||
Seen => 1,
|
||||
},
|
||||
TicketFlagUserID => $Self->{UserID},
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
$CountNew = $Count - $CountNew;
|
||||
my $CountReached = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
Locks => [ 'lock', 'tmp_lock' ],
|
||||
StateType => ['pending reminder'],
|
||||
TicketPendingTimeOlderMinutes => 1,
|
||||
OwnerIDs => [ $Self->{UserID} ],
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $ClassNew = $Param{Config}->{CssClassNew};
|
||||
my $ClassReached = $Param{Config}->{CssClassReached};
|
||||
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
my $IconNew = $Param{Config}->{IconNew};
|
||||
my $IconReached = $Param{Config}->{IconReached};
|
||||
|
||||
my $URL = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{Baselink};
|
||||
my %Return;
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
if ($CountNew) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Count => $CountNew,
|
||||
Description => Translatable('Locked Tickets New'),
|
||||
Class => $ClassNew,
|
||||
Icon => $IconNew,
|
||||
Link => $URL . 'Action=AgentTicketLockedView;Filter=New',
|
||||
AccessKey => $Param{Config}->{AccessKeyNew} || '',
|
||||
};
|
||||
}
|
||||
if ($CountReached) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Count => $CountReached,
|
||||
Description => Translatable('Locked Tickets Reminder Reached'),
|
||||
Class => $ClassReached,
|
||||
Icon => $IconReached,
|
||||
Link => $URL . 'Action=AgentTicketLockedView;Filter=ReminderReached',
|
||||
AccessKey => $Param{Config}->{AccessKeyReached} || '',
|
||||
};
|
||||
}
|
||||
if ($Count) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Count => $Count,
|
||||
Description => Translatable('Locked Tickets Total'),
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=AgentTicketLockedView',
|
||||
AccessKey => $Param{Config}->{AccessKey} || '',
|
||||
};
|
||||
}
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
125
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketResponsible.pm
Normal file
125
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketResponsible.pm
Normal file
@@ -0,0 +1,125 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::TicketResponsible;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Ticket',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# check responsible feature
|
||||
return if !$ConfigObject->Get('Ticket::Responsible');
|
||||
|
||||
# check needed stuff
|
||||
for (qw(Config)) {
|
||||
if ( !$Param{$_} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => "Need $_!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return if !$ConfigObject->Get('Frontend::Module')->{AgentTicketResponsibleView};
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
my $Count = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
StateType => 'Open',
|
||||
ResponsibleIDs => [ $Self->{UserID} ],
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
my $CountNew = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
StateType => 'Open',
|
||||
ResponsibleIDs => [ $Self->{UserID} ],
|
||||
TicketFlag => {
|
||||
Seen => 1,
|
||||
},
|
||||
TicketFlagUserID => $Self->{UserID},
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
$CountNew = $Count - $CountNew;
|
||||
|
||||
my $CountReached = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
StateType => ['pending reminder'],
|
||||
ResponsibleIDs => [ $Self->{UserID} ],
|
||||
TicketPendingTimeOlderMinutes => 1,
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $ClassNew = $Param{Config}->{CssClassNew};
|
||||
my $ClassReached = $Param{Config}->{CssClassReached};
|
||||
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
my $IconNew = $Param{Config}->{IconNew};
|
||||
my $IconReached = $Param{Config}->{IconReached};
|
||||
|
||||
my $URL = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{Baselink};
|
||||
my %Return;
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
if ($CountNew) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => Translatable('Responsible Tickets New'),
|
||||
Count => $CountNew,
|
||||
Class => $ClassNew,
|
||||
Icon => $IconNew,
|
||||
Link => $URL . 'Action=AgentTicketResponsibleView;Filter=New',
|
||||
AccessKey => $Param{Config}->{AccessKeyNew} || '',
|
||||
};
|
||||
}
|
||||
if ($CountReached) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => Translatable('Responsible Tickets Reminder Reached'),
|
||||
Count => $CountReached,
|
||||
Class => $ClassReached,
|
||||
Icon => $IconReached,
|
||||
Link => $URL . 'Action=AgentTicketResponsibleView;Filter=ReminderReached',
|
||||
AccessKey => $Param{Config}->{AccessKeyReached} || '',
|
||||
};
|
||||
}
|
||||
if ($Count) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => Translatable('Responsible Tickets Total'),
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=AgentTicketResponsibleView',
|
||||
AccessKey => $Param{Config}->{AccessKey} || '',
|
||||
};
|
||||
}
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
33
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketSearchFulltext.pm
Normal file
33
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketSearchFulltext.pm
Normal file
@@ -0,0 +1,33 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::TicketSearchFulltext;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
my $Priority = $Param{Config}->{'Priority'};
|
||||
my %Return = ();
|
||||
$Return{ $Priority++ } = {
|
||||
Block => $Param{Config}->{Block},
|
||||
Description => $Param{Config}->{Description},
|
||||
Name => $Param{Config}->{Name},
|
||||
Size => $Param{Config}->{Size},
|
||||
Fulltext => '',
|
||||
Image => '',
|
||||
AccessKey => '',
|
||||
};
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
63
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketSearchProfile.pm
Normal file
63
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketSearchProfile.pm
Normal file
@@ -0,0 +1,63 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::TicketSearchProfile;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::User',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::SearchProfile'
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# get user data
|
||||
my %User = $Kernel::OM->Get('Kernel::System::User')->GetUserData(
|
||||
UserID => $Self->{UserID},
|
||||
);
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# create search profiles string
|
||||
my $ProfilesStrg = $LayoutObject->BuildSelection(
|
||||
Data => {
|
||||
'', '-',
|
||||
$Kernel::OM->Get('Kernel::System::SearchProfile')->SearchProfileList(
|
||||
Base => 'TicketSearch',
|
||||
UserLogin => $User{UserLogin},
|
||||
),
|
||||
},
|
||||
Name => 'Profile',
|
||||
ID => 'ToolBarSearchProfile',
|
||||
Title => $LayoutObject->{LanguageObject}->Translate('Search template'),
|
||||
SelectedID => '',
|
||||
Max => $Param{Config}->{MaxWidth},
|
||||
Class => 'Modernize',
|
||||
);
|
||||
|
||||
my $Priority = $Param{Config}->{'Priority'};
|
||||
my %Return = ();
|
||||
$Return{ $Priority++ } = {
|
||||
Block => $Param{Config}->{Block},
|
||||
Description => $Param{Config}->{Description},
|
||||
Name => $Param{Config}->{Name},
|
||||
Image => '',
|
||||
Link => $ProfilesStrg,
|
||||
AccessKey => '',
|
||||
};
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
110
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketService.pm
Normal file
110
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketService.pm
Normal file
@@ -0,0 +1,110 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::TicketService;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::System::Log',
|
||||
'Kernel::Config',
|
||||
'Kernel::System::Lock',
|
||||
'Kernel::System::State',
|
||||
'Kernel::System::Queue',
|
||||
'Kernel::System::Service',
|
||||
'Kernel::System::Ticket',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
if ( !$Param{Config} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => 'Need Config!',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
# Do nothing if ticket service feature is not enabled.
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
return if !$ConfigObject->Get('Ticket::Service');
|
||||
|
||||
return if !$ConfigObject->Get('Frontend::Module')->{AgentTicketService};
|
||||
|
||||
# Get viewable locks.
|
||||
my @ViewableLockIDs = $Kernel::OM->Get('Kernel::System::Lock')->LockViewableLock( Type => 'ID' );
|
||||
|
||||
# Get viewable states.
|
||||
my @ViewableStateIDs = $Kernel::OM->Get('Kernel::System::State')->StateGetStatesByType(
|
||||
Type => 'Viewable',
|
||||
Result => 'ID',
|
||||
);
|
||||
|
||||
# Get all queues the agent is allowed to see.
|
||||
my %ViewableQueues = $Kernel::OM->Get('Kernel::System::Queue')->GetAllQueues(
|
||||
UserID => $Self->{UserID},
|
||||
Type => 'ro',
|
||||
);
|
||||
my @ViewableQueueIDs = sort keys %ViewableQueues;
|
||||
if ( !@ViewableQueueIDs ) {
|
||||
@ViewableQueueIDs = (999_999);
|
||||
}
|
||||
|
||||
# Get custom services.
|
||||
# Set the service IDs to an array of non existing service ids (0).
|
||||
my @MyServiceIDs = $Kernel::OM->Get('Kernel::System::Service')->GetAllCustomServices( UserID => $Self->{UserID} );
|
||||
if ( !defined $MyServiceIDs[0] ) {
|
||||
@MyServiceIDs = (0);
|
||||
}
|
||||
|
||||
# Get config setting 'ViewAllPossibleTickets' for AgentTicketService and set permissions
|
||||
# accordingly.
|
||||
my $Config = $ConfigObject->Get('Ticket::Frontend::AgentTicketService');
|
||||
my $Permission = 'rw';
|
||||
if ( $Config->{ViewAllPossibleTickets} ) {
|
||||
$Permission = 'ro';
|
||||
}
|
||||
|
||||
# Get number of tickets in MyServices (which are not locked).
|
||||
my $Count = $Kernel::OM->Get('Kernel::System::Ticket')->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
QueueIDs => \@ViewableQueueIDs,
|
||||
ServiceIDs => \@MyServiceIDs,
|
||||
StateIDs => \@ViewableStateIDs,
|
||||
LockIDs => \@ViewableLockIDs,
|
||||
UserID => $Self->{UserID},
|
||||
Permission => $Permission,
|
||||
) || 0;
|
||||
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
|
||||
my $URL = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{Baselink};
|
||||
my %Return;
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
if ($Count) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => Translatable('Tickets in My Services'),
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=AgentTicketService',
|
||||
AccessKey => '',
|
||||
};
|
||||
}
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
154
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketWatcher.pm
Normal file
154
Perl OTRS/Kernel/Output/HTML/ToolBar/TicketWatcher.pm
Normal file
@@ -0,0 +1,154 @@
|
||||
# --
|
||||
# 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::Output::HTML::ToolBar::TicketWatcher;
|
||||
|
||||
use parent 'Kernel::Output::HTML::Base';
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Kernel::Language qw(Translatable);
|
||||
|
||||
our @ObjectDependencies = (
|
||||
'Kernel::Config',
|
||||
'Kernel::Output::HTML::Layout',
|
||||
'Kernel::System::Group',
|
||||
'Kernel::System::Log',
|
||||
'Kernel::System::Ticket',
|
||||
);
|
||||
|
||||
sub Run {
|
||||
my ( $Self, %Param ) = @_;
|
||||
|
||||
# get config object
|
||||
my $ConfigObject = $Kernel::OM->Get('Kernel::Config');
|
||||
|
||||
# check if feature is active
|
||||
return if !$ConfigObject->Get('Ticket::Watcher');
|
||||
|
||||
# check needed stuff
|
||||
for (qw(Config)) {
|
||||
if ( !$Param{$_} ) {
|
||||
$Kernel::OM->Get('Kernel::System::Log')->Log(
|
||||
Priority => 'error',
|
||||
Message => "Need $_!"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return if !$ConfigObject->Get('Frontend::Module')->{AgentTicketWatchView};
|
||||
|
||||
# get layout object
|
||||
my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout');
|
||||
|
||||
# check access
|
||||
my @Groups;
|
||||
if ( $ConfigObject->Get('Ticket::WatcherGroup') ) {
|
||||
@Groups = @{ $ConfigObject->Get('Ticket::WatcherGroup') };
|
||||
}
|
||||
if (@Groups) {
|
||||
my $Access = 0;
|
||||
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
|
||||
GROUP:
|
||||
for my $Group (@Groups) {
|
||||
my $HasPermission = $GroupObject->PermissionCheck(
|
||||
UserID => $Self->{UserID},
|
||||
GroupName => $Group,
|
||||
Type => 'rw',
|
||||
);
|
||||
if ($HasPermission) {
|
||||
$Access = 1;
|
||||
last GROUP;
|
||||
}
|
||||
}
|
||||
|
||||
# return on no access
|
||||
return if !$Access;
|
||||
}
|
||||
|
||||
# get ticket object
|
||||
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
|
||||
|
||||
# find watched tickets
|
||||
my $Count = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
WatchUserIDs => [ $Self->{UserID} ],
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
my $CountNew = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
WatchUserIDs => [ $Self->{UserID} ],
|
||||
TicketFlag => {
|
||||
Seen => 1,
|
||||
},
|
||||
TicketFlagUserID => $Self->{UserID},
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
$CountNew = $Count - $CountNew;
|
||||
|
||||
my $CountReached = $TicketObject->TicketSearch(
|
||||
Result => 'COUNT',
|
||||
StateType => ['pending reminder'],
|
||||
WatchUserIDs => [ $Self->{UserID} ],
|
||||
TicketPendingTimeOlderMinutes => 1,
|
||||
UserID => 1,
|
||||
Permission => 'ro',
|
||||
) || 0;
|
||||
|
||||
my $Class = $Param{Config}->{CssClass};
|
||||
my $ClassNew = $Param{Config}->{CssClassNew};
|
||||
my $ClassReached = $Param{Config}->{CssClassReached};
|
||||
|
||||
my $Icon = $Param{Config}->{Icon};
|
||||
my $IconNew = $Param{Config}->{IconNew};
|
||||
my $IconReached = $Param{Config}->{IconReached};
|
||||
|
||||
my $URL = $LayoutObject->{Baselink};
|
||||
my %Return;
|
||||
my $Priority = $Param{Config}->{Priority};
|
||||
if ($CountNew) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => Translatable('Watched Tickets New'),
|
||||
Count => $CountNew,
|
||||
Class => $ClassNew,
|
||||
Icon => $IconNew,
|
||||
Link => $URL . 'Action=AgentTicketWatchView;Filter=New',
|
||||
AccessKey => $Param{Config}->{AccessKeyNew} || '',
|
||||
};
|
||||
}
|
||||
if ($CountReached) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => Translatable('Watched Tickets Reminder Reached'),
|
||||
Count => $CountReached,
|
||||
Class => $ClassReached,
|
||||
Icon => $IconReached,
|
||||
Link => $URL . 'Action=AgentTicketWatchView;Filter=ReminderReached',
|
||||
AccessKey => $Param{Config}->{AccessKeyReached} || '',
|
||||
};
|
||||
}
|
||||
if ($Count) {
|
||||
$Return{ $Priority++ } = {
|
||||
Block => 'ToolBarItem',
|
||||
Description => Translatable('Watched Tickets Total'),
|
||||
Count => $Count,
|
||||
Class => $Class,
|
||||
Icon => $Icon,
|
||||
Link => $URL . 'Action=AgentTicketWatchView',
|
||||
AccessKey => $Param{Config}->{AccessKey} || '',
|
||||
};
|
||||
}
|
||||
return %Return;
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user