roundcubemail/program/lib/Roundcube/rcube_ldap_generic.php
public static function fulltext_search_filter($value, $attributes, $mode = 1)
    {
        if (empty($attributes)) {
            $attributes = array('cn');
        }

        $groups = array();
        $value = str_replace('*', '', $value);
        $words = $mode == 0 ? rcube_utils::tokenize_string($value, 1) : array($value);

        // set wildcards
        $wp = $ws = '';
        if ($mode != 1) {
            $ws = '*';
            $wp = !$mode ? '*' : '';
        }

        // search each word in all listed attributes
        foreach ($words as $word) {
            $parts = array();
            foreach ($attributes as $attr) {
                $parts[] = "($attr=$wp" . self::quote_string($word) . "$ws)";
            }
            $groups[] = '(|' . join('', $parts) . ')';
        }

        return count($groups) > 1 ? '(&' . join('', $groups) . ')' : join('', $groups);
    }
public static function fulltext_search_filter($value, $attributes, $mode = 1)
    {
        if (empty($attributes)) {
            $attributes = array('cn');
        }

        $groups = array();
        $value = str_replace('*', '', $value);
        $words = $mode == 0 ? rcube_utils::tokenize_string($value, 1) : array($value);

        // set wildcards
        $wp = $ws = '';
        if ($mode != 1) {
            $ws = '*';
            $wp = !$mode ? '*' : '';
        }

        // search each word in all listed attributes
        foreach ($words as $word) {
            $parts = array();
            foreach ($attributes as $attr) {
                $parts[] = "($attr=$wp" . self::quote_string($word) . "$ws)";
            }
            $groups[] = '(|' . join('', $parts) . ')';
        }

        return count($groups) > 1 ? '(&' . join('', $groups) . ')' : join('', $groups);
    }
public static function fulltext_search_filter ( $ value , $ attributes , $ mode = 1 ) { if ( empty ( $ attributes ) ) { $ attributes = array ( 'cn' ) ; } $ groups = array ( ) ; $ value = str_replace ( '*' , '' , $ value ) ; $ words = $ mode == 0 ? rcube_utils :: tokenize_string ( $ value , 1 ) : array ( $ value ) ; // set wildcards $ wp = $ ws = '' ; if ( $ mode != 1 ) { $ ws = '*' ; $ wp = ! $ mode ? '*' : '' ; } // search each word in all listed attributes foreach ( $ words as $ word ) { $ parts = array ( ) ; foreach ( $ attributes as $ attr ) { $ parts [ ] = "($attr=$wp" . self :: quote_string ( $ word ) . "$ws)" ; } $ groups [ ] = '(|' . join ( '' , $ parts ) . ')' ; } return count ( $ groups ) > 1 ? '(&' . join ( '' , $ groups ) . ')' : join ( '' , $ groups ) ; }
Compose an LDAP filter string matching all words from the search string
in the given list of attributes.

@param string  $value    Search value
@param mixed   $attrs    List of LDAP attributes to search
@param int     $mode     Matching mode:
0 - partial (*abc*),
1 - strict (=),
2 - prefix (abc*)
@return string LDAP filter
Compose an LDAP filter string matching all words from the search string in the given list of attributes .