[Svn] r4858 - trunk/plugins/example_addressbook

trac at roundcube.net trac at roundcube.net
Thu Jun 16 14:33:09 CEST 2011


Author: alec
Date: 2011-06-16 07:33:09 -0500 (Thu, 16 Jun 2011)
New Revision: 4858

Modified:
   trunk/plugins/example_addressbook/example_addressbook.php
   trunk/plugins/example_addressbook/example_addressbook_backend.php
Log:
- Add get_name() method


Modified: trunk/plugins/example_addressbook/example_addressbook.php
===================================================================
--- trunk/plugins/example_addressbook/example_addressbook.php	2011-06-16 12:20:19 UTC (rev 4857)
+++ trunk/plugins/example_addressbook/example_addressbook.php	2011-06-16 12:33:09 UTC (rev 4858)
@@ -9,12 +9,13 @@
 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 @@
       $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;
   }
-  
+
 }

Modified: trunk/plugins/example_addressbook/example_addressbook_backend.php
===================================================================
--- trunk/plugins/example_addressbook/example_addressbook_backend.php	2011-06-16 12:20:19 UTC (rev 4857)
+++ trunk/plugins/example_addressbook/example_addressbook_backend.php	2011-06-16 12:33:09 UTC (rev 4858)
@@ -12,20 +12,27 @@
   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 @@
       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 at roundcube.net"));
-    
+
     return $this->result;
   }
 
@@ -74,7 +81,7 @@
     $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 @@
   {
      return false;
   }
-  
+
 }

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list