Ticket #9454: Add example hook for setting search_fields pref
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 16 Dec 2010 22:26:08 +0000 (15:26 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 16 Dec 2010 22:26:18 +0000 (15:26 -0700)
imp/config/hooks.php.dist

index 2deab44..4d2ab82 100644 (file)
@@ -63,16 +63,26 @@ class IMP_Hooks
 //                : $GLOBALS['registry']->call('contacts/getDefaultShare');
 //
 //
+//        case 'search_fields':
 //        case 'search_sources':
-//            // Dynamically set the search_sources preference.
+//            // Dynamically set the search_fields/search_sources preferences.
 //
 //            // Example #1: Use the list of sources defined in the contacts
-//            // application (e.g. Turba) to populate the search_sources
-//            // value.
+//            // application (e.g. Turba).
 //            if (!is_null($username) &&
 //                $GLOBALS['registry']->hasMethod('contacts/sources')) {
 //                $sources = $GLOBALS['registry']->call('contacts/sources');
-//                return json_encode(array_keys($sources));
+//
+//                if ($pref == 'search_fields') {
+//                    $out = array();
+//                    foreach (array_keys($sources) as $source) {
+//                        $out[$source] = array_keys($GLOBALS['registry']->call('contacts/fields', array($source)));
+//                    }
+//                } else {
+//                    $out = array_keys($sources);
+//                }
+//
+//                return json_encode($out);
 //            }
 //
 //            return $value;