Class: UtilController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/util_controller.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#calendarObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/util_controller.rb', line 4

def calendar
  @month = (params[:month] || Time.now.month).to_i
  @year = (params[:year] || Time.now.year).to_i
  first_of_month = Time.utc(@year, @month, 1)
  last_of_month = first_of_month.end_of_month
  
  @min_time = params[:min_time].to_i
  @max_time = params[:max_time].to_i
  @calendar = params[:calendar_id] ? Calendar.find(params[:calendar_id]) : Calendar.find(:first)
  @css_prefix = params[:css_prefix].to_s.gsub(/[^-\w]/, '')
  @popout_direction = params[:popout_direction]
  
  events = @calendar.events.find(:all, :conditions => [ 'start_date >= ? and start_date < ?', first_of_month, last_of_month + 1.day ])
  
  @event_days = {}
  events.each do |e|
    @event_days[e.start_date.mday] = e
  end
  
  render :update do |page|
    page.replace_html 'event_calendar_month_year', :partial => 'calendar_month_year'
    page.replace_html 'event_calendar_days', :partial => 'calendar_days'
  end
end

#date_pickerObject



29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/util_controller.rb', line 29

def date_picker
  @month = params[:month].to_i
  @year = params[:year].to_i
  @min_time = params[:min_time].to_i
  @max_time = params[:max_time].to_i
  @exclude_days = (params[:exclude_days] || '').split(',').map { |d| d.to_i }
  @object = params[:object]
  @method_prefix = params[:method_prefix]
  
  render :partial => 'date_picker'
end

#redirect_permanentObject



41
42
43
# File 'app/controllers/util_controller.rb', line 41

def redirect_permanent
  redirect_to params[:path], :status => 301
end