summaryrefslogtreecommitdiff
path: root/app/controllers/search_controller.rb
diff options
context:
space:
mode:
authorIzaak Alpert <ialpert@blackberry.com>2013-10-23 16:27:40 -0400
committerIzaak Alpert <ialpert@gmail.com>2013-11-13 14:56:35 -0500
commit91c7b266cdffbd82ac70f35ca9bd5d08b989dbe3 (patch)
tree29b357f149b8bf7bb0f4ac88460fb80c5eaa620e /app/controllers/search_controller.rb
parentc946defb3d9ff2ad87a410f2e25999465c4b9065 (diff)
downloadgitlab-ce-91c7b266cdffbd82ac70f35ca9bd5d08b989dbe3.tar.gz
Allow public repo searching
GITLAB-1386 Change-Id: I9a0bbe8db1a9bb00cef33b3e1854d78844b70a45
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r--app/controllers/search_controller.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index f5c3bb133ed..8104f3d077c 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -3,16 +3,7 @@ class SearchController < ApplicationController
project_id = params[:project_id]
group_id = params[:group_id]
- project_ids = current_user.authorized_projects.map(&:id)
-
- if group_id.present?
- @group = Group.find(group_id)
- group_project_ids = @group.projects.map(&:id)
- project_ids.select! { |id| group_project_ids.include?(id)}
- elsif project_id.present?
- @project = Project.find(params[:project_id])
- project_ids.select! { |id| id == project_id.to_i}
- end
+ project_ids = find_project_ids(group_id, project_id)
result = SearchContext.new(project_ids, params).execute
@@ -23,4 +14,18 @@ class SearchController < ApplicationController
@blobs = Kaminari.paginate_array(result[:blobs]).page(params[:page]).per(20)
@total_results = @projects.count + @merge_requests.count + @issues.count + @wiki_pages.count + @blobs.total_count
end
+
+ def find_project_ids(group_id, project_id)
+ project_ids = current_user.authorized_projects.map(&:id)
+
+ if group_id.present?
+ @group = Group.find(group_id)
+ group_project_ids = @group.projects.map(&:id)
+ project_ids.select! { |id| group_project_ids.include?(id) }
+ elsif project_id.present?
+ @project = Project.find(project_id)
+ project_ids = @project.public ? [@project.id] : project_ids.select { |id| id == project_id.to_i }
+ end
+ project_ids
+ end
end