Search: Don't return hidden projects/jobsets

This commit is contained in:
Eelco Dolstra 2013-02-22 15:56:29 +01:00
parent 07daff32b8
commit f3f6e8a4e3

View file

@ -311,16 +311,27 @@ sub search :Local Args(0) {
unless $query =~ /^[a-zA-Z0-9_\-]+$/; unless $query =~ /^[a-zA-Z0-9_\-]+$/;
$c->stash->{projects} = [ $c->model('DB::Projects')->search( $c->stash->{projects} = [ $c->model('DB::Projects')->search(
{ -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }, { -and =>
[ { -or => [ name => { ilike => "%$query%" }, displayName => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }
, { hidden => 0 }
]
},
{ order_by => ["name"] } ) ]; { order_by => ["name"] } ) ];
$c->stash->{jobsets} = [ $c->model('DB::Jobsets')->search( $c->stash->{jobsets} = [ $c->model('DB::Jobsets')->search(
{ -or => [ name => { ilike => "%$query%" }, description => { ilike => "%$query%" } ] }, { -and =>
{ order_by => ["project", "name"] } ) ]; [ { -or => [ "me.name" => { ilike => "%$query%" }, "me.description" => { ilike => "%$query%" } ] }
, { "project.hidden" => 0, "me.hidden" => 0 }
]
},
{ order_by => ["project", "name"], join => ["project"] } ) ];
$c->stash->{jobs} = [ $c->model('DB::Jobs')->search( $c->stash->{jobs} = [ $c->model('DB::Jobs')->search(
{ name => { ilike => "%$query%" } }, { "me.name" => { ilike => "%$query%" }
{ order_by => ["project", "jobset", "name"] } ) ]; , "project.hidden" => 0
, "jobset.hidden" => 0
},
{ order_by => ["project", "jobset", "name"], join => ["project", "jobset"] } ) ];
} }