public function init() { self::$helper = new carddav_common('BACKEND: '); $this->add_hook('addressbooks_list', array($this, 'address_sources')); $this->add_hook('addressbook_get', array($this, 'get_address_book')); $this->add_hook('preferences_list', array($this, 'cd_preferences')); $this->add_hook('preferences_save', array($this, 'cd_save')); $this->add_hook('preferences_sections_list', array($this, 'cd_preferences_section')); $this->add_hook('login_after', array($this, 'init_presets')); if (!array_key_exists('user_id', $_SESSION)) { return; } // use this address book for autocompletion queries // (maybe this should be configurable by the user?) $config = rcmail::get_instance()->config; $sources = (array) $config->get('autocomplete_addressbooks', array('sql')); $dbh = rcmail::get_instance()->db; $sql_result = $dbh->query('SELECT id FROM ' . get_table_name('carddav_addressbooks') . ' WHERE user_id=? AND active=1', $_SESSION['user_id']); while ($abookrow = $dbh->fetch_assoc($sql_result)) { $abookname = "carddav_" . $abookrow['id']; if (!in_array($abookname, $sources)) { $sources[] = $abookname; } } $config->set('autocomplete_addressbooks', $sources); }
public function init() { $this->rc = rcmail::get_instance(); $tasks = explode('|', $this->task); // Since other plugins may also use the Sabre library // In order to avoid version conflicts between Sabre libraries // which might be used by other plugins // It is better to restrict the loading of Sabre library // under necessary tasks if (!in_array($this->rc->task, $tasks)) { return; } else { require_once 'carddav_backend.php'; require_once 'carddav_discovery.php'; require_once 'carddav_common.php'; } self::$helper = new carddav_common('BACKEND: '); $this->add_hook('addressbooks_list', array($this, 'address_sources')); $this->add_hook('addressbook_get', array($this, 'get_address_book')); $this->add_hook('preferences_list', array($this, 'cd_preferences')); $this->add_hook('preferences_save', array($this, 'cd_save')); $this->add_hook('preferences_sections_list', array($this, 'cd_preferences_section')); $this->add_hook('login_after', array($this, 'checkMigrations')); $this->add_hook('login_after', array($this, 'init_presets')); if (!array_key_exists('user_id', $_SESSION)) { return; } // use this address book for autocompletion queries // (maybe this should be configurable by the user?) $config = rcmail::get_instance()->config; $sources = (array) $config->get('autocomplete_addressbooks', array('sql')); $dbh = rcmail::get_instance()->db; $sql_result = $dbh->query('SELECT id FROM ' . get_table_name('carddav_addressbooks') . ' WHERE user_id=? AND active=1', $_SESSION['user_id']); while ($abookrow = $dbh->fetch_assoc($sql_result)) { $abookname = "carddav_" . $abookrow['id']; if (!in_array($abookname, $sources)) { $sources[] = $abookname; } } $config->set('autocomplete_addressbooks', $sources); }