Module: ControllerExtensions

Included in:
ApplicationController
Defined in:
lib/controller_extensions.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) check_openidurl_foruser(user, checkurl)



19
20
21
22
23
24
25
26
27
# File 'lib/controller_extensions.rb', line 19

def check_openidurl_foruser(user,checkurl)
  if(user.openid_url == checkurl or user.openid_url == checkurl +'/')
    return true
  elsif(user.openid_url(true) == checkurl or user.openid_url(true) == checkurl +'/')
    return true
  else
    return false
  end
end

- (Object) log_user_activity(opts = {})



11
12
13
14
15
16
17
# File 'lib/controller_extensions.rb', line 11

def log_user_activity(opts = {})
  # creator check
  if(opts[:creator].nil?)
    @currentuser.nil? ? opts[:creator] = opts[:user] : opts[:creator] = @currentuser
  end
  Activity.log_activity(opts)
end

- (Object) validate_datepicker(options = {})



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/controller_extensions.rb', line 30

def validate_datepicker(options = {})
  flipdates = (options[:flipdates].nil? ? 'true' : options[:flipdates])
  if(params[:datefrom])
    begin
      datefrom = Date.strptime(params[:datefrom])
    rescue
      datefrom = options[:default_datefrom]
    end
  else
    datefrom = options[:default_datefrom]
  end

  if(params[:dateto])
    begin
      dateto = Date.strptime(params[:dateto])
    rescue
      dateto = options[:default_dateto]
    end
  else
    dateto = options[:default_dateto]
  end
  
  datefrom = options[:earliest_date] if (options[:earliest_date] and (datefrom < options[:earliest_date]))
  dateto = options[:latest_date] if (options[:latest_date] and (dateto > options[:latest_date]))
  
  if(flipdates and datefrom > dateto)
    tmp_datefrom = datefrom
    datefrom = dateto
    dateto = tmp_datefrom
  end
  
  return [datefrom,dateto]
end