Aleksander Machniak
2013-01-07 83f7077ec930952cdc9cfc8982b80cd4dad06b5f
program/lib/Roundcube/rcube_contacts.php
@@ -2,8 +2,6 @@
/*
 +-----------------------------------------------------------------------+
 | program/include/rcube_contacts.php                                    |
 |                                                                       |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2006-2012, The Roundcube Dev Team                       |
 |                                                                       |
@@ -13,7 +11,6 @@
 |                                                                       |
 | PURPOSE:                                                              |
 |   Interface to the local address book database                        |
 |                                                                       |
 +-----------------------------------------------------------------------+
 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
 +-----------------------------------------------------------------------+
@@ -48,6 +45,7 @@
    private $fulltext_cols = array('name', 'firstname', 'surname', 'middlename', 'nickname',
      'jobtitle', 'organization', 'department', 'maidenname', 'email', 'phone',
      'address', 'street', 'locality', 'zipcode', 'region', 'country', 'website', 'im', 'notes');
    protected $date_types = array('birthday', 'anniversary');
    // public properties
    public $primary_key = 'contact_id';
@@ -404,32 +402,16 @@
            for ($i=0; $i<$pages; $i++) {
                $this->list_records(null, $i, true);
                while ($row = $this->result->next()) {
                    $id = $row[$this->primary_key];
                    $id    = $row[$this->primary_key];
                    $found = array();
                    foreach (preg_grep($regexp, array_keys($row)) as $col) {
                        $pos     = strpos($col, ':');
                        $colname = $pos ? substr($col, 0, $pos) : $col;
                        $search  = $post_search[$colname];
                        foreach ((array)$row[$col] as $value) {
                            // composite field, e.g. address
                            foreach ((array)$value as $val) {
                                $val = mb_strtolower($val);
                                switch ($mode) {
                                case 1:
                                    $got = ($val == $search);
                                    break;
                                case 2:
                                    $got = ($search == substr($val, 0, strlen($search)));
                                    break;
                                default:
                                    $got = (strpos($val, $search) !== false);
                                    break;
                                }
                                if ($got) {
                                    $found[$colname] = true;
                                    break 2;
                                }
                            if ($this->compare_search_value($colname, $value, $search, $mode)) {
                                $found[$colname] = true;
                                break 2;
                            }
                        }
                    }
@@ -698,7 +680,7 @@
        if ($sql_arr['vcard']) {
            unset($sql_arr['email']);
            $vcard = new rcube_vcard($sql_arr['vcard'], RCMAIL_CHARSET, false, $this->vcard_fieldmap);
            $vcard = new rcube_vcard($sql_arr['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap);
            $record += $vcard->get_assoc() + $sql_arr;
        }
        else {
@@ -717,7 +699,7 @@
        $words = '';
        // copy values into vcard object
        $vcard = new rcube_vcard($record['vcard'] ? $record['vcard'] : $save_data['vcard'], RCMAIL_CHARSET, false, $this->vcard_fieldmap);
        $vcard = new rcube_vcard($record['vcard'] ? $record['vcard'] : $save_data['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap);
        $vcard->reset();
        foreach ($save_data as $key => $values) {
            list($field, $section) = explode(':', $key);