1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 class FeedsController < ApplicationController
19 before_filter :find_scope
25 include CustomFieldsHelper
29 News.with_scope(:find => @find_options) do
30 @news = News.find :all, :order => "#{News.table_name}.created_on DESC", :include => [ :author, :project ]
32 headers["Content-Type"] = "application/rss+xml"
33 render :action => 'news_atom' if 'atom' == params[:format]
38 if @project && params[:query_id]
39 query = Query.find(params[:query_id])
40 query.executed_by = @user
41 # ignore query if it's not valid
42 query = nil unless query.valid?
43 # override with query conditions
44 @find_options[:conditions] = query.statement if query.valid? and @project == query.project
47 Issue.with_scope(:find => @find_options) do
48 @issues = Issue.find :all, :include => [:project, :author, :tracker, :status],
49 :order => "#{Issue.table_name}.created_on DESC"
51 @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
52 headers["Content-Type"] = "application/rss+xml"
53 render :action => 'issues_atom' if 'atom' == params[:format]
58 if @project && params[:query_id]
59 query = Query.find(params[:query_id])
60 query.executed_by = @user
61 # ignore query if it's not valid
62 query = nil unless query.valid?
63 # override with query conditions
64 @find_options[:conditions] = query.statement if query.valid? and @project == query.project
67 Journal.with_scope(:find => @find_options) do
68 @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
69 :order => "#{Journal.table_name}.created_on DESC"
72 @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_changes_details))
73 headers["Content-Type"] = "application/rss+xml"
74 render :action => 'history_atom' if 'atom' == params[:format]
78 # override for feeds specific authentication
79 def check_if_login_required
80 @user = User.find_by_rss_key(params[:key])
81 render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required?
85 if params[:project_id]
87 # check if project is public or if the user is a member
88 @project = Project.find(params[:project_id])
89 render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project))
90 scope = ["#{Project.table_name}.id=?", params[:project_id].to_i]
93 scope = ["#{Project.table_name}.is_public=?", true]
95 @find_options = {:conditions => scope, :limit => Setting.feeds_limit.to_i}