Project

General

Profile

Feature #1077 » ICS_Support__2.patch

Florian L, 2008-05-05 19:35

View differences:

app/controllers/application.rb Locally Modified (Based On LOCAL)
22 22
  include Redmine::MenuManager::MenuController
23 23
  helper Redmine::MenuManager::MenuHelper
24 24
  
25
  require 'icalendar'
26
  
25 27
  REDMINE_SUPPORTED_SCM.each do |scm|
26 28
    require_dependency "repository/#{scm.underscore}"
27 29
  end
......
155 157
    render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
156 158
  end
157 159
  
160
  def render_ics(items, options={})
161
    cal = Icalendar::Calendar.new
162
    items.each { |i| 
163
      event = Icalendar::Event.new
164
      event.dtstart     =  i.start_date
165
      event.dtend       =  i.due_date
166
      if i.is_a? Issue
167
        event.summary     =  i.subject
168
      else
169
        event.summary     =  "V. " + i.name
170
      end
171
      
172
      if !i.description.nil?
173
        event.description = i.description
174
      end
175
      cal.add_event(event)
176
     }
177
    @cal_string = cal.to_ical 
178
    render :template => "common/calendar.ics.erb", :layout => false , :content_type => Mime::ICS
179
  end
180
  
158 181
  def self.accept_key_auth(*actions)
159 182
    actions = actions.flatten.map(&:to_s)
160 183
    write_inheritable_attribute('accept_key_auth_actions', actions)
app/controllers/projects_controller.rb Locally Modified (Based On LOCAL)
336 336
    @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
337 337
    @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
338 338
    events = []
339
    if (request.format == Mime::ICS)
340
        @calendar.startdt = @project.created_on.to_s(:db)
341
    end
339 342
    @project.issues_with_subprojects(@with_subprojects) do
340 343
      events += Issue.find(:all, 
341 344
                           :include => [:tracker, :status, :assigned_to, :priority, :project], 
......
346 349
    end
347 350
    @calendar.events = events
348 351
    
349
    render :layout => false if request.xhr?
352
    respond_to do |format|
353
      format.html { render :layout => false if request.xhr? }
354
      format.ics  { render_ics(events) }
350 355
  end  
356
  end  
351 357

  
352 358
  def gantt
353 359
    @trackers = @project.rolled_up_trackers 
app/views/common/calendar.ics.erb Locally New
1
<%= @cal_string %>
lib/redmine/helpers/calendar.rb Locally Modified (Based On LOCAL)
45 45
        end
46 46
      end
47 47
      
48
      def startdt=(dt)
49
        @startdt = dt
50
      end
51
      
48 52
      # Sets calendar events
49 53
      def events=(events)
50 54
        @events = events
(2-2/12)