- Applied fixes from trunk

pull/17/head
alecpl 12 years ago
parent 9456eacbec
commit ce6ece3ce0

@ -19,11 +19,11 @@
<email>alec@alec.pl</email>
<active>yes</active>
</lead>
<date>2012-03-11</date>
<time>19:00</time>
<date>2012-04-13</date>
<time>12:00</time>
<version>
<release>3.1-beta</release>
<api>3.1-beta</api>
<release>3.1</release>
<api>3.1</api>
</version>
<stability>
<release>stable</release>
@ -31,10 +31,11 @@
</stability>
<license uri="http://www.gnu.org/licenses/gpl.html">GNU GPLv3+</license>
<notes>
- 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
- Fixed doble urlencoding of vcard identifier
- Fixed encoding when default charset is different than vcard charset
- Improved vcards import to work as addressbook::import procedure (with validation and autofix)
- Support IDNA
- Import contacts to default addressbook
</notes>
<contents>
<dir baseinstalldir="/" name="/">
@ -117,5 +118,24 @@
- Add styles for new skin "Larry"
</notes>
</release>
<release>
<date>2012-03-11</date>
<time>19:00</time>
<version>
<release>3.1-beta</release>
<api>3.1-beta</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.gnu.org/licenses/gpl.html">GNU GPLv3+</license>
<notes>
- 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
</notes>
</release>
</changelog>
</package>

@ -66,7 +66,7 @@ class vcard_attachments extends rcube_plugin
$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));
$vcards = rcube_vcard::import($this->message->get_part_content($part, null, true));
// successfully parsed vcards?
if (empty($vcards))
@ -114,46 +114,59 @@ class vcard_attachments extends rcube_plugin
$mbox = get_input_value('_mbox', RCUBE_INPUT_POST);
$mime_id = get_input_value('_part', RCUBE_INPUT_POST);
$rcmail = rcmail::get_instance();
$rcmail = rcmail::get_instance();
$storage = $rcmail->get_storage();
$storage->set_folder($mbox);
if ($uid && $mime_id) {
list($mime_id, $index) = explode(':', $mime_id);
$part = $rcmail->storage->get_message_part($uid, $mime_id);
$part = $storage->get_message_part($uid, $mime_id, null, null, null, true);
}
$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');
&& ($vcard = $vcards[$index]) && $vcard->displayname && $vcard->email
) {
$CONTACTS = $this->get_address_book();
$email = $vcard->email[0];
$contact = $vcard->get_assoc();
$valid = true;
// skip entries without an e-mail address or invalid
if (empty($email) || !$CONTACTS->validate($contact, true)) {
$valid = false;
}
else {
// add contact
$contact = array(
'name' => $vcard->displayname,
'firstname' => $vcard->firstname,
'surname' => $vcard->surname,
'email' => $vcard->email[0],
'vcard' => $vcard->export(),
);
// We're using UTF8 internally
$email = rcube_idn_to_utf8($email);
// compare e-mail address
$existing = $CONTACTS->search('email', $email, 1, false);
// compare display name
if (!$existing->count && $vcard->displayname) {
$existing = $CONTACTS->search('name', $vcard->displayname, 1, false);
}
if ($existing->count) {
$rcmail->output->command('display_message', $this->gettext('contactexists'), 'warning');
$valid = false;
}
}
if ($valid) {
$plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null));
$contact = $plugin['record'];
if (!$plugin['abort'] && ($done = $contacts->insert($contact)))
if (!$plugin['abort'] && $CONTACTS->insert($contact))
$rcmail->output->command('display_message', $this->gettext('addedsuccessfully'), 'confirmation');
else
$rcmail->output->command('display_message', $error_msg, 'error');
}
}
else
else {
$rcmail->output->command('display_message', $error_msg, 'error');
}
$rcmail->output->send();
}
@ -182,4 +195,29 @@ class vcard_attachments extends rcube_plugin
)
);
}
/**
* Getter for default (writable) addressbook
*/
private function get_address_book()
{
if ($this->abook) {
return $this->abook;
}
$rcmail = rcmail::get_instance();
$abook = $rcmail->config->get('default_addressbook');
// Get configured addressbook
$CONTACTS = $rcmail->get_address_book($abook, true);
// Get first writeable addressbook if the configured doesn't exist
// This can happen when user deleted the addressbook (e.g. Kolab folder)
if ($abook === null || $abook === '' || !is_object($CONTACTS)) {
$source = reset($rcmail->get_address_sources(true));
$CONTACTS = $rcmail->get_address_book($source['id'], true);
}
return $this->abook = $CONTACTS;
}
}

@ -5,8 +5,8 @@
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);
rcmail.http_post('plugin.savevcard', { _uid: rcmail.env.uid, _mbox: rcmail.env.mailbox, _part: mime_id }, lock);
return false;
}

@ -164,11 +164,13 @@ class rcube_message
/**
* Get content of a specific part of this message
*
* @param string $mime_id Part MIME-ID
* @param resource $fp File pointer to save the message part
* @param string $mime_id Part MIME-ID
* @param resource $fp File pointer to save the message part
* @param boolean $skip_charset_conv Disables charset conversion
*
* @return string Part content
*/
public function get_part_content($mime_id, $fp=NULL)
public function get_part_content($mime_id, $fp = null, $skip_charset_conv = false)
{
if ($part = $this->mime_parts[$mime_id]) {
// stored in message structure (winmail/inline-uuencode)
@ -179,7 +181,7 @@ class rcube_message
return $fp ? true : $part->body;
}
// get from IMAP
return $this->storage->get_message_part($this->uid, $mime_id, $part, NULL, $fp);
return $this->storage->get_message_part($this->uid, $mime_id, $part, NULL, $fp, $skip_charset_conv);
} else
return null;
}

@ -475,10 +475,10 @@ a.iconbutton.threadmode.selected {
}
#messagelist tbody tr td.attachment span.attachment {
background-position: 0 -998px;
background-position: 0 -996px;
}
#messagelist thead tr td.attachment span.attachment {
background-position: -24px -997px;
background-position: -24px -996px;
}
#messagelist tr td.priority {

Loading…
Cancel
Save