[Tickets #10681] Re: Autocompleter in IMP with inconsistent results
bugs at horde.org
bugs at horde.org
Mon Nov 14 12:07:03 UTC 2011
BITTE NICHT AUF DIESE NACHRICHT ANTWORTEN. NACHRICHTEN AN DIESE
E-MAIL-ADRESSE WERDEN NICHT GELESEN.
Ticket-URL: http://bugs.horde.org/ticket/10681
------------------------------------------------------------------------------
Ticket | 10681
Aktualisiert Von | michael.groene at zel.uni-hannover.de
Zusammenfassung | Autocompleter in IMP with inconsistent results
Warteschlange | Horde Base
Version | 4.0.10
Typ | Bug
Status | Unconfirmed
Priorität | 1. Low
Milestone |
Patch |
Zuständige |
------------------------------------------------------------------------------
michael.groene at zel.uni-hannover.de (2011-11-14 12:07) hat geschrieben:
> Are you sure the hook is running and returning the proper data?
Good hint, I didn't thought about, whether it's returning proper data,
because it was provided in hooks.dist.
I found out, why I got different results.
When the search_fields-pref was set by the hook, it contained ALL
fields, not just the fields, marked to be searched in turba's
backends.php. This lead to too many results, which is why the results
were not being displayed (max. 100).
I expanded the hooks, to filter for that.
Maybe it could be added to the dist?
This is my complete prefs_init-Hook:
public function prefs_init($pref, $value, $username, $scope_ob)
{
switch ($pref) {
case 'add_source':
// Dynamically set the add_source preference.
// Example: Useful hook when using a Turba source with shares
// enabled (i.e. the example localsql configuration).
$value=is_null($username)
? $value
: $GLOBALS['registry']->call('contacts/getDefaultShare');
# return $value;
break;
case 'search_fields':
case 'search_sources':
// Dynamically set the search_fields/search_sources preferences.
// Example #1: Use the list of sources defined in the contacts
// application (e.g. Turba).
if (!is_null($username) &&
$GLOBALS['registry']->hasMethod('contacts/sources')) {
$sources = $GLOBALS['registry']->call('contacts/sources');
if ($pref == 'search_fields') {
$out = array();
foreach (array_keys($sources) as $source) {
# $out[$source] =
array_keys($GLOBALS['registry']->call('contacts/fields',
array($source)));
#reduce to searchable fields
$all_fields =
($GLOBALS['registry']->call('contacts/fields', array($source)));
foreach($all_fields as $field=>$details) {
if($details['search']==true)
$out[$source][]=$field;
}
}
} else {
$out = array_keys($sources);
}
$value=json_encode($out);
}
break;
}
return $value;
}
This was added to the foreach:
#reduce to searchable fields
$all_fields =
($GLOBALS['registry']->call('contacts/fields', array($source)));
foreach($all_fields as $field=>$details) {
if($details['search']==true)
$out[$source][]=$field;
Thanks for advice, can be closed.
More information about the bugs
mailing list