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 scripts::DBUpdateTo6::AddAppointmentCalendarNotification;    ## no critic
10
11use strict;
12use warnings;
13
14use parent qw(scripts::DBUpdateTo6::Base);
15
16our @ObjectDependencies = (
17    'Kernel::System::NotificationEvent',
18    'Kernel::System::Valid',
19);
20
21=head1 NAME
22
23scripts::DBUpdateTo6::AddAppointmentCalendarNotification - Add AppointmentCalendar notification.
24
25=cut
26
27sub Run {
28    my ( $Self, %Param ) = @_;
29
30    my %AppointmentNotifications = (
31        'Appointment reminder notification' => {
32            Data => {
33                NotificationType       => ['Appointment'],
34                VisibleForAgent        => [1],
35                VisibleForAgentTooltip => [
36                    'You will receive a notification each time a reminder time is reached for one of your appointments.'
37                ],
38                Events                => ['AppointmentNotification'],
39                Recipients            => ['AppointmentAgentReadPermissions'],
40                SendOnOutOfOffice     => [1],
41                Transports            => ['Email'],
42                AgentEnabledByDefault => ['Email'],
43            },
44            Message => {
45                'de' => {
46                    'Body' => 'Hallo &lt;OTRS_NOTIFICATION_RECIPIENT_UserFirstname&gt;,<br />
47<br />
48Termin &quot;&lt;OTRS_APPOINTMENT_TITLE&gt;&quot; hat seine Benachrichtigungszeit erreicht.<br />
49<br />
50Beschreibung: &lt;OTRS_APPOINTMENT_DESCRIPTION&gt;<br />
51Standort: &lt;OTRS_APPOINTMENT_LOCATION&gt;<br />
52Kalender: <span style="color: &lt;OTRS_CALENDAR_COLOR&gt;;">■</span> &lt;OTRS_CALENDAR_CALENDARNAME&gt;<br />
53Startzeitpunkt: &lt;OTRS_APPOINTMENT_STARTTIME&gt;<br />
54Endzeitpunkt: &lt;OTRS_APPOINTMENT_ENDTIME&gt;<br />
55Ganztägig: &lt;OTRS_APPOINTMENT_ALLDAY&gt;<br />
56Wiederholung: &lt;OTRS_APPOINTMENT_RECURRING&gt;<br />
57<br />
58<a href="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;" title="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;">&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;</a><br />
59<br />
60-- &lt;OTRS_CONFIG_NotificationSenderName&gt;',
61                    'ContentType' => 'text/html',
62                    'Subject'     => 'Erinnerung: <OTRS_APPOINTMENT_TITLE>',
63                },
64                'en' => {
65                    'Body' => 'Hi &lt;OTRS_NOTIFICATION_RECIPIENT_UserFirstname&gt;,<br />
66<br />
67appointment &quot;&lt;OTRS_APPOINTMENT_TITLE&gt;&quot; has reached its notification time.<br />
68<br />
69Description: &lt;OTRS_APPOINTMENT_DESCRIPTION&gt;<br />
70Location: &lt;OTRS_APPOINTMENT_LOCATION&gt;<br />
71Calendar: <span style="color: &lt;OTRS_CALENDAR_COLOR&gt;;">■</span> &lt;OTRS_CALENDAR_CALENDARNAME&gt;<br />
72Start date: &lt;OTRS_APPOINTMENT_STARTTIME&gt;<br />
73End date: &lt;OTRS_APPOINTMENT_ENDTIME&gt;<br />
74All-day: &lt;OTRS_APPOINTMENT_ALLDAY&gt;<br />
75Repeat: &lt;OTRS_APPOINTMENT_RECURRING&gt;<br />
76<br />
77<a href="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;" title="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;">&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;</a><br />
78<br />
79-- &lt;OTRS_CONFIG_NotificationSenderName&gt;',
80                    'ContentType' => 'text/html',
81                    'Subject'     => 'Reminder: <OTRS_APPOINTMENT_TITLE>',
82                },
83                'hu' => {
84                    'Body' => 'Kedves &lt;OTRS_NOTIFICATION_RECIPIENT_UserFirstname&gt;!<br />
85<br />
86A következő esemény elérte az értesítési idejét: &lt;OTRS_APPOINTMENT_TITLE&gt;<br />
87<br />
88Leírás: &lt;OTRS_APPOINTMENT_DESCRIPTION&gt;<br />
89Hely: &lt;OTRS_APPOINTMENT_LOCATION&gt;<br />
90Naptár: <span style="color: &lt;OTRS_CALENDAR_COLOR&gt;;">■</span> &lt;OTRS_CALENDAR_CALENDARNAME&gt;<br />
91Kezdési dátum: &lt;OTRS_APPOINTMENT_STARTTIME&gt;<br />
92Befejezési dátum: &lt;OTRS_APPOINTMENT_ENDTIME&gt;<br />
93Egész napos: &lt;OTRS_APPOINTMENT_ALLDAY&gt;<br />
94Ismétlődés: &lt;OTRS_APPOINTMENT_RECURRING&gt;<br />
95<br />
96<a href="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;" title="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;">&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;</a><br />
97<br />
98-- &lt;OTRS_CONFIG_NotificationSenderName&gt;',
99                    'ContentType' => 'text/html',
100                    'Subject'     => 'Emlékeztető: <OTRS_APPOINTMENT_TITLE>',
101                },
102                'sr_Cyrl' => {
103                    'Body' => 'Здраво &lt;OTRS_NOTIFICATION_RECIPIENT_UserFirstname&gt;,<br />
104<br />
105време је за обавештење у вези термина &quot;&lt;OTRS_APPOINTMENT_TITLE&gt;&quot;.<br />
106<br />
107Опис: &lt;OTRS_APPOINTMENT_DESCRIPTION&gt;<br />
108Локација: &lt;OTRS_APPOINTMENT_LOCATION&gt;<br />
109Календар: <span style="color: &lt;OTRS_CALENDAR_COLOR&gt;;">■</span> &lt;OTRS_CALENDAR_CALENDARNAME&gt;<br />
110Датум почетка: &lt;OTRS_APPOINTMENT_STARTTIME&gt;<br />
111Датум краја: &lt;OTRS_APPOINTMENT_ENDTIME&gt;<br />
112Целодневно: &lt;OTRS_APPOINTMENT_ALLDAY&gt;<br />
113Понављање: &lt;OTRS_APPOINTMENT_RECURRING&gt;<br />
114<br />
115<a href="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;" title="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;">&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;</a><br />
116<br />
117-- &lt;OTRS_CONFIG_NotificationSenderName&gt;',
118                    'ContentType' => 'text/html',
119                    'Subject'     => 'Подсетник: <OTRS_APPOINTMENT_TITLE>',
120                },
121                'sr_Latn' => {
122                    'Body' => 'Zdravo &lt;OTRS_NOTIFICATION_RECIPIENT_UserFirstname&gt;,<br />
123<br />
124vreme je za obaveštenje u vezi termina &quot;&lt;OTRS_APPOINTMENT_TITLE&gt;&quot;.<br />
125<br />
126Opis: &lt;OTRS_APPOINTMENT_DESCRIPTION&gt;<br />
127Lokacije: &lt;OTRS_APPOINTMENT_LOCATION&gt;<br />
128Kalendar: <span style="color: &lt;OTRS_CALENDAR_COLOR&gt;;">■</span> &lt;OTRS_CALENDAR_CALENDARNAME&gt;<br />
129Datum početka: &lt;OTRS_APPOINTMENT_STARTTIME&gt;<br />
130Datum kraja: &lt;OTRS_APPOINTMENT_ENDTIME&gt;<br />
131Celodnevno: &lt;OTRS_APPOINTMENT_ALLDAY&gt;<br />
132Ponavljanje: &lt;OTRS_APPOINTMENT_RECURRING&gt;<br />
133<br />
134<a href="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;" title="&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;">&lt;OTRS_CONFIG_HttpType&gt;://&lt;OTRS_CONFIG_FQDN&gt;/&lt;OTRS_CONFIG_ScriptAlias&gt;index.pl?Action=AgentAppointmentCalendarOverview;AppointmentID=&lt;OTRS_APPOINTMENT_APPOINTMENTID&gt;</a><br />
135<br />
136-- &lt;OTRS_CONFIG_NotificationSenderName&gt;',
137                    'ContentType' => 'text/html',
138                    'Subject'     => 'Podsetnik: <OTRS_APPOINTMENT_TITLE>',
139                },
140            },
141        },
142    );
143
144    my %ValidList        = $Kernel::OM->Get('Kernel::System::Valid')->ValidList();
145    my %ValidListReverse = reverse %ValidList;
146
147    my $NotificationEventObject = $Kernel::OM->Get('Kernel::System::NotificationEvent');
148
149    # Get all notifications of appointment type.
150    my %NotificationList = $NotificationEventObject->NotificationList(
151        Type => 'Appointment',
152    );
153    my %NotificationListReverse = reverse %NotificationList;
154
155    NEWNOTIFICATION:
156    for my $NotificationName ( sort keys %AppointmentNotifications ) {
157
158        # Do not add new notification if one with the same name exists.
159        next NEWNOTIFICATION if $NotificationListReverse{$NotificationName};
160
161        # Add new event notification.
162        my $ID = $NotificationEventObject->NotificationAdd(
163            Name    => $NotificationName,
164            Data    => $AppointmentNotifications{$NotificationName}->{Data},
165            Message => $AppointmentNotifications{$NotificationName}->{Message},
166            Comment => '',
167            ValidID => $ValidListReverse{valid},
168            UserID  => 1,
169        );
170
171        return if !$ID;
172    }
173
174    return 1;
175}
176
1771;
178
179=head1 TERMS AND CONDITIONS
180
181This software is part of the OTRS project (L<https://otrs.org/>).
182
183This software comes with ABSOLUTELY NO WARRANTY. For details, see
184the enclosed file COPYING for license information (GPL). If you
185did not receive this file, see L<https://www.gnu.org/licenses/gpl-3.0.txt>.
186
187=cut
188