Erweiterung der Benachrichtigungs Variablen um QUEUE

Howto's zu OTRS Themen. Keine neuen Topics mit Fragen in diesem Forum!
Post Reply
risker
Znuny newbie
Posts: 91
Joined: 21 Jan 2008, 08:16
Znuny Version: Kein OTRS
Real Name: Oliver Skibbe
Company: MDKN
Location: Hannover
Contact:

Erweiterung der Benachrichtigungs Variablen um QUEUE

Post by risker »

Um eine generische Signatur mit unterschiedlichen Queue-basierten Telefonnummern zu verwenden habe ich eine Erweiterung für OTRS 3.1.13 geschrieben, welche die Tags <OTRS_QUEUE_*> (inklusive Preferences) verfügbar macht.

Mit Einspielen des Patches und Aktivierung der Felder in der SysConfig können pro Queue unterschiedliche Telefon- und Faxnummern verwendet werden.

Code: Select all

diff -Nur Kernel/System/TemplateGenerator.pm /opt/otrs-3.1.13/Kernel/System/TemplateGenerator.pm
--- Kernel/System/TemplateGenerator.pm	2012-06-21 13:40:05.000000000 +0200
+++ /opt/otrs-3.1.13/Kernel/System/TemplateGenerator.pm	2013-02-19 13:09:25.758970100 +0100
@@ -1026,7 +1026,12 @@
         }
     }
 
+    # queueid is in Data if called from actual query
     my %Queue;
+    if ($Param{Data}->{QueueID}) {
+        $Param{QueueID} = $Param{Data}->{QueueID};
+    }
+
     if ( $Param{QueueID} ) {
         %Queue = $Self->{QueueObject}->QueueGet( ID => $Param{QueueID} );
     }
@@ -1088,6 +1093,29 @@
         }
     }
 
+    # cleanup
+    $Param{Text} =~ s/$Tag.+?$End/-/gi;
+
+    # get queue data and replace it with <OTRS_QUEUE_...
+    $Tag = $Start . 'OTRS_QUEUE_';
+    if ( $Param{QueueID} ) {
+        # html quoting of content
+        if ( $Param{RichText} ) {
+            for ( keys %Queue ) {
+                next if !$Queue{$_};
+                $Queue{$_} = $Self->{HTMLUtilsObject}->ToHTML(
+                    String => $Queue{$_},
+                );
+            }
+        }
+
+        # replace it
+        for ( keys %Queue ) {
+            next if !defined $Queue{$_};
+            $Param{Text} =~ s/$Tag$_$End/$Queue{$_}/gi;
+        }
+    }
+
     # cleanup
     $Param{Text} =~ s/$Tag.+?$End/-/gi;
 
diff -Nur Kernel/System/Ticket/Article.pm /opt/otrs-3.1.13/Kernel/System/Ticket/Article.pm
--- Kernel/System/Ticket/Article.pm	2012-06-21 13:40:06.000000000 +0200
+++ /opt/otrs-3.1.13/Kernel/System/Ticket/Article.pm	2013-02-19 13:09:22.034970100 +0100
@@ -2614,11 +2614,28 @@
             $Notification{Subject} =~ s/<OTRS_OWNER_$_>/$OwnerPreferences{$_}/gi;
         }
     }
-
+    
     # cleanup
     $Notification{Subject} =~ s/<OTRS_OWNER_.+?>/-/gi;
     $Notification{Body}    =~ s/<OTRS_OWNER_.+?>/-/gi;
 
+    # get queue data
+    my %QueuePreferences;
+    if ( $Article{QueueID} ) {
+        %QueuePreferences = $Self->{QueueObject}->QueueGet( ID => $Article{QueueID} );
+    }
+
+    for ( keys %QueuePreferences ) {
+        if ( $QueuePreferences{$_} ) {
+            $Notification{Body}    =~ s/<OTRS_QUEUE_$_>/$QueuePreferences{$_}/gi;
+            $Notification{Subject} =~ s/<OTRS_QUEUE_$_>/$QueuePreferences{$_}/gi;
+        }
+    }
+
+    # cleanup
+    $Notification{Subject} =~ s/<OTRS_QUEUE_.+?>/-/gi;
+    $Notification{Body}    =~ s/<OTRS_QUEUE_.+?>/-/gi;
+
     # get responsible data
     my %ResponsiblePreferences = $Self->{UserObject}->GetUserData(
         UserID => $Article{ResponsibleID},
Ein Beispiel Config File:

Code: Select all

diff -Nur Kernel/Config/Files/QueuePref.xml /opt/otrs-3.1.13/Kernel/Config/Files/QueuePref.xml
--- Kernel/Config/Files/QueuePref.xml	1970-01-01 01:00:00.000000000 +0100
+++ /opt/otrs-3.1.13/Kernel/Config/Files/QueuePref.xml	2013-02-19 13:12:45.006970100 +0100
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<otrs_config version="1.0" init="Application">
+    <ConfigItem Name="QueuePreferences###FaxNumber" Required="0" Valid="0">
+        <Description Translatable="1">Parameters of the example queue attribute FaxNumber.</Description>
+        <Group>Ticket</Group>
+        <SubGroup>Frontend::Queue::Preferences</SubGroup>
+        <Setting>
+            <Hash>
+                <Item Key="Module">Kernel::Output::HTML::QueuePreferencesGeneric</Item>
+                <Item Key="Label">FaxNumber</Item>
+                <Item Key="Desc">Define the queue faxnumber</Item>
+                <Item Key="Block">TextArea</Item>
+                <Item Key="Cols">50</Item>
+                <Item Key="Rows">5</Item>
+                <Item Key="PrefKey">FaxNumber</Item>
+            </Hash>
+        </Setting>
+    </ConfigItem>
+    <ConfigItem Name="QueuePreferences###PhoneNumber" Required="0" Valid="0">
+        <Description Translatable="1">Parameters of the example queue attribute PhoneNumber.</Description>
+        <Group>Ticket</Group>
+        <SubGroup>Frontend::Queue::Preferences</SubGroup>
+        <Setting>
+            <Hash>
+                <Item Key="Module">Kernel::Output::HTML::QueuePreferencesGeneric</Item>
+                <Item Key="Label">PhoneNumber</Item>
+                <Item Key="Desc">Define the queue faxnumber</Item>
+                <Item Key="Block">TextArea</Item>
+                <Item Key="Cols">50</Item>
+                <Item Key="Rows">5</Item>
+                <Item Key="PrefKey">PhoneNumber</Item>
+            </Hash>
+        </Setting>
+    </ConfigItem>
+</otrs_config>
+
Danach kann man auf folgendem Wege auf die neuen Werte zugreifen, falls kein Wert gesetzt ist, setzt OTRS dort "-" ein.

Tel.: 01234 / 5678 - <OTRS_QUEUE_PhoneNumber>
Fax.: 01234 / 5678 - <OTRS_QUEUE_FaxNumber>


Vielleicht hilft es dem Einen oder Anderen :-)
Last edited by risker on 05 Mar 2013, 20:56, edited 1 time in total.
1. OTRS Version: 3.0.12
Module: FAQ, extended TimeAccounting (supports Projects), SystemMonitoring, ITSM, Support
Server: Apache/2.0.55 (Ubuntu 10.04) PHP/5.2.6 mod_ssl/2.2.9 OpenSSL/0.9.8a mod_perl/2.0.4 Perl/v5.8.7.

ImageCIPHRON Security, Communications & Engineering
ImageCIPHRON OTRS Unterstützung & Dienstleistungen
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Erweiterung der Benachrichtigungs Variablen um QUEUE

Post by jojo »

Das geht bereits out of the box, via user preferences: http://blog.otrs.org/2011/09/05/agent-s ... ignatures/
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
risker
Znuny newbie
Posts: 91
Joined: 21 Jan 2008, 08:16
Znuny Version: Kein OTRS
Real Name: Oliver Skibbe
Company: MDKN
Location: Hannover
Contact:

Re: Erweiterung der Benachrichtigungs Variablen um QUEUE

Post by risker »

Meine Erweiterung bezieht sich aber auf QueuePreferences <-> Signatur, sie ist also Agenten unabhängig.

Gerade für Kopfnummern von Abteilungen/Themengebieten sehr sinnvoll.
1. OTRS Version: 3.0.12
Module: FAQ, extended TimeAccounting (supports Projects), SystemMonitoring, ITSM, Support
Server: Apache/2.0.55 (Ubuntu 10.04) PHP/5.2.6 mod_ssl/2.2.9 OpenSSL/0.9.8a mod_perl/2.0.4 Perl/v5.8.7.

ImageCIPHRON Security, Communications & Engineering
ImageCIPHRON OTRS Unterstützung & Dienstleistungen
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Erweiterung der Benachrichtigungs Variablen um QUEUE

Post by reneeb »

Hast Du nicht Lust, das als OTRS-Paket zu bauen und auf OPAR (http://opar.perl-services.de) bereitzustellen?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Post Reply