@@ -1,100 +1,96 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class FeedsController < ApplicationController |
|
19 | 19 | before_filter :find_scope |
|
20 | 20 | session :off |
|
21 | 21 | |
|
22 | 22 | helper :issues |
|
23 | 23 | include IssuesHelper |
|
24 | 24 | helper :custom_fields |
|
25 | 25 | include CustomFieldsHelper |
|
26 | 26 | |
|
27 | 27 | # news feeds |
|
28 | 28 | def news |
|
29 | 29 | News.with_scope(:find => @find_options) do |
|
30 | 30 | @news = News.find :all, :order => "#{News.table_name}.created_on DESC", :include => [ :author, :project ] |
|
31 | 31 | end |
|
32 | 32 | headers["Content-Type"] = "application/rss+xml" |
|
33 | 33 | render :action => 'news_atom' if 'atom' == params[:format] |
|
34 | 34 | end |
|
35 | 35 | |
|
36 | 36 | # issue feeds |
|
37 | 37 | def issues |
|
38 | conditions = nil | |
|
39 | ||
|
40 | if params[:query_id] | |
|
38 | if @project && params[:query_id] | |
|
41 | 39 | query = Query.find(params[:query_id]) |
|
42 | 40 | # ignore query if it's not valid |
|
43 | 41 | query = nil unless query.valid? |
|
44 | conditions = query.statement if query | |
|
42 | # override with query conditions | |
|
43 | @find_options[:conditions] = query.statement if query.valid? and @project == query.project | |
|
45 | 44 | end |
|
46 | 45 | |
|
47 | 46 | Issue.with_scope(:find => @find_options) do |
|
48 | 47 | @issues = Issue.find :all, :include => [:project, :author, :tracker, :status], |
|
49 |
:order => "#{Issue.table_name}.created_on DESC" |
|
|
50 | :conditions => conditions | |
|
48 | :order => "#{Issue.table_name}.created_on DESC" | |
|
51 | 49 | end |
|
52 | 50 | @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues)) |
|
53 | 51 | headers["Content-Type"] = "application/rss+xml" |
|
54 | 52 | render :action => 'issues_atom' if 'atom' == params[:format] |
|
55 | 53 | end |
|
56 | 54 | |
|
57 | 55 | # issue changes feeds |
|
58 | def history | |
|
59 | conditions = nil | |
|
60 | ||
|
61 | if params[:query_id] | |
|
56 | def history | |
|
57 | if @project && params[:query_id] | |
|
62 | 58 | query = Query.find(params[:query_id]) |
|
63 | 59 | # ignore query if it's not valid |
|
64 | 60 | query = nil unless query.valid? |
|
65 | conditions = query.statement if query | |
|
61 | # override with query conditions | |
|
62 | @find_options[:conditions] = query.statement if query.valid? and @project == query.project | |
|
66 | 63 | end |
|
67 | 64 | |
|
68 | 65 | Journal.with_scope(:find => @find_options) do |
|
69 | 66 | @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ], |
|
70 |
:order => "#{Journal.table_name}.created_on DESC" |
|
|
71 | :conditions => conditions | |
|
67 | :order => "#{Journal.table_name}.created_on DESC" | |
|
72 | 68 | end |
|
73 | 69 | |
|
74 | 70 | @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues)) |
|
75 | 71 | headers["Content-Type"] = "application/rss+xml" |
|
76 | 72 | render :action => 'history_atom' if 'atom' == params[:format] |
|
77 | 73 | end |
|
78 | 74 | |
|
79 | 75 | private |
|
80 | 76 | # override for feeds specific authentication |
|
81 | 77 | def check_if_login_required |
|
82 | 78 | @user = User.find_by_rss_key(params[:key]) |
|
83 | 79 | render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required? |
|
84 | 80 | end |
|
85 | 81 | |
|
86 | 82 | def find_scope |
|
87 | 83 | if params[:project_id] |
|
88 | 84 | # project feed |
|
89 | 85 | # check if project is public or if the user is a member |
|
90 | 86 | @project = Project.find(params[:project_id]) |
|
91 | 87 | render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project.id)) |
|
92 | 88 | scope = ["#{Project.table_name}.id=?", params[:project_id].to_i] |
|
93 | 89 | else |
|
94 | 90 | # global feed |
|
95 | 91 | scope = ["#{Project.table_name}.is_public=?", true] |
|
96 | 92 | end |
|
97 | 93 | @find_options = {:conditions => scope, :limit => Setting.feeds_limit} |
|
98 | 94 | return true |
|
99 | 95 | end |
|
100 | 96 | end |
General Comments 0
You need to be logged in to leave comments.
Login now