Passed
Push — master ( 23b088...27bc68 )
by Ahmad
06:31
created

AdminsHelper.email_mapping()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
module AdminsHelper
20
  include Pagy::Frontend
21
22
  # Server Rooms
23
24
  # Gets the email of the room owner to which the recording belongs to
25 View Code Duplication
  def recording_owner_email(room_id)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
26
    Room.find_by(bbb_id: room_id).owner.email.presence || Room.find_by(bbb_id: room_id).owner.username
27
  end
28
29
  # Get the room status to display in the Server Rooms table
30
  def room_is_running(id)
31
    @running_room_bbb_ids.include?(id)
32
  end
33
34
  # Site Settings
35
36
  def admin_invite_registration
37
    controller_name == "admins" && action_name == "index" &&
38
      @settings.get_value("Registration Method") == Rails.configuration.registration_methods[:invite]
39
  end
40
41 View Code Duplication
  def room_authentication_string
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
42
    if @settings.get_value("Room Authentication") == "true"
43
      I18n.t("administrator.site_settings.authentication.enabled")
44
    else
45
      I18n.t("administrator.site_settings.authentication.disabled")
46
    end
47
  end
48
49 View Code Duplication
  def shared_access_string
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
50
    if @settings.get_value("Shared Access") == "true"
51
      I18n.t("administrator.site_settings.authentication.enabled")
52
    else
53
      I18n.t("administrator.site_settings.authentication.disabled")
54
    end
55
  end
56
57 View Code Duplication
  def preupload_string
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
58
    if @settings.get_value("Preupload Presentation") == "true"
59
      I18n.t("administrator.site_settings.authentication.enabled")
60
    else
61
      I18n.t("administrator.site_settings.authentication.disabled")
62
    end
63
  end
64
65
  def recording_default_visibility_string
66
    if @settings.get_value("Default Recording Visibility") == "public"
67
      I18n.t("recording.visibility.public")
68
    else
69
      I18n.t("recording.visibility.unlisted")
70
    end
71
  end
72
73
  def registration_method_string
74
    case @settings.get_value("Registration Method")
75
    when Rails.configuration.registration_methods[:open]
76
        I18n.t("administrator.site_settings.registration.methods.open")
77
    when Rails.configuration.registration_methods[:invite]
78
        I18n.t("administrator.site_settings.registration.methods.invite")
79
    when Rails.configuration.registration_methods[:approval]
80
        I18n.t("administrator.site_settings.registration.methods.approval")
81
      end
82
  end
83
84 View Code Duplication
  def require_consent_string
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
85
    if @settings.get_value("Require Recording Consent") == "true"
86
      I18n.t("administrator.site_settings.authentication.enabled")
87
    else
88
      I18n.t("administrator.site_settings.authentication.disabled")
89
    end
90
  end
91
92
  def log_level_string
93
    case Rails.logger.level
94
    when 0
95
      t("administrator.site_settings.log_level.debug")
96
    when 1
97
      t("administrator.site_settings.log_level.info")
98
    when 2
99
      t("administrator.site_settings.log_level.warn")
100
    when 3
101
      t("administrator.site_settings.log_level.error")
102
    when 4
103
      t("administrator.site_settings.log_level.fatal")
104
    when 5
105
      t("administrator.site_settings.log_level.unknown")
106
    end
107
  end
108
109
  def show_log_dropdown
110
    current_user.has_role?(:super_admin) || !Rails.configuration.loadbalanced_configuration
111
  end
112
113
  def room_limit_number
114
    @settings.get_value("Room Limit").to_i
115
  end
116
117
  def email_mapping
118
    @settings.get_value("Email Mapping")
119
  end
120
121
  # Room Configuration
122
123
  def room_configuration_string(name)
124
    case @settings.get_value(name)
125
    when "enabled"
126
      t("administrator.room_configuration.options.enabled")
127
    when "optional"
128
      t("administrator.room_configuration.options.optional")
129
    when "disabled"
130
      t("administrator.room_configuration.options.disabled")
131
    end
132
  end
133
134
  # Roles
135
136
  def edit_disabled
137
    @edit_disabled ||= @selected_role.priority <= current_user.role.priority
138
  end
139
end
140