1<?php 2/** 3 * IMP Hooks configuration file. 4 * 5 * For more information please see the hooks.php.dist file. 6 */ 7 8class IMP_Hooks 9{ 10 /** 11 * PREFERENCE INIT: Set preference values on login. 12 * 13 * See horde/config/hooks.php.dist for more information. 14 */ 15 public function prefs_init($pref, $value, $username, $scope_ob) 16 { 17 switch ($pref) { 18 case 'add_source': 19 // Dynamically set the add_source preference. 20 return is_null($username) 21 ? $value 22 : $GLOBALS['registry']->call('contacts/getDefaultShare'); 23 24 25 case 'search_fields': 26 case 'search_sources': 27 // Dynamically set the search_fields/search_sources preferences. 28 if (!is_null($username)) { 29 $sources = $GLOBALS['registry']->call('contacts/sources'); 30 31 if ($pref == 'search_fields') { 32 $out = array(); 33 foreach (array_keys($sources) as $source) { 34 $out[$source] = array_keys($GLOBALS['registry']->call('contacts/fields', array($source))); 35 } 36 } else { 37 $out = array_keys($sources); 38 } 39 40 return json_encode($out); 41 } 42 43 return $value; 44 } 45 } 46} 47