[otrs-cvs] otrs/Kernel/System CustomerCompany.pm,1.37,1.38
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/otrs/Kernel/System
In directory lancelot:/tmp/cvs-serv9076/Kernel/System
Modified Files:
CustomerCompany.pm
Log Message:
Fixed Bug #8763 and a framework problem for CustomerUser if connecting to non-utf8 databases.
Author: jh
Index: CustomerCompany.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/CustomerCompany.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -2 -u -d -r1.37 -r1.38
--- CustomerCompany.pm 20 Nov 2012 15:33:29 -0000 1.37
+++ CustomerCompany.pm 29 Nov 2012 12:59:54 -0000 1.38
@@ -120,4 +120,17 @@
}
+ # charset settings
+ my %DatabasePreferences;
+ $Self->{SourceCharset}
+ = $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{SourceCharset} || '';
+ $Self->{DestCharset} = $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{DestCharset}
+ || '';
+ $Self->{CharsetConvertForce}
+ = $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{CharsetConvertForce} || '';
+ if ( $Self->{SourceCharset} !~ /utf(-8|8)/i ) {
+ $DatabasePreferences{Encode} = 0;
+ $DatabasePreferences{Connect} = '';
+ }
+
# create new db connect if DSN is given
if ( $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{DSN} ) {
@@ -131,4 +144,5 @@
DatabasePw => $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{Password},
Type => $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{Type} || '',
+ %DatabasePreferences,
) || die('Can\'t connect to database!');
@@ -222,5 +236,5 @@
}
$SQL .= ")";
-
+ $SQL = $Self->_ConvertTo($SQL);
return if !$Self->{DBObject}->Do( SQL => $SQL );
@@ -309,4 +323,5 @@
$SQL .= "LOWER($Self->{CustomerCompanyKey}) = LOWER('$CustomerIDQuoted')";
}
+ $SQL = $Self->_ConvertTo($SQL);
# get initial data
@@ -320,5 +335,5 @@
for my $Entry ( @{ $Self->{CustomerCompanyMap} } ) {
- $Data{ $Entry->[0] } = $Row[$MapCounter];
+ $Data{ $Entry->[0] } = $Self->_ConvertFrom( $Row[$MapCounter] );
$MapCounter++;
}
@@ -402,4 +417,5 @@
$SQL .= " WHERE LOWER($Self->{CustomerCompanyKey}) = LOWER('$CustomerCompanyIDQuoted')";
}
+ $SQL = $Self->_ConvertTo($SQL);
return if !$Self->{DBObject}->Do( SQL => $SQL );
@@ -515,4 +531,5 @@
}
}
+ $SQL = $Self->_ConvertTo($SQL);
# sql
@@ -532,5 +549,5 @@
my $CustomerCompanyID = shift @Row;
- $List{$CustomerCompanyID} = join( ' ', @Row );
+ $List{$CustomerCompanyID} = join( ' ', map { $Self->_ConvertFrom($_) } @Row );
}
@@ -591,4 +608,37 @@
}
+sub _ConvertFrom {
+ my ( $Self, $Text ) = @_;
+
+ return if !defined $Text;
+
+ if ( !$Self->{SourceCharset} || !$Self->{DestCharset} ) {
+ return $Text;
+ }
+ return $Self->{EncodeObject}->Convert(
+ Text => $Text,
+ From => $Self->{SourceCharset},
+ To => $Self->{DestCharset},
+ Force => $Self->{CharsetConvertForce},
+ );
+}
+
+sub _ConvertTo {
+ my ( $Self, $Text ) = @_;
+
+ return if !defined $Text;
+
+ if ( !$Self->{SourceCharset} || !$Self->{DestCharset} ) {
+ $Self->{EncodeObject}->EncodeInput( \$Text );
+ return $Text;
+ }
+ return $Self->{EncodeObject}->Convert(
+ Text => $Text,
+ To => $Self->{SourceCharset},
+ From => $Self->{DestCharset},
+ Force => $Self->{CharsetConvertForce},
+ );
+}
+
1;
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log