Module: RedmineRefresh

Extended by:
RedmineRefresh
Included in:
RedmineRefresh
Defined in:
lib/redmine_refresh.rb,
lib/redmine_refresh/version.rb

Defined Under Namespace

Classes: Plugin

Constant Summary collapse

DEFAULT_INTERVAL =
120
VERSION =
"0.3.1"

Instance Method Summary collapse

Instance Method Details

#refresh_interval_for(user, refresh_param = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/redmine_refresh.rb', line 16

def refresh_interval_for(user, refresh_param = nil)
  interval = DEFAULT_INTERVAL
  user_interval = user.pref[:refresh_interval].to_i
  #if parameter is provided
  if refresh_param.to_i >= 10
    interval = refresh_param.to_i
    #save it if modified
    if interval != user_interval
      user.pref[:refresh_interval] = interval
      user.pref.save
    end
  #if not, get the user's
  elsif user_interval >= 10
    interval = user_interval
  end
  interval
end

#refresh_status_for_controller(user, controller = nil) ⇒ Object

if should_be_refreshed != RedmineRefresh.refresh_status_for_controller(controller.controller_name)



35
36
37
38
# File 'lib/redmine_refresh.rb', line 35

def refresh_status_for_controller(user, controller = nil)
  controller = controller.to_s
  controller.present? && user.pref[:refresh_status].is_a?(Hash) && user.pref[:refresh_status][controller]
end

#save_refresh_status_for_controller(user, controller, current_refresh_status) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/redmine_refresh.rb', line 40

def save_refresh_status_for_controller(user, controller, current_refresh_status)
  user_refresh_status = refresh_status_for_controller(user, controller)
  controller = controller.to_s
  if controller.present? && user_refresh_status != current_refresh_status
    user.pref[:refresh_status] ||= Hash.new
    user.pref[:refresh_status][controller] = current_refresh_status
    user.pref.save
  end
end