Completed
Push — master ( bfa4f1...253dc9 )
by Jesus
02:28
created
locallib.php 2 patches
Spacing   +340 added lines, -340 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 executes 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 executes using a method GET supported by any version 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,65 +260,65 @@  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
     $recordingArrayRow = array();
265 265
 
266 266
     $playbackArray = array();
267
-    foreach ( $recording->playback->format as $format ) {
268
-        $playbackArray[(string) $format->type] = array( 'type' => (string) $format->type, 'url' => (string) $format->url, 'length' => (string) $format->length );
267
+    foreach ($recording->playback->format as $format) {
268
+        $playbackArray[(string)$format->type] = array('type' => (string)$format->type, 'url' => (string)$format->url, 'length' => (string)$format->length);
269 269
     }
270 270
 
271 271
     //Add the metadata to the recordings array
272 272
     $metadataArray = array();
273 273
     $metadata = get_object_vars($recording->metadata);
274
-    foreach ( $metadata as $key => $value ) {
275
-        if ( is_object($value) ) {
274
+    foreach ($metadata as $key => $value) {
275
+        if (is_object($value)) {
276 276
             $value = '';
277 277
         }
278
-        $metadataArray['meta_'.$key] = $value;
278
+        $metadataArray['meta_' . $key] = $value;
279 279
     }
280 280
 
281
-    $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
+    $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;
282 282
 
283 283
     return $recordingArrayRow;
284 284
 }
285 285
 
286
-function bigbluebuttonbn_recordingBuildSorter($a, $b){
287
-    if ( $a['startTime'] < $b['startTime'] ) {
286
+function bigbluebuttonbn_recordingBuildSorter($a, $b) {
287
+    if ($a['startTime'] < $b['startTime']) {
288 288
         return -1;
289
-    } else if ( $a['startTime'] == $b['startTime']) {
289
+    } else if ($a['startTime'] == $b['startTime']) {
290 290
         return 0;
291 291
     } else {
292 292
         return 1;
293 293
     }
294 294
 }
295 295
 
296
-function bigbluebuttonbn_doDeleteRecordings( $recordIDs, $URL, $SALT ) {
297
-    $ids = 	explode(",", $recordIDs);
298
-    foreach( $ids as $id){
299
-        $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getDeleteRecordingsURL($id, $URL, $SALT) );
300
-        if( $xml && $xml->returncode != 'SUCCESS' ) {
296
+function bigbluebuttonbn_doDeleteRecordings($recordIDs, $URL, $SALT) {
297
+    $ids = explode(",", $recordIDs);
298
+    foreach ($ids as $id) {
299
+        $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getDeleteRecordingsURL($id, $URL, $SALT));
300
+        if ($xml && $xml->returncode != 'SUCCESS') {
301 301
             return false;
302 302
         }
303 303
     }
304 304
     return true;
305 305
 }
306 306
 
307
-function bigbluebuttonbn_doPublishRecordings( $recordIDs, $set, $URL, $SALT ) {
308
-    $ids = 	explode(",", $recordIDs);
309
-    foreach( $ids as $id){
310
-        $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getPublishRecordingsURL($id, $set, $URL, $SALT) );
311
-        if( $xml && $xml->returncode != 'SUCCESS' ) {
307
+function bigbluebuttonbn_doPublishRecordings($recordIDs, $set, $URL, $SALT) {
308
+    $ids = explode(",", $recordIDs);
309
+    foreach ($ids as $id) {
310
+        $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getPublishRecordingsURL($id, $set, $URL, $SALT));
311
+        if ($xml && $xml->returncode != 'SUCCESS') {
312 312
             return false;
313 313
         }
314 314
     }
315 315
     return true;
316 316
 }
317 317
 
318
-function bigbluebuttonbn_doEndMeeting( $meetingID, $modPW, $URL, $SALT ) {
319
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getEndMeetingURL( $meetingID, $modPW, $URL, $SALT ) );
318
+function bigbluebuttonbn_doEndMeeting($meetingID, $modPW, $URL, $SALT) {
319
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getEndMeetingURL($meetingID, $modPW, $URL, $SALT));
320 320
 
321
-    if( $xml ) { //If the xml packet returned failure it displays the message to the user
321
+    if ($xml) { //If the xml packet returned failure it displays the message to the user
322 322
         return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
323 323
     }
324 324
     else { //If the server is unreachable, then prompts the user of the necessary action
@@ -326,46 +326,46 @@  discard block
 block discarded – undo
326 326
     }
327 327
 }
328 328
 
329
-function bigbluebuttonbn_isMeetingRunning( $meetingID, $URL, $SALT ) {
330
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) );
331
-    if ( $xml && $xml->returncode == 'SUCCESS' ) {
332
-        return ( ( $xml->running == 'true' ) ? true : false);
329
+function bigbluebuttonbn_isMeetingRunning($meetingID, $URL, $SALT) {
330
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getIsMeetingRunningURL($meetingID, $URL, $SALT));
331
+    if ($xml && $xml->returncode == 'SUCCESS') {
332
+        return (($xml->running == 'true') ? true : false);
333 333
     } else {
334
-        return ( false );
334
+        return (false);
335 335
     }
336 336
 }
337 337
 
338 338
 
339
-function bigbluebuttonbn_getServerVersion( $URL ){
340
-    $xml = bigbluebuttonbn_wrap_xml_load_file( $URL."api" );
341
-    if ( $xml && $xml->returncode == 'SUCCESS' ) {
339
+function bigbluebuttonbn_getServerVersion($URL) {
340
+    $xml = bigbluebuttonbn_wrap_xml_load_file($URL . "api");
341
+    if ($xml && $xml->returncode == 'SUCCESS') {
342 342
         return $xml->version;
343 343
     } else {
344 344
         return NULL;
345 345
     }
346 346
 }
347 347
 
348
-function bigbluebuttonbn_getMeetingXML( $meetingID, $URL, $SALT ) {
349
-    $xml = bigbluebuttonbn_wrap_xml_load_file( bigbluebuttonbn_getIsMeetingRunningURL( $meetingID, $URL, $SALT ) );
350
-    if ( $xml && $xml->returncode == 'SUCCESS') {
351
-        return ( str_replace('</response>', '', str_replace("<?xml version=\"1.0\"?>\n<response>", '', $xml->asXML())));
348
+function bigbluebuttonbn_getMeetingXML($meetingID, $URL, $SALT) {
349
+    $xml = bigbluebuttonbn_wrap_xml_load_file(bigbluebuttonbn_getIsMeetingRunningURL($meetingID, $URL, $SALT));
350
+    if ($xml && $xml->returncode == 'SUCCESS') {
351
+        return (str_replace('</response>', '', str_replace("<?xml version=\"1.0\"?>\n<response>", '', $xml->asXML())));
352 352
     } else {
353 353
         return 'false';
354 354
     }
355 355
 }
356 356
 
357
-function bigbluebuttonbn_wrap_xml_load_file($url, $method=BIGBLUEBUTTONBN_METHOD_GET, $data=null) {
358
-    if ( bigbluebuttonbn_debugdisplay() ) error_log("Request to: ".$url);
357
+function bigbluebuttonbn_wrap_xml_load_file($url, $method = BIGBLUEBUTTONBN_METHOD_GET, $data = null) {
358
+    if (bigbluebuttonbn_debugdisplay()) error_log("Request to: " . $url);
359 359
 
360 360
     if (extension_loaded('curl')) {
361 361
         $c = new curl();
362
-        $c->setopt( Array( "SSL_VERIFYPEER" => true));
363
-        if( $method == BIGBLUEBUTTONBN_METHOD_POST ) {
364
-            if( !is_null($data) ) {
365
-                if( !is_array($data) ) {
362
+        $c->setopt(Array("SSL_VERIFYPEER" => true));
363
+        if ($method == BIGBLUEBUTTONBN_METHOD_POST) {
364
+            if (!is_null($data)) {
365
+                if (!is_array($data)) {
366 366
                     $options['CURLOPT_HTTPHEADER'] = array(
367 367
                             'Content-Type: text/xml',
368
-                            'Content-Length: '.strlen($data),
368
+                            'Content-Length: ' . strlen($data),
369 369
                             'Content-Language: en-US'
370 370
                         );
371 371
                     $response = $c->post($url, $data, $options);
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
             try {
388 388
                 $xml = new SimpleXMLElement($response, LIBXML_NOCDATA);
389 389
                 return $xml;
390
-            } catch (Exception $e){
390
+            } catch (Exception $e) {
391 391
                 libxml_use_internal_errors($previous);
392
-                $error = 'Caught exception: '.$e->getMessage();
392
+                $error = 'Caught exception: ' . $e->getMessage();
393 393
                 error_log($error);
394 394
                 return NULL;
395 395
             }
@@ -401,18 +401,18 @@  discard block
 block discarded – undo
401 401
     } else {
402 402
         $previous = libxml_use_internal_errors(true);
403 403
         try {
404
-            $xml = simplexml_load_file($url,'SimpleXMLElement', LIBXML_NOCDATA);
404
+            $xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
405 405
             return $xml;
406
-        } catch  (Exception $e){
406
+        } catch (Exception $e) {
407 407
             libxml_use_internal_errors($previous);
408 408
             return NULL;
409 409
         }
410 410
     }
411 411
 }
412 412
 
413
-function bigbluebuttonbn_get_role_name($role_shortname){
413
+function bigbluebuttonbn_get_role_name($role_shortname) {
414 414
     $role = bigbluebuttonbn_get_db_moodle_roles($role_shortname);
415
-    if( $role != null && $role->name != "") {
415
+    if ($role != null && $role->name != "") {
416 416
         $role_name = $role->name;
417 417
     } else {
418 418
         switch ($role_shortname) {
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
     return $role_name;
433 433
 }
434 434
 
435
-function bigbluebuttonbn_get_roles($rolename='all', $format='json'){
435
+function bigbluebuttonbn_get_roles($rolename = 'all', $format = 'json') {
436 436
     $roles = bigbluebuttonbn_get_db_moodle_roles($rolename);
437 437
     $roles_array = array();
438
-    foreach($roles as $role){
439
-        if( $format=='json' ) {
438
+    foreach ($roles as $role) {
439
+        if ($format == 'json') {
440 440
             array_push($roles_array,
441
-                    array( "id" => $role->shortname,
441
+                    array("id" => $role->shortname,
442 442
                         "name" => bigbluebuttonbn_get_role_name($role->shortname)
443 443
                     )
444 444
             );
@@ -449,19 +449,19 @@  discard block
 block discarded – undo
449 449
     return $roles_array;
450 450
 }
451 451
 
452
-function bigbluebuttonbn_get_roles_json($rolename='all'){
452
+function bigbluebuttonbn_get_roles_json($rolename = 'all') {
453 453
     return json_encode(bigbluebuttonbn_get_roles($rolename));
454 454
 }
455 455
 
456
-function bigbluebuttonbn_get_users_json($users, $full=false) {
457
-    if( $full ) {
456
+function bigbluebuttonbn_get_users_json($users, $full = false) {
457
+    if ($full) {
458 458
         return json_encode($users);
459 459
     } else {
460 460
         $users_array = array();
461
-        foreach($users as $user){
461
+        foreach ($users as $user) {
462 462
             array_push($users_array,
463
-                    array( "id" => $user->id,
464
-                            "name" => $user->firstname.' '.$user->lastname
463
+                    array("id" => $user->id,
464
+                            "name" => $user->firstname . ' ' . $user->lastname
465 465
                     )
466 466
             );
467 467
         }
@@ -469,15 +469,15 @@  discard block
 block discarded – undo
469 469
     }
470 470
 }
471 471
 
472
-function bigbluebuttonbn_get_participant_list($bigbluebuttonbn=null, $context=null){
472
+function bigbluebuttonbn_get_participant_list($bigbluebuttonbn = null, $context = null) {
473 473
     global $CFG, $USER;
474 474
 
475 475
     $participant_list_array = array();
476 476
 
477
-    if( $bigbluebuttonbn != null ) {
477
+    if ($bigbluebuttonbn != null) {
478 478
         $participant_list = json_decode($bigbluebuttonbn->participants);
479 479
         if (is_array($participant_list)) {
480
-            foreach($participant_list as $participant){
480
+            foreach ($participant_list as $participant) {
481 481
                 array_push($participant_list_array,
482 482
                         array(
483 483
                             "selectiontype" => $participant->selectiontype,
@@ -497,16 +497,16 @@  discard block
 block discarded – undo
497 497
         );
498 498
 
499 499
         $moderator_defaults = bigbluebuttonbn_get_cfg_moderator_default();
500
-        if ( !isset($moderator_defaults) ) {
500
+        if (!isset($moderator_defaults)) {
501 501
             $moderator_defaults = array('owner');
502 502
         } else {
503 503
             $moderator_defaults = explode(',', $moderator_defaults);
504 504
         }
505
-        foreach( $moderator_defaults as $moderator_default ) {
506
-            if( $moderator_default == 'owner' ) {
505
+        foreach ($moderator_defaults as $moderator_default) {
506
+            if ($moderator_default == 'owner') {
507 507
                 $users = bigbluebuttonbn_get_users($context);
508
-                foreach( $users as $user ){
509
-                    if( $user->id == $USER->id ){
508
+                foreach ($users as $user) {
509
+                    if ($user->id == $USER->id) {
510 510
                         array_push($participant_list_array,
511 511
                                 array(
512 512
                                         "selectiontype" => "user",
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     return $participant_list_array;
533 533
 }
534 534
 
535
-function bigbluebuttonbn_get_participant_list_json($bigbluebuttonbnid=null){
535
+function bigbluebuttonbn_get_participant_list_json($bigbluebuttonbnid = null) {
536 536
     return json_encode(bigbluebuttonbn_get_participant_list($bigbluebuttonbnid));
537 537
 }
538 538
 
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
 
542 542
     if (is_array($participant_list)) {
543 543
         // Iterate looking for all configuration
544
-        foreach($participant_list as $participant){
545
-            if( $participant->selectiontype == 'all' ) {
546
-                if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) {
544
+        foreach ($participant_list as $participant) {
545
+            if ($participant->selectiontype == 'all') {
546
+                if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) {
547 547
                     return true;
548 548
                 }
549 549
             }
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
 
552 552
         //Iterate looking for roles
553 553
         $db_moodle_roles = bigbluebuttonbn_get_db_moodle_roles();
554
-        foreach($participant_list as $participant){
555
-            if( $participant->selectiontype == 'role' ) {
556
-                foreach( $roles as $role ) {
554
+        foreach ($participant_list as $participant) {
555
+            if ($participant->selectiontype == 'role') {
556
+                foreach ($roles as $role) {
557 557
                     $db_moodle_role = bigbluebuttonbn_moodle_db_role_lookup($db_moodle_roles, $role->roleid);
558
-                    if( $participant->selectionid == $db_moodle_role->shortname ) {
559
-                        if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) {
558
+                    if ($participant->selectionid == $db_moodle_role->shortname) {
559
+                        if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) {
560 560
                             return true;
561 561
                         }
562 562
                     }
@@ -565,10 +565,10 @@  discard block
 block discarded – undo
565 565
         }
566 566
 
567 567
         //Iterate looking for users
568
-        foreach($participant_list as $participant){
569
-            if( $participant->selectiontype == 'user' ) {
570
-                if( $participant->selectionid == $user ) {
571
-                    if ( $participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR ) {
568
+        foreach ($participant_list as $participant) {
569
+            if ($participant->selectiontype == 'user') {
570
+                if ($participant->selectionid == $user) {
571
+                    if ($participant->role == BIGBLUEBUTTONBN_ROLE_MODERATOR) {
572 572
                         return true;
573 573
                     }
574 574
                 }
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 }
581 581
 
582 582
 function bigbluebuttonbn_moodle_db_role_lookup($db_moodle_roles, $role_id) {
583
-    foreach( $db_moodle_roles as $db_moodle_role ){
584
-        if( $role_id ==  $db_moodle_role->id ) {
583
+    foreach ($db_moodle_roles as $db_moodle_role) {
584
+        if ($role_id == $db_moodle_role->id) {
585 585
             return $db_moodle_role;
586 586
         }
587 587
     }
@@ -589,25 +589,25 @@  discard block
 block discarded – undo
589 589
 
590 590
 function bigbluebuttonbn_get_error_key($messageKey, $defaultKey = null) {
591 591
     $key = $defaultKey;
592
-    if ( $messageKey == "checksumError" ) {
592
+    if ($messageKey == "checksumError") {
593 593
         $key = 'index_error_checksum';
594
-    } else if ( $messageKey == 'maxConcurrent' ) {
594
+    } else if ($messageKey == 'maxConcurrent') {
595 595
         $key = 'view_error_max_concurrent';
596 596
     }
597 597
     return $key;
598 598
 }
599 599
 
600
-function bigbluebuttonbn_voicebridge_unique($voicebridge, $id=null) {
600
+function bigbluebuttonbn_voicebridge_unique($voicebridge, $id = null) {
601 601
     global $DB;
602 602
 
603 603
     $is_unique = true;
604
-    if ( $voicebridge != 0 ) {
604
+    if ($voicebridge != 0) {
605 605
         $table = "bigbluebuttonbn";
606
-        $select = "voicebridge = ".$voicebridge;
607
-        if ( $id ) {
608
-            $select .= " AND id <> ".$id;
606
+        $select = "voicebridge = " . $voicebridge;
607
+        if ($id) {
608
+            $select .= " AND id <> " . $id;
609 609
         }
610
-        if ( $rooms = $DB->get_records_select($table, $select)  ) {
610
+        if ($rooms = $DB->get_records_select($table, $select)) {
611 611
             $is_unique = false;
612 612
         }
613 613
     }
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
 
621 621
     $duration = 0;
622 622
     $now = time();
623
-    if ( $closingtime > 0 && $now < $closingtime ) {
624
-        $duration = ceil(($closingtime - $now)/60);
623
+    if ($closingtime > 0 && $now < $closingtime) {
624
+        $duration = ceil(($closingtime - $now) / 60);
625 625
         $compensation_time = intval(bigbluebuttonbn_get_cfg_scheduled_duration_compensation());
626 626
         $duration = intval($duration) + $compensation_time;
627 627
     }
@@ -629,13 +629,13 @@  discard block
 block discarded – undo
629 629
     return $duration;
630 630
 }
631 631
 
632
-function bigbluebuttonbn_get_presentation_array($context, $presentation, $id=null) {
632
+function bigbluebuttonbn_get_presentation_array($context, $presentation, $id = null) {
633 633
     $presentation_name = null;
634 634
     $presentation_url = null;
635 635
     $presentation_icon = null;
636 636
     $presentation_mimetype_description = null;
637 637
 
638
-    if ( !empty($presentation) ) {
638
+    if (!empty($presentation)) {
639 639
         $fs = get_file_storage();
640 640
         $files = $fs->get_area_files($context->id, 'mod_bigbluebuttonbn', 'presentation', 0, 'itemid, filepath, filename', false);
641 641
         if (count($files) < 1) {
@@ -649,12 +649,12 @@  discard block
 block discarded – undo
649 649
             $presentation_icon = file_file_icon($file, 24);
650 650
             $presentation_mimetype_description = get_mimetype_description($file);
651 651
 
652
-            if( !is_null($id) ) {
652
+            if (!is_null($id)) {
653 653
                 //Create the nonce component for granting a temporary public access
654 654
                 $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'presentation_cache');
655 655
                 $presentation_nonce_key = sha1($id);
656 656
                 $presentation_nonce_value = bigbluebuttonbn_generate_nonce();
657
-                $cache->set($presentation_nonce_key, array( "value" => $presentation_nonce_value, "counter" => 0 ));
657
+                $cache->set($presentation_nonce_key, array("value" => $presentation_nonce_value, "counter" => 0));
658 658
 
659 659
                 //The item id was adapted for granting public access to the presentation once in order to allow BigBlueButton to gather the file
660 660
                 $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $presentation_nonce_value, $file->get_filepath(), $file->get_filename());
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
         }
666 666
     }
667 667
 
668
-    $presentation_array = array( "url" => $presentation_url, "name" => $presentation_name, "icon" => $presentation_icon, "mimetype_description" => $presentation_mimetype_description);
668
+    $presentation_array = array("url" => $presentation_url, "name" => $presentation_name, "icon" => $presentation_icon, "mimetype_description" => $presentation_mimetype_description);
669 669
 
670 670
     return $presentation_array;
671 671
 }
@@ -675,13 +675,13 @@  discard block
 block discarded – undo
675 675
     $mt = microtime();
676 676
     $rand = mt_rand();
677 677
 
678
-    return md5($mt.$rand);
678
+    return md5($mt . $rand);
679 679
 }
680 680
 
681
-function bigbluebuttonbn_random_password( $length = 8 ) {
681
+function bigbluebuttonbn_random_password($length = 8) {
682 682
 
683 683
     $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
684
-    $password = substr( str_shuffle( $chars ), 0, $length );
684
+    $password = substr(str_shuffle($chars), 0, $length);
685 685
 
686 686
     return $password;
687 687
 }
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
     global $CFG;
774 774
 
775 775
     $version_major = bigbluebuttonbn_get_moodle_version_major();
776
-    if ( $version_major < '2014051200' ) {
776
+    if ($version_major < '2014051200') {
777 777
         //This is valid before v2.7
778 778
         bigbluebuttonbn_event_log_legacy($event_type, $bigbluebuttonbn, $context, $cm);
779 779
 
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
     }
784 784
 }
785 785
 
786
-function bigbluebuttonbn_bbb_broker_get_recordings($meetingid, $password, $forced=false) {
786
+function bigbluebuttonbn_bbb_broker_get_recordings($meetingid, $password, $forced = false) {
787 787
     global $CFG;
788 788
 
789 789
     $recordings = array();
@@ -799,19 +799,19 @@  discard block
 block discarded – undo
799 799
     $result = $cache->get($meetingid);
800 800
     $meeting_info = json_decode($result['meeting_info']);
801 801
     $meeting_info->participantCount += 1;
802
-    if( $is_moderator ) {
802
+    if ($is_moderator) {
803 803
         $meeting_info->moderatorCount += 1;
804 804
     }
805
-    $cache->set($meetingid, array('creation_time' => $result['creation_time'], 'meeting_info' => json_encode($meeting_info) ));
805
+    $cache->set($meetingid, array('creation_time' => $result['creation_time'], 'meeting_info' => json_encode($meeting_info)));
806 806
 }
807 807
 
808 808
 function bigbluebuttonbn_bbb_broker_is_meeting_running($meeting_info) {
809
-    $meeting_running = ( isset($meeting_info) && isset($meeting_info->returncode) && $meeting_info->returncode == 'SUCCESS' );
809
+    $meeting_running = (isset($meeting_info) && isset($meeting_info->returncode) && $meeting_info->returncode == 'SUCCESS');
810 810
 
811 811
     return $meeting_running;
812 812
 }
813 813
 
814
-function bigbluebuttonbn_bbb_broker_get_meeting_info($meetingid, $password, $forced=false) {
814
+function bigbluebuttonbn_bbb_broker_get_meeting_info($meetingid, $password, $forced = false) {
815 815
     global $CFG;
816 816
 
817 817
     $meeting_info = array();
@@ -822,19 +822,19 @@  discard block
 block discarded – undo
822 822
     $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'meetings_cache');
823 823
     $result = $cache->get($meetingid);
824 824
     $now = time();
825
-    if( isset($result) && $now < ($result['creation_time'] + $cache_ttl) && !$forced ) {
825
+    if (isset($result) && $now < ($result['creation_time'] + $cache_ttl) && !$forced) {
826 826
         //Use the value in the cache
827 827
         $meeting_info = json_decode($result['meeting_info']);
828 828
     } else {
829 829
         //Ping again and refresh the cache
830
-        $meeting_info = (array) bigbluebuttonbn_getMeetingInfo( $meetingid, $password, $endpoint, $shared_secret );
831
-        $cache->set($meetingid, array('creation_time' => time(), 'meeting_info' => json_encode($meeting_info) ));
830
+        $meeting_info = (array)bigbluebuttonbn_getMeetingInfo($meetingid, $password, $endpoint, $shared_secret);
831
+        $cache->set($meetingid, array('creation_time' => time(), 'meeting_info' => json_encode($meeting_info)));
832 832
     }
833 833
 
834 834
     return $meeting_info;
835 835
 }
836 836
 
837
-function bigbluebuttonbn_bbb_broker_do_end_meeting($meetingid, $password){
837
+function bigbluebuttonbn_bbb_broker_do_end_meeting($meetingid, $password) {
838 838
     global $CFG;
839 839
 
840 840
     $endpoint = bigbluebuttonbn_get_cfg_server_url();
@@ -843,16 +843,16 @@  discard block
 block discarded – undo
843 843
     bigbluebuttonbn_doEndMeeting($meetingid, $password, $endpoint, $shared_secret);
844 844
 }
845 845
 
846
-function bigbluebuttonbn_bbb_broker_do_publish_recording($recordingid, $publish=true){
846
+function bigbluebuttonbn_bbb_broker_do_publish_recording($recordingid, $publish = true) {
847 847
     global $CFG;
848 848
 
849 849
     $endpoint = bigbluebuttonbn_get_cfg_server_url();
850 850
     $shared_secret = bigbluebuttonbn_get_cfg_shared_secret();
851 851
 
852
-    bigbluebuttonbn_doPublishRecordings($recordingid, ($publish)? 'true': 'false', $endpoint, $shared_secret);
852
+    bigbluebuttonbn_doPublishRecordings($recordingid, ($publish) ? 'true' : 'false', $endpoint, $shared_secret);
853 853
 }
854 854
 
855
-function bigbluebuttonbn_bbb_broker_do_publish_recording_imported($recordingid, $courseID, $bigbluebuttonbnID, $publish=true){
855
+function bigbluebuttonbn_bbb_broker_do_publish_recording_imported($recordingid, $courseID, $bigbluebuttonbnID, $publish = true) {
856 856
     global $DB;
857 857
 
858 858
     //Locate the record to be updated
@@ -861,9 +861,9 @@  discard block
 block discarded – undo
861 861
     $recordings_imported = array();
862 862
     foreach ($records as $key => $record) {
863 863
         $meta = json_decode($record->meta, true);
864
-        if( $recordingid == $meta['recording']['recordID'] ) {
864
+        if ($recordingid == $meta['recording']['recordID']) {
865 865
             // Found, prepare data for the update
866
-            $meta['recording']['published'] = ($publish)? 'true': 'false';
866
+            $meta['recording']['published'] = ($publish) ? 'true' : 'false';
867 867
             $records[$key]->meta = json_encode($meta);
868 868
 
869 869
             // Proceed with the update
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
     }
873 873
 }
874 874
 
875
-function bigbluebuttonbn_bbb_broker_do_delete_recording($recordingid){
875
+function bigbluebuttonbn_bbb_broker_do_delete_recording($recordingid) {
876 876
     global $CFG;
877 877
 
878 878
     $endpoint = bigbluebuttonbn_get_cfg_server_url();
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
     bigbluebuttonbn_doDeleteRecordings($recordingid, $endpoint, $shared_secret);
882 882
 }
883 883
 
884
-function bigbluebuttonbn_bbb_broker_do_delete_recording_imported($recordingid, $courseID, $bigbluebuttonbnID){
884
+function bigbluebuttonbn_bbb_broker_do_delete_recording_imported($recordingid, $courseID, $bigbluebuttonbnID) {
885 885
     global $DB;
886 886
 
887 887
     //Locate the record to be updated
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
     $recordings_imported = array();
891 891
     foreach ($records as $key => $record) {
892 892
         $meta = json_decode($record->meta, true);
893
-        if( $recordingid == $meta['recording']['recordID'] ) {
893
+        if ($recordingid == $meta['recording']['recordID']) {
894 894
             // Execute delete
895 895
             $DB->delete_records("bigbluebuttonbn_logs", array('id' => $key));
896 896
         }
@@ -900,18 +900,18 @@  discard block
 block discarded – undo
900 900
 function bigbluebuttonbn_bbb_broker_validate_parameters($params) {
901 901
     $error = '';
902 902
 
903
-    if ( !isset($params['callback']) ) {
903
+    if (!isset($params['callback'])) {
904 904
         $error = bigbluebuttonbn_bbb_broker_add_error($error, 'This call must include a javascript callback.');
905 905
     }
906 906
 
907
-    if ( !isset($params['action']) ) {
907
+    if (!isset($params['action'])) {
908 908
         $error = bigbluebuttonbn_bbb_broker_add_error($error, 'Action parameter must be included.');
909 909
     } else {
910
-        switch ( strtolower($params['action']) ){
910
+        switch (strtolower($params['action'])) {
911 911
             case 'server_ping':
912 912
             case 'meeting_info':
913 913
             case 'meeting_end':
914
-                if ( !isset($params['id']) ) {
914
+                if (!isset($params['id'])) {
915 915
                     $error = bigbluebuttonbn_bbb_broker_add_error($error, 'The meetingID must be specified.');
916 916
                 }
917 917
                 break;
@@ -921,76 +921,76 @@  discard block
 block discarded – undo
921 921
             case 'recording_unpublish':
922 922
             case 'recording_delete':
923 923
             case 'recording_import':
924
-                if ( !isset($params['id']) ) {
924
+                if (!isset($params['id'])) {
925 925
                     $error = bigbluebuttonbn_bbb_broker_add_error($error, 'The recordingID must be specified.');
926 926
                 }
927 927
                 break;
928 928
             case 'recording_ready':
929
-                if( empty($params['signed_parameters']) ) {
929
+                if (empty($params['signed_parameters'])) {
930 930
                     $error = bigbluebuttonbn_bbb_broker_add_error($error, 'A JWT encoded string must be included as [signed_parameters].');
931 931
                 }
932 932
                 break;
933 933
             default:
934
-                $error = bigbluebuttonbn_bbb_broker_add_error($error, 'Action '.$params['action'].' can not be performed.');
934
+                $error = bigbluebuttonbn_bbb_broker_add_error($error, 'Action ' . $params['action'] . ' can not be performed.');
935 935
         }
936 936
     }
937 937
 
938 938
     return $error;
939 939
 }
940 940
 
941
-function bigbluebuttonbn_bbb_broker_add_error($org_msg, $new_msg='') {
941
+function bigbluebuttonbn_bbb_broker_add_error($org_msg, $new_msg = '') {
942 942
     $error = $org_msg;
943 943
 
944
-    if( !empty($new_msg) ) {
945
-        if( !empty($error) ) $error .= ' ';
944
+    if (!empty($new_msg)) {
945
+        if (!empty($error)) $error .= ' ';
946 946
         $error .= $new_msg;
947 947
     }
948 948
 
949 949
     return $error;
950 950
 }
951 951
 
952
-function bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools=["publishing", "deleting"]) {
952
+function bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools = ["publishing", "deleting"]) {
953 953
     global $OUTPUT, $CFG, $USER;
954 954
 
955 955
     $row = null;
956 956
 
957
-    if ( $bbbsession['managerecordings'] || $recording['published'] == 'true' ) {
958
-        $startTime = isset($recording['startTime'])? floatval($recording['startTime']):0;
957
+    if ($bbbsession['managerecordings'] || $recording['published'] == 'true') {
958
+        $startTime = isset($recording['startTime']) ? floatval($recording['startTime']) : 0;
959 959
         $startTime = $startTime - ($startTime % 1000);
960 960
         $duration = intval(array_values($recording['playbacks'])[0]['length']);
961 961
 
962 962
         //For backward compatibility
963
-        if( isset($recording['meta_contextactivity']) ) {
963
+        if (isset($recording['meta_contextactivity'])) {
964 964
             $meta_activity = str_replace('"', '\"', $recording['meta_contextactivity']);
965
-        } if( isset($recording['meta_bbb-recording-name']) ) {
965
+        } if (isset($recording['meta_bbb-recording-name'])) {
966 966
             $meta_activity = str_replace('"', '\"', $recording['meta_bbb-recording-name']);
967 967
         } else {
968 968
             $meta_activity = str_replace('"', '\"', $recording['meetingName']);
969 969
         }
970 970
 
971
-        if( isset($recording['meta_contextactivitydescription']) ) {
971
+        if (isset($recording['meta_contextactivitydescription'])) {
972 972
             $meta_description = str_replace('"', '\"', $recording['meta_contextactivitydescription']);
973
-        } else if( isset($recording['meta_bbb-recording-description']) ) {
973
+        } else if (isset($recording['meta_bbb-recording-description'])) {
974 974
             $meta_description = str_replace('"', '\"', $recording['meta_bbb-recording-description']);
975 975
         } else {
976 976
             $meta_description = '';
977 977
         }
978 978
 
979 979
         //Set recording_types
980
-        if ( isset($recording['imported']) ) {
981
-            $attributes = 'data-imported="true" title='.get_string('view_recording_link_warning', 'bigbluebuttonbn');
980
+        if (isset($recording['imported'])) {
981
+            $attributes = 'data-imported="true" title=' . get_string('view_recording_link_warning', 'bigbluebuttonbn');
982 982
         } else {
983 983
             $attributes = 'data-imported="false"';
984 984
         }
985 985
 
986 986
         $recording_types = '';
987 987
         if ($recording['published'] == 'true') {
988
-            $recording_types .= '<div id="playbacks-'.$recording['recordID'].'" '.$attributes.'>';
988
+            $recording_types .= '<div id="playbacks-' . $recording['recordID'] . '" ' . $attributes . '>';
989 989
         } else {
990
-            $recording_types .= '<div id="playbacks-'.$recording['recordID'].'" '.$attributes.'" hidden>';
990
+            $recording_types .= '<div id="playbacks-' . $recording['recordID'] . '" ' . $attributes . '" hidden>';
991 991
         }
992
-        foreach ( $recording['playbacks'] as $playback ) {
993
-            $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;';
992
+        foreach ($recording['playbacks'] as $playback) {
993
+            $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;';
994 994
         }
995 995
         $recording_types .= '</div>';
996 996
 
@@ -999,11 +999,11 @@  discard block
 block discarded – undo
999 999
 
1000 1000
         //Set actionbar, if user is allowed to manage recordings
1001 1001
         $actionbar = '';
1002
-        if ( $bbbsession['managerecordings'] ) {
1002
+        if ($bbbsession['managerecordings']) {
1003 1003
             // Set style for imported links
1004
-            if( isset($recording['imported']) ) {
1004
+            if (isset($recording['imported'])) {
1005 1005
                 $recordings_imported_count = 0;
1006
-                $tag_tail = ' '.get_string('view_recording_link', 'bigbluebuttonbn');
1006
+                $tag_tail = ' ' . get_string('view_recording_link', 'bigbluebuttonbn');
1007 1007
                 $head = '<i>';
1008 1008
                 $tail = '</i>';
1009 1009
             } else {
@@ -1017,53 +1017,53 @@  discard block
 block discarded – undo
1017 1017
 
1018 1018
             if (in_array("publishing", $tools)) {
1019 1019
                 ///Set action [show|hide]
1020
-                if ( $recording['published'] == 'true' ){
1020
+                if ($recording['published'] == 'true') {
1021 1021
                     $manage_tag = 'hide';
1022 1022
                     $manage_action = 'unpublish';
1023 1023
                 } else {
1024 1024
                     $manage_tag = 'show';
1025 1025
                     $manage_action = 'publish';
1026 1026
                 }
1027
-                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("'.$manage_action.'", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");';
1027
+                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("' . $manage_action . '", "' . $recording['recordID'] . '", "' . $recording['meetingID'] . '");';
1028 1028
 
1029
-                if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) {
1029
+                if (bigbluebuttonbn_get_cfg_recording_icons_enabled()) {
1030 1030
                     //With icon for publish/unpublish
1031
-                    $icon_attributes = array('id' => 'recording-btn-'.$manage_action.'-'.$recording['recordID']);
1032
-                    $icon = new pix_icon('t/'.$manage_tag, get_string($manage_tag).$tag_tail, 'moodle', $icon_attributes);
1033
-                    $link_attributes = array('id' => 'recording-link-'.$manage_action.'-'.$recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1031
+                    $icon_attributes = array('id' => 'recording-btn-' . $manage_action . '-' . $recording['recordID']);
1032
+                    $icon = new pix_icon('t/' . $manage_tag, get_string($manage_tag) . $tag_tail, 'moodle', $icon_attributes);
1033
+                    $link_attributes = array('id' => 'recording-link-' . $manage_action . '-' . $recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1034 1034
                     $actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false);
1035 1035
                 } else {
1036 1036
                     //With text for publish/unpublish
1037
-                    $link_attributes = array('title' => get_string($manage_tag).$tag_tail, 'class' => 'btn btn-xs', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1038
-                    $actionbar .= $OUTPUT->action_link($url, get_string($manage_tag).$tag_tail, $action, $link_attributes);
1037
+                    $link_attributes = array('title' => get_string($manage_tag) . $tag_tail, 'class' => 'btn btn-xs', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1038
+                    $actionbar .= $OUTPUT->action_link($url, get_string($manage_tag) . $tag_tail, $action, $link_attributes);
1039 1039
                     $actionbar .= "&nbsp;";
1040 1040
                 }
1041 1041
             }
1042 1042
 
1043 1043
             if (in_array("deleting", $tools)) {
1044
-                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("delete", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");';
1044
+                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("delete", "' . $recording['recordID'] . '", "' . $recording['meetingID'] . '");';
1045 1045
 
1046
-                if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) {
1046
+                if (bigbluebuttonbn_get_cfg_recording_icons_enabled()) {
1047 1047
                     //With icon for delete
1048
-                    $icon_attributes = array('id' => 'recording-btn-delete-'.$recording['recordID']);
1049
-                    $icon = new pix_icon('t/delete', get_string('delete').$tag_tail, 'moodle', $icon_attributes);
1050
-                    $link_attributes = array('id' => 'recording-link-delete-'.$recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1048
+                    $icon_attributes = array('id' => 'recording-btn-delete-' . $recording['recordID']);
1049
+                    $icon = new pix_icon('t/delete', get_string('delete') . $tag_tail, 'moodle', $icon_attributes);
1050
+                    $link_attributes = array('id' => 'recording-link-delete-' . $recording['recordID'], 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1051 1051
                     $actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false);
1052 1052
                 } else {
1053 1053
                     //With text for delete
1054
-                    $link_attributes = array('title' => get_string('delete').$tag_tail, 'class' => 'btn btn-xs btn-danger', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1055
-                    $actionbar .= $OUTPUT->action_link($url, get_string('delete').$tag_tail, $action, $link_attributes);
1054
+                    $link_attributes = array('title' => get_string('delete') . $tag_tail, 'class' => 'btn btn-xs btn-danger', 'onclick' => $onclick, 'data-links' => $recordings_imported_count);
1055
+                    $actionbar .= $OUTPUT->action_link($url, get_string('delete') . $tag_tail, $action, $link_attributes);
1056 1056
                 }
1057 1057
             }
1058 1058
 
1059 1059
             if (in_array("importing", $tools)) {
1060
-                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("import", "'.$recording['recordID'].'", "'.$recording['meetingID'].'");';
1060
+                $onclick = 'M.mod_bigbluebuttonbn.broker_manageRecording("import", "' . $recording['recordID'] . '", "' . $recording['meetingID'] . '");';
1061 1061
 
1062
-                if ( bigbluebuttonbn_get_cfg_recording_icons_enabled() ) {
1062
+                if (bigbluebuttonbn_get_cfg_recording_icons_enabled()) {
1063 1063
                     //With icon for import
1064
-                    $icon_attributes = array('id' => 'recording-btn-import-'.$recording['recordID']);
1064
+                    $icon_attributes = array('id' => 'recording-btn-import-' . $recording['recordID']);
1065 1065
                     $icon = new pix_icon('i/import', get_string('import'), 'moodle', $icon_attributes);
1066
-                    $link_attributes = array('id' => 'recording-link-import-'.$recording['recordID'], 'onclick' => $onclick);
1066
+                    $link_attributes = array('id' => 'recording-link-import-' . $recording['recordID'], 'onclick' => $onclick);
1067 1067
                     $actionbar .= $OUTPUT->action_icon($url, $icon, $action, $link_attributes, false);
1068 1068
                 } else {
1069 1069
                     //With text for import
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
         }
1075 1075
 
1076 1076
         //Set corresponding format
1077
-        $dateformat = get_string('strftimerecentfull', 'langconfig').' %Z';
1077
+        $dateformat = get_string('strftimerecentfull', 'langconfig') . ' %Z';
1078 1078
         $formattedStartDate = userdate($startTime / 1000, $dateformat, usertimezone($USER->timezone));
1079 1079
 
1080 1080
         $row = new stdClass();
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
         $row->date_formatted = "{$head}{$formattedStartDate}{$tail}";
1086 1086
         $row->duration = "{$duration}";
1087 1087
         $row->duration_formatted = "{$head}{$duration}{$tail}";
1088
-        if ( $bbbsession['managerecordings'] ) {
1088
+        if ($bbbsession['managerecordings']) {
1089 1089
             $row->actionbar = $actionbar;
1090 1090
         }
1091 1091
     }
@@ -1111,21 +1111,21 @@  discard block
 block discarded – undo
1111 1111
         array("key" =>"duration", "label" => $view_recording_duration, "width" => "50px")
1112 1112
         );
1113 1113
 
1114
-    if ( $bbbsession['managerecordings'] ) {
1114
+    if ($bbbsession['managerecordings']) {
1115 1115
         array_push($recordingsbn_columns, array("key" =>"actionbar", "label" => $view_recording_actionbar, "width" => "75px", "allowHTML" => true));
1116 1116
     }
1117 1117
 
1118 1118
     return $recordingsbn_columns;
1119 1119
 }
1120 1120
 
1121
-function bigbluebuttonbn_get_recording_data($bbbsession, $recordings, $tools=["publishing", "deleting"]) {
1121
+function bigbluebuttonbn_get_recording_data($bbbsession, $recordings, $tools = ["publishing", "deleting"]) {
1122 1122
     $table_data = array();
1123 1123
 
1124 1124
     ///Build table content
1125
-    if ( isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1126
-        foreach ( $recordings as $recording ) {
1125
+    if (isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1126
+        foreach ($recordings as $recording) {
1127 1127
             $row = bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools);
1128
-            if( $row != null ) {
1128
+            if ($row != null) {
1129 1129
                 array_push($table_data, $row);
1130 1130
             }
1131 1131
         }
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
     return $table_data;
1135 1135
 }
1136 1136
 
1137
-function bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools=['publishing','deleting']) {
1137
+function bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools = ['publishing', 'deleting']) {
1138 1138
     global $OUTPUT, $CFG;
1139 1139
 
1140 1140
     ///Set strings to show
@@ -1153,20 +1153,20 @@  discard block
 block discarded – undo
1153 1153
     $table->data = array();
1154 1154
 
1155 1155
     ///Initialize table headers
1156
-    if ( $bbbsession['managerecordings'] ) {
1157
-        $table->head  = array ($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration, $view_recording_actionbar);
1158
-        $table->align = array ('left', 'left', 'left', 'left', 'center', 'left');
1156
+    if ($bbbsession['managerecordings']) {
1157
+        $table->head  = array($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration, $view_recording_actionbar);
1158
+        $table->align = array('left', 'left', 'left', 'left', 'center', 'left');
1159 1159
     } else {
1160
-        $table->head  = array ($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration);
1161
-        $table->align = array ('left', 'left', 'left', 'left', 'center');
1160
+        $table->head  = array($view_recording_recording, $view_recording_activity, $view_recording_description, $view_recording_date, $view_recording_duration);
1161
+        $table->align = array('left', 'left', 'left', 'left', 'center');
1162 1162
     }
1163 1163
 
1164 1164
     ///Build table content
1165
-    if ( isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1166
-        foreach ( $recordings as $recording ){
1165
+    if (isset($recordings) && !array_key_exists('messageKey', $recordings)) {  // There are recordings for this meeting
1166
+        foreach ($recordings as $recording) {
1167 1167
             $row = new html_table_row();
1168
-            $row->id = 'recording-td-'.$recording['recordID'];
1169
-            if ( isset($recording['imported']) ) {
1168
+            $row->id = 'recording-td-' . $recording['recordID'];
1169
+            if (isset($recording['imported'])) {
1170 1170
                 $row->attributes['data-imported'] = 'true';
1171 1171
                 $row->attributes['title'] = get_string('view_recording_link_warning', 'bigbluebuttonbn');
1172 1172
             } else {
@@ -1174,12 +1174,12 @@  discard block
 block discarded – undo
1174 1174
             }
1175 1175
 
1176 1176
             $row_data = bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools);
1177
-            if( $row_data != null ) {
1177
+            if ($row_data != null) {
1178 1178
                 $row_data->date_formatted = str_replace(" ", "&nbsp;", $row_data->date_formatted);
1179
-                if ( $bbbsession['managerecordings'] ) {
1180
-                    $row->cells = array ($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted, $row_data->actionbar );
1179
+                if ($bbbsession['managerecordings']) {
1180
+                    $row->cells = array($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted, $row_data->actionbar);
1181 1181
                 } else {
1182
-                    $row->cells = array ($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted );
1182
+                    $row->cells = array($row_data->recording, $row_data->activity, $row_data->description, $row_data->date_formatted, $row_data->duration_formatted);
1183 1183
                 }
1184 1184
 
1185 1185
                 array_push($table->data, $row);
@@ -1199,12 +1199,12 @@  discard block
 block discarded – undo
1199 1199
     /// Build the message_body
1200 1200
     $msg->activity_type = "";
1201 1201
     $msg->activity_title = $bigbluebuttonbn->name;
1202
-    $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>';
1202
+    $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>';
1203 1203
 
1204 1204
     bigbluebuttonbn_send_notification($sender, $bigbluebuttonbn, $message_text);
1205 1205
 }
1206 1206
 
1207
-function bigbluebuttonbn_server_offers($capability_name){
1207
+function bigbluebuttonbn_server_offers($capability_name) {
1208 1208
     global $CFG;
1209 1209
 
1210 1210
     $capability_offered = null;
@@ -1218,12 +1218,12 @@  discard block
 block discarded – undo
1218 1218
     $host_ends = explode(".", $host);
1219 1219
     $host_ends_length = count($host_ends);
1220 1220
 
1221
-    if( $host_ends_length > 0 && $host_ends[$host_ends_length -1] == 'com' &&  $host_ends[$host_ends_length -2] == 'blindsidenetworks' ) {
1221
+    if ($host_ends_length > 0 && $host_ends[$host_ends_length - 1] == 'com' && $host_ends[$host_ends_length - 2] == 'blindsidenetworks') {
1222 1222
         //Validate the capabilities offered
1223
-        $capabilities = bigbluebuttonbn_getCapabilitiesArray( $endpoint, $shared_secret );
1224
-        if( $capabilities ) {
1223
+        $capabilities = bigbluebuttonbn_getCapabilitiesArray($endpoint, $shared_secret);
1224
+        if ($capabilities) {
1225 1225
             foreach ($capabilities as $capability) {
1226
-                if ( $capability["name"] == $capability_name) {
1226
+                if ($capability["name"] == $capability_name) {
1227 1227
                     $capability_offered = $capability;
1228 1228
                 }
1229 1229
             }
@@ -1233,14 +1233,14 @@  discard block
 block discarded – undo
1233 1233
     return $capability_offered;
1234 1234
 }
1235 1235
 
1236
-function bigbluebuttonbn_server_offers_bn_capabilities(){
1236
+function bigbluebuttonbn_server_offers_bn_capabilities() {
1237 1237
     //Validates if the server may have extended capabilities
1238 1238
     $parsed_url = parse_url(bigbluebuttonbn_get_cfg_server_url());
1239 1239
     $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
1240 1240
     $host_ends = explode(".", $host);
1241 1241
     $host_ends_length = count($host_ends);
1242 1242
 
1243
-    return ( $host_ends_length > 0 && $host_ends[$host_ends_length -1] == 'com' && $host_ends[$host_ends_length -2] == 'blindsidenetworks' );
1243
+    return ($host_ends_length > 0 && $host_ends[$host_ends_length - 1] == 'com' && $host_ends[$host_ends_length - 2] == 'blindsidenetworks');
1244 1244
 }
1245 1245
 
1246 1246
 function bigbluebuttonbn_get_locales_for_ui() {
@@ -1285,89 +1285,89 @@  discard block
 block discarded – undo
1285 1285
 
1286 1286
 function bigbluebuttonbn_get_cfg_server_url_default() {
1287 1287
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1288
-    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: 'http://test-install.blindsidenetworks.com/bigbluebutton/')));
1288
+    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 : 'http://test-install.blindsidenetworks.com/bigbluebutton/')));
1289 1289
 }
1290 1290
 
1291 1291
 function bigbluebuttonbn_get_cfg_shared_secret_default() {
1292 1292
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1293
-    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: '8cd8ef52e8e101574e400365b55e11a6')));
1293
+    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 : '8cd8ef52e8e101574e400365b55e11a6')));
1294 1294
 }
1295 1295
 
1296 1296
 function bigbluebuttonbn_get_cfg_voicebridge_editable() {
1297 1297
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1298
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable: (isset($CFG->bigbluebuttonbn_voicebridge_editable)? $CFG->bigbluebuttonbn_voicebridge_editable: false));
1298
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_voicebridge_editable : (isset($CFG->bigbluebuttonbn_voicebridge_editable) ? $CFG->bigbluebuttonbn_voicebridge_editable : false));
1299 1299
 }
1300 1300
 
1301 1301
 function bigbluebuttonbn_get_cfg_recording_default() {
1302 1302
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1303
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default: (isset($CFG->bigbluebuttonbn_recording_default)? $CFG->bigbluebuttonbn_recording_default: true));
1303
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_default : (isset($CFG->bigbluebuttonbn_recording_default) ? $CFG->bigbluebuttonbn_recording_default : true));
1304 1304
 }
1305 1305
 
1306 1306
 function bigbluebuttonbn_get_cfg_recording_editable() {
1307 1307
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1308
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable: (isset($CFG->bigbluebuttonbn_recording_editable)? $CFG->bigbluebuttonbn_recording_editable: true));
1308
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recording_editable : (isset($CFG->bigbluebuttonbn_recording_editable) ? $CFG->bigbluebuttonbn_recording_editable : true));
1309 1309
 }
1310 1310
 
1311 1311
 function bigbluebuttonbn_get_cfg_recording_tagging_default() {
1312 1312
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1313
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default: (isset($CFG->bigbluebuttonbn_recordingtagging_default)? $CFG->bigbluebuttonbn_recordingtagging_default: false));
1313
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_default : (isset($CFG->bigbluebuttonbn_recordingtagging_default) ? $CFG->bigbluebuttonbn_recordingtagging_default : false));
1314 1314
 }
1315 1315
 
1316 1316
 function bigbluebuttonbn_get_cfg_recording_tagging_editable() {
1317 1317
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1318
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable: (isset($CFG->bigbluebuttonbn_recordingtagging_editable)? $CFG->bigbluebuttonbn_recordingtagging_editable: false));
1318
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingtagging_editable : (isset($CFG->bigbluebuttonbn_recordingtagging_editable) ? $CFG->bigbluebuttonbn_recordingtagging_editable : false));
1319 1319
 }
1320 1320
 
1321 1321
 function bigbluebuttonbn_get_cfg_recording_icons_enabled() {
1322 1322
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1323
-    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));
1323
+    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));
1324 1324
 }
1325 1325
 
1326 1326
 function bigbluebuttonbn_get_cfg_importrecordings_enabled() {
1327 1327
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1328
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled: (isset($CFG->bigbluebuttonbn_importrecordings_enabled)? $CFG->bigbluebuttonbn_importrecordings_enabled: false));
1328
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_importrecordings_enabled : (isset($CFG->bigbluebuttonbn_importrecordings_enabled) ? $CFG->bigbluebuttonbn_importrecordings_enabled : false));
1329 1329
 }
1330 1330
 
1331 1331
 function bigbluebuttonbn_get_cfg_importrecordings_from_deleted_activities_enabled() {
1332 1332
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1333
-    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));
1333
+    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));
1334 1334
 }
1335 1335
 
1336 1336
 function bigbluebuttonbn_get_cfg_waitformoderator_default() {
1337 1337
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1338
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default: (isset($CFG->bigbluebuttonbn_waitformoderator_default)? $CFG->bigbluebuttonbn_waitformoderator_default: false));
1338
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_default : (isset($CFG->bigbluebuttonbn_waitformoderator_default) ? $CFG->bigbluebuttonbn_waitformoderator_default : false));
1339 1339
 }
1340 1340
 
1341 1341
 function bigbluebuttonbn_get_cfg_waitformoderator_editable() {
1342 1342
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1343
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable: (isset($CFG->bigbluebuttonbn_waitformoderator_editable)? $CFG->bigbluebuttonbn_waitformoderator_editable: true));
1343
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_waitformoderator_editable : (isset($CFG->bigbluebuttonbn_waitformoderator_editable) ? $CFG->bigbluebuttonbn_waitformoderator_editable : true));
1344 1344
 }
1345 1345
 
1346 1346
 function bigbluebuttonbn_get_cfg_waitformoderator_ping_interval() {
1347 1347
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1348
-    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));
1348
+    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));
1349 1349
 }
1350 1350
 
1351 1351
 function bigbluebuttonbn_get_cfg_waitformoderator_cache_ttl() {
1352 1352
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1353
-    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));
1353
+    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));
1354 1354
 }
1355 1355
 
1356 1356
 function bigbluebuttonbn_get_cfg_userlimit_default() {
1357 1357
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1358
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default: (isset($CFG->bigbluebuttonbn_userlimit_default)? $CFG->bigbluebuttonbn_userlimit_default: 0));
1358
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_default : (isset($CFG->bigbluebuttonbn_userlimit_default) ? $CFG->bigbluebuttonbn_userlimit_default : 0));
1359 1359
 }
1360 1360
 
1361 1361
 function bigbluebuttonbn_get_cfg_userlimit_editable() {
1362 1362
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1363
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable: (isset($CFG->bigbluebuttonbn_userlimit_editable)? $CFG->bigbluebuttonbn_userlimit_editable: false));
1363
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_userlimit_editable : (isset($CFG->bigbluebuttonbn_userlimit_editable) ? $CFG->bigbluebuttonbn_userlimit_editable : false));
1364 1364
 }
1365 1365
 
1366 1366
 function bigbluebuttonbn_get_cfg_preuploadpresentation_enabled() {
1367 1367
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1368 1368
     if (extension_loaded('curl')) {
1369 1369
         // This feature only works if curl is installed
1370
-        return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled: (isset($CFG->bigbluebuttonbn_preuploadpresentation_enabled)? $CFG->bigbluebuttonbn_preuploadpresentation_enabled: false));
1370
+        return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_preuploadpresentation_enabled : (isset($CFG->bigbluebuttonbn_preuploadpresentation_enabled) ? $CFG->bigbluebuttonbn_preuploadpresentation_enabled : false));
1371 1371
     } else {
1372 1372
         return false;
1373 1373
     }
@@ -1375,37 +1375,37 @@  discard block
 block discarded – undo
1375 1375
 
1376 1376
 function bigbluebuttonbn_get_cfg_sendnotifications_enabled() {
1377 1377
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1378
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled: (isset($CFG->bigbluebuttonbn_sendnotifications_enabled)? $CFG->bigbluebuttonbn_sendnotifications_enabled: false));
1378
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_sendnotifications_enabled : (isset($CFG->bigbluebuttonbn_sendnotifications_enabled) ? $CFG->bigbluebuttonbn_sendnotifications_enabled : false));
1379 1379
 }
1380 1380
 
1381 1381
 function bigbluebuttonbn_get_cfg_recordingready_enabled() {
1382 1382
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1383
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled: (isset($CFG->bigbluebuttonbn_recordingready_enabled)? $CFG->bigbluebuttonbn_recordingready_enabled: false));
1383
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_recordingready_enabled : (isset($CFG->bigbluebuttonbn_recordingready_enabled) ? $CFG->bigbluebuttonbn_recordingready_enabled : false));
1384 1384
 }
1385 1385
 
1386 1386
 function bigbluebuttonbn_get_cfg_moderator_default() {
1387 1387
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1388
-    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default)? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default: (isset($CFG->bigbluebuttonbn_moderator_default)? $CFG->bigbluebuttonbn_moderator_default: 'owner'));
1388
+    return (isset($BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default) ? $BIGBLUEBUTTONBN_CFG->bigbluebuttonbn_moderator_default : (isset($CFG->bigbluebuttonbn_moderator_default) ? $CFG->bigbluebuttonbn_moderator_default : 'owner'));
1389 1389
 }
1390 1390
 
1391 1391
 function bigbluebuttonbn_get_cfg_scheduled_duration_enabled() {
1392 1392
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1393
-    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));
1393
+    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));
1394 1394
 }
1395 1395
 
1396 1396
 function bigbluebuttonbn_get_cfg_scheduled_duration_compensation() {
1397 1397
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1398
-    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));
1398
+    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));
1399 1399
 }
1400 1400
 
1401 1401
 function bigbluebuttonbn_get_cfg_scheduled_pre_opening() {
1402 1402
     global $BIGBLUEBUTTONBN_CFG, $CFG;
1403
-    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));
1403
+    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));
1404 1404
 }
1405 1405
 
1406 1406
 function bigbluebuttonbn_import_get_courses_for_select(array $bbbsession) {
1407 1407
 
1408
-    if( $bbbsession['administrator'] ) {
1408
+    if ($bbbsession['administrator']) {
1409 1409
         $courses = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.fullname');
1410 1410
         //It includes the name of the site as a course (category 0), so remove the first one
1411 1411
         unset($courses["1"]);
@@ -1414,21 +1414,21 @@  discard block
 block discarded – undo
1414 1414
     }
1415 1415
 
1416 1416
     $courses_for_select = [];
1417
-    foreach($courses as $course) {
1418
-        if( $course->id != $bbbsession['course']->id ) {
1417
+    foreach ($courses as $course) {
1418
+        if ($course->id != $bbbsession['course']->id) {
1419 1419
             $courses_for_select[$course->id] = $course->fullname;
1420 1420
         }
1421 1421
     }
1422 1422
     return $courses_for_select;
1423 1423
 }
1424 1424
 
1425
-function bigbluebuttonbn_getRecordedMeetingsDeleted($courseID, $bigbluebuttonbnID=NULL) {
1425
+function bigbluebuttonbn_getRecordedMeetingsDeleted($courseID, $bigbluebuttonbnID = NULL) {
1426 1426
     global $DB;
1427 1427
 
1428 1428
     $records_deleted = array();
1429 1429
 
1430
-    $filter = array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_DELETE );
1431
-    if ( $bigbluebuttonbnID != NULL ) {
1430
+    $filter = array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_DELETE);
1431
+    if ($bigbluebuttonbnID != NULL) {
1432 1432
         $filter['id'] = $bigbluebuttonbnID;
1433 1433
     }
1434 1434
 
@@ -1437,17 +1437,17 @@  discard block
 block discarded – undo
1437 1437
     foreach ($bigbluebuttonbns_deleted as $key => $bigbluebuttonbn_deleted) {
1438 1438
         $records = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_CREATE));
1439 1439
 
1440
-        if( !empty($records) ) {
1440
+        if (!empty($records)) {
1441 1441
             //Remove duplicates
1442 1442
             $unique_records = array();
1443 1443
             foreach ($records as $key => $record) {
1444
-                if (array_key_exists($record->meetingid, $unique_records) ) {
1444
+                if (array_key_exists($record->meetingid, $unique_records)) {
1445 1445
                     unset($records[$key]);
1446 1446
                 } else {
1447 1447
                     $meta = json_decode($record->meta);
1448
-                    if ( !$meta->record ) {
1448
+                    if (!$meta->record) {
1449 1449
                         unset($records[$key]);
1450
-                    } else if ( $bigbluebuttonbn_deleted->meetingid != substr($record->meetingid, 0, strlen($bigbluebuttonbn_deleted->meetingid))) {
1450
+                    } else if ($bigbluebuttonbn_deleted->meetingid != substr($record->meetingid, 0, strlen($bigbluebuttonbn_deleted->meetingid))) {
1451 1451
                         unset($records[$key]);
1452 1452
                     } else {
1453 1453
                         array_push($unique_records, $record->meetingid);
@@ -1462,27 +1462,27 @@  discard block
 block discarded – undo
1462 1462
     return $records_deleted;
1463 1463
 }
1464 1464
 
1465
-function bigbluebuttonbn_getRecordedMeetings($courseID, $bigbluebuttonbnID=NULL) {
1465
+function bigbluebuttonbn_getRecordedMeetings($courseID, $bigbluebuttonbnID = NULL) {
1466 1466
     global $DB;
1467 1467
 
1468 1468
     $records = Array();
1469 1469
 
1470 1470
     $filter = array('course' => $courseID);
1471
-    if ( $bigbluebuttonbnID != NULL ) {
1471
+    if ($bigbluebuttonbnID != NULL) {
1472 1472
         $filter['id'] = $bigbluebuttonbnID;
1473 1473
     }
1474 1474
     $bigbluebuttonbns = $DB->get_records('bigbluebuttonbn', $filter);
1475 1475
 
1476
-    if ( !empty($bigbluebuttonbns) ) {
1476
+    if (!empty($bigbluebuttonbns)) {
1477 1477
         $table = 'bigbluebuttonbn_logs';
1478 1478
 
1479 1479
         //Prepare select for loading records based on existent bigbluebuttonbns
1480 1480
         $select = "";
1481 1481
         foreach ($bigbluebuttonbns as $key => $bigbluebuttonbn) {
1482
-            $select .= strlen($select) == 0? "(": " OR ";
1483
-            $select .= "bigbluebuttonbnid=".$bigbluebuttonbn->id;
1482
+            $select .= strlen($select) == 0 ? "(" : " OR ";
1483
+            $select .= "bigbluebuttonbnid=" . $bigbluebuttonbn->id;
1484 1484
         }
1485
-        $select .= ") AND log='".BIGBLUEBUTTONBN_LOG_EVENT_CREATE."'";
1485
+        $select .= ") AND log='" . BIGBLUEBUTTONBN_LOG_EVENT_CREATE . "'";
1486 1486
 
1487 1487
         //Execute select for loading records based on existent bigbluebuttonbns
1488 1488
         $records = $DB->get_records_select($table, $select);
@@ -1490,8 +1490,8 @@  discard block
 block discarded – undo
1490 1490
         //Remove duplicates
1491 1491
         $unique_records = array();
1492 1492
         foreach ($records as $key => $record) {
1493
-            $record_key = $record->meetingid.','.$record->bigbluebuttonbnid.','.$record->meta;
1494
-            if( array_search($record_key, $unique_records) === false ) {
1493
+            $record_key = $record->meetingid . ',' . $record->bigbluebuttonbnid . ',' . $record->meta;
1494
+            if (array_search($record_key, $unique_records) === false) {
1495 1495
                 array_push($unique_records, $record_key);
1496 1496
             } else {
1497 1497
                 unset($records[$key]);
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
         //Remove the ones with record=false
1502 1502
         foreach ($records as $key => $record) {
1503 1503
             $meta = json_decode($record->meta);
1504
-            if ( !$meta || !$meta->record ) {
1504
+            if (!$meta || !$meta->record) {
1505 1505
                 unset($records[$key]);
1506 1506
             }
1507 1507
         }
@@ -1515,15 +1515,15 @@  discard block
 block discarded – undo
1515 1515
 
1516 1516
     // Load the meetingIDs to be used in the getRecordings request
1517 1517
     $meetingID = '';
1518
-    if ( is_numeric($courseID) ) {
1518
+    if (is_numeric($courseID)) {
1519 1519
         $results = bigbluebuttonbn_getRecordedMeetings($courseID);
1520 1520
 
1521
-        if( bigbluebuttonbn_get_cfg_importrecordings_from_deleted_activities_enabled() ) {
1521
+        if (bigbluebuttonbn_get_cfg_importrecordings_from_deleted_activities_enabled()) {
1522 1522
             $results_deleted = bigbluebuttonbn_getRecordedMeetingsDeleted($courseID);
1523 1523
             $results = array_merge($results, $results_deleted);
1524 1524
         }
1525 1525
 
1526
-        if( $results ) {
1526
+        if ($results) {
1527 1527
             //Eliminates duplicates
1528 1528
             $mIDs = array();
1529 1529
             foreach ($results as $result) {
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
     }
1541 1541
 
1542 1542
     // If there were meetingIDs excecute the getRecordings request
1543
-    if ( $meetingID != '' ) {
1543
+    if ($meetingID != '') {
1544 1544
         $recordings = bigbluebuttonbn_getRecordingsArray($meetingID, $URL, $SALT);
1545 1545
     }
1546 1546
 
@@ -1563,37 +1563,37 @@  discard block
 block discarded – undo
1563 1563
     $recordings_already_imported_indexed = bigbluebuttonbn_index_recordings($recordings_already_imported);
1564 1564
 
1565 1565
     foreach ($recordings as $key => $recording) {
1566
-        if( isset($recordings_already_imported_indexed[$recording['recordID']]) ) {
1566
+        if (isset($recordings_already_imported_indexed[$recording['recordID']])) {
1567 1567
             unset($recordings[$key]);
1568 1568
         }
1569 1569
     }
1570 1570
     return $recordings;
1571 1571
 }
1572 1572
 
1573
-function bigbluebutton_output_recording_table($bbbsession, $recordings, $tools=['publishing','deleting']) {
1573
+function bigbluebutton_output_recording_table($bbbsession, $recordings, $tools = ['publishing', 'deleting']) {
1574 1574
 
1575
-    if ( isset($recordings) && !empty($recordings) ) {  // There are recordings for this meeting
1575
+    if (isset($recordings) && !empty($recordings)) {  // There are recordings for this meeting
1576 1576
         $table = bigbluebuttonbn_get_recording_table($bbbsession, $recordings, $tools);
1577 1577
     }
1578 1578
 
1579 1579
     $output = '';
1580
-    if( isset($table->data) ) {
1580
+    if (isset($table->data)) {
1581 1581
         //Print the table
1582
-        $output .= '<div id="bigbluebuttonbn_html_table">'."\n";
1583
-        $output .= html_writer::table($table)."\n";
1584
-        $output .= '</div>'."\n";
1582
+        $output .= '<div id="bigbluebuttonbn_html_table">' . "\n";
1583
+        $output .= html_writer::table($table) . "\n";
1584
+        $output .= '</div>' . "\n";
1585 1585
 
1586 1586
     } else {
1587
-        $output .= get_string('view_message_norecordings', 'bigbluebuttonbn').'<br>'."\n";
1587
+        $output .= get_string('view_message_norecordings', 'bigbluebuttonbn') . '<br>' . "\n";
1588 1588
     }
1589 1589
 
1590 1590
     return $output;
1591 1591
 }
1592 1592
 
1593
-function bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID=NULL) {
1593
+function bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID = NULL) {
1594 1594
     global $DB;
1595 1595
 
1596
-    if ( $bigbluebuttonbnID != NULL ) {
1596
+    if ($bigbluebuttonbnID != NULL) {
1597 1597
         // Fetch only those related to the $courseID and $bigbluebuttonbnID requested
1598 1598
         $recordings_imported = $DB->get_records('bigbluebuttonbn_logs', array('courseid' => $courseID, 'bigbluebuttonbnid' => $bigbluebuttonbnID, 'log' => BIGBLUEBUTTONBN_LOG_EVENT_IMPORT));
1599 1599
     } else {
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
     return $recordings_imported;
1604 1604
 }
1605 1605
 
1606
-function bigbluebuttonbn_getRecordingsImportedArray($courseID, $bigbluebuttonbnID=NULL) {
1606
+function bigbluebuttonbn_getRecordingsImportedArray($courseID, $bigbluebuttonbnID = NULL) {
1607 1607
     $recordings_imported = bigbluebuttonbn_getRecordingsImported($courseID, $bigbluebuttonbnID);
1608 1608
     $recordings_imported_array = bigbluebuttonbn_import_get_recordings_imported($recordings_imported);
1609 1609
     return $recordings_imported_array;
@@ -1612,7 +1612,7 @@  discard block
 block discarded – undo
1612 1612
 function bigbluebuttonbn_getRecordingsImportedAllInstances($recordID) {
1613 1613
     global $DB, $CFG;
1614 1614
 
1615
-    $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.'%' ));
1615
+    $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 . '%'));
1616 1616
     return $recordings_imported;
1617 1617
 }
1618 1618
 
@@ -1631,8 +1631,8 @@  discard block
 block discarded – undo
1631 1631
 function bigbluebuttonbn_html2text($html, $len) {
1632 1632
     $text = strip_tags($html);
1633 1633
     $text = str_replace("&nbsp;", ' ', $text);
1634
-    if( strlen($text) > $len ) {
1635
-        $text = substr($text, 0, $len)."...";
1634
+    if (strlen($text) > $len) {
1635
+        $text = substr($text, 0, $len) . "...";
1636 1636
     } else {
1637 1637
         $text = substr($text, 0, $len);
1638 1638
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -320,8 +320,7 @@  discard block
 block discarded – undo
320 320
 
321 321
     if( $xml ) { //If the xml packet returned failure it displays the message to the user
322 322
         return array('returncode' => $xml->returncode, 'message' => $xml->message, 'messageKey' => $xml->messageKey);
323
-    }
324
-    else { //If the server is unreachable, then prompts the user of the necessary action
323
+    } else { //If the server is unreachable, then prompts the user of the necessary action
325 324
         return null;
326 325
     }
327 326
 }
@@ -355,7 +354,9 @@  discard block
 block discarded – undo
355 354
 }
356 355
 
357 356
 function bigbluebuttonbn_wrap_xml_load_file($url, $method=BIGBLUEBUTTONBN_METHOD_GET, $data=null) {
358
-    if ( bigbluebuttonbn_debugdisplay() ) error_log("Request to: ".$url);
357
+    if ( bigbluebuttonbn_debugdisplay() ) {
358
+        error_log("Request to: ".$url);
359
+    }
359 360
 
360 361
     if (extension_loaded('curl')) {
361 362
         $c = new curl();
@@ -942,7 +943,9 @@  discard block
 block discarded – undo
942 943
     $error = $org_msg;
943 944
 
944 945
     if( !empty($new_msg) ) {
945
-        if( !empty($error) ) $error .= ' ';
946
+        if( !empty($error) ) {
947
+            $error .= ' ';
948
+        }
946 949
         $error .= $new_msg;
947 950
     }
948 951
 
Please login to merge, or discard this patch.