[otrs-cvs] otrs/Kernel/System CustomerCompany.pm, 1.26.2.1, 1.26.2.2
"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-serv8125/Kernel/System
Modified Files:
Tag: rel-3_1
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.26.2.1
retrieving revision 1.26.2.2
diff -2 -u -d -r1.26.2.1 -r1.26.2.2
--- CustomerCompany.pm 15 Jun 2012 10:27:22 -0000 1.26.2.1
+++ CustomerCompany.pm 29 Nov 2012 12:57:25 -0000 1.26.2.2
@@ -119,4 +119,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} ) {
@@ -130,4 +143,5 @@
DatabasePw => $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{Password},
Type => $Self->{ConfigObject}->Get('CustomerCompany')->{Params}->{Type} || '',
+ %DatabasePreferences,
) || die('Can\'t connect to database!');
@@ -219,4 +233,5 @@
$SQL .= ")";
+ $SQL = $Self->_ConvertTo($SQL);
return if !$Self->{DBObject}->Do( SQL => $SQL );
@@ -292,4 +307,5 @@
$SQL .= "LOWER($Self->{CustomerCompanyKey}) = LOWER('$CustomerIDQuoted')";
}
+ $SQL = $Self->_ConvertTo($SQL);
# get initial data
@@ -303,5 +319,5 @@
for my $Entry ( @{ $Self->{CustomerCompanyMap} } ) {
- $Data{ $Entry->[0] } = $Row[$MapCounter];
+ $Data{ $Entry->[0] } = $Self->_ConvertFrom( $Row[$MapCounter] );
$MapCounter++;
}
@@ -370,5 +386,5 @@
$SQL .= " WHERE $Self->{Lower}($Self->{CustomerCompanyKey}) = $Self->{Lower}('"
. $Self->{DBObject}->Quote( $Param{CustomerCompanyID} ) . "')";
-
+ $SQL = $Self->_ConvertTo($SQL);
return if !$Self->{DBObject}->Do( SQL => $SQL );
@@ -487,4 +503,5 @@
= "SELECT $Self->{CustomerCompanyKey}, $What FROM $Self->{CustomerCompanyTable}";
$CompleteSQL .= $SQL ? " WHERE $SQL" : '';
+ $SQL = $Self->_ConvertTo($SQL);
# ask database
@@ -507,5 +524,5 @@
if ( defined $Row[$Position] ) {
- $Value .= $Row[$Position];
+ $Value .= $Self->_ConvertFrom( $Row[$Position] );
}
}
@@ -529,4 +546,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