Changeset ce6ece3 in github


Ignore:
Timestamp:
Apr 15, 2012 4:22:07 AM (13 months ago)
Author:
alecpl <alec@…>
Branches:
release-0.8
Children:
f7ae899
Parents:
9456eac
Message:
  • Applied fixes from trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/vcard_attachments/package.xml

    r48e9c14 rce6ece3  
    2020                <active>yes</active> 
    2121        </lead> 
    22         <date>2012-03-11</date> 
    23         <time>19:00</time> 
     22        <date>2012-04-13</date> 
     23        <time>12:00</time> 
    2424        <version> 
    25                 <release>3.1-beta</release> 
    26                 <api>3.1-beta</api> 
     25                <release>3.1</release> 
     26                <api>3.1</api> 
    2727        </version> 
    2828        <stability> 
     
    3232        <license uri="http://www.gnu.org/licenses/gpl.html">GNU GPLv3+</license> 
    3333        <notes> 
    34 - Add styles for new skin "Larry" 
    35 - Exec contact_create hook when adding contact (#1486964) 
    36 - Make icons skinable 
    37 - Display vcard icon on messages list when message is of type vcard 
     34- Fixed doble urlencoding of vcard identifier 
     35- Fixed encoding when default charset is different than vcard charset 
     36- Improved vcards import to work as addressbook::import procedure (with validation and autofix) 
     37- Support IDNA 
     38- Import contacts to default addressbook 
    3839        </notes> 
    3940        <contents> 
     
    118119                        </notes> 
    119120                </release> 
     121        <release> 
     122                <date>2012-03-11</date> 
     123                <time>19:00</time> 
     124                <version> 
     125                        <release>3.1-beta</release> 
     126                        <api>3.1-beta</api> 
     127                </version> 
     128                <stability> 
     129                        <release>stable</release> 
     130                        <api>stable</api> 
     131                </stability> 
     132                <license uri="http://www.gnu.org/licenses/gpl.html">GNU GPLv3+</license> 
     133                <notes> 
     134- Add styles for new skin "Larry" 
     135- Exec contact_create hook when adding contact (#1486964) 
     136- Make icons skinable 
     137- Display vcard icon on messages list when message is of type vcard 
     138                </notes> 
     139            </release> 
    120140        </changelog> 
    121141</package> 
  • plugins/vcard_attachments/vcard_attachments.php

    r48e9c14 rce6ece3  
    6767 
    6868        foreach ($this->vcard_parts as $part) { 
    69             $vcards = rcube_vcard::import($this->message->get_part_content($part)); 
     69            $vcards = rcube_vcard::import($this->message->get_part_content($part, null, true)); 
    7070 
    7171            // successfully parsed vcards? 
     
    115115        $mime_id = get_input_value('_part', RCUBE_INPUT_POST); 
    116116 
    117         $rcmail = rcmail::get_instance(); 
     117        $rcmail  = rcmail::get_instance(); 
     118        $storage = $rcmail->get_storage(); 
     119        $storage->set_folder($mbox); 
    118120 
    119121        if ($uid && $mime_id) { 
    120122            list($mime_id, $index) = explode(':', $mime_id); 
    121             $part = $rcmail->storage->get_message_part($uid, $mime_id); 
     123            $part = $storage->get_message_part($uid, $mime_id, null, null, null, true); 
    122124        } 
    123125 
     
    125127 
    126128        if ($part && ($vcards = rcube_vcard::import($part)) 
    127             && ($vcard = $vcards[$index]) && $vcard->displayname && $vcard->email) { 
    128  
    129             $contacts = $rcmail->get_address_book(null, true); 
    130  
    131             // check for existing contacts 
    132             $existing = $contacts->search('email', $vcard->email[0], true, false); 
    133             if ($existing->count) { 
    134                 $rcmail->output->command('display_message', $this->gettext('contactexists'), 'warning'); 
     129            && ($vcard = $vcards[$index]) && $vcard->displayname && $vcard->email 
     130        ) { 
     131            $CONTACTS = $this->get_address_book(); 
     132            $email    = $vcard->email[0]; 
     133            $contact  = $vcard->get_assoc(); 
     134            $valid    = true; 
     135 
     136            // skip entries without an e-mail address or invalid 
     137            if (empty($email) || !$CONTACTS->validate($contact, true)) { 
     138                $valid = false; 
    135139            } 
    136140            else { 
    137                 // add contact 
    138                 $contact = array( 
    139                     'name'      => $vcard->displayname, 
    140                     'firstname' => $vcard->firstname, 
    141                     'surname'   => $vcard->surname, 
    142                     'email'     => $vcard->email[0], 
    143                     'vcard'     => $vcard->export(), 
    144                 ); 
    145  
     141                // We're using UTF8 internally 
     142                $email = rcube_idn_to_utf8($email); 
     143 
     144                // compare e-mail address 
     145                $existing = $CONTACTS->search('email', $email, 1, false); 
     146                // compare display name 
     147                if (!$existing->count && $vcard->displayname) { 
     148                    $existing = $CONTACTS->search('name', $vcard->displayname, 1, false); 
     149                } 
     150 
     151                if ($existing->count) { 
     152                    $rcmail->output->command('display_message', $this->gettext('contactexists'), 'warning'); 
     153                    $valid = false; 
     154                } 
     155            } 
     156 
     157            if ($valid) { 
    146158                $plugin = $rcmail->plugins->exec_hook('contact_create', array('record' => $contact, 'source' => null)); 
    147159                $contact = $plugin['record']; 
    148160 
    149                 if (!$plugin['abort'] && ($done = $contacts->insert($contact))) 
     161                if (!$plugin['abort'] && $CONTACTS->insert($contact)) 
    150162                    $rcmail->output->command('display_message', $this->gettext('addedsuccessfully'), 'confirmation'); 
    151163                else 
     
    153165            } 
    154166        } 
    155         else 
     167        else { 
    156168            $rcmail->output->command('display_message', $error_msg, 'error'); 
     169        } 
    157170 
    158171        $rcmail->output->send(); 
     
    183196        ); 
    184197    } 
     198 
     199    /** 
     200     * Getter for default (writable) addressbook 
     201     */ 
     202    private function get_address_book() 
     203    { 
     204        if ($this->abook) { 
     205            return $this->abook; 
     206        } 
     207 
     208        $rcmail = rcmail::get_instance(); 
     209        $abook  = $rcmail->config->get('default_addressbook'); 
     210 
     211        // Get configured addressbook 
     212        $CONTACTS = $rcmail->get_address_book($abook, true); 
     213 
     214        // Get first writeable addressbook if the configured doesn't exist 
     215        // This can happen when user deleted the addressbook (e.g. Kolab folder) 
     216        if ($abook === null || $abook === '' || !is_object($CONTACTS)) { 
     217            $source   = reset($rcmail->get_address_sources(true)); 
     218            $CONTACTS = $rcmail->get_address_book($source['id'], true); 
     219        } 
     220 
     221        return $this->abook = $CONTACTS; 
     222    } 
    185223} 
  • plugins/vcard_attachments/vcardattach.js

    r48e9c14 rce6ece3  
    66{ 
    77  var lock = rcmail.set_busy(true, 'loading'); 
    8   rcmail.http_post('plugin.savevcard', { _uid: rcmail.env.uid, _mbox: urlencode(rcmail.env.mailbox), _part: urlencode(mime_id) }, lock); 
    9    
     8  rcmail.http_post('plugin.savevcard', { _uid: rcmail.env.uid, _mbox: rcmail.env.mailbox, _part: mime_id }, lock); 
     9 
    1010  return false; 
    1111} 
  • program/include/rcube_message.php

    rb91f048 rce6ece3  
    165165     * Get content of a specific part of this message 
    166166     * 
    167      * @param string $mime_id Part MIME-ID 
    168      * @param resource $fp File pointer to save the message part 
     167     * @param string   $mime_id           Part MIME-ID 
     168     * @param resource $fp File           pointer to save the message part 
     169     * @param boolean  $skip_charset_conv Disables charset conversion 
     170     * 
    169171     * @return string Part content 
    170172     */ 
    171     public function get_part_content($mime_id, $fp=NULL) 
     173    public function get_part_content($mime_id, $fp = null, $skip_charset_conv = false) 
    172174    { 
    173175        if ($part = $this->mime_parts[$mime_id]) { 
     
    180182            } 
    181183            // get from IMAP 
    182             return $this->storage->get_message_part($this->uid, $mime_id, $part, NULL, $fp); 
     184            return $this->storage->get_message_part($this->uid, $mime_id, $part, NULL, $fp, $skip_charset_conv); 
    183185        } else 
    184186            return null; 
  • skins/larry/mail.css

    r3d5240b7 rce6ece3  
    476476 
    477477#messagelist tbody tr td.attachment span.attachment { 
    478         background-position: 0 -998px; 
     478        background-position: 0 -996px; 
    479479} 
    480480#messagelist thead tr td.attachment span.attachment { 
    481         background-position: -24px -997px; 
     481        background-position: -24px -996px; 
    482482} 
    483483 
Note: See TracChangeset for help on using the changeset viewer.