diff --git a/recipient_to_contact/CHANGELOG b/recipient_to_contact/CHANGELOG index 6bd6e20..8b00058 100644 --- a/recipient_to_contact/CHANGELOG +++ b/recipient_to_contact/CHANGELOG @@ -1,5 +1,17 @@ Recipient To Contact Changelog: +Release 0.3.2 +============================== +- Added configuration to not show recipients in the same domain as + the current user's identity domain + +Release 0.3.1 +============================== +- Bugfix: only list writeable addressbooks +- Added pt_BR language support +- Added translation in 'Close' and 'Save' buttons in dialog +- TODO: translate 2 new strings - done only in en_US, en_GB and pt_BR + Release 0.3 ============================== - New maintainer (and first release in over 2 years, sorry). diff --git a/recipient_to_contact/README.md b/recipient_to_contact/README.md new file mode 100644 index 0000000..8be0f2d --- /dev/null +++ b/recipient_to_contact/README.md @@ -0,0 +1,47 @@ +# Roundcube Recipient To Contact Plugin + +## About + +Recipient To Contact is a plugin to quickly add new contacts to address books. When sending an email to recipients that aren't in the address book, this plugin displays a form to quickly save these contacts. Inspired by Automatic Addressbook plugin. + +Features: + + * Simple jQuery UI based interface. + * Parses 'To:', 'Cc:' and 'Bcc:' and automatically fills name and email address fields. + * Configurable: which address books to use for searching; default behavior; etc. + * Can be activated/deactivated through User Preferences section. + * Advanced error handling. + +## Requirements + +1. Plugin is maintained against Roundcube 0.7 and later. +2. jQuery UI plugin is required, which can be obtained from [http://underwa.ter.net/roundcube-plugins]() or [http://myroundcube.googlecode.com](). + +## Installation + +1. Download latest stable release from GitHub. +2. Extract the downloaded archive, and place the `recipient_to_contact` directory in `plugins/` folder. +3. Add `recipient_to_contact` to `$rcmail_config['plugins']` in your Roundcube config. + +## Configuration + +The default config file is `plugins/recipient_to_contact/config.inc.php.dist`. +Rename this to `plugins/recipient_to_contact/config.inc.php` and edit it there. + +Configuration options: + +`recipient_to_contact_addressbooks` + +A list of address book IDs, which would be used for searching existing contacts. For example, if it contains `array('sql', 'global', 'ldap')` the plugin will look for existing contacts only in these address books. The default (an empty array) means the plugin will use address books specified in the `autocomplete_addressbooks` option in the Roundcube configuration file. + +`recipient_to_contact_enabled_by_default` + +Whether the plugin is enabled or disabled for users by default. If set to true, the plugin is enabled and users can disable it through settings menu. + +`recipient_to_contact_use_groups` + +Whether to enable contact groups (and show the UI for selecting them) or not. Defaults to false. + +## License + +This plugin is distributed under the GPLv3 license. Please see http://www.gnu.org/licenses/gpl-3.0.txt for the complete license. \ No newline at end of file diff --git a/recipient_to_contact/config/config.inc.php.dist b/recipient_to_contact/config/config.inc.php.dist index 68d1ee3..cbb05dc 100644 --- a/recipient_to_contact/config/config.inc.php.dist +++ b/recipient_to_contact/config/config.inc.php.dist @@ -19,4 +19,12 @@ $rcmail_config['recipient_to_contact_enabled_by_default'] = true; * * If set to true, the contact group dropdown is shown in the dialog. */ -$rcmail_config['recipient_to_contact_use_groups'] = false; \ No newline at end of file +$rcmail_config['recipient_to_contact_use_groups'] = true; + +/** + * Whether show recipients with same domain as current identity + * + * If set to true, will show all recipients, regardless of their domain + * If set to false, will skip recipients that have same domain as current identity + */ +$rcmail_config['recipient_to_contact_same_domain'] = false; \ No newline at end of file diff --git a/recipient_to_contact/localization/de_DE.inc b/recipient_to_contact/localization/de_DE.inc index 224f45d..cf619e8 100644 --- a/recipient_to_contact/localization/de_DE.inc +++ b/recipient_to_contact/localization/de_DE.inc @@ -14,6 +14,8 @@ $labels['dialog_contact_surname'] = 'Nachname'; $labels['dialog_contact_addressbook'] = 'Adressbuch:'; $labels['dialog_contact_group'] = 'Gruppe: '; $labels['dialog_email'] = 'E-Mail-Adresse'; +$labels['dialog_close_button'] = 'Close'; +$labels['dialog_save_button'] = 'Save'; // various response messages $labels['response_name_empty'] = 'Bitte geben Sie einen Kontaktnamen ein'; diff --git a/recipient_to_contact/localization/en_GB.inc b/recipient_to_contact/localization/en_GB.inc index 6e2d025..74468d2 100644 --- a/recipient_to_contact/localization/en_GB.inc +++ b/recipient_to_contact/localization/en_GB.inc @@ -14,6 +14,8 @@ $labels['dialog_contact_surname'] = 'Surname'; $labels['dialog_contact_addressbook'] = 'Address Book'; $labels['dialog_contact_group'] = 'Group'; $labels['dialog_email'] = 'Email Address'; +$labels['dialog_close_button'] = 'Close'; +$labels['dialog_save_button'] = 'Save'; // various response messages $labels['response_name_empty'] = 'Please enter a contact name'; diff --git a/recipient_to_contact/localization/en_US.inc b/recipient_to_contact/localization/en_US.inc index 19a10c1..c20d7d8 100644 --- a/recipient_to_contact/localization/en_US.inc +++ b/recipient_to_contact/localization/en_US.inc @@ -14,6 +14,8 @@ $labels['dialog_contact_surname'] = 'Surname'; $labels['dialog_contact_addressbook'] = 'Addressbook:'; $labels['dialog_contact_group'] = 'Group: '; $labels['dialog_email'] = 'Email address'; +$labels['dialog_close_button'] = 'Close'; +$labels['dialog_save_button'] = 'Save'; // various response messages $labels['response_name_empty'] = 'Please enter a contact name'; diff --git a/recipient_to_contact/localization/it_IT.inc b/recipient_to_contact/localization/it_IT.inc index 05ac3ff..963997d 100644 --- a/recipient_to_contact/localization/it_IT.inc +++ b/recipient_to_contact/localization/it_IT.inc @@ -14,6 +14,8 @@ $labels['dialog_contact_surname'] = 'Cognome'; $labels['dialog_contact_addressbook'] = 'Rubrica:'; $labels['dialog_contact_group'] = 'Gruppo:'; $labels['dialog_email'] = 'Email'; +$labels['dialog_close_button'] = 'Close'; +$labels['dialog_save_button'] = 'Save'; // various response messages $labels['response_name_empty'] = 'Inserisci un \'nome visualizzato\''; diff --git a/recipient_to_contact/localization/pt_BR.inc b/recipient_to_contact/localization/pt_BR.inc new file mode 100644 index 0000000..c49d7f3 --- /dev/null +++ b/recipient_to_contact/localization/pt_BR.inc @@ -0,0 +1,25 @@ + * Gianfelice Catini * Mat Gadd + * Eliton Claus * @copyright 2009-2013 Namesco Limited + * 2016 Eliton Claus * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 License */ @@ -23,6 +25,7 @@ * @author Vladimir Minakov * Gianfelice Catini * Mat Gadd + * Eliton Claus */ class recipient_to_contact extends rcube_plugin { @@ -95,14 +98,15 @@ public function init() // fetch addressbook sources. If no addressbooks set in the config file, use the same addressbooks // configured for autocompletition - $enabled_addressbooks = $this->rcmail->config->get('recipient_to_contact_addressbooks'); - if (empty($enabled_addressbooks)) { - $this->addressbooks = $this->get_addressbooks( - $this->rcmail->config->get('autocomplete_addressbooks')); - } else { - $this->addressbooks = $this->get_addressbooks($enabled_addressbooks); - } - } + $enabled_addressbooks = $this->rcmail->config->get('recipient_to_contact_addressbooks'); + if (empty($enabled_addressbooks)) { + // get only writeable addressbooks + $this->addressbooks = $this->get_addressbooks($this->rcmail->config->get('autocomplete_addressbooks'), true); + } else { + // get only writeable addressbooks + $this->addressbooks = $this->get_addressbooks($enabled_addressbooks, true); + } + } // hooks for preferences section $this->add_hook('preferences_list', array($this, 'prefs_content')); @@ -121,6 +125,8 @@ public function init() */ public function check_recipients($args) { + $rcmail = rcmail::get_instance(); + // don't process the sent message, if it's a 'Read Receipt' response if (isset($args['headers']['Content-Type']) && strpos($args['headers']['Content-Type'], 'report-type=disposition-notification') !== false) { @@ -145,7 +151,28 @@ public function check_recipients($args) foreach ($recipients as $recipient) { // flag to denote if the current recipient doesn't exist in any of the address books $is_new_contact = true; - + + // if we dont want to list users in same domain as us for some reason + // example: globaladdressbook plugin with all domain users inside + if (!$this->rcmail->config->get('recipient_to_contact_addressbooks')) { + // get current recipient domain + $recipient_domain = preg_replace ('/^[^@]*@(.*)$/', '$1', $recipient['mailto']); + // get identity used to send email + $identity = $rcmail->user->get_identity(); + // get current identity domain + $identity_domain = preg_replace ('/^[^@]*@(.*)$/', '$1', $identity['email']); + + // check if recipient domain match with this identify domain + // if match, continue loop and ignore recipient + if ($recipient_domain == $identity_domain) { + unset($recipient_domain); + unset($identity); + unset($identity_domain); + $is_new_contact = false; + continue; + } + } + // interate over over address books and search for a contact with the same email address foreach ($this->addressbooks as $abook_id => $address_source) { $address_book = $this->rcmail->get_address_book($abook_id); @@ -229,14 +256,14 @@ public function save_contacts() // visualization name cannot be empty if (empty($contact['_name'])) { $response[$key]['status'] = 'fail'; - $response[$key]['message'] = Q($this->gettext('response_name_empty')); + $response[$key]['message'] = rcube::Q($this->gettext('response_name_empty')); continue; } // email should be valid if (!check_email($contact['_email'], false)) { $response[$key]['status'] = 'fail'; - $response[$key]['message'] = Q($this->gettext('response_email_invalid')); + $response[$key]['message'] = rcube::Q($this->gettext('response_email_invalid')); continue; } @@ -248,7 +275,7 @@ public function save_contacts() 'firstname' => $contact['_firstname'], 'surname' => $contact['_surname'])); if ($id == false) { $response[$key]['status'] = 'fail'; - $response[$key]['message'] = Q($this->gettext('response_server_error')); + $response[$key]['message'] = rcube::Q($this->gettext('response_server_error')); continue; } @@ -260,7 +287,7 @@ public function save_contacts() // all ok $response[$key]['status'] = 'ok'; - $response[$key]['message'] = Q($this->gettext('response_confirm')); + $response[$key]['message'] = rcube::Q($this->gettext('response_confirm')); } // return reponse to client @@ -294,16 +321,17 @@ public function prefs_content($args) 'style' => 'margin-left: -300px') ); - $args['blocks']['recipienttocontact']['options']['description'] = array( - 'title' => html::div(null, Q($this->gettext('prefs_descr'))) . html::br(), - 'content' => '' - ); - - $args['blocks']['recipienttocontact']['name'] = $this->gettext('prefs_title'); + $args['blocks']['recipienttocontact']['name'] = rcube::Q($this->gettext('prefs_title')); $args['blocks']['recipienttocontact']['options']['use_subscriptions'] = array( - 'title' => html::label($field_id, Q($this->gettext('prefs_option'))), - 'content' => $checkbox->show($use_recipienttocontact ? 1 : 0), + 'title' => html::label($field_id, rcube::Q($this->gettext('prefs_option'))), + 'content' => $checkbox->show($use_recipienttocontact ? 1 : 0) + ); + + $args['blocks']['recipienttocontact']['options']['description'] = array( + 'title' => html::div(null, rcube::Q($this->gettext('prefs_descr'))) . html::br(), + 'content' => '' ); + } return $args; @@ -320,7 +348,7 @@ public function prefs_section_link($args) { $args['list']['recipienttocontact'] = array( 'id' => 'recipienttocontact', - 'section' => Q($this->gettext('prefs_title')) + 'section' => rcube::Q($this->gettext('prefs_title')) ); return $args; @@ -360,7 +388,7 @@ public function prefs_save($args) * * @return array Addressbooks sources. */ - protected function get_addressbooks(array $ids, $writable = false) + protected function get_addressbooks(array $ids, $writable = true) { $ids = array_flip($ids); @@ -369,7 +397,7 @@ protected function get_addressbooks(array $ids, $writable = false) unset($ids['sql']); $ids[0] = 0; } - $all_addresbooks = $this->rcmail->get_address_sources(); + $all_addresbooks = $this->rcmail->get_address_sources($writable); // return standard output from get_address_sources including only addressbooks specified in $ids return array_intersect_key($all_addresbooks, $ids);