Erweiterung der Benachrichtigungs Variablen um QUEUE

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

Erweiterung der Benachrichtigungs Variablen um QUEUE

Postby risker » 05 Mar 2013, 17:16

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
Moderator
Posts: 13961
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: Erweiterung der Benachrichtigungs Variablen um QUEUE

Postby jojo » 05 Mar 2013, 17:59

Das geht bereits out of the box, via user preferences: http://blog.otrs.org/2011/09/05/agent-s ... ignatures/
"Production": OTRS Business Solution™ 6, STORM powered by OTRS
"Testing": OTRS git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

risker
OTRS expert
Posts: 91
Joined: 21 Jan 2008, 08:16
OTRS Version?: Kein OTRS
Real Name: Oliver Skibbe
Company: MDKN
Location: Hannover
Contact:

Re: Erweiterung der Benachrichtigungs Variablen um QUEUE

Postby risker » 05 Mar 2013, 18:08

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
OTRS guru
Posts: 4363
Joined: 13 Mar 2011, 09:54
OTRS Version?: 3.3.x
Company: Perl-Services.de
Contact:

Re: Erweiterung der Benachrichtigungs Variablen um QUEUE

Postby reneeb » 06 Mar 2013, 14:40

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


Return to “Howto's”

Who is online

Users browsing this forum: No registered users and 1 guest