Mercurial > hg > rc1
comparison plugins/example_addressbook/example_addressbook.php @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e000243b222 |
---|---|
1 <?php | |
2 | |
3 require_once(__DIR__ . '/example_addressbook_backend.php'); | |
4 | |
5 /** | |
6 * Sample plugin to add a new address book | |
7 * with just a static list of contacts | |
8 * | |
9 * @license GNU GPLv3+ | |
10 * @author Thomas Bruederli | |
11 */ | |
12 class example_addressbook extends rcube_plugin | |
13 { | |
14 private $abook_id = 'static'; | |
15 private $abook_name = 'Static List'; | |
16 | |
17 public function init() | |
18 { | |
19 $this->add_hook('addressbooks_list', array($this, 'address_sources')); | |
20 $this->add_hook('addressbook_get', array($this, 'get_address_book')); | |
21 | |
22 // use this address book for autocompletion queries | |
23 // (maybe this should be configurable by the user?) | |
24 $config = rcmail::get_instance()->config; | |
25 $sources = (array) $config->get('autocomplete_addressbooks', array('sql')); | |
26 if (!in_array($this->abook_id, $sources)) { | |
27 $sources[] = $this->abook_id; | |
28 $config->set('autocomplete_addressbooks', $sources); | |
29 } | |
30 } | |
31 | |
32 public function address_sources($p) | |
33 { | |
34 $abook = new example_addressbook_backend($this->abook_name); | |
35 $p['sources'][$this->abook_id] = array( | |
36 'id' => $this->abook_id, | |
37 'name' => $this->abook_name, | |
38 'readonly' => $abook->readonly, | |
39 'groups' => $abook->groups, | |
40 ); | |
41 return $p; | |
42 } | |
43 | |
44 public function get_address_book($p) | |
45 { | |
46 if ($p['id'] === $this->abook_id) { | |
47 $p['instance'] = new example_addressbook_backend($this->abook_name); | |
48 } | |
49 | |
50 return $p; | |
51 } | |
52 | |
53 } |