2016-02-12 14:07:15 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
|
|
|
class AppVersion
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
get current app version
|
|
|
|
|
|
|
|
version = AppVersion.get
|
|
|
|
|
|
|
|
returns
|
|
|
|
|
|
|
|
'20150212131700:0' # 'version:if_browser_reload_is_required'
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.get
|
|
|
|
Setting.get('app_version')
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
set new app version and if browser reload is required
|
|
|
|
|
|
|
|
AppVersion.set(true) # true == reload is required / false == no reload is required
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.set(reload_required = false)
|
2016-02-23 10:54:35 +00:00
|
|
|
return false if !Setting.find_by(name: 'app_version')
|
2016-02-12 14:07:15 +00:00
|
|
|
version = "#{Time.zone.now.strftime('%Y%m%d%H%M%S')}:#{reload_required}"
|
|
|
|
Setting.set('app_version', version)
|
|
|
|
|
|
|
|
# broadcast to clients
|
|
|
|
Sessions.broadcast(event_data)
|
|
|
|
end
|
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
get event data
|
|
|
|
|
|
|
|
AppVersion.event_data
|
|
|
|
|
|
|
|
returnes
|
|
|
|
|
|
|
|
{
|
2016-05-25 07:19:45 +00:00
|
|
|
event: 'maintenance'
|
2016-02-12 14:07:15 +00:00
|
|
|
data: {
|
2016-05-25 07:19:45 +00:00
|
|
|
type: 'app_version',
|
2016-02-12 14:07:15 +00:00
|
|
|
app_version: app_version,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
|
|
|
def self.event_data
|
|
|
|
{
|
2016-05-25 07:19:45 +00:00
|
|
|
event: 'maintenance',
|
2016-02-12 14:07:15 +00:00
|
|
|
data: {
|
2016-05-25 07:19:45 +00:00
|
|
|
type: 'app_version',
|
2016-02-12 14:07:15 +00:00
|
|
|
app_version: get,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|