From 2b1e9e6e95fc1e5a5a7052deca7217d192a8af06 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 21 Jan 2015 05:08:23 +0100 Subject: DefaultTo: Add comments, create_* and change_* fields Add some more database fields to be more like the default otrs interface and track the creation time and user and the last change time and user. Also now we have a comments field to add an additional description. --- DefaultTo.sopm | 5 +++++ Kernel/System/DefaultTo.pm | 29 ++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/DefaultTo.sopm b/DefaultTo.sopm index 64f0282..ea6abc8 100644 --- a/DefaultTo.sopm +++ b/DefaultTo.sopm @@ -24,6 +24,11 @@ + + + + + diff --git a/Kernel/System/DefaultTo.pm b/Kernel/System/DefaultTo.pm index c033189..ef631cb 100644 --- a/Kernel/System/DefaultTo.pm +++ b/Kernel/System/DefaultTo.pm @@ -36,7 +36,8 @@ sub Add { my ( $Self, %Param ) = @_; # check needed stuff - for my $Needed (qw(Title RemoveDefault AddNew NewAddress)) { + for my $Needed (qw(Title RemoveDefault AddNew NewAddress Comment + UserID)) { if ( !$Param{$Needed} ) { $Self->{LogObject}->Log( Priority => 'error', @@ -49,13 +50,17 @@ sub Add { # insert new DefaultTo return if !$Self->{DBObject}->Do( SQL => 'INSERT INTO default_to ' - . '(title, remove_default, add_new, new_address) ' - . 'VALUES (?, ?, ?, ?)', + . '(title, remove_default, add_new, new_address, comments, ' + . ' create_time, create_by, change_time, change_by) ' + . 'VALUES (?, ?, ?, ?, ?, current_timestamp, ?, current_timestamp, ?)', Bind => [ \$Param{Title}, \$Param{RemoveDefault}, \$Param{AddNew}, \$Param{NewAddress}, + \$Param{Comment}, + \$Param{UserID}, + \$Param{UserID}, ], ); @@ -84,7 +89,8 @@ sub Update { my ( $Self, %Param ) = @_; # check needed stuff - for my $Needed (qw(ID Title RemoveDefault AddNew NewAddress)) { + for my $Needed (qw(ID Title RemoveDefault AddNew NewAddress Comment + UserID)) { if ( !$Param{$Needed} ) { $Self->{LogObject}->Log( Priority => 'error', @@ -96,14 +102,17 @@ sub Update { # insert new DefaultTo return if !$Self->{DBObject}->Do( - SQL => 'UPDATE default_to SET title = ?, ' - . 'remove_default = ?, add_new = ?, new_address = ? ' + SQL => 'UPDATE default_to SET title = ?, remove_default = ?, ' + . 'add_new = ?, new_address = ?, comments = ?, change_by = ? ' + . 'change_time = current_timestamp ' . 'WHERE id = ?', Bind => [ \$Param{Title}, \$Param{RemoveDefault}, \$Param{AddNew}, \$Param{NewAddress}, + \$Param{Comment}, + \$Param{UserID}, \$Param{ID}, ], ); @@ -125,7 +134,8 @@ sub Get { # get RrsponseChangeDefaultTO obejct return if !$Self->{DBObject}->Prepare( - SQL => 'SELECT id, title, remove_default, add_new, new_address ' + SQL => 'SELECT id, title, remove_default, add_new, new_address, ' + . 'comments, create_time, create_by, change_time, change_by ' . 'FROM default_to WHERE id = ?', Bind => [ \$Param{ID} ], Limit => 1, @@ -139,6 +149,11 @@ sub Get { RemoveDefault => $Data[2], AddNew => $Data[3], NewAddress => $Data[4], + Comment => $Data[5], + CreateTime => $Data[6], + CreateBy => $Data[7], + ChangeTime => $Data[8], + ChangeBy => $Data[9], ); } -- cgit v1.2.3-1-g7c22