Project

General

Profile

Feature #1043 » redmine-my-calendar.patch

Carl Nygard, 2008-04-11 21:24

View differences:

/var/www/html/redmine/app/controllers/my_controller.rb 2008-04-11 15:04:34.000000000 -0400
48 48
    @blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT
49 49
  end
50 50

  
51
  def calendar
52
    @user = User.current;
53

  
54
    @trackers = Tracker.find(:all, :order => 'position')
55
    retrieve_selected_tracker_ids(@trackers)
56
    
57
    if params[:year] and params[:year].to_i > 1900
58
      @year = params[:year].to_i
59
      if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
60
        @month = params[:month].to_i
61
      end    
62
    end
63
    @year ||= Date.today.year
64
    @month ||= Date.today.month    
65
    @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), 
66
                                               current_language, :month)
67
    
68
    @calendar.events = Issue.find(:all,
69
                                  :include => [:project, :tracker, :priority, :assigned_to],
70
                                  :conditions => ["#{Issue.table_name}.assigned_to_id=? AND ((start_date>=? and start_date<=?) or (due_date>=? and due_date<=?)) AND #{Issue.table_name}.tracker_id IN (#{@selected_tracker_ids.join(',')})", @user.id, @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]) unless @user.projects.empty?
71

  
72
    logger.debug "Date: #{@month} (#{month_name(@month).downcase}) #{@year}"
73
    render :layout => false if request.xhr?
74
  end
75

  
76

  
51 77
  # Edit user's account
52 78
  def account
53 79
    @user = User.current
......
157 183
    session[:page_layout] = nil
158 184
    redirect_to :action => 'page'
159 185
  end
186

  
187
  private
188
  def retrieve_selected_tracker_ids(selectable_trackers)
189
    if ids = params[:tracker_ids]
190
      @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
191
    else
192
      @selected_tracker_ids = selectable_trackers.collect {|t| t.id.to_s }
193
    end
194
  end
195

  
160 196
end
161
-- redmine-0.6.4/app/views/layouts/base.rhtml	2008-03-12 14:10:48.000000000 -0400
197
++ /var/www/html/redmine/app/views/layouts/base.rhtml	2008-04-11 15:05:40.000000000 -0400
......
31 31
    </div>
32 32
    <%= link_to l(:label_home), home_url, :class => 'home' %>
33 33
    <%= link_to l(:label_my_page), { :controller => 'my', :action => 'page'}, :class => 'mypage' if User.current.logged? %>
34
    <%= link_to l(:label_my_calendar), { :controller => 'my', :action => 'calendar'}, :class => 'mypage' if User.current.logged? %>
34 35
    <%= link_to l(:label_project_plural), { :controller => 'projects' }, :class => 'projects' %>
35 36
    <%= link_to l(:label_administration), { :controller => 'admin' }, :class => 'admin' if User.current.admin? %>
36 37
    <%= link_to l(:label_help), Redmine::Info.help_url, :class => 'help' %>
/var/www/html/redmine/lang/en.yml 2008-04-11 15:05:52.000000000 -0400
244 244
label_password_lost: Lost password
245 245
label_home: Home
246 246
label_my_page: My page
247
label_my_calendar: My Calendar
247 248
label_my_account: My account
248 249
label_my_projects: My projects
249 250
label_administration: Administration
(1-1/3)