6.0.0-git
2021-01-18

[#7489] _prefs_hook_fullname charset problem
Summary _prefs_hook_fullname charset problem
Queue Horde Framework Packages
Queue Version FRAMEWORK_3
Type Bug
State Resolved
Priority 2. Medium
Owners jan (at) horde (dot) org
Requester frank.richter (at) hrz (dot) tu-chemnitz (dot) de
Created 2008-10-13 (4480 days ago)
Due
Updated 2009-03-19 (4323 days ago)
Assigned 2009-03-16 (4326 days ago)
Resolved 2009-03-16 (4326 days ago)
Milestone
Patch No

History
2009-03-19 09:15:51 frank (dot) richter (at) hrz (dot) tu-chemnitz (dot) de Comment #11 Reply to this comment
Can you please try the version that I committed?
Yes, it works. Thank you!


2009-03-16 16:53:32 Jan Schneider Comment #10
State ⇒ Resolved
Reply to this comment
Works as per feedback from Petr (lampa).
2009-03-16 12:01:55 Jan Schneider Comment #9
State ⇒ Feedback
Reply to this comment
Can you please try the version that I committed?
2008-11-22 03:55:09 Chuck Hagenbuch Assigned to Jan Schneider
State ⇒ Assigned
 
2008-11-18 13:58:30 lampa (at) fit (dot) vutbr (dot) cz Comment #7
New Attachment: prefs-patch Download
Reply to this comment
Can you please re-upload that patch as a unified diff, and attach it
as a separate text file instead of pasting it, so that the linebreaks
are intelligible?
Sure, here it is.
2008-11-16 22:24:00 Chuck Hagenbuch Comment #6 Reply to this comment
Can you please re-upload that patch as a unified diff, and attach it 
as a separate text file instead of pasting it, so that the linebreaks 
are intelligible?
2008-11-04 16:50:46 lampa (at) fit (dot) vutbr (dot) cz Comment #5 Reply to this comment
I had the same problem, hooked default preference is converted to sql 
driver charset, but it shouldn't be. Here is a patch:



*** horde-3.2.2/lib/Horde/Prefs.php     2008-09-10 12:31:51.000000000 +0200

--- horde/lib/Horde/Prefs.php   2008-11-04 17:34:11.000000000 +0100

***************

*** 786,792 ****

                   empty($this->_scopes[$scope][$name]['v']) ||

                   $this->_scopes[$scope][$name]['m'] & _PREF_DEFAULT) {

                   $val = Horde::callHook('_prefs_hook_' . $name, 
array($this->_user), 'horde', $name);

!                 $this->_scopes[$scope][$name]['v'] = 
$this->convertToDriver($val, NLS::getCharset());

                   if ($this->_scopes[$scope][$name]['m'] & _PREF_LOCKED) {

                       $this->_scopes[$scope][$name]['m'] |= _PREF_DIRTY;

                   }

--- 786,796 ----

                   empty($this->_scopes[$scope][$name]['v']) ||

                   $this->_scopes[$scope][$name]['m'] & _PREF_DEFAULT) {

                   $val = Horde::callHook('_prefs_hook_' . $name, 
array($this->_user), 'horde', $name);

!               if (($this->_scopes[$scope][$name]['m'] & 
_PREF_DEFAULT) == 0) {

!                     $this->_scopes[$scope][$name]['v'] = 
$this->convertToDriver($val, NLS::getCharset());

!               } else {

!                   $this->_scopes[$scope][$name]['v'] = $val;

!               }

                   if ($this->_scopes[$scope][$name]['m'] & _PREF_LOCKED) {

                       $this->_scopes[$scope][$name]['m'] |= _PREF_DIRTY;

                   }


2008-10-24 10:59:44 Jan Schneider Comment #4 Reply to this comment
Maybe, but in any case it seems to try to convert from a charset that 
is incorrect. Is the question mark literally in the log? And how is 
the name supposed to correctly look like?
2008-10-20 13:15:39 frank (dot) richter (at) hrz (dot) tu-chemnitz (dot) de Comment #3 Reply to this comment
$outputcharset = $GLOBALS['conf']['sql']['charset'];
Thansk, but it doesn't help. I see in lib/Horde/Prefs.php in function 
_callHooks:

the value is converted by convertToDriver($val, NLS::getCharset());

If I omit the convertToDriver call here, and giving the UTF-8 value, 
ist works - the database contains the Latin1-value. Is it a "multiple 
encoding problem"?



Frank


2008-10-19 17:06:24 Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
It's probably necessary to convert to the charset of the preference 
backend. Try:

$outputcharset = $GLOBALS['conf']['sql']['charset'];

instead.
2008-10-13 10:15:38 frank (dot) richter (at) hrz (dot) tu-chemnitz (dot) de Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Summary ⇒ _prefs_hook_fullname charset problem
Queue ⇒ Horde Framework Packages
Milestone ⇒
Patch ⇒ No
Reply to this comment
Hi,

I'm migrating from Horde 3.1/IMP 4.1 to 3.3/4.3. We defined a hook for 
fullname in horde/config/hooks.php (taken from the example):

   if (!function_exists('_prefs_hook_fullname')) {

      function _prefs_hook_fullname($user = null)

      {

          $ldapServer = 'ldap.tu-chemnitz.de';

          $ldapPort = '389';

          $searchBase = 'dc=tu-chemnitz, dc=de';

          $ldapcharset = 'UTF-8';

          $outputcharset = NLS::getCharset();



          $ds = @ldap_connect($ldapServer, $ldapPort);



          if (is_null($user)) {

              $user = Auth::getAuth();

              if ($user === false)

                 return '';

          }

          $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $user);

          $information = @ldap_get_entries($ds, $searchResult);

          if ($information === false || $information["count"] < 1) return '';

          if ($information[0]['displayname'][0] != '') {

              $name = $information[0]['displayname'][0];

          } else {

              $name = $information[0]['cn'][0];

          }

          ldap_close($ds);



          $name = String::convertCharset($name, $ldapcharset, $outputcharset);

          Horde::logMessage("fullname: $name, $ldapcharset, 
$outputcharset", __FILE__, __LINE__, LOG_DEBUG);

          return ($name);

          # return (empty($name) ? $user : $name);

      }

  }



There are problem with names containing umlauts - from the Logfile:



Oct 13 11:48:12 HORDE [debug] [imp] fullname: Ottö Tcshtester, UTF-8, 
UTF-8 [pid 15336 on line 192 of "/var/www/html/horde/config/hooks.php"]

Oct 13 11:48:12 HORDE [debug] [imp] fullname: Ottö Tcshtester, UTF-8, 
UTF-8 [pid 15336 on line 192 of "/var/www/html/horde/config/hooks.php"]

Oct 13 11:48:12 HORDE [debug] [imp] SQL Query by Prefs_sql::store(): 
INSERT INTO horde_prefs (pref_uid, pref_scope, pref_name, pref_value) 
VALUES(?, ?, ?, ?), values: tcot, horde, identities, 
a:1:{i:0;a:5:{s:2:"id";s:17:"Standardidentit&#65533;t";s:8:"fullname";s:12:"Ott?shtester";s:9:"from_addr";s:34:"otto.tcshtester@hrz.tu-chemnitz.de";s:10:"alias_addr";a:1:{i:0;s:23:"tcot@hrz.tu-chemnitz.de";}s:10:"default_id";s:1:"0";}} [pid 15336 on line 244 of 
"/var/www/html/horde/lib/Horde/Prefs/sql.php"]



The full name doesn't contain the umlaut. Setting the name via the 
Webbrowser is ok - umlauts are correctly

This function works in Horde 3.1 Do you have any idea?



Thanks in advance,

Frank


Saved Queries