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