1
|
|
|
<?php |
2
|
|
|
// This file is part of Moodle - http://moodle.org/ |
3
|
|
|
// |
4
|
|
|
// Moodle is free software: you can redistribute it and/or modify |
5
|
|
|
// it under the terms of the GNU General Public License as published by |
6
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
7
|
|
|
// (at your option) any later version. |
8
|
|
|
// |
9
|
|
|
// Moodle is distributed in the hope that it will be useful, |
10
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12
|
|
|
// GNU General Public License for more details. |
13
|
|
|
// |
14
|
|
|
// You should have received a copy of the GNU General Public License |
15
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The mod_bigbluebuttonbn locallib/mobileview. |
19
|
|
|
* |
20
|
|
|
* @package mod_bigbluebuttonbn |
21
|
|
|
* @copyright 2018 onwards, Blindside Networks Inc |
22
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace mod_bigbluebuttonbn\locallib; |
26
|
|
|
|
27
|
|
|
defined('MOODLE_INTERNAL') || die(); |
28
|
|
|
global $CFG; |
29
|
|
|
require_once($CFG->dirroot . '/mod/bigbluebuttonbn/locallib.php'); |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Methods used to render view BBB in mobile. |
33
|
|
|
* |
34
|
|
|
* @copyright 2018 onwards, Blindside Networks Inc |
35
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
36
|
|
|
*/ |
37
|
|
|
class mobileview { |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Build url for join to session. |
41
|
|
|
* This method is similar to "join_meeting()" in bbb_view. |
42
|
|
|
* @param array $bbbsession |
43
|
|
|
* @return string |
44
|
|
|
*/ |
45
|
|
|
public static function build_url_join_session(&$bbbsession) { |
46
|
|
|
$password = $bbbsession['viewerPW']; |
47
|
|
|
if ($bbbsession['administrator'] || $bbbsession['moderator']) { |
48
|
|
|
$password = $bbbsession['modPW']; |
49
|
|
|
} |
50
|
|
|
$joinurl = bigbluebuttonbn_get_join_url($bbbsession['meetingid'], $bbbsession['username'], |
51
|
|
|
$password, $bbbsession['logoutURL'], null, $bbbsession['userID'], $bbbsession['clienttype']); |
52
|
|
|
|
53
|
|
|
return($joinurl); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Return the status of an activity [open|not_started|ended]. |
58
|
|
|
* |
59
|
|
|
* @param array $bbbsession |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
View Code Duplication |
public static function get_activity_status(&$bbbsession) { |
|
|
|
|
63
|
|
|
$now = time(); |
64
|
|
|
if (!empty($bbbsession['bigbluebuttonbn']->openingtime) && $now < $bbbsession['bigbluebuttonbn']->openingtime) { |
65
|
|
|
// The activity has not been opened. |
66
|
|
|
return 'not_started'; |
67
|
|
|
} |
68
|
|
|
if (!empty($bbbsession['bigbluebuttonbn']->closingtime) && $now > $bbbsession['bigbluebuttonbn']->closingtime) { |
69
|
|
|
// The activity has been closed. |
70
|
|
|
return 'ended'; |
71
|
|
|
} |
72
|
|
|
// The activity is open. |
73
|
|
|
return 'open'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Helper for preparing metadata used while creating the meeting. |
78
|
|
|
* |
79
|
|
|
* @param array $bbbsession |
80
|
|
|
* @return array |
81
|
|
|
*/ |
82
|
|
|
public static function create_meeting_metadata(&$bbbsession) { |
83
|
|
|
return bigbluebuttonbn_create_meeting_metadata($bbbsession); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Helper to prepare data used for create meeting. |
88
|
|
|
* @param array $bbbsession |
89
|
|
|
* @return array |
90
|
|
|
* @throws \coding_exception |
91
|
|
|
*/ |
92
|
|
|
public static function create_meeting_data(&$bbbsession) { |
93
|
|
|
$data = ['meetingID' => $bbbsession['meetingid'], |
94
|
|
|
'name' => bigbluebuttonbn_html2text($bbbsession['meetingname'], 64), |
95
|
|
|
'attendeePW' => $bbbsession['viewerPW'], |
96
|
|
|
'moderatorPW' => $bbbsession['modPW'], |
97
|
|
|
'logoutURL' => $bbbsession['logoutURL'], |
98
|
|
|
]; |
99
|
|
|
$data['record'] = self::create_meeting_data_record($bbbsession['record']); |
100
|
|
|
// Check if auto_start_record is enable. |
101
|
|
View Code Duplication |
if ($data['record'] == 'true' && $bbbsession['recordallfromstart']) { |
|
|
|
|
102
|
|
|
$data['autoStartRecording'] = 'true'; |
103
|
|
|
// Check if hide_record_button is enable. |
104
|
|
|
if ($bbbsession['recordallfromstart'] && $bbbsession['recordhidebutton']) { |
105
|
|
|
$data['allowStartStopRecording'] = 'false'; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
$data['welcome'] = trim($bbbsession['welcome']); |
109
|
|
|
// Set the duration for the meeting. |
110
|
|
|
$durationtime = self::create_meeting_data_duration($bbbsession['bigbluebuttonbn']->closingtime); |
111
|
|
View Code Duplication |
if ($durationtime > 0) { |
|
|
|
|
112
|
|
|
$data['duration'] = $durationtime; |
113
|
|
|
$data['welcome'] .= '<br><br>'; |
114
|
|
|
$data['welcome'] .= str_replace( |
115
|
|
|
'%duration%', |
116
|
|
|
(string) $durationtime, |
117
|
|
|
get_string('bbbdurationwarning', 'bigbluebuttonbn') |
118
|
|
|
); |
119
|
|
|
} |
120
|
|
|
$voicebridge = intval($bbbsession['voicebridge']); |
121
|
|
|
if ($voicebridge > 0 && $voicebridge < 79999) { |
122
|
|
|
$data['voiceBridge'] = $voicebridge; |
123
|
|
|
} |
124
|
|
|
$maxparticipants = intval($bbbsession['userlimit']); |
125
|
|
|
if ($maxparticipants > 0) { |
126
|
|
|
$data['maxParticipants'] = $maxparticipants; |
127
|
|
|
} |
128
|
|
|
if ($bbbsession['muteonstart']) { |
129
|
|
|
$data['muteOnStart'] = 'true'; |
130
|
|
|
} |
131
|
|
|
return $data; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Helper for returning the flag to know if the meeting is recorded. |
136
|
|
|
* |
137
|
|
|
* @param boolean $record |
138
|
|
|
* @return string |
139
|
|
|
*/ |
140
|
|
|
public static function create_meeting_data_record($record) { |
141
|
|
|
if ((boolean)\mod_bigbluebuttonbn\locallib\config::recordings_enabled() && $record) { |
142
|
|
|
return 'true'; |
143
|
|
|
} |
144
|
|
|
return 'false'; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Helper for returning the duration expected for the meeting. |
149
|
|
|
* |
150
|
|
|
* @param string $closingtime |
151
|
|
|
* @return integer |
152
|
|
|
*/ |
153
|
|
|
public static function create_meeting_data_duration($closingtime) { |
154
|
|
|
if ((boolean)\mod_bigbluebuttonbn\locallib\config::get('scheduled_duration_enabled')) { |
155
|
|
|
return bigbluebuttonbn_get_duration($closingtime); |
156
|
|
|
} |
157
|
|
|
return 0; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.