Changeset 4197 in subversion
- Timestamp:
- Nov 8, 2010 6:17:28 PM (3 years ago)
- Location:
- trunk/plugins/kolab_addressbook
- Files:
-
- 2 edited
-
kolab_addressbook.php (modified) (4 diffs)
-
rcube_kolab_contacts.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/kolab_addressbook/kolab_addressbook.php
r4134 r4197 17 17 class kolab_addressbook extends rcube_plugin 18 18 { 19 private $abook_id = 'kolab'; 20 private $abook; 21 19 private $kolab; 20 private $folders; 21 private $sources; 22 22 23 /** 23 24 * Required startup method of a Roundcube plugin … … 32 33 $this->add_hook('imap_init', array($this, 'imap_init')); 33 34 34 // use this address book for autocompletion queries35 $config = rcmail::get_instance()->config;36 $sources = (array) $config->get('autocomplete_addressbooks', array('sql'));37 if (!in_array($this->abook_id, $sources)) {38 $sources[] = $this->abook_id;39 $config->set('autocomplete_addressbooks', $sources);40 }41 42 35 // extend include path to load bundled Horde classes 43 36 $include_path = $this->home . '/lib' . PATH_SEPARATOR . ini_get('include_path'); … … 56 49 public function address_sources($p) 57 50 { 58 // get single instance (for now) 59 $abook = rcube_kolab_contacts::singleton(); 60 61 // maybe here we'll add more than one item 62 $p['sources'][$this->abook_id] = array( 63 'id' => $this->abook_id, 64 'name' => 'Kolab', 65 'readonly' => $abook->readonly, 66 'groups' => $abook->groups, 67 ); 51 // setup Kolab backend 52 rcube_kolab::setup(); 53 54 // get all folders that have "contact" type 55 $this->kolab = Kolab_List::singleton(); 56 $this->folders = $this->kolab->getByType('contact'); 57 58 if (PEAR::isError($this->folders)) { 59 raise_error(array( 60 'code' => 600, 'type' => 'php', 61 'file' => __FILE__, 'line' => __LINE__, 62 'message' => "Failed to list contact folders from Kolab server:" . $this->folders->getMessage()), 63 true, false); 64 } 65 else { 66 foreach ($this->folders as $c_folder) { 67 // create instance of rcube_contacts 68 $abook_id = strtolower(asciiwords(strtr($c_folder->name, '/', '-'))); 69 $abook = new rcube_kolab_contacts($c_folder->name); 70 $this->sources[$abook_id] = $abook; 71 72 // register this address source 73 $p['sources'][$abook_id] = array( 74 'id' => $abook_id, 75 'name' => $c_folder->name, 76 'readonly' => $abook->readonly, 77 'groups' => $abook->groups, 78 ); 79 } 80 } 81 68 82 return $p; 69 83 } … … 75 89 public function get_address_book($p) 76 90 { 77 if ($ p['id'] === $this->abook_id) {78 $p['instance'] = rcube_kolab_contacts::singleton();91 if ($this->sources[$p['id']]) { 92 $p['instance'] = $this->sources[$p['id']]; 79 93 } 80 94 -
trunk/plugins/kolab_addressbook/rcube_kolab_contacts.php
r4134 r4197 29 29 private $result; 30 30 private $imap_folder = 'INBOX/Contacts'; 31 32 33 /** 34 * Singleton getter 35 */ 36 public static function singleton() 37 { 38 if (!self::$instance) 39 self::$instance = new rcube_kolab_contacts; 40 return self::$instance; 41 } 42 43 44 public function __construct() 45 { 46 // setup Kolab backend 47 rcube_kolab::setup(); 48 49 // fetch objects from Cotnacts folder 31 32 33 public function __construct($imap_folder = null) 34 { 35 if ($imap_folder) 36 $this->imap_folder = $imap_folder; 37 38 // fetch objects from Contacts folder 50 39 $this->_kolab = Kolab_List::singleton(); 51 40 $this->_folder = $this->_kolab->getFolder($this->imap_folder);
Note: See TracChangeset
for help on using the changeset viewer.
