diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-08-30 09:52:48 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-08-30 09:52:48 +0000 |
| commit | b850600c73fe8da5f1c8aaa0b31140c43dd348e8 (patch) | |
| tree | eb47c728466d2d208293eb5b56dd6ab88ab23754 /plugins/vcard_attachments | |
| parent | 77475c07839ce8fff72a4d00f8045888933cd43e (diff) | |
- Exec contact_create hook when adding contact via vcard_attachment (#1486964)
git-svn-id: https://svn.roundcube.net/trunk@3922 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/vcard_attachments')
| -rw-r--r-- | plugins/vcard_attachments/package.xml | 34 | ||||
| -rw-r--r-- | plugins/vcard_attachments/vcard_attachments.php | 26 |
2 files changed, 42 insertions, 18 deletions
diff --git a/plugins/vcard_attachments/package.xml b/plugins/vcard_attachments/package.xml index e10b4a84c..64a92defb 100644 --- a/plugins/vcard_attachments/package.xml +++ b/plugins/vcard_attachments/package.xml @@ -19,10 +19,10 @@ <email>alec@alec.pl</email> <active>yes</active> </lead> - <date>2010-04-28</date> - <time>12:00:00</time> + <date></date> + <time></time> <version> - <release>2.0</release> + <release></release> <api>2.0</api> </version> <stability> @@ -31,11 +31,7 @@ </stability> <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> <notes> -- 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 +- Exec contact_create hook when adding contact (#1486964) </notes> <contents> <dir baseinstalldir="/" name="/"> @@ -68,4 +64,26 @@ </required> </dependencies> <phprelease/> + <changelog> + <release> + <date>2010-04-28</date> + <time>12:00:00</time> + <version> + <release>2.0</release> + <api>2.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> + <notes> +- 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 + </notes> + </release> + </changelog> </package> diff --git a/plugins/vcard_attachments/vcard_attachments.php b/plugins/vcard_attachments/vcard_attachments.php index 4bf9accbb..a4c1795b7 100644 --- a/plugins/vcard_attachments/vcard_attachments.php +++ b/plugins/vcard_attachments/vcard_attachments.php @@ -31,7 +31,7 @@ class vcard_attachments extends rcube_plugin function message_load($p) { $this->message = $p['object']; - + // handle attachments vcard attachments foreach ((array)$this->message->attachments as $attachment) { if ($this->is_vcard($attachment)) { @@ -45,7 +45,7 @@ class vcard_attachments extends rcube_plugin $this->vcard_bodies[] = $part->mime_id; } } - + if ($this->vcard_parts) $this->add_texts('localization'); } @@ -69,13 +69,16 @@ class vcard_attachments extends rcube_plugin if (in_array($part, $this->vcard_bodies)) $p['content'] = ''; + $style = 'margin:0.5em 1em; padding:0.2em 0.5em; border:1px solid #999; ' + .'border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; width: auto'; + 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('style' => "margin:0.5em 1em; padding:0.2em 0.5em; border:1px solid #999; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; width: auto"), + $p['content'] .= html::p(array('style' => $style), html::a(array( 'href' => "#", 'onclick' => "return plugin_vcard_save_contact('".JQ($part.':'.$idx)."')", @@ -113,12 +116,12 @@ class vcard_attachments extends rcube_plugin } $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) { @@ -126,23 +129,26 @@ class vcard_attachments extends rcube_plugin } else { // add contact - $success = $contacts->insert(array( + $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 ($success) + 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(); } |
