From 48e9c14ebded89d858c8be0333f77f77a81b0877 Mon Sep 17 00:00:00 2001 From: thomascube Date: Sat, 31 Mar 2012 12:25:48 +0000 Subject: Move plugins repository into roundcubemail root folder; svn:externals are not defined anymore --- plugins/vcard_attachments/localization/cs_CZ.inc | 21 +++ plugins/vcard_attachments/localization/de_CH.inc | 7 + plugins/vcard_attachments/localization/de_DE.inc | 7 + plugins/vcard_attachments/localization/en_US.inc | 7 + plugins/vcard_attachments/localization/es_ES.inc | 7 + plugins/vcard_attachments/localization/et_EE.inc | 7 + plugins/vcard_attachments/localization/gl_ES.inc | 7 + plugins/vcard_attachments/localization/it_IT.inc | 7 + plugins/vcard_attachments/localization/ja_JP.inc | 20 +++ plugins/vcard_attachments/localization/pl_PL.inc | 7 + plugins/vcard_attachments/localization/pt_BR.inc | 7 + plugins/vcard_attachments/localization/ru_RU.inc | 7 + plugins/vcard_attachments/localization/sv_SE.inc | 7 + plugins/vcard_attachments/localization/zh_TW.inc | 7 + plugins/vcard_attachments/package.xml | 121 ++++++++++++++ plugins/vcard_attachments/skins/default/style.css | 17 ++ plugins/vcard_attachments/skins/default/vcard.png | Bin 0 -> 493 bytes .../skins/default/vcard_add_contact.png | Bin 0 -> 1361 bytes plugins/vcard_attachments/skins/larry/style.css | 21 +++ plugins/vcard_attachments/skins/larry/vcard.png | Bin 0 -> 493 bytes .../skins/larry/vcard_add_contact.png | Bin 0 -> 1859 bytes plugins/vcard_attachments/vcard_attachments.php | 185 +++++++++++++++++++++ plugins/vcard_attachments/vcardattach.js | 23 +++ 23 files changed, 492 insertions(+) create mode 100644 plugins/vcard_attachments/localization/cs_CZ.inc create mode 100644 plugins/vcard_attachments/localization/de_CH.inc create mode 100644 plugins/vcard_attachments/localization/de_DE.inc create mode 100644 plugins/vcard_attachments/localization/en_US.inc create mode 100644 plugins/vcard_attachments/localization/es_ES.inc create mode 100644 plugins/vcard_attachments/localization/et_EE.inc create mode 100644 plugins/vcard_attachments/localization/gl_ES.inc create mode 100644 plugins/vcard_attachments/localization/it_IT.inc create mode 100644 plugins/vcard_attachments/localization/ja_JP.inc create mode 100644 plugins/vcard_attachments/localization/pl_PL.inc create mode 100644 plugins/vcard_attachments/localization/pt_BR.inc create mode 100644 plugins/vcard_attachments/localization/ru_RU.inc create mode 100644 plugins/vcard_attachments/localization/sv_SE.inc create mode 100644 plugins/vcard_attachments/localization/zh_TW.inc create mode 100644 plugins/vcard_attachments/package.xml create mode 100644 plugins/vcard_attachments/skins/default/style.css create mode 100644 plugins/vcard_attachments/skins/default/vcard.png create mode 100644 plugins/vcard_attachments/skins/default/vcard_add_contact.png create mode 100644 plugins/vcard_attachments/skins/larry/style.css create mode 100644 plugins/vcard_attachments/skins/larry/vcard.png create mode 100644 plugins/vcard_attachments/skins/larry/vcard_add_contact.png create mode 100644 plugins/vcard_attachments/vcard_attachments.php create mode 100644 plugins/vcard_attachments/vcardattach.js (limited to 'plugins/vcard_attachments') diff --git a/plugins/vcard_attachments/localization/cs_CZ.inc b/plugins/vcard_attachments/localization/cs_CZ.inc new file mode 100644 index 000000000..11ae8c98f --- /dev/null +++ b/plugins/vcard_attachments/localization/cs_CZ.inc @@ -0,0 +1,21 @@ + | ++-----------------------------------------------------------------------+ + +*/ + +$labels = array(); +$labels['addvcardmsg'] = 'Přidat vCard do adresáře'; +$labels['vcardsavefailed'] = 'Nelze uložit vCard'; + +?> diff --git a/plugins/vcard_attachments/localization/de_CH.inc b/plugins/vcard_attachments/localization/de_CH.inc new file mode 100644 index 000000000..48bb90013 --- /dev/null +++ b/plugins/vcard_attachments/localization/de_CH.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/de_DE.inc b/plugins/vcard_attachments/localization/de_DE.inc new file mode 100644 index 000000000..48bb90013 --- /dev/null +++ b/plugins/vcard_attachments/localization/de_DE.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/en_US.inc b/plugins/vcard_attachments/localization/en_US.inc new file mode 100644 index 000000000..bce44d739 --- /dev/null +++ b/plugins/vcard_attachments/localization/en_US.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/es_ES.inc b/plugins/vcard_attachments/localization/es_ES.inc new file mode 100644 index 000000000..0aba6b391 --- /dev/null +++ b/plugins/vcard_attachments/localization/es_ES.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/et_EE.inc b/plugins/vcard_attachments/localization/et_EE.inc new file mode 100644 index 000000000..eb6ce230f --- /dev/null +++ b/plugins/vcard_attachments/localization/et_EE.inc @@ -0,0 +1,7 @@ + diff --git a/plugins/vcard_attachments/localization/gl_ES.inc b/plugins/vcard_attachments/localization/gl_ES.inc new file mode 100644 index 000000000..4c3574a8f --- /dev/null +++ b/plugins/vcard_attachments/localization/gl_ES.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/it_IT.inc b/plugins/vcard_attachments/localization/it_IT.inc new file mode 100644 index 000000000..55cde3961 --- /dev/null +++ b/plugins/vcard_attachments/localization/it_IT.inc @@ -0,0 +1,7 @@ + diff --git a/plugins/vcard_attachments/localization/ja_JP.inc b/plugins/vcard_attachments/localization/ja_JP.inc new file mode 100644 index 000000000..00467a885 --- /dev/null +++ b/plugins/vcard_attachments/localization/ja_JP.inc @@ -0,0 +1,20 @@ + | + +-----------------------------------------------------------------------+ + @version $Id$ +*/ + +$labels = array(); +$labels['addvcardmsg'] = 'vCardをアドレス帳に追加'; +$labels['vcardsavefailed'] = 'vCardを保存できませんでした。'; + diff --git a/plugins/vcard_attachments/localization/pl_PL.inc b/plugins/vcard_attachments/localization/pl_PL.inc new file mode 100644 index 000000000..800e35b38 --- /dev/null +++ b/plugins/vcard_attachments/localization/pl_PL.inc @@ -0,0 +1,7 @@ + diff --git a/plugins/vcard_attachments/localization/pt_BR.inc b/plugins/vcard_attachments/localization/pt_BR.inc new file mode 100644 index 000000000..263f88442 --- /dev/null +++ b/plugins/vcard_attachments/localization/pt_BR.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/ru_RU.inc b/plugins/vcard_attachments/localization/ru_RU.inc new file mode 100644 index 000000000..1688c5dc8 --- /dev/null +++ b/plugins/vcard_attachments/localization/ru_RU.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/sv_SE.inc b/plugins/vcard_attachments/localization/sv_SE.inc new file mode 100644 index 000000000..4c9faddf9 --- /dev/null +++ b/plugins/vcard_attachments/localization/sv_SE.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/localization/zh_TW.inc b/plugins/vcard_attachments/localization/zh_TW.inc new file mode 100644 index 000000000..361837bfc --- /dev/null +++ b/plugins/vcard_attachments/localization/zh_TW.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/plugins/vcard_attachments/package.xml b/plugins/vcard_attachments/package.xml new file mode 100644 index 000000000..066c908bf --- /dev/null +++ b/plugins/vcard_attachments/package.xml @@ -0,0 +1,121 @@ + + + vcard_attachments + pear.roundcube.net + vCard handler for Roundcube + This plugin detects vCard attachments/bodies and shows a button(s) to add them to address book + + Thomas Bruederli + thomasb + roundcube@gmail.com + yes + + + Aleksander Machniak + alec + alec@alec.pl + yes + + 2012-03-11 + + + 3.1-beta + 3.1-beta + + + stable + stable + + GNU GPLv3+ + +- Add styles for new skin "Larry" +- Exec contact_create hook when adding contact (#1486964) +- Make icons skinable +- Display vcard icon on messages list when message is of type vcard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.1 + + + 1.7.0 + + + + + + + 2010-04-28 + + + 2.0 + 2.0 + + + stable + stable + + GNU GPLv2 + +- Added support for Content-Type: text/directory; profile=vCard +- Added handler for message bodies of type vCard (#1486683) +- Added support for more than one vCard attachment/body +- Added support for more than one contact in one vCard file +- Created package.xml + + + + 2012-03-11 + + + 3.1 + 3.1 + + + stable + stable + + GNU GPLv3+ + + - Add styles for new skin "Larry" + + + + diff --git a/plugins/vcard_attachments/skins/default/style.css b/plugins/vcard_attachments/skins/default/style.css new file mode 100644 index 000000000..044d3983e --- /dev/null +++ b/plugins/vcard_attachments/skins/default/style.css @@ -0,0 +1,17 @@ + +p.vcardattachment { + margin: 0.5em 1em; + border: 1px solid #999; + border-radius:4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + width: auto; +} + +p.vcardattachment a { + display: block; + background: url(vcard_add_contact.png) 4px 0px no-repeat; + padding: 0.7em 0.5em 0.3em 42px; + height: 22px; +} diff --git a/plugins/vcard_attachments/skins/default/vcard.png b/plugins/vcard_attachments/skins/default/vcard.png new file mode 100644 index 000000000..8bf6b1b72 Binary files /dev/null and b/plugins/vcard_attachments/skins/default/vcard.png differ diff --git a/plugins/vcard_attachments/skins/default/vcard_add_contact.png b/plugins/vcard_attachments/skins/default/vcard_add_contact.png new file mode 100644 index 000000000..478c1f3f2 Binary files /dev/null and b/plugins/vcard_attachments/skins/default/vcard_add_contact.png differ diff --git a/plugins/vcard_attachments/skins/larry/style.css b/plugins/vcard_attachments/skins/larry/style.css new file mode 100644 index 000000000..eb70082ee --- /dev/null +++ b/plugins/vcard_attachments/skins/larry/style.css @@ -0,0 +1,21 @@ + +p.vcardattachment { + margin: 0.5em 1em; + width: auto; + background: #f9f9f9; + border: 1px solid #d3d3d3; + border-radius:4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + box-shadow: 0 0 2px #ccc; + -o-box-shadow: 0 0 2px #ccc; + -webkit-box-shadow: 0 0 2px #ccc; + -moz-box-shadow: 0 0 2px #ccc; +} + +p.vcardattachment a { + display: block; + background: url(vcard_add_contact.png) 6px 2px no-repeat; + padding: 1.2em 0.5em 0.7em 46px; +} diff --git a/plugins/vcard_attachments/skins/larry/vcard.png b/plugins/vcard_attachments/skins/larry/vcard.png new file mode 100644 index 000000000..8bf6b1b72 Binary files /dev/null and b/plugins/vcard_attachments/skins/larry/vcard.png differ diff --git a/plugins/vcard_attachments/skins/larry/vcard_add_contact.png b/plugins/vcard_attachments/skins/larry/vcard_add_contact.png new file mode 100644 index 000000000..a8ce459f8 Binary files /dev/null and b/plugins/vcard_attachments/skins/larry/vcard_add_contact.png differ diff --git a/plugins/vcard_attachments/vcard_attachments.php b/plugins/vcard_attachments/vcard_attachments.php new file mode 100644 index 000000000..c321e84aa --- /dev/null +++ b/plugins/vcard_attachments/vcard_attachments.php @@ -0,0 +1,185 @@ +action == 'show' || $rcmail->action == 'preview') { + $this->add_hook('message_load', array($this, 'message_load')); + $this->add_hook('template_object_messagebody', array($this, 'html_output')); + } + else if (!$rcmail->output->framed && (!$rcmail->action || $rcmail->action == 'list')) { + $icon = 'plugins/vcard_attachments/' .$this->local_skin_path(). '/vcard.png'; + $rcmail->output->set_env('vcard_icon', $icon); + $this->include_script('vcardattach.js'); + } + + $this->register_action('plugin.savevcard', array($this, 'save_vcard')); + } + + /** + * Check message bodies and attachments for vcards + */ + function message_load($p) + { + $this->message = $p['object']; + + // handle attachments vcard attachments + foreach ((array)$this->message->attachments as $attachment) { + if ($this->is_vcard($attachment)) { + $this->vcard_parts[] = $attachment->mime_id; + } + } + // the same with message bodies + foreach ((array)$this->message->parts as $idx => $part) { + if ($this->is_vcard($part)) { + $this->vcard_parts[] = $part->mime_id; + $this->vcard_bodies[] = $part->mime_id; + } + } + + if ($this->vcard_parts) + $this->add_texts('localization'); + } + + /** + * This callback function adds a box below the message content + * if there is a vcard attachment available + */ + function html_output($p) + { + $attach_script = false; + $icon = 'plugins/vcard_attachments/' .$this->local_skin_path(). '/vcard_add_contact.png'; + + foreach ($this->vcard_parts as $part) { + $vcards = rcube_vcard::import($this->message->get_part_content($part)); + + // successfully parsed vcards? + if (empty($vcards)) + continue; + + // remove part's body + if (in_array($part, $this->vcard_bodies)) + $p['content'] = ''; + + foreach ($vcards as $idx => $vcard) { + $display = $vcard->displayname; + if ($vcard->email[0]) + $display .= ' <'.$vcard->email[0].'>'; + + // add box below messsage body + $p['content'] .= html::p(array('class' => 'vcardattachment'), + html::a(array( + 'href' => "#", + 'onclick' => "return plugin_vcard_save_contact('" . JQ($part.':'.$idx) . "')", + 'title' => $this->gettext('addvcardmsg'), + ), + html::span(null, Q($display))) + ); + } + + $attach_script = true; + } + + if ($attach_script) { + $this->include_script('vcardattach.js'); + $this->include_stylesheet($this->local_skin_path() . '/style.css'); + } + + return $p; + } + + /** + * Handler for request action + */ + function save_vcard() + { + $this->add_texts('localization', true); + + $uid = get_input_value('_uid', RCUBE_INPUT_POST); + $mbox = get_input_value('_mbox', RCUBE_INPUT_POST); + $mime_id = get_input_value('_part', RCUBE_INPUT_POST); + + $rcmail = rcmail::get_instance(); + + if ($uid && $mime_id) { + list($mime_id, $index) = explode(':', $mime_id); + $part = $rcmail->storage->get_message_part($uid, $mime_id); + } + + $error_msg = $this->gettext('vcardsavefailed'); + + if ($part && ($vcards = rcube_vcard::import($part)) + && ($vcard = $vcards[$index]) && $vcard->displayname && $vcard->email) { + + $contacts = $rcmail->get_address_book(null, true); + + // check for existing contacts + $existing = $contacts->search('email', $vcard->email[0], true, false); + if ($existing->count) { + $rcmail->output->command('display_message', $this->gettext('contactexists'), 'warning'); + } + else { + // add contact + $contact = array( + 'name' => $vcard->displayname, + 'firstname' => $vcard->firstname, + 'surname' => $vcard->surname, + 'email' => $vcard->email[0], + 'vcard' => $vcard->export(), + ); + + $plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null)); + $contact = $plugin['record']; + + if (!$plugin['abort'] && ($done = $contacts->insert($contact))) + $rcmail->output->command('display_message', $this->gettext('addedsuccessfully'), 'confirmation'); + else + $rcmail->output->command('display_message', $error_msg, 'error'); + } + } + else + $rcmail->output->command('display_message', $error_msg, 'error'); + + $rcmail->output->send(); + } + + /** + * Checks if specified message part is a vcard data + * + * @param rcube_message_part Part object + * + * @return boolean True if part is of type vcard + */ + function is_vcard($part) + { + return ( + // Content-Type: text/vcard; + $part->mimetype == 'text/vcard' || + // Content-Type: text/x-vcard; + $part->mimetype == 'text/x-vcard' || + // Content-Type: text/directory; profile=vCard; + ($part->mimetype == 'text/directory' && ( + ($part->ctype_parameters['profile'] && + strtolower($part->ctype_parameters['profile']) == 'vcard') + // Content-Type: text/directory; (with filename=*.vcf) + || ($part->filename && preg_match('/\.vcf$/i', $part->filename)) + ) + ) + ); + } +} diff --git a/plugins/vcard_attachments/vcardattach.js b/plugins/vcard_attachments/vcardattach.js new file mode 100644 index 000000000..31df2468d --- /dev/null +++ b/plugins/vcard_attachments/vcardattach.js @@ -0,0 +1,23 @@ +/* + * vcard_attachments plugin script + * @version @package_version@ + */ +function plugin_vcard_save_contact(mime_id) +{ + var lock = rcmail.set_busy(true, 'loading'); + rcmail.http_post('plugin.savevcard', { _uid: rcmail.env.uid, _mbox: urlencode(rcmail.env.mailbox), _part: urlencode(mime_id) }, lock); + + return false; +} + +function plugin_vcard_insertrow(data) +{ + var ctype = data.row.ctype; + if (ctype == 'text/vcard' || ctype == 'text/x-vcard' || ctype == 'text/directory') { + $('#rcmrow'+data.uid+' > td.attachment').html(''); + } +} + +if (window.rcmail && rcmail.gui_objects.messagelist) { + rcmail.addEventListener('insertrow', function(data, evt) { plugin_vcard_insertrow(data); }); +} -- cgit v1.2.3