Turba_Driver::search PHP Метод

    public function search(array $search_criteria, $sort_order = null, $search_type = 'AND', array $return_fields = array(), array $custom_strict = array(), $match_begin = false, $count_only = false)
    {
        global $injector;
        /* Add any fields that must match exactly for this source to the
         * $strict_fields array. */
        $strict_fields = $custom_strict_fields = array();
        foreach ($this->strict as $strict_field) {
            $strict_fields[$strict_field] = true;
        }
        /* Differentiate between provided $custom_strict fields - which honor
         * the $search_type and $strict fields which are not
         * explicitly requested as part of this search, and as such, are not
         * constrained by the requested $search_type. */
        foreach ($custom_strict as $strict_field) {
            if (isset($this->map[$strict_field])) {
                $custom_strict_fields[$this->map[$strict_field]] = true;
            }
        }
        /* Translate the Turba attributes to driver-specific attributes. */
        $fields = $this->makeSearch($search_criteria, $search_type, $strict_fields, $match_begin, $custom_strict_fields);
        /* If we are not using Horde_Share, enforce the requirement that the
         * current user must be the owner of the addressbook. */
        if (isset($this->map['__owner'])) {
            $fields = array('AND' => array($fields, array('field' => $this->toDriver('__owner'), 'op' => '=', 'test' => $this->getContactOwner())));
        }
        if (in_array('email', $return_fields) && !in_array('emails', $return_fields)) {
            $return_fields[] = 'emails';
        }
        if (count($return_fields)) {
            $default_fields = array('__key', '__type', '__owner', '__members', 'name');
            if ($this->alternativeName) {
                $default_fields[] = $this->alternativeName;
            }
            $return_fields_pre = array_unique(array_merge($default_fields, $return_fields));
            $return_fields = array();
            foreach ($return_fields_pre as $field) {
                $result = $this->toDriver($field);
                if (is_array($result)) {
                    foreach ($result as $composite_field) {
                        $composite_result = $this->toDriver($composite_field);
                        if ($composite_result) {
                            $return_fields[] = $composite_result;
                        }
                    }
                } elseif ($result) {
                    $return_fields[] = $result;
                }
            }
        } else {
            /* Need to force the array to be re-keyed for the (fringe) case
             * where we might have 1 DB field mapped to 2 or more Turba
             * fields */
            $return_fields = array_values(array_unique(array_values($this->fields)));
        }
        /* Retrieve the search results from the driver. */
        $objects = $this->_search($fields, $return_fields, $this->toDriverKeys($this->getBlobs()), isset($search_criteria['tags']) ? false : $count_only);
        /* Need some magic if we are searching tags */
        $list = $this->_filterTags($objects, !empty($search_criteria['tags']) ? $injector->getInstance('Turba_Tagger')->split($search_criteria['tags']) : array(), $sort_order);
        if ($count_only) {
            return $list->count();
        }
        return $list;
    }