diff --git a/CHANGELOG b/CHANGELOG index 18353c2..34c3a87 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ Roundcube Webmail GlobalAddressbook =================================== +Version 1.10 (2017-05-19, rc-1.0) +================================================= + * Add %i macro to get domain from default identity + Version 1.9 (2014-08-31, rc-1.0) ================================================= * Replace globaladdressbook_readonly option with globaladdressbook_perms diff --git a/composer.json b/composer.json index 05f124e..173fedd 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "http://github.com/JohnDoh/Roundcube-Plugin-Global-Address-Book/", "license": "GPL-3.0", "type": "roundcube-plugin", - "version": "1.9", + "version": "1.10", "authors": [ { "name": "Philip Weir", @@ -25,7 +25,7 @@ }, "extra": { "roundcube": { - "min-version": "1.0-beta" + "min-version": "1.0" } } } \ No newline at end of file diff --git a/config.inc.php.dist b/config.inc.php.dist index a4a4a2b..924df0a 100644 --- a/config.inc.php.dist +++ b/config.inc.php.dist @@ -7,6 +7,7 @@ // the name of the dummy user which holds the global address book, if the user does not exist it will be created // the name can contain the following macros that will be expanded as follows: // %d is replaced with the domain part of the username (if the username is an email address or default mail domain if not) +// %i is replaced with the domain part of the email address from the user's default identity // %h is replaced with the imap host (from the session info) // eg. to create one global address book per domain: global_addressbook@%d $config['globaladdressbook_user'] = '[global_addressbook_user]'; @@ -34,5 +35,3 @@ $config['globaladdressbook_autocomplete'] = true; // check globaladdressbook for known senders when displaying remote inline images $config['globaladdressbook_check_safe'] = true; - -?> \ No newline at end of file diff --git a/globaladdressbook.php b/globaladdressbook.php index 7f7bf59..cf67444 100644 --- a/globaladdressbook.php +++ b/globaladdressbook.php @@ -5,7 +5,6 @@ * * Plugin to add a global address book * - * @version @package_version@ * @author Philip Weir * * Copyright (C) 2009-2014 Philip Weir @@ -44,9 +43,7 @@ public function init() $this->load_config(); $this->add_texts('localization/'); - $this->user_name = $rcmail->config->get('globaladdressbook_user', '[global_addressbook_user]'); - $this->user_name = str_replace('%d', $rcmail->user->get_username('domain'), $this->user_name); - $this->user_name = str_replace('%h', $_SESSION['storage_host'], $this->user_name); + $this->user_name = globaladdressbook::parse_user($rcmail->config->get('globaladdressbook_user', '[global_addressbook_user]')); $this->groups = $rcmail->config->get('globaladdressbook_groups', false); $this->name = $this->gettext('globaladdressbook'); $this->_set_permissions(); @@ -121,6 +118,24 @@ public function check_known_senders($args) return $args; } + public static function parse_user($name) + { + $user = rcube::get_instance()->user; + + // %h - IMAP host + $h = $_SESSION['storage_host']; + // %d - domain name after the '@' from username + $d = $user->get_username('domain'); + // %i - domain name after the '@' from e-mail address of default identity + if (strpos($name, '%i') !== false) { + $user_ident = $user->list_emails(true); + list($local, $domain) = explode('@', $user_ident['email']); + $i = $domain; + } + + return str_replace(array('%h', '%d', '%i'), array($h, $d, $i), $name); + } + private function _set_permissions() { $rcmail = rcube::get_instance(); diff --git a/localization/cs_CZ.inc b/localization/cs_CZ.inc index 1002ab0..cd972df 100644 --- a/localization/cs_CZ.inc +++ b/localization/cs_CZ.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Globalní Adresář'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/de_CH.inc b/localization/de_CH.inc index 6ed2b47..8ce7fb6 100644 --- a/localization/de_CH.inc +++ b/localization/de_CH.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Allgemeines Adressbuch'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/de_DE.inc b/localization/de_DE.inc index 6ed2b47..8ce7fb6 100644 --- a/localization/de_DE.inc +++ b/localization/de_DE.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Allgemeines Adressbuch'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/en_GB.inc b/localization/en_GB.inc index c8bc6d7..20719e3 100644 --- a/localization/en_GB.inc +++ b/localization/en_GB.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Global Addresses'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/en_US.inc b/localization/en_US.inc index c8bc6d7..20719e3 100644 --- a/localization/en_US.inc +++ b/localization/en_US.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Global Addresses'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/es_AR.inc b/localization/es_AR.inc index 0686db7..87da2f0 100644 --- a/localization/es_AR.inc +++ b/localization/es_AR.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Direcciones globales'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/es_ES.inc b/localization/es_ES.inc index 54b0a75..2614e7b 100644 --- a/localization/es_ES.inc +++ b/localization/es_ES.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Direcciones globales'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/fr_FR.inc b/localization/fr_FR.inc index 8b47afd..5cb995c 100644 --- a/localization/fr_FR.inc +++ b/localization/fr_FR.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Adresses Globales'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/gl_ES.inc b/localization/gl_ES.inc index 334338e..c7d93a5 100644 --- a/localization/gl_ES.inc +++ b/localization/gl_ES.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Direccións globais'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/hu_HU.inc b/localization/hu_HU.inc index 1e084d6..986997a 100644 --- a/localization/hu_HU.inc +++ b/localization/hu_HU.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Globális címjegyzék'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/it_IT.inc b/localization/it_IT.inc index 8cfa2e7..9d114ca 100644 --- a/localization/it_IT.inc +++ b/localization/it_IT.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Indirizzi Globali'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/ja_JP.inc b/localization/ja_JP.inc index 18f319f..8d92198 100644 --- a/localization/ja_JP.inc +++ b/localization/ja_JP.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'グローバル・アドレス'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/nl_NL.inc b/localization/nl_NL.inc index 8510a30..74bb05d 100644 --- a/localization/nl_NL.inc +++ b/localization/nl_NL.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Globale adressen'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/pl_PL.inc b/localization/pl_PL.inc index 20a412a..082d193 100644 --- a/localization/pl_PL.inc +++ b/localization/pl_PL.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Globalne adresy'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/pt_BR.inc b/localization/pt_BR.inc index e8d5e1f..1127c60 100644 --- a/localization/pt_BR.inc +++ b/localization/pt_BR.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Contatos Globais'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/pt_PT.inc b/localization/pt_PT.inc index 816635b..1a6652b 100644 --- a/localization/pt_PT.inc +++ b/localization/pt_PT.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Endereços Globais'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/ro_RO.inc b/localization/ro_RO.inc index 37df135..bb18e0a 100644 --- a/localization/ro_RO.inc +++ b/localization/ro_RO.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Agendă globală'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/ru_RU.inc b/localization/ru_RU.inc index 385bc1a..db59571 100644 --- a/localization/ru_RU.inc +++ b/localization/ru_RU.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'Глобальные адреса'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/tr_TR.inc b/localization/tr_TR.inc index fb568d9..ac4e7f0 100644 --- a/localization/tr_TR.inc +++ b/localization/tr_TR.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = 'global adresler'; $messages = array(); - -?> \ No newline at end of file diff --git a/localization/zh_TW.inc b/localization/zh_TW.inc index 4e0f8f6..a44896f 100644 --- a/localization/zh_TW.inc +++ b/localization/zh_TW.inc @@ -5,5 +5,3 @@ $labels = array(); $labels['globaladdressbook'] = '公用通訊錄'; $messages = array(); - -?> \ No newline at end of file