Feature #1077 » ICS_Support__4.patch
| app/controllers/issues_controller.rb (working copy) | ||
|---|---|---|
| 24 | 24 |
before_filter :find_project, :only => [:new, :update_form, :preview] |
| 25 | 25 |
before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :update_form, :context_menu] |
| 26 | 26 |
before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar] |
| 27 |
accept_key_auth :index, :show, :changes |
|
| 27 |
accept_key_auth :index, :show, :changes, :calendar
|
|
| 28 | 28 | |
| 29 | 29 |
helper :journals |
| 30 | 30 |
helper :projects |
| ... | ... | |
| 401 | 401 |
retrieve_query |
| 402 | 402 |
if @query.valid? |
| 403 | 403 |
events = [] |
| 404 |
if (request.format == Mime::ICS) |
|
| 405 |
@calendar.startdt = @project.created_on.to_s(:db) |
|
| 406 |
end |
|
| 404 | 407 |
events += Issue.find(:all, |
| 405 | 408 |
:include => [:tracker, :status, :assigned_to, :priority, :project], |
| 406 | 409 |
:conditions => ["(#{@query.statement}) AND ((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]
|
| ... | ... | |
| 410 | 413 |
|
| 411 | 414 |
@calendar.events = events |
| 412 | 415 |
end |
| 413 |
|
|
| 414 |
render :layout => false if request.xhr? |
|
| 416 |
respond_to do |format| |
|
| 417 |
format.html { render :layout => false if request.xhr? }
|
|
| 418 |
format.ics { render_ics(events) }
|
|
| 419 |
end |
|
| 420 |
# render :layout => false if request.xhr? |
|
| 415 | 421 |
end |
| 416 | 422 |
|
| 417 | 423 |
def context_menu |
| app/controllers/application_controller.rb (working copy) | ||
|---|---|---|
| 17 | 17 | |
| 18 | 18 |
require 'uri' |
| 19 | 19 |
require 'cgi' |
| 20 |
require 'icalendar' |
|
| 20 | 21 | |
| 21 | 22 |
class ApplicationController < ActionController::Base |
| 22 | 23 |
include Redmine::I18n |
| ... | ... | |
| 53 | 54 |
user = User.try_to_autologin(cookies[:autologin]) |
| 54 | 55 |
session[:user_id] = user.id if user |
| 55 | 56 |
user |
| 56 |
elsif params[:format] == 'atom' && params[:key] && accept_key_auth_actions.include?(params[:action])
|
|
| 57 |
elsif ['atom', 'ics'].include?(params[:format]) && params[:key] && accept_key_auth_actions.include?(params[:action])
|
|
| 57 | 58 |
# RSS key authentication does not start a session |
| 58 | 59 |
User.find_by_rss_key(params[:key]) |
| 59 | 60 |
end |
| ... | ... | |
| 186 | 187 |
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml' |
| 187 | 188 |
end |
| 188 | 189 |
|
| 190 |
def render_ics(items, options={})
|
|
| 191 |
cal = Icalendar::Calendar.new |
|
| 192 |
items.each { |i|
|
|
| 193 |
event = Icalendar::Event.new |
|
| 194 |
event.dtstart = i.start_date |
|
| 195 |
event.dtend = i.due_date |
|
| 196 |
if i.is_a? Issue |
|
| 197 |
event.summary = i.subject |
|
| 198 |
else |
|
| 199 |
event.summary = "V. " + i.name |
|
| 200 |
end |
|
| 201 |
if !i.description.nil? |
|
| 202 |
event.description = i.description |
|
| 203 |
end |
|
| 204 |
cal.add_event(event) |
|
| 205 |
} |
|
| 206 |
@cal_string = cal.to_ical |
|
| 207 |
render :template => "common/calendar.ics.erb", :layout => false , :content_type => Mime::ICS |
|
| 208 |
end |
|
| 209 |
|
|
| 189 | 210 |
def self.accept_key_auth(*actions) |
| 190 | 211 |
actions = actions.flatten.map(&:to_s) |
| 191 | 212 |
write_inheritable_attribute('accept_key_auth_actions', actions)
|
| app/views/issues/_sidebar.rhtml (working copy) | ||
|---|---|---|
| 3 | 3 |
<% if @project %> |
| 4 | 4 |
<%= link_to l(:field_summary), :controller => 'reports', :action => 'issue_report', :id => @project %><br /> |
| 5 | 5 |
<%= link_to l(:label_change_log), :controller => 'projects', :action => 'changelog', :id => @project %><br /> |
| 6 |
<%= link_to 'ICS with open issues', :controller => 'issues', :action => 'calendar', :format => 'ics', :key => User.current.rss_key, :project_id => @project %><br /> |
|
| 7 |
<%= link_to 'ICS with all issues', :controller => 'issues', :action => 'calendar', :format => 'ics', :status_id => '*', :key => User.current.rss_key, :project_id => @project %> |
|
| 6 | 8 |
<% end %> |
| 7 | 9 |
<%= call_hook(:view_issues_sidebar_issues_bottom) %> |
| 8 | 10 | |
| lib/redmine/helpers/calendar.rb (working copy) | ||
|---|---|---|
| 44 | 44 |
raise 'Invalid period' |
| 45 | 45 |
end |
| 46 | 46 |
end |
| 47 | ||
| 48 |
def startdt=(dt) |
|
| 49 |
@startdt = dt |
|
| 50 |
end |
|
| 47 | 51 |
|
| 48 | 52 |
# Sets calendar events |
| 49 | 53 |
def events=(events) |