3 require_once(dirname(__FILE__) . '/example_addressbook_backend.php');
6 * Sample plugin to add a new address book
7 * with just a static list of contacts
9 class example_addressbook extends rcube_plugin
11 private $abook_id = 'static';
13 public function init()
15 $this->add_hook('addressbooks_list', array($this, 'address_sources'));
16 $this->add_hook('addressbook_get', array($this, 'get_address_book'));
18 // use this address book for autocompletion queries
19 // (maybe this should be configurable by the user?)
20 $config = rcmail::get_instance()->config;
21 $sources = (array) $config->get('autocomplete_addressbooks', array('sql'));
22 if (!in_array($this->abook_id, $sources)) {
23 $sources[] = $this->abook_id;
24 $config->set('autocomplete_addressbooks', $sources);
28 public function address_sources($p)
30 $abook = new example_addressbook_backend;
31 $p['sources'][$this->abook_id] = array(
32 'id' => $this->abook_id,
33 'name' => 'Static List',
34 'readonly' => $abook->readonly,
35 'groups' => $abook->groups,
40 public function get_address_book($p)
42 if ($p['id'] === $this->abook_id) {
43 $p['instance'] = new example_addressbook_backend;