1# -- 2# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ 3# -- 4# This software comes with ABSOLUTELY NO WARRANTY. For details, see 5# the enclosed file COPYING for license information (GPL). If you 6# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt. 7# -- 8 9package Kernel::Output::HTML::Notification::AgentTimeZoneCheck; 10 11use parent 'Kernel::Output::HTML::Base'; 12 13use strict; 14use warnings; 15 16use Kernel::Language qw(Translatable); 17use Kernel::System::DateTime; 18 19our @ObjectDependencies = ( 20 'Kernel::Config', 21 'Kernel::System::User', 22 'Kernel::Output::HTML::Layout', 23); 24 25sub Run { 26 my ( $Self, %Param ) = @_; 27 28 my $ShowUserTimeZoneSelectionNotification 29 = $Kernel::OM->Get('Kernel::Config')->Get('ShowUserTimeZoneSelectionNotification'); 30 return '' if !$ShowUserTimeZoneSelectionNotification; 31 32 my %UserPreferences = $Kernel::OM->Get('Kernel::System::User')->GetPreferences( 33 UserID => $Self->{UserID}, 34 ); 35 return '' if !%UserPreferences; 36 37 # Ignore stored time zone if it's actually an old-style offset which is not valid anymore. 38 # Please see bug#13374 for more information. 39 if ( 40 $UserPreferences{UserTimeZone} 41 && !Kernel::System::DateTime->IsTimeZoneValid( TimeZone => $UserPreferences{UserTimeZone} ) 42 ) 43 { 44 delete $UserPreferences{UserTimeZone}; 45 } 46 47 # Do not show notification if user has already valid time zone in the preferences. 48 return '' if $UserPreferences{UserTimeZone}; 49 50 # If OTRSTimeZone and UserDefaultTimeZone match and are not set to UTC, don't show a notification, 51 # because in this case it almost certainly means that only this time zone is relevant. 52 my $OTRSTimeZone = Kernel::System::DateTime->OTRSTimeZoneGet(); 53 my $UserDefaultTimeZone = Kernel::System::DateTime->UserDefaultTimeZoneGet(); 54 return '' if $OTRSTimeZone eq $UserDefaultTimeZone && $OTRSTimeZone ne 'UTC'; 55 56 # show notification to set time zone 57 my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout'); 58 return $LayoutObject->Notify( 59 Priority => 'Notice', 60 Link => $LayoutObject->{Baselink} . 'Action=AgentPreferences;Subaction=Group;Group=UserProfile', 61 Info => 62 Translatable('Please select a time zone in your preferences and confirm it by clicking the save button.'), 63 ); 64} 65 661; 67