|
1
|
|
|
# frozen_string_literal: true |
|
2
|
|
|
|
|
3
|
|
|
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/. |
|
4
|
|
|
# |
|
5
|
|
|
# Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below). |
|
6
|
|
|
# |
|
7
|
|
|
# This program is free software; you can redistribute it and/or modify it under the |
|
8
|
|
|
# terms of the GNU Lesser General Public License as published by the Free Software |
|
9
|
|
|
# Foundation; either version 3.0 of the License, or (at your option) any later |
|
10
|
|
|
# version. |
|
11
|
|
|
# |
|
12
|
|
|
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY |
|
13
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
14
|
|
|
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|
15
|
|
|
# |
|
16
|
|
|
# You should have received a copy of the GNU Lesser General Public License along |
|
17
|
|
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
|
|
19
|
|
|
class Setting < ApplicationRecord |
|
20
|
|
|
has_many :features |
|
21
|
|
|
|
|
22
|
|
|
# Updates the value of the feature and enables it |
|
23
|
|
|
def update_value(name, value) |
|
24
|
|
|
feature = features.find_or_create_by!(name: name) |
|
25
|
|
|
|
|
26
|
|
|
feature.update_attributes(value: value, enabled: true) |
|
27
|
|
|
end |
|
28
|
|
|
|
|
29
|
|
|
# Returns the value if enabled or the default if not enabled |
|
30
|
|
|
def get_value(name) |
|
31
|
|
|
feature = features.find_or_create_by!(name: name) |
|
32
|
|
|
if feature[:enabled] |
|
33
|
|
|
feature[:value] |
|
34
|
|
|
else |
|
35
|
|
|
case name |
|
36
|
|
|
when "Primary Color" |
|
37
|
|
|
Rails.configuration.primary_color_default |
|
38
|
|
|
when "Registration Method" |
|
39
|
|
|
Rails.configuration.registration_method_default |
|
40
|
|
|
when "Room Authentication" |
|
41
|
|
|
false |
|
42
|
|
|
when "Room Limit" |
|
43
|
|
|
Rails.configuration.number_of_rooms_default |
|
44
|
|
|
end |
|
45
|
|
|
end |
|
46
|
|
|
end |
|
47
|
|
|
|
|
48
|
|
|
# Returns an image that is stored locally |
|
49
|
|
|
def get_image(name) |
|
50
|
|
|
feature = features.find_or_create_by!(name: name) |
|
51
|
|
|
|
|
52
|
|
|
if feature[:enabled] && feature.image.attached? |
|
53
|
|
|
feature.image |
|
54
|
|
|
else |
|
55
|
|
|
case name |
|
56
|
|
|
when "Branding Image" |
|
57
|
|
|
Rails.configuration.branding_image_default |
|
58
|
|
|
end |
|
59
|
|
|
end |
|
60
|
|
|
end |
|
61
|
|
|
end |
|
62
|
|
|
|