Module: ControllerExtensions
- Included in:
- ApplicationController
- Defined in:
- lib/controller_extensions.rb
Instance Method Summary (collapse)
- - (Object) check_openidurl_foruser(user, checkurl)
- - (Object) log_user_activity(opts = {})
- - (Object) validate_datepicker(options = {})
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( = {}) flipdates = ([:flipdates].nil? ? 'true' : [:flipdates]) if(params[:datefrom]) begin datefrom = Date.strptime(params[:datefrom]) rescue datefrom = [:default_datefrom] end else datefrom = [:default_datefrom] end if(params[:dateto]) begin dateto = Date.strptime(params[:dateto]) rescue dateto = [:default_dateto] end else dateto = [:default_dateto] end datefrom = [:earliest_date] if ([:earliest_date] and (datefrom < [:earliest_date])) dateto = [:latest_date] if ([:latest_date] and (dateto > [:latest_date])) if(flipdates and datefrom > dateto) tmp_datefrom = datefrom datefrom = dateto dateto = tmp_datefrom end return [datefrom,dateto] end |