|
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
|
|
View Code Duplication |
def room_authentication_required |
|
|
|
|
|
|
27
|
|
|
Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Authentication") == "true" && |
|
28
|
|
|
current_user.nil? |
|
29
|
|
|
end |
|
30
|
|
|
|
|
31
|
|
|
def number_of_rooms_allowed |
|
32
|
|
|
Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i |
|
33
|
|
|
end |
|
34
|
|
|
|
|
35
|
|
View Code Duplication |
def room_limit_exceeded |
|
|
|
|
|
|
36
|
|
|
limit = Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i |
|
37
|
|
|
|
|
38
|
|
|
# Does not apply to admin or users that aren't signed in |
|
39
|
|
|
# 15+ option is used as unlimited |
|
40
|
|
|
return false if current_user&.has_role?(:admin) || limit == 15 |
|
41
|
|
|
|
|
42
|
|
|
current_user.rooms.length >= limit |
|
43
|
|
|
end |
|
44
|
|
|
|
|
45
|
|
|
def current_room_exceeds_limit(room) |
|
46
|
|
|
# Get how many rooms need to be deleted to reach allowed room number |
|
47
|
|
|
limit = Setting.find_or_create_by!(provider: user_settings_provider).get_value("Room Limit").to_i |
|
48
|
|
|
|
|
49
|
|
|
return false if current_user&.has_role?(:admin) || limit == 15 |
|
50
|
|
|
|
|
51
|
|
|
@diff = current_user.rooms.count - limit |
|
52
|
|
|
@diff.positive? && current_user.rooms.pluck(:id).index(room.id) + 1 > limit |
|
53
|
|
|
end |
|
54
|
|
|
end |
|
55
|
|
|
|