ich habe ein kleines Skript zum Anonymisiseren von Tickets geschrieben, das ich hier mal vorstellen möchte.
OTRS selbst sieht ja aus Revisionsgründen nicht vor Kundendaten zu löschen. Aus Datenschutzgründen bin ich jedoch gehalten, Daten von ehemaligen Kunden nicht länger als unbedingt notwendig zu speichern. Da wir über keinen festen sondern über einen stark fluktuierenden Kundenstamm verfügen, wäre das manuelle Entfernen einzelner Kunden und ihrer Daten viel zu aufwendig.
Das Skript wird über den GenericAgent aufgerufen und auf alle Tickets angewendet, die seit 3 Monaten geschlossen sind. Es geht wie folgt vor:
1. löscht alle Artikel (Email, Anruf, Notiz) des Tickets inklusive Anhänge, abgesehen vom "Eröffnungsartikel"
2. prüft, ob der Kunde noch weitere Tickets im System hat
3. wenn dies nicht der Fall ist, löscht es den Kunden aus dem System
4. löscht es die Kundenverankerung und das evtl. Aktenzeichen aus dem Ticket
5. trägt die Aktion in die Tickethistory ein
Code: Select all
#!/usr/bin/perl -w
# --
# uld.makeTicketAnonymous - a script addressed by GenericAgent to make Tickets anonymous
# Copyright (C) 2010 ULD SH, http://www.datenschutzzentrum.de/
# --
# $Id: uld.makeTicketAnonymous,v 1.0 2010/01/27 11:22:17 tr Exp $
# --
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# or see http://www.gnu.org/licenses/agpl.txt.
# --
use strict;
use warnings;
# use ../ as lib location
use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);
use lib dirname($RealBin) . "/Kernel/cpan-lib";
use vars qw($VERSION);
$VERSION = qw($Revision: 1.14 $) [1];
use Kernel::Config;
use Kernel::System::Encode;
use Kernel::System::Time;
use Kernel::System::Log;
use Kernel::System::Main;
use Kernel::System::DB;
use Kernel::System::Ticket;
use Kernel::System::User;
use Kernel::System::Ticket::ArticleStorageDB;
# common objects
my %CommonObject = ();
$CommonObject{ConfigObject} = Kernel::Config->new();
$CommonObject{EncodeObject} = Kernel::System::Encode->new(%CommonObject);
$CommonObject{LogObject} = Kernel::System::Log->new(LogPrefix => 'OTRS-getTicketThread', %CommonObject,);
$CommonObject{TimeObject} = Kernel::System::Time->new(%CommonObject);
$CommonObject{MainObject} = Kernel::System::Main->new(%CommonObject);
$CommonObject{DBObject} = Kernel::System::DB->new(%CommonObject);
$CommonObject{TicketObject} = Kernel::System::Ticket->new(%CommonObject);
$CommonObject{UserObject} = Kernel::System::User->new(%CommonObject);
# -- get TicketID from CMD, generate TicketObject
my $TicketID = shift || die 'Got no ARG[0]';
my %Ticket = $CommonObject{TicketObject}->TicketGet( TicketID => $TicketID );
# -- get UserID
my $SQL = "SELECT user_id FROM ticket WHERE id = $TicketID";
$CommonObject{DBObject}->Prepare(SQL => $SQL);
my @Row = $CommonObject{DBObject}->FetchrowArray();
# -- get articles to ticket in Array ArticleBox
my @ArticleBox = $CommonObject{TicketObject}->ArticleGet(TicketID => $Ticket{TicketID});
# -- first article shall be left as base ticketinfo
if ( @ArticleBox > 1 ) {
shift @ArticleBox;
foreach my $Article ( @ArticleBox ) {
# -- deletes articles and attachments - also the base ticketinfo!!! => ignore the smallest article_id (shift)
my $Email = $CommonObject{TicketObject}->ArticleDelete(ArticleID => $Article->{ArticleID}, UserID => '$UserID');
}
}
# -- check if customer_user has further tickets
# -- customer_company is not used in our case
$SQL = "SELECT id FROM ticket WHERE customer_id = '$Ticket{CustomerUserID}'";
$CommonObject{DBObject}->Prepare(SQL => $SQL);
my $Counter = 0;
while ( @Row = $CommonObject{DBObject}->FetchrowArray() ) {
$Counter++;
}
if ( $Counter == 1 ) {
# -- customer_user has no further tickets, customerinfos should be deleted
$SQL = "DELETE FROM customer_user WHERE login = '$Ticket{CustomerUserID}'";
$CommonObject{DBObject}->Do(SQL => $SQL);
}
# -- make ticket anonymos ( freetext3 is in our case the reference number )
$SQL = "UPDATE ticket SET customer_user_id = NULL, customer_id = NULL, freetext3 = NULL WHERE id = $Ticket{TicketID}";
$CommonObject{DBObject}->Do(SQL => $SQL);
# -- HistoryAdd
$CommonObject{TicketObject}->HistoryAdd(Name => '%%makeTicketAnonymous%%',
HistoryType => 'Misc',
TicketID => $Ticket{TicketID},
CreateUserID => '1');
1;
Vielleicht hat ja noch jemand Verwendung für das Skript oder Anregungen?