Hello!

To allow users (or groups of users by using a shared email address) to receive 
notifications about actions on all tickets in a set of queues we have created 
the following patch:

"subscriber_notification.patch"

It adds four new user-settings:
 * Answer notification
 * Note notification
 * Phone call notification
 * Owner changed notification

These settings enable the user to receive a notification when the 
corresponding event arises on a ticket in one of the users watched queues. 
(As determined by the setting "my queues")

The patch was created for OTRS version 2.3.2, but it applies cleanly to OTRS 
versions 2.3.2, 2.3.3, and 2.3.4.

Best regards
Janek Walkenhorst
-- 
Janek Walkenhorst
Software Engineering Apprentice

Univention GmbH
Linux for your business
Mary-Somerville-Str.1
28359 Bremen
Tel. : +49 421 22232-0
Fax : +49 421 22232-99

[email protected]
http://www.univention.de

Geschäftsführer: Peter H. Ganten
HRB 20755 Amtsgericht Bremen
Steuer-Nr.: 71-597-02876
Index: Kernel/Language/de.pm
===================================================================
--- Kernel/Language/de.pm
+++ Kernel/Language/de.pm
@@ -509,6 +509,14 @@ sub Data {
         'Send me a notification if a ticket is unlocked by the system.' => 'Zusenden einer Mitteilung, wenn ein Ticket vom System freigegeben ("unlocked") wird.',
         'Move notification' => 'Mitteilung bei Queue-Wechsel',
         'Send me a notification if a ticket is moved into one of "My Queues".' => 'Zusenden einer Mitteilung beim Verschieben eines Tickets in "Meine Queues".',
+        'Answer notification' => 'Mitteilung bei Antwort.',
+        'Send me a notification if someone writes an answer to a ticket in one of "My Queues".' => 'Zusenden einer Mitteilung beim Versand einer Antwort an einem Ticket in "Meine Queues".',
+        'Note notification' => 'Mitteilung bei Notiz',
+        'Send me a notification if someone writes a note to a ticket in one of "My Queues".' => 'Zusenden einer Mitteilung wenn eine Notiz an ein Ticket in "Meine Queues" geschrieben wurde.',
+        'Phone call notification' => 'Mitteilung bei Anruf',
+        'Send me a notification if someone writes a note for a phone call to a ticket in one of "My Queues".' => 'Zusender einer Mitteilung wenn ein Anruf an einem Ticket in "Meine Queues" festgehalten wurde.',
+        'Owner changed notification' => 'Mitteilung bei Besitzerwechsel',
+        'Send me a notification if the owner of a ticket in one of "My Queues" has been changed.' => 'Zusenden einer Mitteilung wenn der Besitzer eines Tickets in "Meine Queues" ge?ndert wurde.',
         'Your queue selection of your favourite queues. You also get notified about those queues via email if enabled.' => 'Queue Auswahl der bevorzugten Queues. Es werden E-Mail-Benachrichtigungen ?ber diese ausgew?hlten Queues versendet.',
         'Custom Queue' => 'Bevorzugte Queue',
         'QueueView refresh time' => 'Queue-Ansicht Aktualisierungszeit',
Index: Kernel/System/Ticket.pm
===================================================================
--- Kernel/System/Ticket.pm
+++ Kernel/System/Ticket.pm
@@ -4786,6 +4786,9 @@ sub OwnerSet {
             # get user data
             my %Preferences = $Self->{UserObject}->GetUserData( UserID => $Param{NewUserID} );
 
+            # remember already sent info
+            my %AlreadySent = ();
+            $AlreadySent{$Param{NewUserID}} = 1;
             # send agent notification
             $Self->SendAgentNotification(
                 Type                  => 'OwnerUpdate',
@@ -4794,6 +4797,30 @@ sub OwnerSet {
                 TicketID              => $Param{TicketID},
                 UserID                => $Param{UserID},
             );
+            # send notifications to agents which have subscribed to this queue
+            my %Ticket = $Self->TicketGet( TicketID => $Param{TicketID} );
+            for ( $Self->GetSubscribedUserIDsByQueueID( QueueID => $Ticket{QueueID} ) ) {
+                if ( $AlreadySent{$_} ) {
+                    next;
+                }
+
+                # remember already sent info
+                $AlreadySent{$_} = 1;
+                my %UserData = $Self->{UserObject}->GetUserData(
+                    UserID => $_,
+                    Cached => 1,
+                    Valid  => 1,
+                );
+                if ( $UserData{UserOwnerUpdateNotification} ) {
+                    $Self->SendAgentNotification(
+                        Type                  => 'OwnerUpdate',
+                        UserData              => \%UserData,
+                        CustomerMessageParams => \%Param,
+                        TicketID              => $Param{TicketID},
+                        UserID                => $Param{UserID},
+                    );
+                }
+            }
         }
 
         # send customer notification email
@@ -4974,16 +5001,34 @@ sub ResponsibleSet {
                 TicketID              => $Param{TicketID},
                 UserID                => $Param{UserID},
             );
+
+            # send notifications to agents which have subscribed to this queue
+            my %AlreadySent = ();
+            my %Ticket = $Self->TicketGet( TicketID => $Param{TicketID} );
+            for ( $Self->GetSubscribedUserIDsByQueueID( QueueID => $Ticket{QueueID} ) ) {
+                if ( $AlreadySent{$_} ) {
+                    next;
+                }
+
+                # remember already sent info
+                $AlreadySent{$_} = 1;
+                my %UserData = $Self->{UserObject}->GetUserData(
+                    UserID => $_,
+                    Cached => 1,
+                    Valid  => 1,
+                );
+                if ( $UserData{UserOwnerUpdateNotification} ) {
+                    $Self->SendAgentNotification(
+                        Type                  => 'OwnerUpdate',
+                        UserData              => \%Preferences,
+                        CustomerMessageParams => \%Param,
+                        TicketID              => $Param{TicketID},
+                        UserID                => $Param{UserID},
+                    );
+                }
+            }
         }
 
-        #        # send customer notification email
-        #        my %Preferences = $Self->{UserObject}->GetUserData(UserID => $Param{NewUserID});
-        #        $Self->SendCustomerNotification(
-        #            Type => 'ResponsibleUpdate',
-        #            CustomerMessageParams => \%Preferences,
-        #            TicketID => $Param{TicketID},
-        #            UserID => $Param{UserID},
-        #        );
     }
 
     # ticket event
Index: Kernel/System/Ticket/Article.pm
===================================================================
--- Kernel/System/Ticket/Article.pm
+++ Kernel/System/Ticket/Article.pm
@@ -512,6 +512,39 @@ sub ArticleCreate {
         }
     }
 
+    #send notifications to agents which have subscribed to this queue
+    if ($Param{HistoryType} =~ /^(SendAnswer|AddNote|PhoneCallAgent)$/i) {
+        for ( $Self->GetSubscribedUserIDsByQueueID( QueueID => $Ticket{QueueID} ) ) {
+            if ( $AlreadySent{$_} ) {
+                next;
+            }
+
+            # remember already sent info
+            $AlreadySent{$_} = 1;
+            my %UserData = $Self->{UserObject}->GetUserData(
+                UserID => $_,
+                Cached => 1,
+                Valid  => 1,
+            );
+
+            if ( ( $Param{HistoryType} =~ /^(SendAnswer)$/i      && $UserData{UserSendAnswerNotification}     )
+              || ( $Param{HistoryType} =~ /^(AddNote)$/i         && $UserData{UserAddNoteNotification}        )
+              || ( $Param{HistoryType} =~ /^(PhoneCallAgent)$/i  && $UserData{UserPhoneCallAgentNotification} )
+              || ( $Param{HistoryType} =~ /^(OwnerUpdate)$/i     && $UserData{UserOwnerUpdateNotification}    )
+            ) {
+                # send notification
+                $Self->SendAgentNotification(
+                    Type                  => $Param{HistoryType},
+                    UserData              => \%UserData,
+                    CustomerMessageParams => \%Param,
+                    TicketID              => $Param{TicketID},
+                    Queue                 => $Param{Queue},
+                    UserID                => $Param{UserID},
+                );
+            }
+        }
+    }
+
     # send forced notifications
     if ( $Param{ForceNotificationToUserID} && ref $Param{ForceNotificationToUserID} eq 'ARRAY' )
     {
Index: Kernel/Config/Files/Ticket.xml
===================================================================
--- Kernel/Config/Files/Ticket.xml	2008-08-21 22:09:06.000000000 +0200
+++ Kernel/Config/Files/Ticket.xml	2009-01-05 15:26:32.000000000 +0100
@@ -6289,6 +6289,98 @@
                 <Item Key="Activ">1</Item>
             </Hash>
         </Setting>
+	</ConfigItem>
+    <ConfigItem Name="PreferencesGroups###AnswerNotify" Required="0" Valid="1">
+        <Description Lang="en">Parameters for the AnswerNotify object in the preference view.</Description>
+        <Description Lang="de">Parameter f?r das AnswerNotify-Objekt in der Ansicht f?r die Einstellungen.</Description>
+        <Group>Ticket</Group>
+        <SubGroup>Frontend::Agent::Preferences</SubGroup>
+        <Setting>
+            <Hash>
+                <Item Key="Module">Kernel::Output::HTML::PreferencesGeneric</Item>
+                <Item Key="Colum">Mail Management</Item>
+                <Item Key="Label">Answer notification</Item>
+                <Item Key="Desc">Send me a notification if someone writes an answer to a ticket in one of "My Queues".</Item>
+                <Item Key="Data">
+                    <Hash>
+                        <Item Key="0">No</Item>
+                        <Item Key="1">Yes</Item>
+                    </Hash>
+                </Item>
+                <Item Key="PrefKey">UserSendAnswerNotification</Item>
+                <Item Key="Prio">5000</Item>
+                <Item Key="Activ">1</Item>
+            </Hash>
+        </Setting>
+	</ConfigItem>
+    <ConfigItem Name="PreferencesGroups###NoteNotify" Required="0" Valid="1">
+        <Description Lang="en">Parameters for the NoteNotify object in the preference view.</Description>
+        <Description Lang="de">Parameter f?r das NoteNotify-Objekt in der Ansicht f?r die Einstellungen.</Description>
+        <Group>Ticket</Group>
+        <SubGroup>Frontend::Agent::Preferences</SubGroup>
+        <Setting>
+            <Hash>
+                <Item Key="Module">Kernel::Output::HTML::PreferencesGeneric</Item>
+                <Item Key="Colum">Mail Management</Item>
+                <Item Key="Label">Note notification</Item>
+                <Item Key="Desc">Send me a notification if someone writes a note to a ticket in one of "My Queues".</Item>
+                <Item Key="Data">
+                    <Hash>
+                        <Item Key="0">No</Item>
+                        <Item Key="1">Yes</Item>
+                    </Hash>
+                </Item>
+                <Item Key="PrefKey">UserAddNoteNotification</Item>
+                <Item Key="Prio">6000</Item>
+                <Item Key="Activ">1</Item>
+            </Hash>
+        </Setting>
+    </ConfigItem>
+    <ConfigItem Name="PreferencesGroups###PhoneCallNotify" Required="0" Valid="1">
+        <Description Lang="en">Parameters for the PhoneCallNotify object in the preference view.</Description>
+        <Description Lang="de">Parameter f?r das PhoneCallNotify-Objekt in der Ansicht f?r die Einstellungen.</Description>
+        <Group>Ticket</Group>
+        <SubGroup>Frontend::Agent::Preferences</SubGroup>
+        <Setting>
+            <Hash>
+                <Item Key="Module">Kernel::Output::HTML::PreferencesGeneric</Item>
+                <Item Key="Colum">Mail Management</Item>
+                <Item Key="Label">Phone call notification</Item>
+                <Item Key="Desc">Send me a notification if someone writes a note for a phone call to a ticket in one of "My Queues".</Item>
+                <Item Key="Data">
+                    <Hash>
+                        <Item Key="0">No</Item>
+                        <Item Key="1">Yes</Item>
+                    </Hash>
+                </Item>
+                <Item Key="PrefKey">UserPhoneCallAgentNotification</Item>
+                <Item Key="Prio">7000</Item>
+                <Item Key="Activ">1</Item>
+            </Hash>
+        </Setting>
+    </ConfigItem>
+    <ConfigItem Name="PreferencesGroups###OwnerUpdateNotify" Required="0" Valid="1">
+        <Description Lang="en">Parameters for the OwnerUpdateNotify object in the preference view.</Description>
+        <Description Lang="de">Parameter f?r das OwnerUpdateNotify-Objekt in der Ansicht f?r die Einstellungen.</Description>
+        <Group>Ticket</Group>
+        <SubGroup>Frontend::Agent::Preferences</SubGroup>
+        <Setting>
+            <Hash>
+                <Item Key="Module">Kernel::Output::HTML::PreferencesGeneric</Item>
+                <Item Key="Colum">Mail Management</Item>
+                <Item Key="Label">Owner changed notification</Item>
+                <Item Key="Desc">Send me a notification if the owner of a ticket in one of "My Queues" has been changed.</Item>
+                <Item Key="Data">
+                    <Hash>
+                        <Item Key="0">No</Item>
+                        <Item Key="1">Yes</Item>
+                    </Hash>
+                </Item>
+                <Item Key="PrefKey">UserOwnerUpdateNotification</Item>
+                <Item Key="Prio">8000</Item>
+                <Item Key="Activ">1</Item>
+            </Hash>
+        </Setting>
     </ConfigItem>
     <ConfigItem Name="PreferencesGroups###CustomQueue" Required="0" Valid="1">
         <Description Lang="en">Parameters for the CustomQueue object in the preference view.</Description>

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev

Reply via email to