roundcubemail/program/lib/Roundcube/rcube_contacts.php
private function convert_save_data($save_data, $record = array())
    {
        $out = array();
        $words = '';

        // copy values into vcard object
        $vcard = new rcube_vcard($record['vcard'] ?: $save_data['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap);
        $vcard->reset();

        // don't store groups in vCard (#1490277)
        $vcard->set('groups', null);
        unset($save_data['groups']);

        foreach ($save_data as $key => $values) {
            list($field, $section) = explode(':', $key);
            $fulltext = in_array($field, $this->fulltext_cols);
            // avoid casting DateTime objects to array
            if (is_object($values) && is_a($values, 'DateTime')) {
                $values = array(0 => $values);
            }
            foreach ((array)$values as $value) {
                if (isset($value))
                    $vcard->set($field, $value, $section);
                if ($fulltext && is_array($value))
                    $words .= ' ' . rcube_utils::normalize_string(join(" ", $value));
                else if ($fulltext && strlen($value) >= 3)
                    $words .= ' ' . rcube_utils::normalize_string($value);
            }
        }
        $out['vcard'] = $vcard->export(false);

        foreach ($this->table_cols as $col) {
            $key = $col;
            if (!isset($save_data[$key]))
                $key .= ':home';
            if (isset($save_data[$key])) {
                if (is_array($save_data[$key]))
                    $out[$col] = join(self::SEPARATOR, $save_data[$key]);
                else
                    $out[$col] = $save_data[$key];
            }
        }

        // save all e-mails in database column
        $out['email'] = join(self::SEPARATOR, $vcard->email);

        // join words for fulltext search
        $out['words'] = join(" ", array_unique(explode(" ", $words)));

        return $out;
    }
private function convert_save_data($save_data, $record = array())
    {
        $out = array();
        $words = '';

        // copy values into vcard object
        $vcard = new rcube_vcard($record['vcard'] ?: $save_data['vcard'], RCUBE_CHARSET, false, $this->vcard_fieldmap);
        $vcard->reset();

        // don't store groups in vCard (#1490277)
        $vcard->set('groups', null);
        unset($save_data['groups']);

        foreach ($save_data as $key => $values) {
            list($field, $section) = explode(':', $key);
            $fulltext = in_array($field, $this->fulltext_cols);
            // avoid casting DateTime objects to array
            if (is_object($values) && is_a($values, 'DateTime')) {
                $values = array(0 => $values);
            }
            foreach ((array)$values as $value) {
                if (isset($value))
                    $vcard->set($field, $value, $section);
                if ($fulltext && is_array($value))
                    $words .= ' ' . rcube_utils::normalize_string(join(" ", $value));
                else if ($fulltext && strlen($value) >= 3)
                    $words .= ' ' . rcube_utils::normalize_string($value);
            }
        }
        $out['vcard'] = $vcard->export(false);

        foreach ($this->table_cols as $col) {
            $key = $col;
            if (!isset($save_data[$key]))
                $key .= ':home';
            if (isset($save_data[$key])) {
                if (is_array($save_data[$key]))
                    $out[$col] = join(self::SEPARATOR, $save_data[$key]);
                else
                    $out[$col] = $save_data[$key];
            }
        }

        // save all e-mails in database column
        $out['email'] = join(self::SEPARATOR, $vcard->email);

        // join words for fulltext search
        $out['words'] = join(" ", array_unique(explode(" ", $words)));

        return $out;
    }
private function convert_save_data ( $ save_data , $ record = array ( ) ) { $ out = array ( ) ; $ words = '' ; // copy values into vcard object $ vcard = new rcube_vcard ( $ record [ 'vcard' ] ? : $ save_data [ 'vcard' ] , RCUBE_CHARSET , false , $ this -> vcard_fieldmap ) ; $ vcard -> reset ( ) ; // don't store groups in vCard (#1490277) $ vcard -> set ( 'groups' , null ) ; unset ( $ save_data [ 'groups' ] ) ; foreach ( $ save_data as $ key => $ values ) { list ( $ field , $ section ) = explode ( ':' , $ key ) ; $ fulltext = in_array ( $ field , $ this -> fulltext_cols ) ; // avoid casting DateTime objects to array if ( is_object ( $ values ) && is_a ( $ values , 'DateTime' ) ) { $ values = array ( 0 => $ values ) ; } foreach ( ( array ) $ values as $ value ) { if ( isset ( $ value ) ) $ vcard -> set ( $ field , $ value , $ section ) ; if ( $ fulltext && is_array ( $ value ) ) $ words .= ' ' . rcube_utils :: normalize_string ( join ( " " , $ value ) ) ; else if ( $ fulltext && strlen ( $ value ) >= 3 ) $ words .= ' ' . rcube_utils :: normalize_string ( $ value ) ; } } $ out [ 'vcard' ] = $ vcard -> export ( false ) ; foreach ( $ this -> table_cols as $ col ) { $ key = $ col ; if ( ! isset ( $ save_data [ $ key ] ) ) $ key .= ':home' ; if ( isset ( $ save_data [ $ key ] ) ) { if ( is_array ( $ save_data [ $ key ] ) ) $ out [ $ col ] = join ( self :: SEPARATOR , $ save_data [ $ key ] ) ; else $ out [ $ col ] = $ save_data [ $ key ] ; } } // save all e-mails in database column $ out [ 'email' ] = join ( self :: SEPARATOR , $ vcard -> email ) ; // join words for fulltext search $ out [ 'words' ] = join ( " " , array_unique ( explode ( " " , $ words ) ) ) ; return $ out ; }
Convert input data for storing in the database
Convert input data for storing in the database