See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace mod_bigbluebuttonbn\external; 18 19 use external_api; 20 use external_function_parameters; 21 use external_single_structure; 22 use external_value; 23 use mod_bigbluebuttonbn\instance; 24 use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy; 25 use mod_bigbluebuttonbn\meeting; 26 use restricted_context_exception; 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 global $CFG; 31 require_once($CFG->libdir . '/externallib.php'); 32 33 /** 34 * External service to fetch meeting information. 35 * 36 * @package mod_bigbluebuttonbn 37 * @category external 38 * @copyright 2018 onwards, Blindside Networks Inc 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41 class meeting_info extends external_api { 42 43 /** 44 * Returns description of method parameters. 45 * 46 * @return external_function_parameters 47 */ 48 public static function execute_parameters(): external_function_parameters { 49 return new external_function_parameters([ 50 'bigbluebuttonbnid' => new external_value(PARAM_INT, 'bigbluebuttonbn instance id'), 51 'groupid' => new external_value(PARAM_INT, 'bigbluebuttonbn group id', VALUE_DEFAULT, 0), 52 'updatecache' => new external_value(PARAM_BOOL, 'update cache ?', VALUE_DEFAULT, false), 53 ]); 54 } 55 56 /** 57 * Fetch meeting information. 58 * 59 * @param int $bigbluebuttonbnid the bigbluebuttonbn instance id 60 * @param int $groupid 61 * @param bool $updatecache 62 * @return array 63 * @throws \moodle_exception 64 * @throws restricted_context_exception 65 */ 66 public static function execute( 67 int $bigbluebuttonbnid, 68 int $groupid, 69 bool $updatecache = false 70 ): array { 71 // Validate the bigbluebuttonbnid ID. 72 [ 73 'bigbluebuttonbnid' => $bigbluebuttonbnid, 74 'groupid' => $groupid, 75 'updatecache' => $updatecache, 76 ] = self::validate_parameters(self::execute_parameters(), [ 77 'bigbluebuttonbnid' => $bigbluebuttonbnid, 78 'groupid' => $groupid, 79 'updatecache' => $updatecache, 80 ]); 81 82 // Fetch the session, features, and profile. 83 $instance = instance::get_from_instanceid($bigbluebuttonbnid); 84 $instance->set_group_id($groupid); 85 if (!groups_group_visible($groupid, $instance->get_course(), $instance->get_cm())) { 86 throw new restricted_context_exception(); 87 } 88 $context = $instance->get_context(); 89 90 // Validate that the user has access to this activity and to manage recordings. 91 self::validate_context($context); 92 93 // Check if the BBB server is working. 94 $serverversion = bigbluebutton_proxy::get_server_version(); 95 if ($serverversion === null) { 96 throw new \moodle_exception('general_error_no_answer', 'mod_bigbluebuttonbn', 97 bigbluebutton_proxy::get_server_not_available_url($instance), 98 bigbluebutton_proxy::get_server_not_available_message($instance)); 99 } 100 $meetinginfo = (array) meeting::get_meeting_info_for_instance($instance, $updatecache); 101 102 // Make the structure WS friendly. 103 array_walk($meetinginfo['features'], function(&$value, $key){ 104 $value = ['name' => $key, 'isenabled' => (bool) $value]; 105 }); 106 return $meetinginfo; 107 } 108 109 /** 110 * Describe the return structure of the external service. 111 * 112 * @return external_single_structure 113 * @since Moodle 3.0 114 */ 115 public static function execute_returns(): external_single_structure { 116 return new external_single_structure([ 117 'cmid' => new external_value(PARAM_INT, 'CM id'), 118 'userlimit' => new external_value(PARAM_INT, 'User limit'), 119 'bigbluebuttonbnid' => new external_value(PARAM_RAW, 'bigbluebuttonbn instance id'), 120 'groupid' => new external_value(PARAM_INT, 'bigbluebuttonbn group id', VALUE_DEFAULT, 0), 121 'meetingid' => new external_value(PARAM_RAW, 'Meeting id'), 122 'openingtime' => new external_value(PARAM_INT, 'Opening time', VALUE_OPTIONAL), 123 'closingtime' => new external_value(PARAM_INT, 'Closing time', VALUE_OPTIONAL), 124 'statusrunning' => new external_value(PARAM_BOOL, 'Status running', VALUE_OPTIONAL), 125 'statusclosed' => new external_value(PARAM_BOOL, 'Status closed', VALUE_OPTIONAL), 126 'statusopen' => new external_value(PARAM_BOOL, 'Status open', VALUE_OPTIONAL), 127 'statusmessage' => new external_value(PARAM_TEXT, 'Status message', VALUE_OPTIONAL), 128 'startedat' => new external_value(PARAM_INT, 'Started at', VALUE_OPTIONAL), 129 'moderatorcount' => new external_value(PARAM_INT, 'Moderator count', VALUE_OPTIONAL), 130 'participantcount' => new external_value(PARAM_INT, 'Participant count', VALUE_OPTIONAL), 131 'moderatorplural' => new external_value(PARAM_BOOL, 'Several moderators ?', VALUE_OPTIONAL), 132 'participantplural' => new external_value(PARAM_BOOL, 'Several participants ?', VALUE_OPTIONAL), 133 'canjoin' => new external_value(PARAM_BOOL, 'Can join'), 134 'ismoderator' => new external_value(PARAM_BOOL, 'Is moderator'), 135 'presentations' => new \external_multiple_structure( 136 new external_single_structure([ 137 'url' => new external_value(PARAM_URL, 'presentation URL'), 138 'iconname' => new external_value(PARAM_RAW, 'icon name'), 139 'icondesc' => new external_value(PARAM_TEXT, 'icon text'), 140 'name' => new external_value(PARAM_TEXT, 'presentation name'), 141 ]) 142 ), 143 'joinurl' => new external_value(PARAM_URL, 'Join URL'), 144 'guestaccessenabled' => new external_value(PARAM_BOOL, 'Guest access enabled', VALUE_OPTIONAL), 145 'guestjoinurl' => new external_value(PARAM_URL, 'Guest URL', VALUE_OPTIONAL), 146 'guestpassword' => new external_value(PARAM_RAW, 'Guest join password', VALUE_OPTIONAL), 147 'features' => new \external_multiple_structure( 148 new external_single_structure([ 149 'name' => new external_value(PARAM_ALPHA, 'Feature name.'), 150 'isenabled' => new external_value(PARAM_BOOL, 'Whether the feature is enabled.'), 151 ]), 'List of features for the instance', VALUE_OPTIONAL 152 ), 153 ] 154 ); 155 } 156 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body