diff --git a/Changelog b/Changelog index 29dea1d..ff17756 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +v0.5 : +* able to work wit rouncube 0.9 to 1.3, including the 1.2 and 1.X releases, deprecating the rcmail usage + v0.4 : * Refresh contact list when editing a contact in collected addressbook and having on_edit_move_to_default set to true (#68) * Refresh contact list when copying a contact from collected addressbook and having on_edit_move_to_default set to true (Fix #69) diff --git a/INSTALL b/INSTALL index e5857fd..41a1101 100644 --- a/INSTALL +++ b/INSTALL @@ -3,10 +3,10 @@ Look at https://github.com/sblaisot/automatic_addressbook Installing automatic addressbook plugin --------------------------------------- -You need roundcube > 0.4 installed. +You need roundcube > 0.9 installed. -automatic_addressbook plugin version 0.2 has been tester against roundcube 0.5 and 0.6. -above versions have been tested against roundcube 0.8.0 and 0.8.1 with larry skin and mysql backend. +automatic_addressbook plugin version 0.2 has been tester against roundcube 0.9 + with larry skin and mysql backend. Download the latest version archive @@ -16,15 +16,13 @@ Download the latest version archive mv automatic_addressbook /plugins/ 2. Execute the relevant SQL/.initial.sql script on your database (process depends on your DB engine) - If your Roundcube Database starts with a prefix set the prefix also in the SQL Statement: "REFERENCES `PREFIX_users`(`user_id`)" + If your Roundcube Database starts with a prefix set the prefix also in create table also references table query sentences. 3. Add "automatic_addressbook" to the plugins list in /config/main.inc.php or /config/config.inc.php depending on your roundcube version, for example : $rcmail_config['plugins'] = array('automatic_addressbook',); -It works :) - Configuration ------------- @@ -37,9 +35,11 @@ You can customize some settings : Among others, you can choose if your users will have automatic_addressbook enabled or disabled by default (use_auto_abook option). -Upgrading roundcube to 0.6 +Olders roundcube up to 0.8 -------------------------- +you must use files before commit ca622de3364b996c655eea2e7724ce6e325e9b9d for older versions. + If you upgrade from roundcube 0.5 to 0.6, automatic addressbook plugin will continue to work : Be sure to use the last version of the plugin ; diff --git a/automatic_addressbook.php b/automatic_addressbook.php index 3a19716..f23747f 100755 --- a/automatic_addressbook.php +++ b/automatic_addressbook.php @@ -55,7 +55,7 @@ public function init() // use this address book for autocompletion queries - $config = rcmail::get_instance()->config; + $config = rcube::get_instance()->config; $sources = $config->get('autocomplete_addressbooks', array('sql')); if (!in_array($this->abook_id, $sources) && @@ -74,8 +74,8 @@ public function init() */ public function address_sources($p) { - $rcmail = rcmail::get_instance(); - if ($rcmail->config->get('use_auto_abook', true)) { + $rcube = rcube::get_instance(); + if ($rcube->config->get('use_auto_abook', true)) { $p['sources'][$this->abook_id] = array('id' => $this->abook_id, 'name' => rcube_utils::rep_specialchars_output($this->gettext('automaticallycollected')), @@ -93,10 +93,10 @@ public function address_sources($p) */ public function get_address_book($p) { - $rcmail = rcmail::get_instance(); - if (($p['id'] === $this->abook_id) && $rcmail->config->get('use_auto_abook', true)) { + $rcube = rcube::get_instance(); + if (($p['id'] === $this->abook_id) && $rcube->config->get('use_auto_abook', true)) { require_once dirname(__FILE__) . '/automatic_addressbook_backend.php'; - $p['instance'] = new automatic_addressbook_backend($rcmail->db, $rcmail->user->ID); + $p['instance'] = new automatic_addressbook_backend($rcube->db, $rcube->user->ID); $p['instance']->groups = false; } return $p; @@ -112,9 +112,9 @@ public function get_address_book($p) */ public function register_recipients($p) { - $rcmail = rcmail::get_instance(); + $rcube = rcube::get_instance(); - if (!$rcmail->config->get('use_auto_abook', true)) { + if (!$rcube->config->get('use_auto_abook', true)) { return; } @@ -136,7 +136,7 @@ public function register_recipients($p) } require_once dirname(__FILE__) . '/automatic_addressbook_backend.php'; - $CONTACTS = new automatic_addressbook_backend($rcmail->db, $rcmail->user->ID); + $CONTACTS = new automatic_addressbook_backend($rcube->db, $rcube->user->ID); foreach ($all_recipients as $recipient) { // Bcc and Cc can be empty @@ -156,10 +156,10 @@ public function register_recipients($p) * address book if it is not already in an addressbook, so we * first lookup in every address source. */ - $book_types = (array)$rcmail->config->get('autocomplete_addressbooks', 'sql'); + $book_types = (array)$rcube->config->get('autocomplete_addressbooks', 'sql'); foreach ($book_types as $id) { - $abook = $rcmail->get_address_book($id); + $abook = $rcube->get_address_book($id); $previous_entries = $abook->search('email', $contact['email'], false, false); if ($previous_entries->count) { @@ -167,7 +167,7 @@ public function register_recipients($p) } } if (!$previous_entries->count) { - $plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, + $plugin = $rcube->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => $this->abook_id)); if (!$plugin['abort']) { $CONTACTS->insert($contact, false); @@ -205,7 +205,7 @@ public function add_addressbook_category($args) public function settings_table($args) { if ($args['section'] == 'addressbook') { - $use_auto_abook = rcmail::get_instance()->config->get('use_auto_abook', true); + $use_auto_abook = rcube::get_instance()->config->get('use_auto_abook', true); $field_id = 'rcmfd_use_auto_abook'; $checkbox = new html_checkbox(array( @@ -218,7 +218,7 @@ public function settings_table($args) 'content' => $checkbox->show($use_auto_abook ? 1 : 0), ); - $use_auto_abook_for_completion = rcmail::get_instance()->config->get('use_auto_abook_for_completion', true); + $use_auto_abook_for_completion = rcube::get_instance()->config->get('use_auto_abook_for_completion', true); $field_id2 = 'rcmfd_use_auto_abook_for_completion'; $checkbox2 = new html_checkbox(array( 'name' => '_use_auto_abook_for_completion', @@ -242,10 +242,10 @@ public function settings_table($args) public function save_prefs($args) { if ($args['section'] == 'addressbook') { - $rcmail = rcmail::get_instance(); - $use_auto_abook = $rcmail->config->get('use_auto_abook'); + $rcube = rcube::get_instance(); + $use_auto_abook = $rcube->config->get('use_auto_abook'); $args['prefs']['use_auto_abook'] = isset($_POST['_use_auto_abook']) ? true : false; - $use_auto_abook_for_completion = $rcmail->config->get('use_auto_abook_for_completion'); + $use_auto_abook_for_completion = $rcube->config->get('use_auto_abook_for_completion'); $args['prefs']['use_auto_abook_for_completion'] = isset($_POST['_use_auto_abook_for_completion']) ? true : false; } return $args; @@ -260,24 +260,24 @@ public function save_prefs($args) */ public function handle_doubles($args) { - $rcmail = rcmail::get_instance(); - if (!$rcmail->config->get('use_auto_abook', true)) { + $rcube = rcube::get_instance(); + if (!$rcube->config->get('use_auto_abook', true)) { return $args; } - $moveto = $rcmail->config->get('on_edit_move_to_default'); + $moveto = $rcube->config->get('on_edit_move_to_default'); if ($args['source'] == $this->abook_id && !empty($args['id']) && $moveto) { - $args['source'] = $rcmail->config->get('default_addressbook'); - $plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $args['record'], + $args['source'] = $rcube->config->get('default_addressbook'); + $plugin = $rcube->plugins->exec_hook('contact_create', array('record' => $args['record'], 'source' => $args['source'])); if (!$plugin['abort']) { - $CONTACTS = $rcmail->get_address_book($args['source']); + $CONTACTS = $rcube->get_address_book($args['source']); $insert_id = $CONTACTS->insert($args['record'], false); } else { $insert_id = $plugin['result']; } - $rcmail->output->show_message('automatic_addressbook.contactmoved', 'confirmation'); - $rcmail->output->command('parent.list_contacts'); + $rcube->output->show_message('automatic_addressbook.contactmoved', 'confirmation'); + $rcube->output->command('parent.list_contacts'); return array('abort' => true, 'result' => $insert_id); } @@ -296,23 +296,23 @@ public function handle_doubles($args) foreach ($contact_emails as $contact_email) { if (!empty($contact_email)) { - $auto_abook = $rcmail->get_address_book($this->abook_id); + $auto_abook = $rcube->get_address_book($this->abook_id); $auto_abook->reset(); $collected_contact = $auto_abook->search('email', $contact_email, false, true); while ($record = $collected_contact->iterate()) { - $plugin = $rcmail->plugins->exec_hook('contact_delete', array('id' => $record['contact_id'], + $plugin = $rcube->plugins->exec_hook('contact_delete', array('id' => $record['contact_id'], 'source' => $this->abook_id)); if (!$plugin['abort']) { $auto_abook->delete($record['contact_id']); - $rcmail->output->show_message('automatic_addressbook.contactremoved', 'confirmation'); + $rcube->output->show_message('automatic_addressbook.contactremoved', 'confirmation'); } } } } - if ($rcmail->task == "addressbook" && - $rcmail->action == "copy" && + if ($rcube->task == "addressbook" && + $rcube->action == "copy" && $_REQUEST['_source'] == $this->abook_id) { - $rcmail->output->command('parent.list_contacts'); + $rcube->output->command('parent.list_contacts'); } } diff --git a/automatic_addressbook_backend.php b/automatic_addressbook_backend.php index afaa701..e24262a 100755 --- a/automatic_addressbook_backend.php +++ b/automatic_addressbook_backend.php @@ -17,6 +17,6 @@ class automatic_addressbook_backend extends rcube_contacts function __construct($dbconn, $user) { parent::__construct($dbconn, $user); - $this->db_name = rcmail::get_instance()->db->table_name('collected_contacts'); + $this->db_name = rcube::get_instance()->db->table_name('collected_contacts'); } } diff --git a/composer.json b/composer.json index ab9fb05..38332c4 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ "extra": { "roundcube": { - "min-version": "0.6.0", + "min-version": "0.9.0", "max-version": "10.21", "sql-dir": "SQL" }