6.0.0-alpha14
6/29/25

[#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 10/13/2008 (6103 days ago)
Due
Updated 03/19/2009 (5946 days ago)
Assigned 03/16/2009 (5949 days ago)
Resolved 03/16/2009 (5949 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
03/19/2009 09:15:51 AM 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!


03/16/2009 04:53:32 PM Jan Schneider Comment #10
State ⇒ Resolved
Reply to this comment
Works as per feedback from Petr (lampa).
03/16/2009 12:01:55 PM Jan Schneider Comment #9
State ⇒ Feedback
Reply to this comment
Can you please try the version that I committed?
11/22/2008 03:55:09 AM Chuck Hagenbuch Assigned to Jan Schneider
State ⇒ Assigned
 
11/18/2008 01:58:30 PM 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.
11/16/2008 10:24:00 PM 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?
11/04/2008 04:50:46 PM 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;

                   }


10/24/2008 10:59:44 AM 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?
10/20/2008 01:15:39 PM 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


10/19/2008 05:06:24 PM 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.
10/13/2008 10:15:38 AM frank (dot) richter (at) hrz (dot) tu-chemnitz (dot) de Comment #1
Priority ⇒ 2. Medium
State ⇒ Unconfirmed
Patch ⇒ No
Milestone ⇒
Summary ⇒ _prefs_hook_fullname charset problem
Type ⇒ Bug
Queue ⇒ Horde Framework Packages
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