diff options
| -rw-r--r-- | plugins/example_addressbook/example_addressbook.php | 19 | ||||
| -rw-r--r-- | plugins/example_addressbook/example_addressbook_backend.php | 25 |
2 files changed, 26 insertions, 18 deletions
diff --git a/plugins/example_addressbook/example_addressbook.php b/plugins/example_addressbook/example_addressbook.php index c50f8d8ce..a15461f44 100644 --- a/plugins/example_addressbook/example_addressbook.php +++ b/plugins/example_addressbook/example_addressbook.php @@ -9,12 +9,13 @@ require_once(dirname(__FILE__) . '/example_addressbook_backend.php'); class example_addressbook extends rcube_plugin { private $abook_id = 'static'; - + private $abook_name = 'Static List'; + public function init() { $this->add_hook('addressbooks_list', array($this, 'address_sources')); $this->add_hook('addressbook_get', array($this, 'get_address_book')); - + // use this address book for autocompletion queries // (maybe this should be configurable by the user?) $config = rcmail::get_instance()->config; @@ -24,26 +25,26 @@ class example_addressbook extends rcube_plugin $config->set('autocomplete_addressbooks', $sources); } } - + public function address_sources($p) { - $abook = new example_addressbook_backend; + $abook = new example_addressbook_backend($this->abook_name); $p['sources'][$this->abook_id] = array( 'id' => $this->abook_id, - 'name' => 'Static List', + 'name' => $this->abook_name, 'readonly' => $abook->readonly, 'groups' => $abook->groups, ); return $p; } - + public function get_address_book($p) { if ($p['id'] === $this->abook_id) { - $p['instance'] = new example_addressbook_backend; + $p['instance'] = new example_addressbook_backend($this->abook_name); } - + return $p; } - + } diff --git a/plugins/example_addressbook/example_addressbook_backend.php b/plugins/example_addressbook/example_addressbook_backend.php index 5f4e0f45c..8c143c25f 100644 --- a/plugins/example_addressbook/example_addressbook_backend.php +++ b/plugins/example_addressbook/example_addressbook_backend.php @@ -12,20 +12,27 @@ class example_addressbook_backend extends rcube_addressbook public $primary_key = 'ID'; public $readonly = true; public $groups = true; - + private $filter; private $result; - - public function __construct() + private $name; + + public function __construct($name) { $this->ready = true; + $this->name = $name; + } + + public function get_name() + { + return $this->name; } - + public function set_search_set($filter) { $this->filter = $filter; } - + public function get_search_set() { return $this->filter; @@ -44,12 +51,12 @@ class example_addressbook_backend extends rcube_addressbook array('ID' => 'testgroup2', 'name' => "Sample Group"), ); } - + public function list_records($cols=null, $subset=0) { $this->result = $this->count(); $this->result->add(array('ID' => '111', 'name' => "Example Contact", 'firstname' => "Example", 'surname' => "Contact", 'email' => "example@roundcube.net")); - + return $this->result; } @@ -74,7 +81,7 @@ class example_addressbook_backend extends rcube_addressbook $this->list_records(); $first = $this->result->first(); $sql_arr = $first['ID'] == $id ? $first : null; - + return $assoc && $sql_arr ? $sql_arr : $this->result; } @@ -105,5 +112,5 @@ class example_addressbook_backend extends rcube_addressbook { return false; } - + } |
