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';
12 private $abook_name = 'Static List';
14 public function init()
16 $this->add_hook('addressbooks_list', array($this, 'address_sources'));
17 $this->add_hook('addressbook_get', array($this, 'get_address_book'));
19 // use this address book for autocompletion queries
20 // (maybe this should be configurable by the user?)
21 $config = rcmail::get_instance()->config;
22 $sources = (array) $config->get('autocomplete_addressbooks', array('sql'));
23 if (!in_array($this->abook_id, $sources)) {
24 $sources[] = $this->abook_id;
25 $config->set('autocomplete_addressbooks', $sources);
29 public function address_sources($p)
31 $abook = new example_addressbook_backend($this->abook_name);
32 $p['sources'][$this->abook_id] = array(
33 'id' => $this->abook_id,
34 'name' => $this->abook_name,
35 'readonly' => $abook->readonly,
36 'groups' => $abook->groups,
41 public function get_address_book($p)
43 if ($p['id'] === $this->abook_id) {
44 $p['instance'] = new example_addressbook_backend($this->abook_name);