1: <?php
2: /**
3: * Copyright 2012-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2012-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Special prefs handling for the 'sourceselect' preference.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2012-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Prefs_Special_Sourceselect implements Horde_Core_Prefs_Ui_Special
24: {
25: /**
26: */
27: public function init(Horde_Core_Prefs_Ui $ui)
28: {
29: }
30:
31: /**
32: */
33: public function display(Horde_Core_Prefs_Ui $ui)
34: {
35: $contacts = $GLOBALS['injector']->getInstance('IMP_Contacts');
36: return Horde_Core_Prefs_Ui_Widgets::addressbooks(array(
37: 'fields' => $contacts->fields,
38: 'sources' => $contacts->sources
39: ));
40: }
41:
42: /**
43: */
44: public function update(Horde_Core_Prefs_Ui $ui)
45: {
46: global $prefs;
47:
48: $data = Horde_Core_Prefs_Ui_Widgets::addressbooksUpdate($ui);
49: $updated = false;
50:
51: if (isset($data['sources'])) {
52: $prefs->setValue('search_sources', $data['sources']);
53: $updated = true;
54: }
55:
56: if (isset($data['fields'])) {
57: $prefs->setValue('search_fields', $data['fields']);
58: $updated = true;
59: }
60:
61: return $updated;
62: }
63:
64: }
65: