Changeset 1757

Show
Ignore:
Timestamp:
04/03/08 18:22:41 (4 months ago)
Author:
mpaschal
Message:

Search all kinds of entries when searching entries
BugzID: 75420

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-33/lib/MT/App/Search.pm

    r1726 r1757  
    6666                }, 
    6767                'sort'  => 'authored_on', 
    68                 terms   => { status => 2 }, #MT::Entry::RELEASE() 
     68                terms   => { status => 2, class => '*' }, #MT::Entry::RELEASE() 
    6969                filter_types => { 
    7070                    author   => \&_join_author, 
     
    342342 
    343343    my @terms; 
    344     push @terms, \%def_terms if %def_terms; 
     344    if (%def_terms) { 
     345        # If we have a term for the model's class column, add it separately, so 
     346        # array search() doesn't add the default class column term. 
     347        my $type = $app->{searchparam}{Type}; 
     348        my $model_class = MT->model($type); 
     349        if (my $class_col = $model_class->properties->{class_column}) { 
     350            if ($def_terms{$class_col}) { 
     351                push @terms, { $class_col => delete $def_terms{$class_col} }; 
     352            } 
     353        } 
     354 
     355        push @terms, \%def_terms; 
     356    } 
    345357 
    346358    my $columns = $params->{columns}; 
  • branches/release-33/lib/MT/Object.pm

    r1608 r1757  
    277277    } 
    278278    elsif (ref $terms eq 'ARRAY') { 
     279        if (my @class_terms = grep { ref $_ eq 'HASH' && 1 == scalar keys %$_ && $_->{$col} } @$terms) { 
     280            # Filter out any unlimiting class terms (class = *). 
     281            @$terms = grep { ref $_ ne 'HASH' || 1 != scalar keys %$_ || !$_->{$col} || $_->{$col} ne '*' } @$terms; 
     282 
     283            # The class column has been explicitly given or removed, so don't 
     284            # add one. 
     285            return; 
     286        } 
    279287        @$terms = ( { $col => $props->{class_type} } => 'AND' => [ @$terms ] ); 
    280  
    281288    } 
    282289}