Completed
Push — master ( d51556...d3ec1f )
by Jesus
02:19
created
locallib.php 1 patch
Spacing   +345 added lines, -345 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 global $BIGBLUEBUTTONBN_CFG, $CFG;
16 16
 
17
-require_once(dirname(__FILE__).'/lib.php');
17
+require_once(dirname(__FILE__) . '/lib.php');
18 18
 
19 19
 const BIGBLUEBUTTONBN_FORCED = true;
20 20
 
@@ -33,21 +33,21 @@  discard block
 block discarded – undo
33 33
 const BIGBLUEBUTTON_EVENT_RECORDING_PUBLISHED = 'recording_published';
34 34
 const BIGBLUEBUTTON_EVENT_RECORDING_UNPUBLISHED = 'recording_unpublished';
35 35
 
36
-function bigbluebuttonbn_logs(array $bbbsession, $event, array $overrides = [], $meta = NULL ) {
36
+function bigbluebuttonbn_logs(array $bbbsession, $event, array $overrides = [], $meta = NULL) {
37 37
     global $DB;
38 38
 
39 39
     $log = new stdClass();
40 40
 
41
-    $log->courseid = isset($overrides['courseid'])? $overrides['courseid']: $bbbsession['course']->id;
42
-    $log->bigbluebuttonbnid = isset($overrides['bigbluebuttonbnid'])? $overrides['bigbluebuttonbnid']: $bbbsession['bigbluebuttonbn']->id;
43
-    $log->userid = isset($overrides['userid'])? $overrides['userid']: $bbbsession['userID'];
44
-    $log->meetingid = isset($overrides['meetingid'])? $overrides['meetingid']: $bbbsession['meetingid'];
45
-    $log->timecreated = isset($overrides['timecreated'])? $overrides['timecreated']: time();
41
+    $log->courseid = isset($overrides['courseid']) ? $overrides['courseid'] : $bbbsession['course']->id;
42
+    $log->bigbluebuttonbnid = isset($overrides['bigbluebuttonbnid']) ? $overrides['bigbluebuttonbnid'] : $bbbsession['bigbluebuttonbn']->id;
43
+    $log->userid = isset($overrides['userid']) ? $overrides['userid'] : $bbbsession['userID'];
44
+    $log->meetingid = isset($overrides['meetingid']) ? $overrides['meetingid'] : $bbbsession['meetingid'];
45
+    $log->timecreated = isset($overrides['timecreated']) ? $overrides['timecreated'] : time();
46 46
     $log->log = $event;
47
-    if ( isset($meta) ) {
47
+    if (isset($meta)) {
48 48
         $log->meta = $meta;
49
-    } else if( $event == BIGBLUEBUTTONBN_LOG_EVENT_CREATE) {
50
-        $log->meta = '{"record":'.($bbbsession['record']? 'true': 'false').'}';
49
+    } else if ($event == BIGBLUEBUTTONBN_LOG_EVENT_CREATE) {
50
+        $log->meta = '{"record":' . ($bbbsession['record'] ? 'true' : 'false') . '}';
51 51
     }
52 52
 
53 53
     $returnid = $DB->insert_record('bigbluebuttonbn_logs', $log);
@@ -56,132 +56,132 @@  discard block
 block discarded – undo
56 56
  ////////////////////////////
57 57
 //  BigBlueButton API Calls  //
58 58
  ////////////////////////////
59
-function bigbluebuttonbn_getJoinURL( $meetingID, $userName, $PW, $SALT, $URL, $logoutURL ) {
60
-    $url_join = $URL."api/join?";
61
-    $params = 'meetingID='.urlencode($meetingID).'&fullName='.urlencode($userName).'&password='.urlencode($PW).'&logoutURL='.urlencode($logoutURL);
62
-    $url = $url_join.$params.'&checksum='.sha1("join".$params.$SALT);
59
+function bigbluebuttonbn_getJoinURL($meetingID, $userName, $PW, $SALT, $URL, $logoutURL) {
60
+    $url_join = $URL . "api/join?";
61
+    $params = 'meetingID=' . urlencode($meetingID) . '&fullName=' . urlencode($userName) . '&password=' . urlencode($PW) . '&logoutURL=' . urlencode($logoutURL);
62
+    $url = $url_join . $params . '&checksum=' . sha1("join" . $params . $SALT);
63 63
     return $url;
64 64
 }
65 65
 
66
-function bigbluebuttonbn_getCreateMeetingURL($name, $meetingID, $attendeePW, $moderatorPW, $welcome, $logoutURL, $SALT, $URL, $record = 'false', $duration=0, $voiceBridge=0, $maxParticipants=0, $metadata=array() ) {
67
-    $url_create = $URL."api/create?";
66
+function bigbluebuttonbn_getCreateMeetingURL($name, $meetingID, $attendeePW, $moderatorPW, $welcome, $logoutURL, $SALT, $URL, $record = 'false', $duration = 0, $voiceBridge = 0, $maxParticipants = 0, $metadata = array()) {
67
+    $url_create = $URL . "api/create?";
68 68
 
69
-    $params = 'name='.urlencode($name).'&meetingID='.urlencode($meetingID).'&attendeePW='.urlencode($attendeePW).'&moderatorPW='.urlencode($moderatorPW).'&logoutURL='.urlencode($logoutURL).'&record='.$record;
69
+    $params = 'name=' . urlencode($name) . '&meetingID=' . urlencode($meetingID) . '&attendeePW=' . urlencode($attendeePW) . '&moderatorPW=' . urlencode($moderatorPW) . '&logoutURL=' . urlencode($logoutURL) . '&record=' . $record;
70 70
 
71 71
     $voiceBridge = intval($voiceBridge);
72
-    if ( $voiceBridge > 0 && $voiceBridge < 79999) {
73
-        $params .= '&voiceBridge='.$voiceBridge;
72
+    if ($voiceBridge > 0 && $voiceBridge < 79999) {
73
+        $params .= '&voiceBridge=' . $voiceBridge;
74 74
     }
75 75
 
76 76
     $duration = intval($duration);
77
-    if( $duration > 0 ) {
78
-        $params .= '&duration='.$duration;
77
+    if ($duration > 0) {
78
+        $params .= '&duration=' . $duration;
79 79
     }
80 80
 
81 81
     $maxParticipants = intval($maxParticipants);
82
-    if( $maxParticipants > 0 ) {
83
-        $params .= '&maxParticipants='.$maxParticipants;
82
+    if ($maxParticipants > 0) {
83
+        $params .= '&maxParticipants=' . $maxParticipants;
84 84
     }
85 85
 
86
-    if( trim( $welcome ) ) {
87
-        $params .= '&welcome='.urlencode($welcome);
86
+    if (trim($welcome)) {
87
+        $params .= '&welcome=' . urlencode($welcome);
88 88
     }
89 89
 
90 90
     foreach ($metadata as $key => $value) {
91
-        $params .= '&'.$key.'='.urlencode($value);
91
+        $params .= '&' . $key . '=' . urlencode($value);
92 92
     }
93 93
 
94
-    $url = $url_create.$params.'&checksum='.sha1("create".$params.$SALT);
94
+    $url = $url_create . $params . '&checksum=' . sha1("create" . $params . $SALT);
95 95
     return $url;
96 96
 }
97 97
 
98
-function bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) {
99
-    $base_url = $URL."api/isMeetingRunning?";
100
-    $params = 'meetingID='.urlencode($meetingID);
101
-    $url = $base_url.$params.'&checksum='.sha1("isMeetingRunning".$params.$SALT);
98
+function bigbluebuttonbn_getIsMeetingRunningURL($meetingID, $URL, $SALT) {
99
+    $base_url = $URL . "api/isMeetingRunning?";
100
+    $params = 'meetingID=' . urlencode($meetingID);
101
+    $url = $base_url . $params . '&checksum=' . sha1("isMeetingRunning" . $params . $SALT);
102 102
     return $url;
103 103
 }
104 104
 
105
-function bigbluebuttonbn_getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) {
106
-    $base_url = $URL."api/getMeetingInfo?";
107
-    $params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW);
108
-    $url = $base_url.$params.'&checksum='.sha1("getMeetingInfo".$params.$SALT);
105
+function bigbluebuttonbn_getMeetingInfoURL($meetingID, $modPW, $URL, $SALT) {
106
+    $base_url = $URL . "api/getMeetingInfo?";
107
+    $params = 'meetingID=' . urlencode($meetingID) . '&password=' . urlencode($modPW);
108
+    $url = $base_url . $params . '&checksum=' . sha1("getMeetingInfo" . $params . $SALT);
109 109
     return $url;
110 110
 }
111 111
 
112
-function bigbluebuttonbn_getMeetingsURL( $URL, $SALT ) {
113
-    $base_url = $URL."api/getMeetings?";
114
-    $url = $base_url.'&checksum='.sha1("getMeetings".$SALT);
112
+function bigbluebuttonbn_getMeetingsURL($URL, $SALT) {
113
+    $base_url = $URL . "api/getMeetings?";
114
+    $url = $base_url . '&checksum=' . sha1("getMeetings" . $SALT);
115 115
     return $url;
116 116
 }
117 117
 
118
-function bigbluebuttonbn_getEndMeetingURL( $meetingID, $modPW, $URL, $SALT ) {
119
-    $base_url = $URL."api/end?";
120
-    $params = 'meetingID='.urlencode($meetingID).'&password='.urlencode($modPW);
121
-    $url = $base_url.$params.'&checksum='.sha1("end".$params.$SALT);
118
+function bigbluebuttonbn_getEndMeetingURL($meetingID, $modPW, $URL, $SALT) {
119
+    $base_url = $URL . "api/end?";
120
+    $params = 'meetingID=' . urlencode($meetingID) . '&password=' . urlencode($modPW);
121
+    $url = $base_url . $params . '&checksum=' . sha1("end" . $params . $SALT);
122 122
     return $url;
123 123
 }
124 124
 
125
-function bigbluebuttonbn_getRecordingsURL( $URL, $SALT, $meetingID=null ) {
126
-    $base_url_record = $URL."api/getRecordings?";
127
-    if( $meetingID == null ) {
125
+function bigbluebuttonbn_getRecordingsURL($URL, $SALT, $meetingID = null) {
126
+    $base_url_record = $URL . "api/getRecordings?";
127
+    if ($meetingID == null) {
128 128
         $params = "";
129 129
     } else {
130
-        $params = "meetingID=".urlencode($meetingID);
130
+        $params = "meetingID=" . urlencode($meetingID);
131 131
     }
132
-    $url = $base_url_record.$params."&checksum=".sha1("getRecordings".$params.$SALT);
132
+    $url = $base_url_record . $params . "&checksum=" . sha1("getRecordings" . $params . $SALT);
133 133
     return $url;
134 134
 }
135 135
 
136
-function bigbluebuttonbn_getDeleteRecordingsURL( $recordID, $URL, $SALT ) {
137
-    $url_delete = $URL."api/deleteRecordings?";
138
-    $params = 'recordID='.urlencode($recordID);
139
-    $url = $url_delete.$params.'&checksum='.sha1("deleteRecordings".$params.$SALT);
136
+function bigbluebuttonbn_getDeleteRecordingsURL($recordID, $URL, $SALT) {
137
+    $url_delete = $URL . "api/deleteRecordings?";
138
+    $params = 'recordID=' . urlencode($recordID);
139
+    $url = $url_delete . $params . '&checksum=' . sha1("deleteRecordings" . $params . $SALT);
140 140
     return $url;
141 141
 }
142 142
 
143
-function bigbluebuttonbn_getPublishRecordingsURL( $recordID, $set, $URL, $SALT ) {
144
-    $url_publish = $URL."api/publishRecordings?";
145
-    $params = 'recordID='.$recordID."&publish=".$set;
146
-    $url = $url_publish.$params.'&checksum='.sha1("publishRecordings".$params.$SALT);
143
+function bigbluebuttonbn_getPublishRecordingsURL($recordID, $set, $URL, $SALT) {
144
+    $url_publish = $URL . "api/publishRecordings?";
145
+    $params = 'recordID=' . $recordID . "&publish=" . $set;
146
+    $url = $url_publish . $params . '&checksum=' . sha1("publishRecordings" . $params . $SALT);
147 147
     return $url;
148 148
 }
149 149
 
150
-function bigbluebuttonbn_getCreateMeetingArray( $username, $meetingID, $welcomeString, $mPW, $aPW, $SALT, $URL, $logoutURL, $record='false', $duration=0, $voiceBridge=0, $maxParticipants=0, $metadata=array(), $presentation_name=null, $presentation_url=null ) {
150
+function bigbluebuttonbn_getCreateMeetingArray($username, $meetingID, $welcomeString, $mPW, $aPW, $SALT, $URL, $logoutURL, $record = 'false', $duration = 0, $voiceBridge = 0, $maxParticipants = 0, $metadata = array(), $presentation_name = null, $presentation_url = null) {
151 151
     $create_meeting_url = bigbluebuttonbn_getCreateMeetingURL($username, $meetingID, $aPW, $mPW, $welcomeString, $logoutURL, $SALT, $URL, $record, $duration, $voiceBridge, $maxParticipants, $metadata);
152
-    if( !is_null($presentation_name) && !is_null($presentation_url) ) {
153
-        $xml = bigbluebuttonbn_wrap_xml_load_file( $create_meeting_url,
152
+    if (!is_null($presentation_name) && !is_null($presentation_url)) {
153
+        $xml = bigbluebuttonbn_wrap_xml_load_file($create_meeting_url,
154 154
                 BIGBLUEBUTTONBN_METHOD_POST,
155
-                "<?xml version='1.0' encoding='UTF-8'?><modules><module name='presentation'><document url='".$presentation_url."' /></module></modules>"
155
+                "<?xml version='1.0' encoding='UTF-8'?><modules><module name='presentation'><document url='" . $presentation_url . "' /></module></modules>"
156 156
                 );
157 157
     } else {
158
-        $xml = bigbluebuttonbn_wrap_xml_load_file( $create_meeting_url );
158
+        $xml = bigbluebuttonbn_wrap_xml_load_file($create_meeting_url);
159 159
     }
160 160
 
161
-    if ( $xml ) {
161
+    if ($xml) {
162 162
         if ($xml->meetingID) {
163
-            return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey, 'meetingID' => $xml->meetingID, 'attendeePW' => $xml->attendeePW, 'moderatorPW' => $xml->moderatorPW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded );
163
+            return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey, 'meetingID' => $xml->meetingID, 'attendeePW' => $xml->attendeePW, 'moderatorPW' => $xml->moderatorPW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded);
164 164
         } else {
165
-            return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey );
165
+            return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
166 166
         }
167 167
     } else {
168 168
         return null;
169 169
     }
170 170
 }
171 171
 
172
-function bigbluebuttonbn_getMeetingsArray($meetingID, $URL, $SALT ) {
173
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getMeetingsURL($URL, $SALT) );
172
+function bigbluebuttonbn_getMeetingsArray($meetingID, $URL, $SALT) {
173
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getMeetingsURL($URL, $SALT));
174 174
 
175
-    if ( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey ) {    //The meetings were returned
175
+    if ($xml && $xml->returncode == 'SUCCESS' && $xml->messageKey) {    //The meetings were returned
176 176
         return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
177 177
 
178
-    } else if($xml && $xml->returncode == 'SUCCESS') {                    //If there were meetings already created
178
+    } else if ($xml && $xml->returncode == 'SUCCESS') {                    //If there were meetings already created
179 179
         foreach ($xml->meetings->meeting as $meeting) {
180
-            $meetings[] = array( 'meetingID' => $meeting->meetingID, 'moderatorPW' => $meeting->moderatorPW, 'attendeePW' => $meeting->attendeePW, 'hasBeenForciblyEnded' => $meeting->hasBeenForciblyEnded, 'running' => $meeting->running );
180
+            $meetings[] = array('meetingID' => $meeting->meetingID, 'moderatorPW' => $meeting->moderatorPW, 'attendeePW' => $meeting->attendeePW, 'hasBeenForciblyEnded' => $meeting->hasBeenForciblyEnded, 'running' => $meeting->running);
181 181
         }
182 182
         return $meetings;
183 183
 
184
-    } else if( $xml ) { //If the xml packet returned failure it displays the message to the user
184
+    } else if ($xml) { //If the xml packet returned failure it displays the message to the user
185 185
         return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
186 186
 
187 187
     } else { //If the server is unreachable, then prompts the user of the necessary action
@@ -189,21 +189,21 @@  discard block
 block discarded – undo
189 189
     }
190 190
 }
191 191
 
192
-function bigbluebuttonbn_getMeetingInfo( $meetingID, $modPW, $URL, $SALT ) {
193
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) );
192
+function bigbluebuttonbn_getMeetingInfo($meetingID, $modPW, $URL, $SALT) {
193
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getMeetingInfoURL($meetingID, $modPW, $URL, $SALT));
194 194
     return $xml;
195 195
 }
196 196
 
197
-function bigbluebuttonbn_getMeetingInfoArray( $meetingID, $modPW, $URL, $SALT ) {
198
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getMeetingInfoURL( $meetingID, $modPW, $URL, $SALT ) );
197
+function bigbluebuttonbn_getMeetingInfoArray($meetingID, $modPW, $URL, $SALT) {
198
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getMeetingInfoURL($meetingID, $modPW, $URL, $SALT));
199 199
 
200
-    if( $xml && $xml->returncode == 'SUCCESS' && $xml->messageKey == null){//The meeting info was returned
201
-        return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey );
200
+    if ($xml && $xml->returncode == 'SUCCESS' && $xml->messageKey == null) {//The meeting info was returned
201
+        return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
202 202
 
203
-    } else if($xml && $xml->returncode == 'SUCCESS'){ //If there were meetings already created
204
-        return array('returncode' => $xml->returncode, 'meetingID' => $xml->meetingID, 'moderatorPW' => $xml->moderatorPW, 'attendeePW' => $xml->attendeePW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, 'running' => $xml->running, 'recording' => $xml->recording, 'startTime' => $xml->startTime, 'endTime' => $xml->endTime, 'participantCount' => $xml->participantCount, 'moderatorCount' => $xml->moderatorCount, 'attendees' => $xml->attendees, 'metadata' => $xml->metadata );
203
+    } else if ($xml && $xml->returncode == 'SUCCESS') { //If there were meetings already created
204
+        return array('returncode' => $xml->returncode, 'meetingID' => $xml->meetingID, 'moderatorPW' => $xml->moderatorPW, 'attendeePW' => $xml->attendeePW, 'hasBeenForciblyEnded' => $xml->hasBeenForciblyEnded, 'running' => $xml->running, 'recording' => $xml->recording, 'startTime' => $xml->startTime, 'endTime' => $xml->endTime, 'participantCount' => $xml->participantCount, 'moderatorCount' => $xml->moderatorCount, 'attendees' => $xml->attendees, 'metadata' => $xml->metadata);
205 205
 
206
-    } else if( ($xml && $xml->returncode == 'FAILED') || $xml) { //If the xml packet returned failure it displays the message to the user
206
+    } else if (($xml && $xml->returncode == 'FAILED') || $xml) { //If the xml packet returned failure it displays the message to the user
207 207
         return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
208 208
 
209 209
     } else { //If the server is unreachable, then prompts the user of the necessary action
@@ -211,19 +211,19 @@  discard block
 block discarded – undo
211 211
     }
212 212
 }
213 213
 
214
-function bigbluebuttonbn_getRecordingsArray( $meetingIDs, $URL, $SALT ) {
214
+function bigbluebuttonbn_getRecordingsArray($meetingIDs, $URL, $SALT) {
215 215
     $recordings = array();
216 216
 
217
-    if ( is_array($meetingIDs) ) {
217
+    if (is_array($meetingIDs)) {
218 218
         // getRecordings is executed using a method POST (supported only on BBB 1.0 and later)
219
-        $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getRecordingsURL( $URL, $SALT ), BIGBLUEBUTTONBN_METHOD_POST, $meetingIDs );
219
+        $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getRecordingsURL($URL, $SALT), BIGBLUEBUTTONBN_METHOD_POST, $meetingIDs);
220 220
     } else {
221 221
         // getRecordings is executed using a method GET (supported by all versions of BBB)
222
-        $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getRecordingsURL( $URL, $SALT, $meetingIDs ) );
222
+        $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getRecordingsURL($URL, $SALT, $meetingIDs));
223 223
     }
224 224
 
225
-    if ( $xml && $xml->returncode == 'SUCCESS' && isset($xml->recordings) ) { //If there were meetings already created
226
-        foreach ( $xml->recordings->recording as $recording ) {
225
+    if ($xml && $xml->returncode == 'SUCCESS' && isset($xml->recordings)) { //If there were meetings already created
226
+        foreach ($xml->recordings->recording as $recording) {
227 227
             $recordings[] = bigbluebuttonbn_getRecordingArrayRow($recording);
228 228
         }
229 229
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
     return $recordings;
234 234
 }
235 235
 
236
-function bigbluebuttonbn_index_recordings($recordings, $index_key='recordID') {
236
+function bigbluebuttonbn_index_recordings($recordings, $index_key = 'recordID') {
237 237
     $indexed_recordings = array();
238 238
 
239 239
     foreach ($recordings as $recording) {
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
     return $indexed_recordings;
244 244
 }
245 245
 
246
-function bigbluebuttonbn_getRecordingArray( $recordingID, $meetingID, $URL, $SALT ) {
246
+function bigbluebuttonbn_getRecordingArray($recordingID, $meetingID, $URL, $SALT) {
247 247
     $recordingArray = array();
248 248
 
249
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getRecordingsURL( $URL, $SALT, $meetingID ) );
249
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getRecordingsURL($URL, $SALT, $meetingID));
250 250
 
251
-    if ( $xml && $xml->returncode == 'SUCCESS' && isset($xml->recordings) ) { //If there were meetings already created
251
+    if ($xml && $xml->returncode == 'SUCCESS' && isset($xml->recordings)) { //If there were meetings already created
252 252
         foreach ($xml->recordings->recording as $recording) {
253
-            if( $recording->recordID == $recordingID ) {
253
+            if ($recording->recordID == $recordingID) {
254 254
                 $recordingArray = bigbluebuttonbn_getRecordingArrayRow($recording);
255 255
                 break;
256 256
             }
@@ -260,64 +260,64 @@  discard block
 block discarded – undo
260 260
     return $recordingArray;
261 261
 }
262 262
 
263
-function bigbluebuttonbn_getRecordingArrayRow( $recording ) {
263
+function bigbluebuttonbn_getRecordingArrayRow($recording) {
264 264
 
265 265
     $playbackArray = array();
266
-    foreach ( $recording->playback->format as $format ) {
267
-        $playbackArray[(string) $format->type] = array( 'type' => (string) $format->type, 'url' => (string) $format->url, 'length' => (string) $format->length );
266
+    foreach ($recording->playback->format as $format) {
267
+        $playbackArray[(string)$format->type] = array('type' => (string)$format->type, 'url' => (string)$format->url, 'length' => (string)$format->length);
268 268
     }
269 269
 
270 270
     //Add the metadata to the recordings array
271 271
     $metadataArray = array();
272 272
     $metadata = get_object_vars($recording->metadata);
273
-    foreach ( $metadata as $key => $value ) {
274
-        if ( is_object($value) ) {
273
+    foreach ($metadata as $key => $value) {
274
+        if (is_object($value)) {
275 275
             $value = '';
276 276
         }
277
-        $metadataArray['meta_'.$key] = $value;
277
+        $metadataArray['meta_' . $key] = $value;
278 278
     }
279 279
 
280
-    $recordingArrayRow = array( 'recordID' => (string) $recording->recordID, 'meetingID' => (string) $recording->meetingID, 'meetingName' => (string) $recording->name, 'published' => (string) $recording->published, 'startTime' => (string) $recording->startTime, 'endTime' => (string) $recording->endTime, 'playbacks' => $playbackArray ) + $metadataArray;
280
+    $recordingArrayRow = array('recordID' => (string)$recording->recordID, 'meetingID' => (string)$recording->meetingID, 'meetingName' => (string)$recording->name, 'published' => (string)$recording->published, 'startTime' => (string)$recording->startTime, 'endTime' => (string)$recording->endTime, 'playbacks' => $playbackArray) + $metadataArray;
281 281
 
282 282
     return $recordingArrayRow;
283 283
 }
284 284
 
285
-function bigbluebuttonbn_recordingBuildSorter($a, $b){
286
-    if ( $a['startTime'] < $b['startTime'] ) {
285
+function bigbluebuttonbn_recordingBuildSorter($a, $b) {
286
+    if ($a['startTime'] < $b['startTime']) {
287 287
         return -1;
288
-    } else if ( $a['startTime'] == $b['startTime']) {
288
+    } else if ($a['startTime'] == $b['startTime']) {
289 289
         return 0;
290 290
     } else {
291 291
         return 1;
292 292
     }
293 293
 }
294 294
 
295
-function bigbluebuttonbn_doDeleteRecordings( $recordIDs, $URL, $SALT ) {
296
-    $ids = 	explode(",", $recordIDs);
297
-    foreach( $ids as $id){
298
-        $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getDeleteRecordingsURL($id, $URL, $SALT) );
299
-        if( $xml && $xml->returncode != 'SUCCESS' ) {
295
+function bigbluebuttonbn_doDeleteRecordings($recordIDs, $URL, $SALT) {
296
+    $ids = explode(",", $recordIDs);
297
+    foreach ($ids as $id) {
298
+        $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getDeleteRecordingsURL($id, $URL, $SALT));
299
+        if ($xml && $xml->returncode != 'SUCCESS') {
300 300
             return false;
301 301
         }
302 302
     }
303 303
     return true;
304 304
 }
305 305
 
306
-function bigbluebuttonbn_doPublishRecordings( $recordIDs, $set, $URL, $SALT ) {
307
-    $ids = 	explode(",", $recordIDs);
308
-    foreach( $ids as $id){
309
-        $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getPublishRecordingsURL($id, $set, $URL, $SALT) );
310
-        if( $xml && $xml->returncode != 'SUCCESS' ) {
306
+function bigbluebuttonbn_doPublishRecordings($recordIDs, $set, $URL, $SALT) {
307
+    $ids = explode(",", $recordIDs);
308
+    foreach ($ids as $id) {
309
+        $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getPublishRecordingsURL($id, $set, $URL, $SALT));
310
+        if ($xml && $xml->returncode != 'SUCCESS') {
311 311
             return false;
312 312
         }
313 313
     }
314 314
     return true;
315 315
 }
316 316
 
317
-function bigbluebuttonbn_doEndMeeting( $meetingID, $modPW, $URL, $SALT ) {
318
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getEndMeetingURL( $meetingID, $modPW, $URL, $SALT ) );
317
+function bigbluebuttonbn_doEndMeeting($meetingID, $modPW, $URL, $SALT) {
318
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getEndMeetingURL($meetingID, $modPW, $URL, $SALT));
319 319
 
320
-    if( $xml ) { //If the xml packet returned failure it displays the message to the user
320
+    if ($xml) { //If the xml packet returned failure it displays the message to the user
321 321
         return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
322 322
     }
323 323
     else { //If the server is unreachable, then prompts the user of the necessary action
@@ -325,46 +325,46 @@  discard block
 block discarded – undo
325 325
     }
326 326
 }
327 327
 
328
-function bigbluebuttonbn_isMeetingRunning( $meetingID, $URL, $SALT ) {
329
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) );
330
-    if ( $xml && $xml->returncode == 'SUCCESS' ) {
331
-        return ( ( $xml->running == 'true' ) ? true : false);
328
+function bigbluebuttonbn_isMeetingRunning($meetingID, $URL, $SALT) {
329
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getIsMeetingRunningURL($meetingID, $URL, $SALT));
330
+    if ($xml && $xml->returncode == 'SUCCESS') {
331
+        return (($xml->running == 'true') ? true : false);
332 332
     } else {
333
-        return ( false );
333
+        return (false);
334 334
     }
335 335
 }
336 336
 
337 337
 
338
-function bigbluebuttonbn_getServerVersion( $URL ){
339
-    $xml = bigbluebuttonbn_wrap_xml_load_file( $URL."api" );
340
-    if ( $xml && $xml->returncode == 'SUCCESS' ) {
338
+function bigbluebuttonbn_getServerVersion($URL) {
339
+    $xml = bigbluebuttonbn_wrap_xml_load_file($URL . "api");
340
+    if ($xml && $xml->returncode == 'SUCCESS') {
341 341
         return $xml->version;
342 342
     } else {
343 343
         return NULL;
344 344
     }
345 345
 }
346 346
 
347
-function bigbluebuttonbn_getMeetingXML( $meetingID, $URL, $SALT ) {
348
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) );
349
-    if ( $xml && $xml->returncode == 'SUCCESS') {
350
-        return ( str_replace('</response>', '', str_replace("<?xml version=\"1.0\"?>\n<response>", '', $xml->asXML())));
347
+function bigbluebuttonbn_getMeetingXML($meetingID, $URL, $SALT) {
348
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getIsMeetingRunningURL($meetingID, $URL, $SALT));
349
+    if ($xml && $xml->returncode == 'SUCCESS') {
350
+        return (str_replace('</response>', '', str_replace("<?xml version=\"1.0\"?>\n<response>", '', $xml->asXML())));
351 351
     } else {
352 352
         return 'false';
353 353
     }
354 354
 }
355 355
 
356
-function bigbluebuttonbn_wrap_xml_load_file($url, $method=BIGBLUEBUTTONBN_METHOD_GET, $data=null) {
357
-    if ( bigbluebuttonbn_debugdisplay() ) error_log("Request to: ".$url);
356
+function bigbluebuttonbn_wrap_xml_load_file($url, $method = BIGBLUEBUTTONBN_METHOD_GET, $data = null) {
357
+    if (bigbluebuttonbn_debugdisplay()) error_log("Request to: " . $url);
358 358
 
359 359
     if (extension_loaded('curl')) {
360 360
         $c = new curl();
361
-        $c->setopt( Array( "SSL_VERIFYPEER" => true));
362
-        if( $method == BIGBLUEBUTTONBN_METHOD_POST ) {
363
-            if( !is_null($data) ) {
364
-                if( !is_array($data) ) {
361
+        $c->setopt(Array("SSL_VERIFYPEER" => true));
362
+        if ($method == BIGBLUEBUTTONBN_METHOD_POST) {
363
+            if (!is_null($data)) {
364
+                if (!is_array($data)) {
365 365
                     $options['CURLOPT_HTTPHEADER'] = array(
366 366
                             'Content-Type: text/xml',
367
-                            'Content-Length: '.strlen($data),
367
+                            'Content-Length: ' . strlen($data),
368 368
                             'Content-Language: en-US'
369 369
                         );
370 370
                     $response = $c->post($url, $data, $options);
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
             try {
387 387
                 $xml = new SimpleXMLElement($response, LIBXML_NOCDATA);
388 388
                 return $xml;
389
-            } catch (Exception $e){
389
+            } catch (Exception $e) {
390 390
                 libxml_use_internal_errors($previous);
391
-                $error = 'Caught exception: '.$e->getMessage();
391
+                $error = 'Caught exception: ' . $e->getMessage();
392 392
                 error_log($error);
393 393
                 return NULL;
394 394
             }
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
     } else {
401 401
         $previous = libxml_use_internal_errors(true);
402 402
         try {
403
-            $xml = simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA);
403
+            $xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
404 404
             return $xml;
405
-        } catch  (Exception $e){
405
+        } catch (Exception $e) {
406 406
             libxml_use_internal_errors($previous);
407 407
             return NULL;
408 408
         }
@@ -416,10 +416,10 @@  discard block
 block discarded – undo
416 416
     $user_roles = get_user_roles($context, $userid);
417 417
     if ($user_roles) {
418 418
         $where = '';
419
-        foreach ($user_roles as $key => $value){
420
-            $where .= (empty($where) ? ' WHERE' : ' AND').' id='.$value->roleid;
419
+        foreach ($user_roles as $key => $value) {
420
+            $where .= (empty($where) ? ' WHERE' : ' AND') . ' id=' . $value->roleid;
421 421
         }
422
-        $user_roles = $DB->get_records_sql('SELECT * FROM {role}'.$where);
422
+        $user_roles = $DB->get_records_sql('SELECT * FROM {role}' . $where);
423 423
     }
424 424
     return $user_roles;
425 425
 }
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
     return array($guest_role->id => $guest_role);
430 430
 }
431 431
 
432
-function bigbluebuttonbn_get_role_name($role_shortname){
432
+function bigbluebuttonbn_get_role_name($role_shortname) {
433 433
     $role = bigbluebuttonbn_get_db_moodle_roles($role_shortname);
434
-    if( $role != null && $role->name != "") {
434
+    if ($role != null && $role->name != "") {
435 435
         $role_name = $role->name;
436 436
     } else {
437 437
         switch ($role_shortname) {
@@ -451,13 +451,13 @@  discard block
 block discarded – undo
451 451
     return $role_name;
452 452
 }
453 453
 
454
-function bigbluebuttonbn_get_roles($rolename='all', $format='json'){
454
+function bigbluebuttonbn_get_roles($rolename = 'all', $format = 'json') {
455 455
     $roles = bigbluebuttonbn_get_db_moodle_roles($rolename);
456 456
     $roles_array = array();
457
-    foreach($roles as $role){
458
-        if( $format=='json' ) {
457
+    foreach ($roles as $role) {
458
+        if ($format == 'json') {
459 459
             array_push($roles_array,
460
-                    array( "id" => $role->shortname,
460
+                    array("id" => $role->shortname,
461 461
                         "name" => bigbluebuttonbn_get_role_name($role->shortname)
462 462
                     )
463 463
             );
@@ -468,19 +468,19 @@  discard block
 block discarded – undo
468 468
     return $roles_array;
469 469
 }
470 470
 
471
-function bigbluebuttonbn_get_roles_json($rolename='all'){
471
+function bigbluebuttonbn_get_roles_json($rolename = 'all') {
472 472
     return json_encode(bigbluebuttonbn_get_roles($rolename));
473 473
 }
474 474
 
475
-function bigbluebuttonbn_get_users_json($users, $full=false) {
476
-    if( $full ) {
475
+function bigbluebuttonbn_get_users_json($users, $full = false) {
476
+    if ($full) {
477 477
         return json_encode($users);
478 478
     } else {
479 479
         $users_array = array();
480
-        foreach($users as $user){
480
+        foreach ($users as $user) {
481 481
             array_push($users_array,
482
-                    array( "id" => $user->id,
483
-                            "name" => $user->firstname.' '.$user->lastname
482
+                    array("id" => $user->id,
483
+                            "name" => $user->firstname . ' ' . $user->lastname
484 484
                     )
485 485
             );
486 486
         }
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
     }
489 489
 }
490 490
 
491
-function bigbluebuttonbn_get_participant_list($bigbluebuttonbn=null, $context=null){
491
+function bigbluebuttonbn_get_participant_list($bigbluebuttonbn = null, $context = null) {
492 492
     global $CFG, $USER;
493 493
 
494 494
     $participant_list_array = array();
495 495
 
496
-    if( $bigbluebuttonbn != null ) {
496
+    if ($bigbluebuttonbn != null) {
497 497
         $participant_list = json_decode($bigbluebuttonbn->participants);
498 498
         if (is_array($participant_list)) {
499
-            foreach($participant_list as $participant){
499
+            foreach ($participant_list as $participant) {
500 500
                 array_push($participant_list_array,
501 501
                         array(
502 502
                             "selectiontype" => $participant->selectiontype,
@@ -516,16 +516,16 @@  discard block
 block discarded – undo
516 516
         );
517 517
 
518 518
         $moderator_defaults = bigbluebuttonbn_get_cfg_moderator_default();
519
-        if ( !isset($moderator_defaults) ) {
519
+        if (!isset($moderator_defaults)) {
520 520
             $moderator_defaults = array('owner');
521 521
         } else {
522 522
             $moderator_defaults = explode(',', $moderator_defaults);
523 523
         }
524
-        foreach( $moderator_defaults as $moderator_default ) {
525
-            if( $moderator_default == 'owner' ) {
524
+        foreach ($moderator_defaults as $moderator_default) {
525
+            if ($moderator_default == 'owner') {
526 526
                 $users = bigbluebuttonbn_get_users($context);
527
-                foreach( $users as $user ){
528
-                    if( $user->id == $USER->id ){
527
+                foreach ($users as $user) {
528
+                    if ($user->id == $USER->id) {
529 529
                         array_push($participant_list_array,
530 530
                                 array(
531 531
                                         "selectiontype" => "user",
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
     return $participant_list_array;
552 552
 }
553 553
 
554
-function bigbluebuttonbn_get_participant_list_json($bigbluebuttonbnid=null){
554
+function bigbluebuttonbn_get_participant_list_json($bigbluebuttonbnid = null) {
555 555
     return json_encode(bigbluebuttonbn_get_participant_list($bigbluebuttonbnid));
556 556
 }
557 557
 
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
 
561 561
     if (is_array($participant_list)) {
562 562
         // Iterate looking for all configuration
563
-        foreach($participant_list as $participant){
564
-            if( $participant->selectiontype == 'all' ) {
565
-                if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) {
563
+        foreach ($participant_list as $participant) {
564
+            if ($participant->selectiontype == 'all') {
565
+                if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) {
566 566
                     return true;
567 567
                 }
568 568
             }
@@ -570,12 +570,12 @@  discard block
 block discarded – undo
570 570
 
571 571
         //Iterate looking for roles
572 572
         $db_moodle_roles = bigbluebuttonbn_get_db_moodle_roles();
573
-        foreach($participant_list as $participant){
574
-            if( $participant->selectiontype == 'role' ) {
575
-                foreach( $roles as $role ) {
573
+        foreach ($participant_list as $participant) {
574
+            if ($participant->selectiontype == 'role') {
575
+                foreach ($roles as $role) {
576 576
                     $db_moodle_role = bigbluebuttonbn_moodle_db_role_lookup($db_moodle_roles, $role->id);
577
-                    if( $participant->selectionid == $db_moodle_role->shortname ) {
578
-                        if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) {
577
+                    if ($participant->selectionid == $db_moodle_role->shortname) {
578
+                        if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) {
579 579
                             return true;
580 580
                         }
581 581
                     }
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
         }
585 585
 
586 586
         //Iterate looking for users
587
-        foreach($participant_list as $participant){
588
-            if( $participant->selectiontype == 'user' ) {
589
-                if( $participant->selectionid == $user ) {
590
-                    if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) {
587
+        foreach ($participant_list as $participant) {
588
+            if ($participant->selectiontype == 'user') {
589
+                if ($participant->selectionid == $user) {
590
+                    if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) {
591 591
                         return true;
592 592
                     }
593 593
                 }
@@ -599,8 +599,8 @@  discard block
 block discarded – undo
599 599
 }
600 600
 
601 601
 function bigbluebuttonbn_moodle_db_role_lookup($db_moodle_roles, $role_id) {
602
-    foreach( $db_moodle_roles as $db_moodle_role ){
603
-        if( $role_id ==  $db_moodle_role->id ) {
602
+    foreach ($db_moodle_roles as $db_moodle_role) {
603
+        if ($role_id == $db_moodle_role->id) {
604 604
             return $db_moodle_role;
605 605
         }
606 606
     }
@@ -608,25 +608,25 @@  discard block
 block discarded – undo
608 608
 
609 609
 function bigbluebuttonbn_get_error_key($messageKey, $defaultKey = null) {
610 610
     $key = $defaultKey;
611
-    if ( $messageKey == "checksumError" ) {
611
+    if ($messageKey == "checksumError") {
612 612
         $key = 'index_error_checksum';
613
-    } else if ( $messageKey == 'maxConcurrent' ) {
613
+    } else if ($messageKey == 'maxConcurrent') {
614 614
         $key = 'view_error_max_concurrent';
615 615
     }
616 616
     return $key;
617 617
 }
618 618
 
619
-function bigbluebuttonbn_voicebridge_unique($voicebridge, $id=null) {
619
+function bigbluebuttonbn_voicebridge_unique($voicebridge, $id = null) {
620 620
     global $DB;
621 621
 
622 622
     $is_unique = true;
623
-    if ( $voicebridge != 0 ) {
623
+    if ($voicebridge != 0) {
624 624
         $table = "bigbluebuttonbn";
625
-        $select = "voicebridge = ".$voicebridge;
626
-        if ( $id ) {
627
-            $select .= " AND id <> ".$id;
625
+        $select = "voicebridge = " . $voicebridge;
626
+        if ($id) {
627
+            $select .= " AND id <> " . $id;
628 628
         }
629
-        if ( $rooms = $DB->get_records_select($table, $select)  ) {
629
+        if ($rooms = $DB->get_records_select($table, $select)) {
630 630
             $is_unique = false;
631 631
         }
632 632
     }
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 
640 640
     $duration = 0;
641 641
     $now = time();
642
-    if ( $closingtime > 0 && $now < $closingtime ) {
643
-        $duration = ceil(($closingtime - $now)/60);
642
+    if ($closingtime > 0 && $now < $closingtime) {
643
+        $duration = ceil(($closingtime - $now) / 60);
644 644
         $compensation_time = intval(bigbluebuttonbn_get_cfg_scheduled_duration_compensation());
645 645
         $duration = intval($duration) + $compensation_time;
646 646
     }
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
     return $duration;
649 649
 }
650 650
 
651
-function bigbluebuttonbn_get_presentation_array($context, $presentation, $id=null) {
651
+function bigbluebuttonbn_get_presentation_array($context, $presentation, $id = null) {
652 652
     $presentation_name = null;
653 653
     $presentation_url = null;
654 654
     $presentation_icon = null;
655 655
     $presentation_mimetype_description = null;
656 656
 
657
-    if ( !empty($presentation) ) {
657
+    if (!empty($presentation)) {
658 658
         $fs = get_file_storage();
659 659
         $files = $fs->get_area_files($context->id, 'mod_bigbluebuttonbn', 'presentation', 0, 'itemid, filepath, filename', false);
660 660
         if (count($files) < 1) {
@@ -668,12 +668,12 @@  discard block
 block discarded – undo
668 668
             $presentation_icon = file_file_icon($file, 24);
669 669
             $presentation_mimetype_description = get_mimetype_description($file);
670 670
 
671
-            if( !is_null($id) ) {
671
+            if (!is_null($id)) {
672 672
                 //Create the nonce component for granting a temporary public access
673 673
                 $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'presentation_cache');
674 674
                 $presentation_nonce_key = sha1($id);
675 675
                 $presentation_nonce_value = bigbluebuttonbn_generate_nonce();
676
-                $cache->set($presentation_nonce_key, array( "value" => $presentation_nonce_value, "counter" => 0 ));
676
+                $cache->set($presentation_nonce_key, array("value" => $presentation_nonce_value, "counter" => 0));
677 677
 
678 678
                 //The item id was adapted for granting public access to the presentation once in order to allow BigBlueButton to gather the file
679 679
                 $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $presentation_nonce_value, $file->get_filepath(), $file->get_filename());
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
         }
685 685
     }
686 686
 
687
-    $presentation_array = array( "url" => $presentation_url, "name" => $presentation_name, "icon" => $presentation_icon, "mimetype_description" => $presentation_mimetype_description);
687
+    $presentation_array = array("url" => $presentation_url, "name" => $presentation_name, "icon" => $presentation_icon, "mimetype_description" => $presentation_mimetype_description);
688 688
 
689 689
     return $presentation_array;
690 690
 }
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
     $mt = microtime();
695 695
     $rand = mt_rand();
696 696
 
697
-    return md5($mt.$rand);
697
+    return md5($mt . $rand);
698 698
 }
699 699
 
700
-function bigbluebuttonbn_random_password( $length = 8 ) {
700
+function bigbluebuttonbn_random_password($length = 8) {
701 701
 
702 702
     $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
703
-    $password = substr( str_shuffle( $chars ), 0, $length );
703
+    $password = substr(str_shuffle($chars), 0, $length);
704 704
 
705 705
     return $password;
706 706
 }
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
     global $CFG;
793 793
 
794 794
     $version_major = bigbluebuttonbn_get_moodle_version_major();
795
-    if ( $version_major < '2014051200' ) {
795
+    if ($version_major < '2014051200') {
796 796
         //This is valid before v2.7
797 797
         bigbluebuttonbn_event_log_legacy($event_type, $bigbluebuttonbn, $context, $cm);
798 798
 
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
     }
803 803
 }
804 804
 
805
-function bigbluebuttonbn_bbb_broker_get_recordings($meetingid, $password, $forced=false) {
805
+function bigbluebuttonbn_bbb_broker_get_recordings($meetingid, $password, $forced = false) {
806 806
     global $CFG;
807 807
 
808 808
     $recordings = array();
@@ -818,19 +818,19 @@  discard block
 block discarded – undo
818 818
     $result = $cache->get($meetingid);
819 819
     $meeting_info = json_decode($result['meeting_info']);
820 820
     $meeting_info->participantCount += 1;
821
-    if( $is_moderator ) {
821
+    if ($is_moderator) {
822 822
         $meeting_info->moderatorCount += 1;
823 823
     }
824
-    $cache->set($meetingid, array('creation_time' => $result['creation_time'], 'meeting_info' => json_encode($meeting_info) ));
824
+    $cache->set($meetingid, array('creation_time' => $result['creation_time'], 'meeting_info' => json_encode($meeting_info)));
825 825
 }
826 826
 
827 827
 function bigbluebuttonbn_bbb_broker_is_meeting_running($meeting_info) {
828
-    $meeting_running = ( isset($meeting_info) && isset($meeting_info->returncode) && $meeting_info->returncode == 'SUCCESS' );
828
+    $meeting_running = (isset($meeting_info) && isset($meeting_info->returncode) && $meeting_info->returncode == 'SUCCESS');
829 829
 
830 830
     return $meeting_running;
831 831
 }
832 832
 
833
-function bigbluebuttonbn_bbb_broker_get_meeting_info($meetingid, $password, $forced=false) {
833
+function bigbluebuttonbn_bbb_broker_get_meeting_info($meetingid, $password, $forced = false) {
834 834
     global $CFG;
835 835
 
836 836
     $meeting_info = array();
@@ -841,19 +841,19 @@  discard block
 block discarded – undo
841 841
     $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'meetings_cache');
842 842
     $result = $cache->get($meetingid);
843 843
     $now = time();
844
-    if( isset($result) && $now < ($result['creation_time'] + $cache_ttl) && !$forced ) {
844
+    if (isset($result) && $now < ($result['creation_time'] + $cache_ttl) && !$forced) {
845 845
         //Use the value in the cache
846 846
         $meeting_info = json_decode($result['meeting_info']);
847 847
     } else {
848 848
         //Ping again and refresh the cache
849
-        $meeting_info = (array) bigbluebuttonbn_getMeetingInfo( $meetingid, $password, $endpoint, $shared_secret );
850
-        $cache->set($meetingid, array('creation_time' => time(), 'meeting_info' => json_encode($meeting_info) ));
849
+        $meeting_info = (array)bigbluebuttonbn_getMeetingInfo($meetingid, $password, $endpoint, $shared_secret);
850
+        $cache->set($meetingid, array('creation_time' => time(), 'meeting_info' => json_encode($meeting_info)));
851 851
     }
852 852
 
853 853
     return $meeting_info;
854 854
 }
855 855
 
856
-function bigbluebuttonbn_bbb_broker_do_end_meeting($meetingid, $password){
856
+function bigbluebuttonbn_bbb_broker_do_end_meeting($meetingid, $password) {
857 857
     global $CFG;
858 858
 
859 859
     $endpoint = bigbluebuttonbn_get_cfg_server_url();
@@ -862,16 +862,16 @@  discard block
 block discarded – undo
862 862
     bigbluebuttonbn_doEndMeeting($meetingid, $password, $endpoint, $shared_secret);
863 863
 }
864 864
 
865
-function bigbluebuttonbn_bbb_broker_do_publish_recording($recordingid, $publish=true){
865
+function bigbluebuttonbn_bbb_broker_do_publish_recording($recordingid, $publish = true) {
866 866
     global $CFG;
867 867
 
868 868
     $endpoint = bigbluebuttonbn_get_cfg_server_url();
869 869
     $shared_secret = bigbluebuttonbn_get_cfg_shared_secret();
870 870
 
871
-    bigbluebuttonbn_doPublishRecordings($recordingid, ($publish)? 'true': 'false', $endpoint, $shared_secret);
871
+    bigbluebuttonbn_doPublishRecordings($recordingid, ($publish) ? 'true' : 'false', $endpoint, $shared_secret);
872 872
 }
873 873
 
874
-function bigbluebuttonbn_bbb_broker_do_publish_recording_imported($recordingid, $courseID, $bigbluebuttonbnID, $publish=true){
874
+function bigbluebuttonbn_bbb_broker_do_publish_recording_imported($recordingid, $courseID, $bigbluebuttonbnID, $publish = true) {
875 875
     global $DB;
876 876
 
877 877
     //Locate the record to be updated
@@ -880,9 +880,9 @@  discard block
 block discarded – undo
880 880
     $recordings_imported = array();
881 881
     foreach ($records as $key => $record) {
882 882
         $meta = json_decode($record->meta, true);
883
-        if( $recordingid == $meta['recording']['recordID'] ) {
883
+        if ($recordingid == $meta['recording']['recordID']) {
884 884
             // Found, prepare data for the update
885
-            $meta['recording']['published'] = ($publish)? 'true': 'false';
885
+            $meta['recording']['published'] = ($publish) ? 'true' : 'false';
886 886
             $records[$key]->meta = json_encode($meta);
887 887
 
888 888
             // Proceed with the update
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
     }
892 892
 }
893 893
 
894
-function bigbluebuttonbn_bbb_broker_do_delete_recording($recordingid){
894
+function bigbluebuttonbn_bbb_broker_do_delete_recording($recordingid) {
895 895
     global $CFG;
896 896
 
897 897
     $endpoint = bigbluebuttonbn_get_cfg_server_url();
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
     bigbluebuttonbn_doDeleteRecordings($recordingid, $endpoint, $shared_secret);
901 901
 }
902 902
 
903
-function bigbluebuttonbn_bbb_broker_do_delete_recording_imported($recordingid, $courseID, $bigbluebuttonbnID){
903
+function bigbluebuttonbn_bbb_broker_do_delete_recording_imported($recordingid, $courseID, $bigbluebuttonbnID) {
904 904
     global $DB;
905 905
 
906 906
     //Locate the record to be updated
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
     $recordings_imported = array();
910 910
     foreach ($records as $key => $record) {
911 911
         $meta = json_decode($record->meta, true);
912
-        if( $recordingid == $meta['recording']['recordID'] ) {
912
+        if ($recordingid == $meta['recording']['recordID']) {
913 913
             // Execute delete
914 914
             $DB->delete_records("bigbluebuttonbn_logs", array('id' => $key));
915 915
         }
@@ -919,18 +919,18 @@  discard block
 block discarded – undo
919 919
 function bigbluebuttonbn_bbb_broker_validate_parameters($params) {
920 920
     $error = '';
921 921
 
922
-    if ( !isset($params['callback']) ) {
922
+    if (!isset($params['callback'])) {
923 923
         $error = bigbluebuttonbn_bbb_broker_add_error($error, 'This call must include a javascript callback.');
924 924
     }
925 925
 
926
-    if ( !isset($params['action']) ) {
926
+    if (!isset($params['action'])) {
927 927
         $error = bigbluebuttonbn_bbb_broker_add_error($error, 'Action parameter must be included.');
928 928
     } else {
929
-        switch ( strtolower($params['action']) ){
929
+        switch (strtolower($params['action'])) {
930 930
             case 'server_ping':
931 931
             case 'meeting_info':
932 932
             case 'meeting_end':
933
-                if ( !isset($params['id']) ) {
933
+                if (!isset($params['id'])) {
934 934
                     $error = bigbluebuttonbn_bbb_broker_add_error($error, 'The meetingID must be specified.');
935 935
                 }
936 936
                 break;
@@ -940,76 +940,76 @@  discard block
 block discarded – undo
940 940
             case 'recording_unpublish':
941 941
             case 'recording_delete':
942 942
             case 'recording_import':
943
-                if ( !isset($params['id']) ) {
943
+                if (!isset($params['id'])) {
944 944
                     $error = bigbluebuttonbn_bbb_broker_add_error($error, 'The recordingID must be specified.');
945 945
                 }
946 946
                 break;
947 947
             case 'recording_ready':
948
-                if( empty($params['signed_parameters']) ) {
948
+                if (empty($params['signed_parameters'])) {
949 949
                     $error = bigbluebuttonbn_bbb_broker_add_error($error, 'A JWT encoded string must be included as [signed_parameters].');
950 950
                 }
951 951
                 break;
952 952
             default:
953
-                $error = bigbluebuttonbn_bbb_broker_add_error($error, 'Action '.$params['action'].' can not be performed.');
953
+                $error = bigbluebuttonbn_bbb_broker_add_error($error, 'Action ' . $params['action'] . ' can not be performed.');
954 954
         }
955 955
     }
956 956
 
957 957
     return $error;
958 958
 }
959 959
 
960
-function bigbluebuttonbn_bbb_broker_add_error($org_msg, $new_msg='') {
960
+function bigbluebuttonbn_bbb_broker_add_error($org_msg, $new_msg = '') {
961 961
     $error = $org_msg;
962 962
 
963
-    if( !empty($new_msg) ) {
964
-        if( !empty($error) ) $error .= ' ';
963
+    if (!empty($new_msg)) {
964
+        if (!empty($error)) $error .= ' ';
965 965
         $error .= $new_msg;
966 966
     }
967 967
 
968 968
     return $error;
969 969
 }
970 970
 
971
-function bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools=["publishing", "deleting"]) {
971
+function bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools = ["publishing", "deleting"]) {
972 972
     global $OUTPUT, $CFG, $USER;
973 973
 
974 974
     $row = null;
975 975
 
976
-    if ( $bbbsession['managerecordings'] || $recording['published'] == 'true' ) {
977
-        $startTime = isset($recording['startTime'])? floatval($recording['startTime']):0;
976
+    if ($bbbsession['managerecordings'] || $recording['published'] == 'true') {
977
+        $startTime = isset($recording['startTime']) ? floatval($recording['startTime']) : 0;
978 978
         $startTime = $startTime - ($startTime % 1000);
979 979
         $duration = intval(array_values($recording['playbacks'])[0]['length']);
980 980
 
981 981
         //For backward compatibility
982
-        if( isset($recording['meta_contextactivity']) ) {
982
+        if (isset($recording['meta_contextactivity'])) {
983 983
             $meta_activity = str_replace('"', '\"', $recording['meta_contextactivity']);
984
-        } if( isset($recording['meta_bbb-recording-name']) ) {
984
+        } if (isset($recording['meta_bbb-recording-name'])) {
985 985
             $meta_activity = str_replace('"', '\"', $recording['meta_bbb-recording-name']);
986 986
         } else {
987 987
             $meta_activity = str_replace('"', '\"', $recording['meetingName']);
988 988
         }
989 989
 
990
-        if( isset($recording['meta_contextactivitydescription']) ) {
990
+        if (isset($recording['meta_contextactivitydescription'])) {
991 991
             $meta_description = str_replace('"', '\"', $recording['meta_contextactivitydescription']);
992
-        } else if( isset($recording['meta_bbb-recording-description']) ) {
992
+        } else if (isset($recording['meta_bbb-recording-description'])) {
993 993
             $meta_description = str_replace('"', '\"', $recording['meta_bbb-recording-description']);
994 994
         } else {
995 995
             $meta_description = '';
996 996
         }
997 997
 
998 998
         //Set recording_types
999
-        if ( isset($recording['imported']) ) {
1000
-            $attributes = 'data-imported="true" title='.get_string('view_recording_link_warning', 'bigbluebuttonbn');
999
+        if (isset($recording['imported'])) {
1000
+            $attributes = 'data-imported="true" title=' . get_string('view_recording_link_warning', 'bigbluebuttonbn');
1001 1001
         } else {
1002 1002
             $attributes = 'data-imported="false"';
1003 1003
         }
1004 1004
 
1005 1005
         $recording_types = '';
1006 1006
         if ($recording['published'] == 'true') {
1007
-            $recording_types .= '<div id="playbacks-'.$recording['recordID'].'" '.$attributes.'>';
1007
+            $recording_types .= '<div id="playbacks-' . $recording['recordID'] . '" ' . $attributes . '>';
1008 1008
         } else {
1009
-            $recording_types .= '<div id="playbacks-'.$recording['recordID'].'" '.$attributes.'" hidden>';
1009
+            $recording_types .= '<div id="playbacks-' . $recording['recordID'] . '" ' . $attributes . '" hidden>';
1010 1010
         }
1011
-        foreach ( $recording['playbacks'] as $playback ) {
1012
-            $recording_types .= $OUTPUT->action_link($playback['url'], get_string('view_recording_format_'.$playback['type'], 'bigbluebuttonbn'), null, array('title' => get_string('view_recording_format_'.$playback['type'], 'bigbluebuttonbn'), 'target' => '_new') ).'&#32;';
1011
+        foreach ($recording['playbacks'] as $playback) {
1012
+            $recording_types .= $OUTPUT->action_link($playback['url'], get_string('view_recording_format_' . $playback['type'], 'bigbluebuttonbn'), null, array('title' => get_string('view_recording_format_' . $playback['type'], 'bigbluebuttonbn'), 'target' => '_new')) . '&#32;';
1013 1013
         }
1014 1014
         $recording_types .= '</div>';
1015 1015
 
@@ -1018,11 +1018,11 @@  discard block
 block discarded – undo
1018 1018
 
1019 1019
         //Set actionbar, if user is allowed to manage recordings
1020 1020
         $actionbar = '';
1021
-        if ( $bbbsession['managerecordings'] ) {
1021
+        if ($bbbsession['managerecordings']) {
1022 1022
             // Set style for imported links
1023
-            if( isset($recording['imported']) ) {
1023
+            if (isset($recording['imported'])) {
1024 1024
                 $recordings_imported_count = 0;
1025
-                $tag_tail = ' '.get_string('view_recording_link', 'bigbluebuttonbn');
1025
+                $tag_tail = ' ' . get_string('view_recording_link', 'bigbluebuttonbn');
1026 1026
                 $head = '<i>';
1027 1027
                 $tail = '</i>';
1028 1028
             } else {
@@ -1036,53 +1036,53 @@  discard block
 block discarded – undo
1036 1036
 
1037 1037
             if (in_array("publishing", $tools)) {
1038 1038
                 ///Set action [show|hide]
1039
-                if ( $recording['published'] == 'true' ){
1039
+                if ($recording['published'] == 'true') {
1040 1040
                     $manage_tag = 'hide';
1041 1041
                     $manage_action = 'unpublish';
1042 1042
                 } else {
1043 1043
                     $manage_tag = 'show';
1044 1044
                     $manage_action = 'publish';
1045 1045
                 }
1046
-                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("'.$manage_action.'", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");';
1046
+                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("' . $manage_action . '", "' . $recording['recordID'] . '", "' . $recording['meetingID'] . '");';
1047 1047
 
1048
-                if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) {
1048
+                if (bigbluebuttonbn_get_cfg_recording_icons_enabled()) {
1049 1049
                     //With icon for publish/unpublish
1050
-                    $icon_attributes = array('id' => 'recording-btn-'.$manage_action.'-'.$recording['recordID']);
1051
-                    $icon = new pix_icon('t/'.$manage_tag, get_string($manage_tag).$tag_tail, 'moodle', $icon_attributes);
1052
-                    $link_attributes = array('id' => 'recording-link-'.$manage_action.'-'.$recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1050
+                    $icon_attributes = array('id' => 'recording-btn-' . $manage_action . '-' . $recording['recordID']);
1051
+                    $icon = new pix_icon('t/' . $manage_tag, get_string($manage_tag) . $tag_tail, 'moodle', $icon_attributes);
1052
+                    $link_attributes = array('id' => 'recording-link-' . $manage_action . '-' . $recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1053 1053
                     $actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false);
1054 1054
                 } else {
1055 1055
                     //With text for publish/unpublish
1056
-                    $link_attributes = array('title' => get_string($manage_tag).$tag_tail, 'class' => 'btn btn-xs', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1057
-                    $actionbar .= $OUTPUT->action_link($url, get_string($manage_tag).$tag_tail, $action, $link_attributes);
1056
+                    $link_attributes = array('title' => get_string($manage_tag) . $tag_tail, 'class' => 'btn btn-xs', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1057
+                    $actionbar .= $OUTPUT->action_link($url, get_string($manage_tag) . $tag_tail, $action, $link_attributes);
1058 1058
                     $actionbar .= "&nbsp;";
1059 1059
                 }
1060 1060
             }
1061 1061
 
1062 1062
             if (in_array("deleting", $tools)) {
1063
-                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("delete", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");';
1063
+                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("delete", "' . $recording['recordID'] . '", "' . $recording['meetingID'] . '");';
1064 1064
 
1065
-                if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) {
1065
+                if (bigbluebuttonbn_get_cfg_recording_icons_enabled()) {
1066 1066
                     //With icon for delete
1067
-                    $icon_attributes = array('id' => 'recording-btn-delete-'.$recording['recordID']);
1068
-                    $icon = new pix_icon('t/delete', get_string('delete').$tag_tail, 'moodle', $icon_attributes);
1069
-                    $link_attributes = array('id' => 'recording-link-delete-'.$recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1067
+                    $icon_attributes = array('id' => 'recording-btn-delete-' . $recording['recordID']);
1068
+                    $icon = new pix_icon('t/delete', get_string('delete') . $tag_tail, 'moodle', $icon_attributes);
1069
+                    $link_attributes = array('id' => 'recording-link-delete-' . $recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1070 1070
                     $actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false);
1071 1071
                 } else {
1072 1072
                     //With text for delete
1073
-                    $link_attributes = array('title' => get_string('delete').$tag_tail, 'class' => 'btn btn-xs btn-danger', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1074
-                    $actionbar .= $OUTPUT->action_link($url, get_string('delete').$tag_tail, $action, $link_attributes);
1073
+                    $link_attributes = array('title' => get_string('delete') . $tag_tail, 'class' => 'btn btn-xs btn-danger', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1074
+                    $actionbar .= $OUTPUT->action_link($url, get_string('delete') . $tag_tail, $action, $link_attributes);
1075 1075
                 }
1076 1076
             }
1077 1077
 
1078 1078
             if (in_array("importing", $tools)) {
1079
-                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("import", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");';
1079
+                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("import", "' . $recording['recordID'] . '", "' . $recording['meetingID'] . '");';
1080 1080
 
1081
-                if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) {
1081
+                if (bigbluebuttonbn_get_cfg_recording_icons_enabled()) {
1082 1082
                     //With icon for import
1083
-                    $icon_attributes = array('id' => 'recording-btn-import-'.$recording['recordID']);
1083
+                    $icon_attributes = array('id' => 'recording-btn-import-' . $recording['recordID']);
1084 1084
                     $icon = new pix_icon('i/import', get_string('import'), 'moodle', $icon_attributes);
1085
-                    $link_attributes = array('id' => 'recording-link-import-'.$recording['recordID'], 'onclick' => $onclick);
1085
+                    $link_attributes = array('id' => 'recording-link-import-' . $recording['recordID'], 'onclick' => $onclick);
1086 1086
                     $actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false);
1087 1087
                 } else {
1088 1088
                     //With text for import
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
         }
1094 1094
 
1095 1095
         //Set corresponding format
1096
-        $dateformat = get_string('strftimerecentfull', 'langconfig').' %Z';
1096
+        $dateformat = get_string('strftimerecentfull', 'langconfig') . ' %Z';
1097 1097
         $formattedStartDate = userdate($startTime / 1000, $dateformat, usertimezone($USER->timezone));
1098 1098
 
1099 1099
         $row = new stdClass();
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
         $row->date_formatted = "{$head}{$formattedStartDate}{$tail}";
1105 1105
         $row->duration = "{$duration}";
1106 1106
         $row->duration_formatted = "{$head}{$duration}{$tail}";
1107
-        if ( $bbbsession['managerecordings'] ) {
1107
+        if ($bbbsession['managerecordings']) {
1108 1108
             $row->actionbar = $actionbar;
1109 1109
         }
1110 1110
     }
@@ -1130,21 +1130,21 @@  discard block
 block discarded – undo
1130 1130
         array("key" =>"duration", "label" => $view_recording_duration, "width" => "50px")
1131 1131
         );
1132 1132
 
1133
-    if ( $bbbsession['managerecordings'] ) {
1133
+    if ($bbbsession['managerecordings']) {
1134 1134
         array_push($recordingsbn_columns, array("key" =>"actionbar", "label" => $view_recording_actionbar, "width" => "75px", "allowHTML" => true));
1135 1135
     }
1136 1136
 
1137 1137
     return $recordingsbn_columns;
1138 1138
 }
1139 1139
 
1140
-function bigbluebuttonbn_get_recording_data($bbbsession, $recordings, $tools=["publishing", "deleting"]) {
1140
+function bigbluebuttonbn_get_recording_data($bbbsession, $recordings, $tools = ["publishing", "deleting"]) {
1141 1141
     $table_data = array();
1142 1142
 
1143 1143
     ///Build table content
1144
-    if ( isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1145
-        foreach ( $recordings as $recording ) {
1144
+    if (isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1145
+        foreach ($recordings as $recording) {
1146 1146
             $row = bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools);
1147
-            if( $row != null ) {
1147
+            if ($row != null) {
1148 1148
                 array_push($table_data, $row);
1149 1149
             }
1150 1150
         }
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
     return $table_data;
1154 1154
 }
1155 1155
 
1156
-function bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools=['publishing','deleting']) {
1156
+function bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools = ['publishing', 'deleting']) {
1157 1157
     global $OUTPUT, $CFG;
1158 1158
 
1159 1159
     ///Set strings to show
@@ -1172,20 +1172,20 @@  discard block
 block discarded – undo
1172 1172
     $table->data = array();
1173 1173
 
1174 1174
     ///Initialize table headers
1175
-    if ( $bbbsession['managerecordings'] ) {
1176
-        $table->head  = array ($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration, $view_recording_actionbar);
1177
-        $table->align = array ('left', 'left', 'left', 'left', 'center', 'left');
1175
+    if ($bbbsession['managerecordings']) {
1176
+        $table->head  = array($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration, $view_recording_actionbar);
1177
+        $table->align = array('left', 'left', 'left', 'left', 'center', 'left');
1178 1178
     } else {
1179
-        $table->head  = array ($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration);
1180
-        $table->align = array ('left', 'left', 'left', 'left', 'center');
1179
+        $table->head  = array($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration);
1180
+        $table->align = array('left', 'left', 'left', 'left', 'center');
1181 1181
     }
1182 1182
 
1183 1183
     ///Build table content
1184
-    if ( isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1185
-        foreach ( $recordings as $recording ){
1184
+    if (isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1185
+        foreach ($recordings as $recording) {
1186 1186
             $row = new html_table_row();
1187
-            $row->id = 'recording-td-'.$recording['recordID'];
1188
-            if ( isset($recording['imported']) ) {
1187
+            $row->id = 'recording-td-' . $recording['recordID'];
1188
+            if (isset($recording['imported'])) {
1189 1189
                 $row->attributes['data-imported'] = 'true';
1190 1190
                 $row->attributes['title'] = get_string('view_recording_link_warning', 'bigbluebuttonbn');
1191 1191
             } else {
@@ -1193,12 +1193,12 @@  discard block
 block discarded – undo
1193 1193
             }
1194 1194
 
1195 1195
             $row_data = bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools);
1196
-            if( $row_data != null ) {
1196
+            if ($row_data != null) {
1197 1197
                 $row_data->date_formatted = str_replace(" ", "&nbsp;", $row_data->date_formatted);
1198
-                if ( $bbbsession['managerecordings'] ) {
1199
-                    $row->cells = array ($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted, $row_data->actionbar );
1198
+                if ($bbbsession['managerecordings']) {
1199
+                    $row->cells = array($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted, $row_data->actionbar);
1200 1200
                 } else {
1201
-                    $row->cells = array ($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted );
1201
+                    $row->cells = array($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted);
1202 1202
                 }
1203 1203
 
1204 1204
                 array_push($table->data, $row);
@@ -1218,12 +1218,12 @@  discard block
 block discarded – undo
1218 1218
     /// Build the message_body
1219 1219
     $msg->activity_type = "";
1220 1220
     $msg->activity_title = $bigbluebuttonbn->name;
1221
-    $message_text = '<p>'.get_string('email_body_recording_ready_for', 'bigbluebuttonbn').' '.$msg->activity_type.' &quot;'.$msg->activity_title.'&quot; '.get_string('email_body_recording_ready_is_ready', 'bigbluebuttonbn').'.</p>';
1221
+    $message_text = '<p>' . get_string('email_body_recording_ready_for', 'bigbluebuttonbn') . ' ' . $msg->activity_type . ' &quot;' . $msg->activity_title . '&quot; ' . get_string('email_body_recording_ready_is_ready', 'bigbluebuttonbn') . '.</p>';
1222 1222
 
1223 1223
     bigbluebuttonbn_send_notification($sender, $bigbluebuttonbn, $message_text);
1224 1224
 }
1225 1225
 
1226
-function bigbluebuttonbn_server_offers($capability_name){
1226
+function bigbluebuttonbn_server_offers($capability_name) {
1227 1227
     global $CFG;
1228 1228
 
1229 1229
     $capability_offered = null;
@@ -1237,12 +1237,12 @@  discard block
 block discarded – undo
1237 1237
     $host_ends = explode(".", $host);
1238 1238
     $host_ends_length = count($host_ends);
1239 1239
 
1240
-    if( $host_ends_length > 0 && $host_ends[$host_ends_length -1] == 'com' &&  $host_ends[$host_ends_length -2] == 'blindsidenetworks' ) {
1240
+    if ($host_ends_length > 0 && $host_ends[$host_ends_length - 1] == 'com' && $host_ends[$host_ends_length - 2] == 'blindsidenetworks') {
1241 1241
         //Validate the capabilities offered
1242
-        $capabilities = bigbluebuttonbn_getCapabilitiesArray( $endpoint, $shared_secret );
1243
-        if( $capabilities ) {
1242
+        $capabilities = bigbluebuttonbn_getCapabilitiesArray($endpoint, $shared_secret);
1243
+        if ($capabilities) {
1244 1244
             foreach ($capabilities as $capability) {
1245
-                if ( $capability["name"] == $capability_name) {
1245
+                if ($capability["name"] == $capability_name) {
1246 1246
                     $capability_offered = $capability;
1247 1247
                 }
1248 1248
             }
@@ -1252,14 +1252,14 @@  discard block
 block discarded – undo
1252 1252
     return $capability_offered;
1253 1253
 }
1254 1254
 
1255
-function bigbluebuttonbn_server_offers_bn_capabilities(){
1255
+function bigbluebuttonbn_server_offers_bn_capabilities() {
1256 1256
     //Validates if the server may have extended capabilities
1257 1257
     $parsed_url = parse_url(bigbluebuttonbn_get_cfg_server_url());
1258 1258
     $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
1259 1259
     $host_ends = explode(".", $host);
1260 1260
     $host_ends_length = count($host_ends);
1261 1261
 
1262
-    return ( $host_ends_length > 0 && $host_ends[$host_ends_length -1] == 'com' && $host_ends[$host_ends_length -2] == 'blindsidenetworks' );
1262
+    return ($host_ends_length > 0 && $host_ends[$host_ends_length - 1] == 'com' && $host_ends[$host_ends_length - 2] == 'blindsidenetworks');
1263 1263
 }
1264 1264
 
1265 1265
 function bigbluebuttonbn_get_locales_for_ui() {
@@ -1304,89 +1304,89 @@  discard block
 block discarded – undo
1304 1304
 
1305 1305
 function bigbluebuttonbn_get_cfg_server_url_default() {
1306 1306
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1307
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_server_url)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_server_url: (isset($CFG->bigbluebuttonbn_server_url)? $CFG->bigbluebuttonbn_server_url: (isset($CFG->BigBlueButtonBNServerURL)? $CFG->BigBlueButtonBNServerURL: BIGBLUEBUTTONBN_DEFAULT_SERVER_URL)));
1307
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_server_url) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_server_url : (isset($CFG->bigbluebuttonbn_server_url) ? $CFG->bigbluebuttonbn_server_url : (isset($CFG->BigBlueButtonBNServerURL) ? $CFG->BigBlueButtonBNServerURL : BIGBLUEBUTTONBN_DEFAULT_SERVER_URL)));
1308 1308
 }
1309 1309
 
1310 1310
 function bigbluebuttonbn_get_cfg_shared_secret_default() {
1311 1311
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1312
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_shared_secret)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_shared_secret: (isset($CFG->bigbluebuttonbn_shared_secret)? $CFG->bigbluebuttonbn_shared_secret: (isset($CFG->BigBlueButtonBNSecuritySalt)? $CFG->BigBlueButtonBNSecuritySalt: BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET)));
1312
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_shared_secret) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_shared_secret : (isset($CFG->bigbluebuttonbn_shared_secret) ? $CFG->bigbluebuttonbn_shared_secret : (isset($CFG->BigBlueButtonBNSecuritySalt) ? $CFG->BigBlueButtonBNSecuritySalt : BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET)));
1313 1313
 }
1314 1314
 
1315 1315
 function bigbluebuttonbn_get_cfg_voicebridge_editable() {
1316 1316
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1317
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable: (isset($CFG->bigbluebuttonbn_voicebridge_editable)? $CFG->bigbluebuttonbn_voicebridge_editable: false));
1317
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable : (isset($CFG->bigbluebuttonbn_voicebridge_editable) ? $CFG->bigbluebuttonbn_voicebridge_editable : false));
1318 1318
 }
1319 1319
 
1320 1320
 function bigbluebuttonbn_get_cfg_recording_default() {
1321 1321
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1322
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default: (isset($CFG->bigbluebuttonbn_recording_default)? $CFG->bigbluebuttonbn_recording_default: true));
1322
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default : (isset($CFG->bigbluebuttonbn_recording_default) ? $CFG->bigbluebuttonbn_recording_default : true));
1323 1323
 }
1324 1324
 
1325 1325
 function bigbluebuttonbn_get_cfg_recording_editable() {
1326 1326
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1327
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable: (isset($CFG->bigbluebuttonbn_recording_editable)? $CFG->bigbluebuttonbn_recording_editable: true));
1327
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable : (isset($CFG->bigbluebuttonbn_recording_editable) ? $CFG->bigbluebuttonbn_recording_editable : true));
1328 1328
 }
1329 1329
 
1330 1330
 function bigbluebuttonbn_get_cfg_recording_tagging_default() {
1331 1331
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1332
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default: (isset($CFG->bigbluebuttonbn_recordingtagging_default)? $CFG->bigbluebuttonbn_recordingtagging_default: false));
1332
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default : (isset($CFG->bigbluebuttonbn_recordingtagging_default) ? $CFG->bigbluebuttonbn_recordingtagging_default : false));
1333 1333
 }
1334 1334
 
1335 1335
 function bigbluebuttonbn_get_cfg_recording_tagging_editable() {
1336 1336
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1337
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable: (isset($CFG->bigbluebuttonbn_recordingtagging_editable)? $CFG->bigbluebuttonbn_recordingtagging_editable: false));
1337
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable : (isset($CFG->bigbluebuttonbn_recordingtagging_editable) ? $CFG->bigbluebuttonbn_recordingtagging_editable : false));
1338 1338
 }
1339 1339
 
1340 1340
 function bigbluebuttonbn_get_cfg_recording_icons_enabled() {
1341 1341
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1342
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_icons_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_icons_enabled: (isset($CFG->bigbluebuttonbn_recording_icons_enabled)? $CFG->bigbluebuttonbn_recording_icons_enabled: true));
1342
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_icons_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_icons_enabled : (isset($CFG->bigbluebuttonbn_recording_icons_enabled) ? $CFG->bigbluebuttonbn_recording_icons_enabled : true));
1343 1343
 }
1344 1344
 
1345 1345
 function bigbluebuttonbn_get_cfg_importrecordings_enabled() {
1346 1346
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1347
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled: (isset($CFG->bigbluebuttonbn_importrecordings_enabled)? $CFG->bigbluebuttonbn_importrecordings_enabled: false));
1347
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled : (isset($CFG->bigbluebuttonbn_importrecordings_enabled) ? $CFG->bigbluebuttonbn_importrecordings_enabled : false));
1348 1348
 }
1349 1349
 
1350 1350
 function bigbluebuttonbn_get_cfg_importrecordings_from_deleted_activities_enabled() {
1351 1351
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1352
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled: (isset($CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled)? $CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled: false));
1352
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled : (isset($CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled) ? $CFG->bigbluebuttonbn_importrecordings_from_deleted_activities_enabled : false));
1353 1353
 }
1354 1354
 
1355 1355
 function bigbluebuttonbn_get_cfg_waitformoderator_default() {
1356 1356
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1357
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default: (isset($CFG->bigbluebuttonbn_waitformoderator_default)? $CFG->bigbluebuttonbn_waitformoderator_default: false));
1357
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default : (isset($CFG->bigbluebuttonbn_waitformoderator_default) ? $CFG->bigbluebuttonbn_waitformoderator_default : false));
1358 1358
 }
1359 1359
 
1360 1360
 function bigbluebuttonbn_get_cfg_waitformoderator_editable() {
1361 1361
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1362
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable: (isset($CFG->bigbluebuttonbn_waitformoderator_editable)? $CFG->bigbluebuttonbn_waitformoderator_editable: true));
1362
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable : (isset($CFG->bigbluebuttonbn_waitformoderator_editable) ? $CFG->bigbluebuttonbn_waitformoderator_editable : true));
1363 1363
 }
1364 1364
 
1365 1365
 function bigbluebuttonbn_get_cfg_waitformoderator_ping_interval() {
1366 1366
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1367
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_ping_interval)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_ping_interval: (isset($CFG->bigbluebuttonbn_waitformoderator_ping_interval)? $CFG->bigbluebuttonbn_waitformoderator_ping_interval: 15));
1367
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_ping_interval) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_ping_interval : (isset($CFG->bigbluebuttonbn_waitformoderator_ping_interval) ? $CFG->bigbluebuttonbn_waitformoderator_ping_interval : 15));
1368 1368
 }
1369 1369
 
1370 1370
 function bigbluebuttonbn_get_cfg_waitformoderator_cache_ttl() {
1371 1371
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1372
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_cache_ttl)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_cache_ttl: (isset($CFG->bigbluebuttonbn_waitformoderator_cache_ttl)? $CFG->bigbluebuttonbn_waitformoderator_cache_ttl: 60));
1372
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_cache_ttl) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_cache_ttl : (isset($CFG->bigbluebuttonbn_waitformoderator_cache_ttl) ? $CFG->bigbluebuttonbn_waitformoderator_cache_ttl : 60));
1373 1373
 }
1374 1374
 
1375 1375
 function bigbluebuttonbn_get_cfg_userlimit_default() {
1376 1376
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1377
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default: (isset($CFG->bigbluebuttonbn_userlimit_default)? $CFG->bigbluebuttonbn_userlimit_default: 0));
1377
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default : (isset($CFG->bigbluebuttonbn_userlimit_default) ? $CFG->bigbluebuttonbn_userlimit_default : 0));
1378 1378
 }
1379 1379
 
1380 1380
 function bigbluebuttonbn_get_cfg_userlimit_editable() {
1381 1381
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1382
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable: (isset($CFG->bigbluebuttonbn_userlimit_editable)? $CFG->bigbluebuttonbn_userlimit_editable: false));
1382
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable : (isset($CFG->bigbluebuttonbn_userlimit_editable) ? $CFG->bigbluebuttonbn_userlimit_editable : false));
1383 1383
 }
1384 1384
 
1385 1385
 function bigbluebuttonbn_get_cfg_preuploadpresentation_enabled() {
1386 1386
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1387 1387
     if (extension_loaded('curl')) {
1388 1388
         // This feature only works if curl is installed
1389
-        return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled: (isset($CFG->bigbluebuttonbn_preuploadpresentation_enabled)? $CFG->bigbluebuttonbn_preuploadpresentation_enabled: false));
1389
+        return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled : (isset($CFG->bigbluebuttonbn_preuploadpresentation_enabled) ? $CFG->bigbluebuttonbn_preuploadpresentation_enabled : false));
1390 1390
     } else {
1391 1391
         return false;
1392 1392
     }
@@ -1394,37 +1394,37 @@  discard block
 block discarded – undo
1394 1394
 
1395 1395
 function bigbluebuttonbn_get_cfg_sendnotifications_enabled() {
1396 1396
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1397
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled: (isset($CFG->bigbluebuttonbn_sendnotifications_enabled)? $CFG->bigbluebuttonbn_sendnotifications_enabled: false));
1397
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled : (isset($CFG->bigbluebuttonbn_sendnotifications_enabled) ? $CFG->bigbluebuttonbn_sendnotifications_enabled : false));
1398 1398
 }
1399 1399
 
1400 1400
 function bigbluebuttonbn_get_cfg_recordingready_enabled() {
1401 1401
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1402
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled: (isset($CFG->bigbluebuttonbn_recordingready_enabled)? $CFG->bigbluebuttonbn_recordingready_enabled: false));
1402
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled : (isset($CFG->bigbluebuttonbn_recordingready_enabled) ? $CFG->bigbluebuttonbn_recordingready_enabled : false));
1403 1403
 }
1404 1404
 
1405 1405
 function bigbluebuttonbn_get_cfg_moderator_default() {
1406 1406
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1407
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default: (isset($CFG->bigbluebuttonbn_moderator_default)? $CFG->bigbluebuttonbn_moderator_default: 'owner'));
1407
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default : (isset($CFG->bigbluebuttonbn_moderator_default) ? $CFG->bigbluebuttonbn_moderator_default : 'owner'));
1408 1408
 }
1409 1409
 
1410 1410
 function bigbluebuttonbn_get_cfg_scheduled_duration_enabled() {
1411 1411
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1412
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_enabled: (isset($CFG->bigbluebuttonbn_scheduled_duration_enabled)? $CFG->bigbluebuttonbn_scheduled_duration_enabled: false));
1412
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_enabled : (isset($CFG->bigbluebuttonbn_scheduled_duration_enabled) ? $CFG->bigbluebuttonbn_scheduled_duration_enabled : false));
1413 1413
 }
1414 1414
 
1415 1415
 function bigbluebuttonbn_get_cfg_scheduled_duration_compensation() {
1416 1416
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1417
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_compensation)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_compensation: (isset($CFG->bigbluebuttonbn_scheduled_duration_compensation)? $CFG->bigbluebuttonbn_scheduled_duration_compensation: 10));
1417
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_compensation) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_duration_compensation : (isset($CFG->bigbluebuttonbn_scheduled_duration_compensation) ? $CFG->bigbluebuttonbn_scheduled_duration_compensation : 10));
1418 1418
 }
1419 1419
 
1420 1420
 function bigbluebuttonbn_get_cfg_scheduled_pre_opening() {
1421 1421
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1422
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_pre_opening)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_pre_opening: (isset($CFG->bigbluebuttonbn_scheduled_pre_opening)? $CFG->bigbluebuttonbn_scheduled_pre_opening: 10));
1422
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_pre_opening) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_scheduled_pre_opening : (isset($CFG->bigbluebuttonbn_scheduled_pre_opening) ? $CFG->bigbluebuttonbn_scheduled_pre_opening : 10));
1423 1423
 }
1424 1424
 
1425 1425
 function bigbluebuttonbn_import_get_courses_for_select(array $bbbsession) {
1426 1426
 
1427
-    if( $bbbsession['administrator'] ) {
1427
+    if ($bbbsession['administrator']) {
1428 1428
         $courses = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.fullname');
1429 1429
         //It includes the name of the site as a course (category 0), so remove the first one
1430 1430
         unset($courses["1"]);
@@ -1433,21 +1433,21 @@  discard block
 block discarded – undo
1433 1433
     }
1434 1434
 
1435 1435
     $courses_for_select = [];
1436
-    foreach($courses as $course) {
1437
-        if( $course->id != $bbbsession['course']->id ) {
1436
+    foreach ($courses as $course) {
1437
+        if ($course->id != $bbbsession['course']->id) {
1438 1438
             $courses_for_select[$course->id] = $course->fullname;
1439 1439
         }
1440 1440
     }
1441 1441
     return $courses_for_select;
1442 1442
 }
1443 1443
 
1444
-function bigbluebuttonbn_getRecordedMeetingsDeleted($courseID, $bigbluebuttonbnID=NULL) {
1444
+function bigbluebuttonbn_getRecordedMeetingsDeleted($courseID, $bigbluebuttonbnID = NULL) {
1445 1445
     global $DB;
1446 1446
 
1447 1447
     $records_deleted = array();
1448 1448
 
1449
-    $filter = array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_DELETE );
1450
-    if ( $bigbluebuttonbnID != NULL ) {
1449
+    $filter = array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_DELETE);
1450
+    if ($bigbluebuttonbnID != NULL) {
1451 1451
         $filter['id'] = $bigbluebuttonbnID;
1452 1452
     }
1453 1453
 
@@ -1456,17 +1456,17 @@  discard block
 block discarded – undo
1456 1456
     foreach ($bigbluebuttonbns_deleted as $key => $bigbluebuttonbn_deleted) {
1457 1457
         $records = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_CREATE));
1458 1458
 
1459
-        if( !empty($records) ) {
1459
+        if (!empty($records)) {
1460 1460
             //Remove duplicates
1461 1461
             $unique_records = array();
1462 1462
             foreach ($records as $key => $record) {
1463
-                if (array_key_exists($record->meetingid, $unique_records) ) {
1463
+                if (array_key_exists($record->meetingid, $unique_records)) {
1464 1464
                     unset($records[$key]);
1465 1465
                 } else {
1466 1466
                     $meta = json_decode($record->meta);
1467
-                    if ( !$meta->record ) {
1467
+                    if (!$meta->record) {
1468 1468
                         unset($records[$key]);
1469
-                    } else if ( $bigbluebuttonbn_deleted->meetingid != substr($record->meetingid, 0, strlen($bigbluebuttonbn_deleted->meetingid))) {
1469
+                    } else if ($bigbluebuttonbn_deleted->meetingid != substr($record->meetingid, 0, strlen($bigbluebuttonbn_deleted->meetingid))) {
1470 1470
                         unset($records[$key]);
1471 1471
                     } else {
1472 1472
                         array_push($unique_records, $record->meetingid);
@@ -1481,27 +1481,27 @@  discard block
 block discarded – undo
1481 1481
     return $records_deleted;
1482 1482
 }
1483 1483
 
1484
-function bigbluebuttonbn_getRecordedMeetings($courseID, $bigbluebuttonbnID=NULL) {
1484
+function bigbluebuttonbn_getRecordedMeetings($courseID, $bigbluebuttonbnID = NULL) {
1485 1485
     global $DB;
1486 1486
 
1487 1487
     $records = Array();
1488 1488
 
1489 1489
     $filter = array('course' => $courseID);
1490
-    if ( $bigbluebuttonbnID != NULL ) {
1490
+    if ($bigbluebuttonbnID != NULL) {
1491 1491
         $filter['id'] = $bigbluebuttonbnID;
1492 1492
     }
1493 1493
     $bigbluebuttonbns = $DB->get_records('bigbluebuttonbn', $filter);
1494 1494
 
1495
-    if ( !empty($bigbluebuttonbns) ) {
1495
+    if (!empty($bigbluebuttonbns)) {
1496 1496
         $table = 'bigbluebuttonbn_logs';
1497 1497
 
1498 1498
         //Prepare select for loading records based on existent bigbluebuttonbns
1499 1499
         $select = "";
1500 1500
         foreach ($bigbluebuttonbns as $key => $bigbluebuttonbn) {
1501
-            $select .= strlen($select) == 0? "(": " OR ";
1502
-            $select .= "bigbluebuttonbnid=".$bigbluebuttonbn->id;
1501
+            $select .= strlen($select) == 0 ? "(" : " OR ";
1502
+            $select .= "bigbluebuttonbnid=" . $bigbluebuttonbn->id;
1503 1503
         }
1504
-        $select .= ") AND log='".BIGBLUEBUTTONBN_LOG_EVENT_CREATE."'";
1504
+        $select .= ") AND log='" . BIGBLUEBUTTONBN_LOG_EVENT_CREATE . "'";
1505 1505
 
1506 1506
         //Execute select for loading records based on existent bigbluebuttonbns
1507 1507
         $records = $DB->get_records_select($table, $select);
@@ -1509,8 +1509,8 @@  discard block
 block discarded – undo
1509 1509
         //Remove duplicates
1510 1510
         $unique_records = array();
1511 1511
         foreach ($records as $key => $record) {
1512
-            $record_key = $record->meetingid.','.$record->bigbluebuttonbnid.','.$record->meta;
1513
-            if( array_search($record_key, $unique_records) === false ) {
1512
+            $record_key = $record->meetingid . ',' . $record->bigbluebuttonbnid . ',' . $record->meta;
1513
+            if (array_search($record_key, $unique_records) === false) {
1514 1514
                 array_push($unique_records, $record_key);
1515 1515
             } else {
1516 1516
                 unset($records[$key]);
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
         //Remove the ones with record=false
1521 1521
         foreach ($records as $key => $record) {
1522 1522
             $meta = json_decode($record->meta);
1523
-            if ( !$meta || !$meta->record ) {
1523
+            if (!$meta || !$meta->record) {
1524 1524
                 unset($records[$key]);
1525 1525
             }
1526 1526
         }
@@ -1533,15 +1533,15 @@  discard block
 block discarded – undo
1533 1533
     $recordings = array();
1534 1534
 
1535 1535
     // Load the meetingIDs to be used in the getRecordings request
1536
-    if ( is_numeric($courseID) ) {
1536
+    if (is_numeric($courseID)) {
1537 1537
         $results = bigbluebuttonbn_getRecordedMeetings($courseID);
1538 1538
 
1539
-        if( bigbluebuttonbn_get_cfg_importrecordings_from_deleted_activities_enabled() ) {
1539
+        if (bigbluebuttonbn_get_cfg_importrecordings_from_deleted_activities_enabled()) {
1540 1540
             $results_deleted = bigbluebuttonbn_getRecordedMeetingsDeleted($courseID);
1541 1541
             $results = array_merge($results, $results_deleted);
1542 1542
         }
1543 1543
 
1544
-        if( $results ) {
1544
+        if ($results) {
1545 1545
             $mIDs = array();
1546 1546
             //Eliminates duplicates
1547 1547
             foreach ($results as $result) {
@@ -1549,10 +1549,10 @@  discard block
 block discarded – undo
1549 1549
             }
1550 1550
 
1551 1551
             // If there are mIDs excecute a paginated getRecordings request
1552
-            if ( !empty($mIDs) ) {
1552
+            if (!empty($mIDs)) {
1553 1553
                 $pages = floor(sizeof($mIDs) / 25) + 1;
1554
-                for ( $page = 1; $page <= $pages; $page++ ) {
1555
-                    $meetingIDs = array_slice($mIDs, ($page-1)*25, 25);
1554
+                for ($page = 1; $page <= $pages; $page++) {
1555
+                    $meetingIDs = array_slice($mIDs, ($page - 1) * 25, 25);
1556 1556
                     $fetched_recordings = bigbluebuttonbn_getRecordingsArray(implode(',', $meetingIDs), $URL, $SALT);
1557 1557
                     $recordings = array_merge($recordings, $fetched_recordings);
1558 1558
                 }
@@ -1579,37 +1579,37 @@  discard block
 block discarded – undo
1579 1579
     $recordings_already_imported_indexed = bigbluebuttonbn_index_recordings($recordings_already_imported);
1580 1580
 
1581 1581
     foreach ($recordings as $key => $recording) {
1582
-        if( isset($recordings_already_imported_indexed[$recording['recordID']]) ) {
1582
+        if (isset($recordings_already_imported_indexed[$recording['recordID']])) {
1583 1583
             unset($recordings[$key]);
1584 1584
         }
1585 1585
     }
1586 1586
     return $recordings;
1587 1587
 }
1588 1588
 
1589
-function bigbluebutton_output_recording_table($bbbsession, $recordings, $tools=['publishing','deleting']) {
1589
+function bigbluebutton_output_recording_table($bbbsession, $recordings, $tools = ['publishing', 'deleting']) {
1590 1590
 
1591
-    if ( isset($recordings) && !empty($recordings) ) {  // There are recordings for this meeting
1591
+    if (isset($recordings) && !empty($recordings)) {  // There are recordings for this meeting
1592 1592
         $table = bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools);
1593 1593
     }
1594 1594
 
1595 1595
     $output = '';
1596
-    if( isset($table->data) ) {
1596
+    if (isset($table->data)) {
1597 1597
         //Print the table
1598
-        $output .= '<div id="bigbluebuttonbn_html_table">'."\n";
1599
-        $output .= html_writer::table($table)."\n";
1600
-        $output .= '</div>'."\n";
1598
+        $output .= '<div id="bigbluebuttonbn_html_table">' . "\n";
1599
+        $output .= html_writer::table($table) . "\n";
1600
+        $output .= '</div>' . "\n";
1601 1601
 
1602 1602
     } else {
1603
-        $output .= get_string('view_message_norecordings', 'bigbluebuttonbn').'<br>'."\n";
1603
+        $output .= get_string('view_message_norecordings', 'bigbluebuttonbn') . '<br>' . "\n";
1604 1604
     }
1605 1605
 
1606 1606
     return $output;
1607 1607
 }
1608 1608
 
1609
-function bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID=NULL) {
1609
+function bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID = NULL) {
1610 1610
     global $DB;
1611 1611
 
1612
-    if ( $bigbluebuttonbnID != NULL ) {
1612
+    if ($bigbluebuttonbnID != NULL) {
1613 1613
         // Fetch only those related to the $courseID and $bigbluebuttonbnID requested
1614 1614
         $recordings_imported = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'bigbluebuttonbnid' => $bigbluebuttonbnID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_IMPORT));
1615 1615
     } else {
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
     return $recordings_imported;
1620 1620
 }
1621 1621
 
1622
-function bigbluebuttonbn_getRecordingsImportedArray($courseID, $bigbluebuttonbnID=NULL) {
1622
+function bigbluebuttonbn_getRecordingsImportedArray($courseID, $bigbluebuttonbnID = NULL) {
1623 1623
     $recordings_imported = bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID);
1624 1624
     $recordings_imported_array = bigbluebuttonbn_import_get_recordings_imported($recordings_imported);
1625 1625
     return $recordings_imported_array;
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
 function bigbluebuttonbn_getRecordingsImportedAllInstances($recordID) {
1629 1629
     global $DB, $CFG;
1630 1630
 
1631
-    $recordings_imported = $DB->get_records_sql('SELECT * FROM '.$CFG->prefix.'bigbluebuttonbn_logs WHERE log=? AND '.$DB->sql_like('meta', '?'), array( BIGBLUEBUTTONBN_LOG_EVENT_IMPORT, '%'.$recordID.'%' ));
1631
+    $recordings_imported = $DB->get_records_sql('SELECT * FROM ' . $CFG->prefix . 'bigbluebuttonbn_logs WHERE log=? AND ' . $DB->sql_like('meta', '?'), array(BIGBLUEBUTTONBN_LOG_EVENT_IMPORT, '%' . $recordID . '%'));
1632 1632
     return $recordings_imported;
1633 1633
 }
1634 1634
 
@@ -1647,8 +1647,8 @@  discard block
 block discarded – undo
1647 1647
 function bigbluebuttonbn_html2text($html, $len) {
1648 1648
     $text = strip_tags($html);
1649 1649
     $text = str_replace("&nbsp;", ' ', $text);
1650
-    if( strlen($text) > $len ) {
1651
-        $text = substr($text, 0, $len)."...";
1650
+    if (strlen($text) > $len) {
1651
+        $text = substr($text, 0, $len) . "...";
1652 1652
     } else {
1653 1653
         $text = substr($text, 0, $len);
1654 1654
     }
Please login to merge, or discard this patch.