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

RoomsHelper.total_room_count()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 5
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 RoomsHelper
20
  # Helper to generate the path to a Google Calendar event creation
21
  # It will have its title set as the room name, and the location as the URL to the room
22
  def google_calendar_path
23
    "http://calendar.google.com/calendar/r/eventedit?text=#{@room.name}&location=#{request.base_url + request.fullpath}"
24
  end
25
26
  def room_authentication_required
27
    @settings.get_value("Room Authentication") == "true" &&
28
      current_user.nil?
29
  end
30
31
  def current_room_exceeds_limit(room)
32
    # Get how many rooms need to be deleted to reach allowed room number
33
    limit = @settings.get_value("Room Limit").to_i
34
35
    return false if current_user&.has_role?(:admin) || limit == 15
36
37
    @diff = current_user.rooms.count - limit
38
    @diff.positive? && current_user.rooms.pluck(:id).index(room.id) + 1 > limit
39
  end
40
41
  def room_configuration(name)
42
    @settings.get_value(name)
43
  end
44
45
  def preupload_allowed?
46
    @settings.get_value("Preupload Presentation") == "true"
47
  end
48
49
  def display_joiner_consent
50
    # If the require consent setting is checked, then check the room setting, else, set to false
51
    if recording_consent_required?
52
      room_setting_with_config("recording")
53
    else
54
      false
55
    end
56
  end
57
58
  # Array of recording formats not to show for public recordings
59
  def hidden_format_public
60
    ENV.fetch("HIDDEN_FORMATS_PUBLIC", "").split(",")
61
  end
62
63
  # Returns the total number of visibile rooms for the current user
64
  def total_room_count(user)
65
    total = user.rooms.length
66
    total += user.shared_rooms.length if shared_access_allowed
67
    total
68
  end
69
end
70