Completed
Pull Request — v2.2-stable (#68)
by
unknown
01:59
created
locallib.php 1 patch
Doc Comments   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
  * Helper function to retrieve recordings from a BigBlueButton server.
174 174
  *
175 175
  * @param string|array $meetingids   list of meetingIDs "mid1,mid2,mid3" or array("mid1","mid2","mid3")
176
- * @param string|array $recordingids list of $recordingids "rid1,rid2,rid3" or array("rid1","rid2","rid3") for filtering
176
+ * @param string $recordingids list of $recordingids "rid1,rid2,rid3" or array("rid1","rid2","rid3") for filtering
177 177
  *
178
- * @return associative array with recordings indexed by recordID, each recording is a non sequential associative array
178
+ * @return string array with recordings indexed by recordID, each recording is a non sequential associative array
179 179
  */
180 180
 function bigbluebuttonbn_get_recordings_array($meetingids, $recordingids = []) {
181 181
     $meetingidsarray = $meetingids;
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
  * Helper function to retrieve imported recordings from the Moodle database.
263 263
  * The references are stored as events in bigbluebuttonbn_logs.
264 264
  *
265
- * @param string $courseid
265
+ * @param integer $courseid
266 266
  * @param string $bigbluebuttonbnid
267 267
  * @param bool   $subset
268 268
  *
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 /**
291 291
  * Helper function to retrive the default config.xml file.
292 292
  *
293
- * @return string
293
+ * @return null|SimpleXMLElement
294 294
  */
295 295
 function bigbluebuttonbn_get_default_config_xml() {
296 296
     $xml = bigbluebuttonbn_wrap_xml_load_file(
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
  * @param object $a
373 373
  * @param object $b
374 374
  *
375
- * @return array
375
+ * @return integer
376 376
  */
377 377
 function bigbluebuttonbn_recording_build_sorter($a, $b) {
378 378
     if ($a['startTime'] < $b['startTime']) {
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
  * @param string $data
484 484
  * @param string $contenttype
485 485
  *
486
- * @return object
486
+ * @return null|SimpleXMLElement
487 487
  */
488 488
 function bigbluebuttonbn_wrap_xml_load_file($url, $method = 'GET', $data = null, $contenttype = 'text/xml') {
489 489
     if (extension_loaded('curl')) {
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
  * @param string $data
525 525
  * @param string $contenttype
526 526
  *
527
- * @return object
527
+ * @return string
528 528
  */
529 529
 function bigbluebuttonbn_wrap_xml_load_file_curl_request($url, $method = 'GET', $data = null, $contenttype = 'text/xml') {
530 530
     $c = new curl();
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
  * @param integer $instance
895 895
  * @param integer $voicebridge
896 896
  *
897
- * @return string
897
+ * @return boolean
898 898
  */
899 899
 function bigbluebuttonbn_voicebridge_unique($instance, $voicebridge) {
900 900
     global $DB;
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 /**
998 998
  * Helper returns an array with all possible bigbluebuttonbn events.
999 999
  *
1000
- * @return array
1000
+ * @return string[]
1001 1001
  */
1002 1002
 function bigbluebuttonbn_events() {
1003 1003
     return array(
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
  * @param string $meetingid
1224 1224
  * @param string $configxml
1225 1225
  *
1226
- * @return object
1226
+ * @return null|SimpleXMLElement
1227 1227
  */
1228 1228
 function bigbluebuttonbn_set_config_xml($meetingid, $configxml) {
1229 1229
     $urldefaultconfig = \mod_bigbluebuttonbn\locallib\config::get('server_url').'api/setConfigXML?';
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
  * @param array $recording
1273 1273
  * @param array $tools
1274 1274
  *
1275
- * @return array
1275
+ * @return null|stdClass
1276 1276
  */
1277 1277
 function bigbluebuttonbn_get_recording_data_row($bbbsession, $recording, $tools = ['protect', 'publish', 'delete']) {
1278 1278
     if (!bigbluebuttonbn_include_recording_table_row($bbbsession, $recording)) {
@@ -1836,7 +1836,7 @@  discard block
 block discarded – undo
1836 1836
  *
1837 1837
  * @param array $bbbsession
1838 1838
  * @param array $recording
1839
- * @param object $rowdata
1839
+ * @param stdClass $rowdata
1840 1840
  *
1841 1841
  * @return object
1842 1842
  */
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
  * Helper function to define the sql used for gattering the bigbluebuttonbnids whose meetingids should be included
2032 2032
  * in the getRecordings request considering only those that belong to deleted activities.
2033 2033
  *
2034
- * @param string $courseid
2034
+ * @param integer $courseid
2035 2035
  * @param string $bigbluebuttonbnid
2036 2036
  * @param bool   $subset
2037 2037
  *
@@ -2055,7 +2055,7 @@  discard block
 block discarded – undo
2055 2055
  * Helper function to define the sql used for gattering the bigbluebuttonbnids whose meetingids should be included
2056 2056
  * in the getRecordings request considering only those that belong to imported recordings.
2057 2057
  *
2058
- * @param string $courseid
2058
+ * @param integer $courseid
2059 2059
  * @param string $bigbluebuttonbnid
2060 2060
  * @param bool   $subset
2061 2061
  *
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
 /**
2079 2079
  * Helper function to get recordings  and imported recordings together.
2080 2080
  *
2081
- * @param string $courseid
2081
+ * @param integer $courseid
2082 2082
  * @param string $bigbluebuttonbnid
2083 2083
  * @param bool   $subset
2084 2084
  * @param bool   $includedeleted
@@ -2096,7 +2096,7 @@  discard block
 block discarded – undo
2096 2096
  * Helper function to retrieve recordings from the BigBlueButton. The references are stored as events
2097 2097
  * in bigbluebuttonbn_logs.
2098 2098
  *
2099
- * @param string $courseid
2099
+ * @param integer $courseid
2100 2100
  * @param string $bigbluebuttonbnid
2101 2101
  * @param bool   $subset
2102 2102
  * @param bool   $includedeleted
Please login to merge, or discard this patch.
bbb_broker.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -440,26 +440,26 @@  discard block
 block discarded – undo
440 440
             return array(
441 441
                 'status' => false,
442 442
                 'message' => get_string('view_recording_publish_link_deleted', 'bigbluebuttonbn')
443
-              );
443
+                );
444 444
         }
445 445
         if ($realrecordings[$params['id']]['published'] !== 'true') {
446 446
             return array(
447 447
                 'status' => false,
448 448
                 'message' => get_string('view_recording_publish_link_not_published', 'bigbluebuttonbn')
449
-              );
449
+                );
450 450
         }
451 451
         return array(
452 452
             'status' => bigbluebuttonbn_publish_recording_imported(
453 453
                 $recordings[$params['id']]['imported'], true
454 454
             )
455
-          );
455
+            );
456 456
     }
457 457
     // As the recordingid was not identified as imported recording link, execute actual publish.
458 458
     return array(
459 459
         'status' => bigbluebuttonbn_publish_recordings(
460 460
             $params['id'], 'true'
461 461
         )
462
-      );
462
+        );
463 463
 }
464 464
 
465 465
 /**
@@ -480,26 +480,26 @@  discard block
 block discarded – undo
480 480
             return array(
481 481
                 'status' => false,
482 482
                 'message' => get_string('view_recording_unprotect_link_deleted', 'bigbluebuttonbn')
483
-              );
483
+                );
484 484
         }
485 485
         if ($realrecordings[$params['id']]['protected'] === 'true') {
486 486
             return array(
487 487
                 'status' => false,
488 488
                 'message' => get_string('view_recording_unprotect_link_not_unprotected', 'bigbluebuttonbn')
489
-              );
489
+                );
490 490
         }
491 491
         return array(
492 492
             'status' => bigbluebuttonbn_protect_recording_imported(
493 493
                 $recordings[$params['id']]['imported'], false
494 494
             )
495
-          );
495
+            );
496 496
     }
497 497
     // As the recordingid was not identified as imported recording link, execute actual uprotect.
498 498
     return array(
499 499
         'status' => bigbluebuttonbn_update_recordings(
500 500
             $params['id'], array('protect' => 'false')
501 501
         )
502
-      );
502
+        );
503 503
 }
504 504
 
505 505
 /**
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
             'status' => bigbluebuttonbn_publish_recording_imported(
519 519
                 $recordings[$params['id']]['imported'], false
520 520
             )
521
-          );
521
+            );
522 522
     }
523 523
     // As the recordingid was not identified as imported recording link, execute unpublish on a real recording.
524 524
     // First: Unpublish imported links associated to the recording.
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         'status' => bigbluebuttonbn_publish_recordings(
537 537
             $params['id'], 'false'
538 538
         )
539
-      );
539
+        );
540 540
 }
541 541
 
542 542
 /**
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
             'status' => bigbluebuttonbn_protect_recording_imported(
556 556
                 $recordings[$params['id']]['imported'], true
557 557
             )
558
-          );
558
+            );
559 559
     }
560 560
     // As the recordingid was not identified as imported recording link, execute protect on a real recording.
561 561
     // First: Protect imported links associated to the recording.
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
         'status' => bigbluebuttonbn_update_recordings(
574 574
             $params['id'], array('protect' => 'true')
575 575
         )
576
-      );
576
+        );
577 577
 }
578 578
 
579 579
 /**
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
             'status' => bigbluebuttonbn_delete_recording_imported(
593 593
                 $recordings[$params['id']]['imported']
594 594
             )
595
-          );
595
+            );
596 596
     }
597 597
     // As the recordingid was not identified as imported recording link, execute delete on a real recording.
598 598
     // First: Delete imported links associated to the recording.
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
     // Second: Execute the actual delete.
607 607
     return array(
608 608
         'status' => bigbluebuttonbn_delete_recordings($params['id'])
609
-      );
609
+        );
610 610
 }
611 611
 
612 612
 /**
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
             'status' => bigbluebuttonbn_update_recording_imported(
625 625
                 $recordings[$params['id']]['imported'], json_decode($params['meta'], true)
626 626
             )
627
-          );
627
+            );
628 628
     }
629 629
 
630 630
     // As the recordingid was not identified as imported recording link, execute update on a real recording.
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
         'status' => bigbluebuttonbn_update_recordings(
635 635
             $params['id'], json_decode($params['meta'])
636 636
         )
637
-      );
637
+        );
638 638
 }
639 639
 
640 640
 /**
@@ -666,14 +666,14 @@  discard block
 block discarded – undo
666 666
     }
667 667
     // Sends the messages.
668 668
     try {
669
-      //That if was for trying to workaround the several emails sent for one record ready
670
-      if(bigbluebuttonbn_get_count_callback_event_log($decodedparameters->record_id) == 0)){
669
+        //That if was for trying to workaround the several emails sent for one record ready
670
+        if(bigbluebuttonbn_get_count_callback_event_log($decodedparameters->record_id) == 0)){
671 671
         bigbluebuttonbn_send_notification_recording_ready($bigbluebuttonbn);
672
-      }
673
-      $overrides = array('meetingid' => $bigbluebuttonbn->meetingid);
674
-      $meta = '{"recordID":'.$decodedparameters->record_id.'}';
675
-      bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTON_LOG_EVENT_CALLBACK, $overrides, $meta);
676
-      header('HTTP/1.0 202 Accepted');
672
+        }
673
+        $overrides = array('meetingid' => $bigbluebuttonbn->meetingid);
674
+        $meta = '{"recordID":'.$decodedparameters->record_id.'}';
675
+        bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTON_LOG_EVENT_CALLBACK, $overrides, $meta);
676
+        header('HTTP/1.0 202 Accepted');
677 677
     } catch (Exception $e) {
678 678
         $error = 'Caught exception: '.$e->getMessage();
679 679
         header('HTTP/1.0 503 Service Unavailable. '.$error);
@@ -807,11 +807,11 @@  discard block
 block discarded – undo
807 807
     $params['recording_ready'] = [
808 808
             'bigbluebuttonbn' => 'An id for the bigbluebuttonbn instance should be included.',
809 809
             'signed_parameters' => 'A JWT encoded string must be included as [signed_parameters].'
810
-          ];
810
+            ];
811 811
     $params['live_session_events'] = [
812 812
             'bigbluebuttonbn' => 'An id for the bigbluebuttonbn instance should be included.',
813 813
             'signed_parameters' => 'A JWT encoded string must be included as [signed_parameters].'
814
-          ];
814
+            ];
815 815
     return $params;
816 816
 }
817 817
 
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
  */
823 823
 function bigbluebuttonbn_broker_required_parameters_default($id) {
824 824
     return [
825
-              'id' => "The {$id} must be specified.",
826
-              'callback' => 'This call must include a javascript callback.'
827
-           ];
825
+                'id' => "The {$id} must be specified.",
826
+                'callback' => 'This call must include a javascript callback.'
827
+            ];
828 828
 }
829 829
 
830 830
 /**
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
  */
25 25
 
26 26
 
27
-require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
28
-require_once(dirname(__FILE__).'/locallib.php');
27
+require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
28
+require_once(dirname(__FILE__) . '/locallib.php');
29 29
 
30 30
 use \Firebase\JWT\JWT;
31 31
 
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 $params['meta'] = optional_param('meta', '', PARAM_TEXT);
42 42
 
43 43
 if (empty($params['action'])) {
44
-    header('HTTP/1.0 400 Bad Request. Parameter ['.$params['action'].'] was not included');
44
+    header('HTTP/1.0 400 Bad Request. Parameter [' . $params['action'] . '] was not included');
45 45
     return;
46 46
 }
47 47
 
48 48
 $error = bigbluebuttonbn_broker_validate_parameters($params);
49 49
 if (!empty($error)) {
50
-    header('HTTP/1.0 400 Bad Request. '.$error);
50
+    header('HTTP/1.0 400 Bad Request. ' . $error);
51 51
     return;
52 52
 }
53 53
 
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
         bigbluebuttonbn_broker_live_session_events($params, $bigbluebuttonbn, $cm);
133 133
         return;
134 134
     }
135
-    header('HTTP/1.0 400 Bad request. The action '. $a . ' doesn\'t exist');
135
+    header('HTTP/1.0 400 Bad request. The action ' . $a . ' doesn\'t exist');
136 136
     return;
137 137
 
138 138
 } catch (Exception $e) {
139
-    header('HTTP/1.0 500 Internal Server Error. '.$e->getMessage());
139
+    header('HTTP/1.0 500 Internal Server Error. ' . $e->getMessage());
140 140
     return;
141 141
 }
142 142
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 function bigbluebuttonbn_broker_recording_info_current($recording, $params) {
323 323
     $callbackresponse['status'] = true;
324 324
     $callbackresponse['found'] = true;
325
-    $callbackresponse['published'] = (string) $recording['published'];
325
+    $callbackresponse['published'] = (string)$recording['published'];
326 326
     if (!isset($params['meta']) || empty($params['meta'])) {
327 327
         return $callbackresponse;
328 328
     }
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
         $decodedparameters = JWT::decode($params['signed_parameters'],
652 652
             \mod_bigbluebuttonbn\locallib\config::get('shared_secret'), array('HS256'));
653 653
     } catch (Exception $e) {
654
-        $error = 'Caught exception: '.$e->getMessage();
655
-        header('HTTP/1.0 400 Bad Request. '.$error);
654
+        $error = 'Caught exception: ' . $e->getMessage();
655
+        header('HTTP/1.0 400 Bad Request. ' . $error);
656 656
         return;
657 657
     }
658 658
 
@@ -667,16 +667,16 @@  discard block
 block discarded – undo
667 667
     // Sends the messages.
668 668
     try {
669 669
       //That if was for trying to workaround the several emails sent for one record ready
670
-      if(bigbluebuttonbn_get_count_callback_event_log($decodedparameters->record_id) == 0)){
670
+      if (bigbluebuttonbn_get_count_callback_event_log($decodedparameters->record_id) == 0)){
671 671
         bigbluebuttonbn_send_notification_recording_ready($bigbluebuttonbn);
672 672
       }
673 673
       $overrides = array('meetingid' => $bigbluebuttonbn->meetingid);
674
-      $meta = '{"recordID":'.$decodedparameters->record_id.'}';
674
+      $meta = '{"recordID":' . $decodedparameters->record_id . '}';
675 675
       bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTON_LOG_EVENT_CALLBACK, $overrides, $meta);
676 676
       header('HTTP/1.0 202 Accepted');
677 677
     } catch (Exception $e) {
678
-        $error = 'Caught exception: '.$e->getMessage();
679
-        header('HTTP/1.0 503 Service Unavailable. '.$error);
678
+        $error = 'Caught exception: ' . $e->getMessage();
679
+        header('HTTP/1.0 503 Service Unavailable. ' . $error);
680 680
     }
681 681
 }
682 682
 
@@ -697,13 +697,13 @@  discard block
 block discarded – undo
697 697
     $importrecordings = $SESSION->bigbluebuttonbn_importrecordings;
698 698
     if (!isset($importrecordings[$params['id']])) {
699 699
         $error = "Recording {$params['id']} could not be found. It can not be imported";
700
-        header('HTTP/1.0 404 Not found. '.$error);
700
+        header('HTTP/1.0 404 Not found. ' . $error);
701 701
         return;
702 702
     }
703 703
     $callbackresponse = array('status' => true);
704 704
     $importrecordings[$params['id']]['imported'] = true;
705 705
     $overrides = array('meetingid' => $importrecordings[$params['id']]['meetingID']);
706
-    $meta = '{"recording":'.json_encode($importrecordings[$params['id']]).'}';
706
+    $meta = '{"recording":' . json_encode($importrecordings[$params['id']]) . '}';
707 707
     bigbluebuttonbn_log($bbbsession['bigbluebuttonbn'], BIGBLUEBUTTONBN_LOG_EVENT_IMPORT, $overrides, $meta);
708 708
     // Moodle event logger: Create an event for recording imported.
709 709
     if (isset($bbbsession['bigbluebutton']) && isset($bbbsession['cm'])) {
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
         $decodedparameters = JWT::decode($params['signed_parameters'],
730 730
             \mod_bigbluebuttonbn\locallib\config::get('shared_secret'), array('HS256'));
731 731
     } catch (Exception $e) {
732
-        $error = 'Caught exception: '.$e->getMessage();
733
-        header('HTTP/1.0 400 Bad Request. '.$error);
732
+        $error = 'Caught exception: ' . $e->getMessage();
733
+        header('HTTP/1.0 400 Bad Request. ' . $error);
734 734
         return;
735 735
     }
736 736
     // Validate that the bigbluebuttonbn activity corresponds to the meeting_id received.
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
     $requiredparams = bigbluebuttonbn_broker_required_parameters();
766 766
     $action = strtolower($params['action']);
767 767
     if (!array_key_exists($action, $requiredparams)) {
768
-        return 'Action '.$params['action'].' can not be performed.';
768
+        return 'Action ' . $params['action'] . ' can not be performed.';
769 769
     }
770 770
     return bigbluebuttonbn_broker_validate_parameters_message($params, $requiredparams[$action]);
771 771
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -667,9 +667,11 @@
 block discarded – undo
667 667
     // Sends the messages.
668 668
     try {
669 669
       //That if was for trying to workaround the several emails sent for one record ready
670
-      if(bigbluebuttonbn_get_count_callback_event_log($decodedparameters->record_id) == 0)){
670
+      if(bigbluebuttonbn_get_count_callback_event_log($decodedparameters->record_id) == 0) {
671
+          ){
671 672
         bigbluebuttonbn_send_notification_recording_ready($bigbluebuttonbn);
672 673
       }
674
+      }
673 675
       $overrides = array('meetingid' => $bigbluebuttonbn->meetingid);
674 676
       $meta = '{"recordID":'.$decodedparameters->record_id.'}';
675 677
       bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTON_LOG_EVENT_CALLBACK, $overrides, $meta);
Please login to merge, or discard this patch.