28 |
28 |
@question.strip!
|
29 |
29 |
@all_words = params[:all_words] || (params[:submit] ? false : true)
|
30 |
30 |
@titles_only = !params[:titles_only].nil?
|
|
31 |
@all_projects = params[:all_projects] || (params[:submit] ? false : true)
|
31 |
32 |
|
32 |
33 |
offset = nil
|
33 |
34 |
begin; offset = params[:offset].to_time if params[:offset]; rescue; end
|
... | ... | |
39 |
40 |
end
|
40 |
41 |
|
41 |
42 |
if @project
|
42 |
|
# only show what the user is allowed to view
|
43 |
|
@object_types = %w(issues news documents changesets wiki_pages messages)
|
44 |
|
@object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)}
|
45 |
|
|
46 |
|
@scope = @object_types.select {|t| params[t]}
|
47 |
|
@scope = @object_types if @scope.empty?
|
|
43 |
object_types_and_scope(@project)
|
|
44 |
if @all_projects
|
|
45 |
@projects = Project.find(:all, :conditions => Project.visible_by(User.current))
|
|
46 |
else
|
|
47 |
@projects = [@project]
|
|
48 |
end
|
48 |
49 |
else
|
49 |
50 |
@object_types = @scope = %w(projects)
|
50 |
51 |
end
|
... | ... | |
62 |
63 |
like_tokens = @tokens.collect {|w| "%#{w.downcase}%"}
|
63 |
64 |
@results = []
|
64 |
65 |
limit = 10
|
65 |
|
if @project
|
66 |
|
@scope.each do |s|
|
67 |
|
@results += s.singularize.camelcase.constantize.search(like_tokens, @project,
|
68 |
|
:all_words => @all_words,
|
69 |
|
:titles_only => @titles_only,
|
70 |
|
:limit => (limit+1),
|
71 |
|
:offset => offset,
|
72 |
|
:before => params[:previous].nil?)
|
|
66 |
if @projects
|
|
67 |
@projects.each do |project|
|
|
68 |
object_types_and_scope(project)
|
|
69 |
@scope.each do |s|
|
|
70 |
@results += s.singularize.camelcase.constantize.search(like_tokens, project,
|
|
71 |
:all_words => @all_words,
|
|
72 |
:titles_only => @titles_only,
|
|
73 |
:limit => (limit+1),
|
|
74 |
:offset => offset,
|
|
75 |
:before => params[:previous].nil?)
|
|
76 |
end
|
73 |
77 |
end
|
|
78 |
object_types_and_scope(@project) if @project #make sure object types and scope match current project last
|
74 |
79 |
@results = @results.sort {|a,b| b.event_datetime <=> a.event_datetime}
|
75 |
80 |
if params[:previous].nil?
|
76 |
81 |
@pagination_previous_date = @results[0].event_datetime if offset && @results[0]
|
... | ... | |
108 |
113 |
rescue ActiveRecord::RecordNotFound
|
109 |
114 |
render_404
|
110 |
115 |
end
|
|
116 |
|
|
117 |
# only show what the user is allowed to view
|
|
118 |
def object_types_and_scope(project)
|
|
119 |
@object_types = %w(issues news documents changesets wiki_pages messages)
|
|
120 |
@object_types = @object_types.select {|o| User.current.allowed_to?("view_#{o}".to_sym, @project)}
|
|
121 |
@scope = @object_types.select {|t| params[t]}
|
|
122 |
@scope = @object_types if @scope.empty?
|
|
123 |
end
|
111 |
124 |
end
|