|
|
|
@ -21,6 +21,7 @@ class vcard_attachments extends rcube_plugin
|
|
|
|
|
|
|
|
|
|
if ($rcmail->action == 'show' || $rcmail->action == 'preview') {
|
|
|
|
|
$this->add_hook('message_load', array($this, 'message_load'));
|
|
|
|
|
$this->add_hook('message_objects', array($this, 'message_objects'));
|
|
|
|
|
$this->add_hook('template_object_messagebody', array($this, 'html_output'));
|
|
|
|
|
}
|
|
|
|
|
else if ($rcmail->action == 'upload') {
|
|
|
|
@ -31,7 +32,7 @@ class vcard_attachments extends rcube_plugin
|
|
|
|
|
$btn_class = strpos($skin_path, 'classic') ? 'button' : 'listbutton';
|
|
|
|
|
|
|
|
|
|
$this->add_texts('localization', true);
|
|
|
|
|
$this->include_stylesheet($skin_path . '/style.css');
|
|
|
|
|
$this->include_stylesheet($skin_path . '/style.css', true);
|
|
|
|
|
$this->include_script('vcardattach.js');
|
|
|
|
|
$this->add_button(
|
|
|
|
|
array(
|
|
|
|
@ -46,8 +47,8 @@ class vcard_attachments extends rcube_plugin
|
|
|
|
|
'compose-contacts-toolbar');
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
$skin_path = $this->local_skin_path();
|
|
|
|
|
$this->include_stylesheet($skin_path . '/style.css', true);
|
|
|
|
|
$this->include_script('vcardattach.js');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -81,12 +82,13 @@ class vcard_attachments extends rcube_plugin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This callback function adds a box below the message content
|
|
|
|
|
* This callback function adds a box above the message content
|
|
|
|
|
* if there is a vcard attachment available
|
|
|
|
|
*/
|
|
|
|
|
function html_output($p)
|
|
|
|
|
function message_objects($p)
|
|
|
|
|
{
|
|
|
|
|
$attach_script = false;
|
|
|
|
|
$rcmail = rcmail::get_instance();
|
|
|
|
|
|
|
|
|
|
foreach ($this->vcard_parts as $part) {
|
|
|
|
|
$vcards = rcube_vcard::import($this->message->get_part_content($part, null, true));
|
|
|
|
@ -96,11 +98,6 @@ class vcard_attachments extends rcube_plugin
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// remove part's body
|
|
|
|
|
if (in_array($part, $this->vcard_bodies)) {
|
|
|
|
|
$p['content'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($vcards as $idx => $vcard) {
|
|
|
|
|
// skip invalid vCards
|
|
|
|
|
if (empty($vcard->email) || empty($vcard->email[0])) {
|
|
|
|
@ -108,15 +105,16 @@ class vcard_attachments extends rcube_plugin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$display = $vcard->displayname . ' <'.$vcard->email[0].'>';
|
|
|
|
|
$vid = rcube::JQ($part.':'.$idx);
|
|
|
|
|
|
|
|
|
|
// add box below message body
|
|
|
|
|
$p['content'] .= html::p(array('class' => 'vcardattachment'),
|
|
|
|
|
html::a(array(
|
|
|
|
|
'href' => "#",
|
|
|
|
|
'onclick' => "return plugin_vcard_save_contact('" . rcube::JQ($part.':'.$idx) . "')",
|
|
|
|
|
'title' => $this->gettext('addvcardmsg'),
|
|
|
|
|
),
|
|
|
|
|
html::span(null, rcube::Q($display)))
|
|
|
|
|
$p['content'][] = html::p(array('class' => 'vcardattachment aligned-buttons'),
|
|
|
|
|
html::span(null, rcube::Q($display)) .
|
|
|
|
|
html::tag('button', array(
|
|
|
|
|
'onclick' => "return plugin_vcard_save_contact('$vid')",
|
|
|
|
|
'title' => $this->gettext('addvcardmsg'),
|
|
|
|
|
'class' => 'import',
|
|
|
|
|
), rcube::Q($rcmail->gettext('import')))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -125,7 +123,23 @@ class vcard_attachments extends rcube_plugin
|
|
|
|
|
|
|
|
|
|
if ($attach_script) {
|
|
|
|
|
$this->include_script('vcardattach.js');
|
|
|
|
|
$this->include_stylesheet($this->local_skin_path() . '/style.css');
|
|
|
|
|
$this->include_stylesheet($this->local_skin_path() . '/style.css', true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This callback function removes message part's content
|
|
|
|
|
* for parts that are vcards
|
|
|
|
|
*/
|
|
|
|
|
function html_output($p)
|
|
|
|
|
{
|
|
|
|
|
foreach ($this->vcard_parts as $part) {
|
|
|
|
|
// remove part's body
|
|
|
|
|
if (in_array($part, $this->vcard_bodies)) {
|
|
|
|
|
$p['content'] = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $p;
|
|
|
|
|