Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working with RC 1.3, 1.2, 1.X and 0.9 by deprecating the rcmail usage #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v0.5 :
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not include version release information in your PR as you don't know how it will be named (could be 1.0 or 0.4.1). Prefere using unreleased: here, I will name it when releasing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well there's no problem! always you can override by a new commit by yourselft.. that's all

* 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)
Expand Down
14 changes: 7 additions & 7 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tester -> tested.
Please do not update this one concerning automatic_addressbook v0.2 (an old version) or remove it completely

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as i said.. can you merged and later just updated by yourselft? can you explain me more in detail?

with larry skin and mysql backend.

Download the latest version archive

Expand All @@ -16,15 +16,13 @@ Download the latest version archive
mv automatic_addressbook <path_to_roundcube>/plugins/

2. Execute the relevant SQL/<db engine>.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
<path_to_roundcube>/config/main.inc.php or <path_to_roundcube>/config/config.inc.php depending on your roundcube version, for example :

$rcmail_config['plugins'] = array('automatic_addressbook',);

It works :)


Configuration
-------------
Expand All @@ -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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer reference to plugin version rather than commit id

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i used commit due that commit included some changes! lasted older version still have minor issues that i'm working on


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 ;
Expand Down
62 changes: 31 additions & 31 deletions automatic_addressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand All @@ -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')),
Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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
Expand All @@ -156,18 +156,18 @@ 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) {
break;
}
}
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);
Expand Down Expand Up @@ -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(
Expand All @@ -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',
Expand All @@ -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;
Expand All @@ -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);
}

Expand All @@ -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');
}
}

Expand Down
2 changes: 1 addition & 1 deletion automatic_addressbook_backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"extra":
{
"roundcube": {
"min-version": "0.6.0",
"min-version": "0.9.0",
"max-version": "10.21",
"sql-dir": "SQL"
}
Expand Down
14 changes: 10 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@ Aims to reproduce the similar features of thunderbird or gmail.</description>
<date>2012-11-06</date>
<time>23:08:19</time>
<version>
<release>0.4</release>
<api>0.4</api>
<release>0.5</release>
<api>0.5</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.gnu.org/licenses/gpl-3.0.html">GNU GPLv3+</license>
<notes>
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)
Expand Down Expand Up @@ -130,8 +133,8 @@ v0.2 and before :
<changelog>
<release>
<version>
<release>0.4</release>
<api>0.4</api>
<release>0.5</release>
<api>0.5</api>
</version>
<stability>
<release>stable</release>
Expand All @@ -140,6 +143,9 @@ v0.2 and before :
<date>2012-11-06</date>
<license uri="http://www.gnu.org/licenses/gpl-3.0.html">GNU GPLv3+</license>
<notes>
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)
Expand Down