Differences Between: [Versions 400 and 403] [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 core_external\external_api; 20 use core_external\external_function_parameters; 21 use core_external\external_multiple_structure; 22 use core_external\external_single_structure; 23 use core_external\external_value; 24 use core_external\restricted_context_exception; 25 use mod_bigbluebuttonbn\instance; 26 use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy; 27 use mod_bigbluebuttonbn\meeting; 28 29 /** 30 * External service to fetch meeting information. 31 * 32 * @package mod_bigbluebuttonbn 33 * @category external 34 * @copyright 2018 onwards, Blindside Networks Inc 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class meeting_info extends external_api { 38 39 /** 40 * Returns description of method parameters. 41 * 42 * @return external_function_parameters 43 */ 44 public static function execute_parameters(): external_function_parameters { 45 return new external_function_parameters([ 46 'bigbluebuttonbnid' => new external_value(PARAM_INT, 'bigbluebuttonbn instance id'), 47 'groupid' => new external_value(PARAM_INT, 'bigbluebuttonbn group id', VALUE_DEFAULT, 0), 48 'updatecache' => new external_value(PARAM_BOOL, 'update cache ?', VALUE_DEFAULT, false), 49 ]); 50 } 51 52 /** 53 * Fetch meeting information. 54 * 55 * @param int $bigbluebuttonbnid the bigbluebuttonbn instance id 56 * @param int $groupid 57 * @param bool $updatecache 58 * @return array 59 * @throws \moodle_exception 60 * @throws restricted_context_exception 61 */ 62 public static function execute( 63 int $bigbluebuttonbnid, 64 int $groupid, 65 bool $updatecache = false 66 ): array { 67 // Validate the bigbluebuttonbnid ID. 68 [ 69 'bigbluebuttonbnid' => $bigbluebuttonbnid, 70 'groupid' => $groupid, 71 'updatecache' => $updatecache, 72 ] = self::validate_parameters(self::execute_parameters(), [ 73 'bigbluebuttonbnid' => $bigbluebuttonbnid, 74 'groupid' => $groupid, 75 'updatecache' => $updatecache, 76 ]); 77 78 // Fetch the session, features, and profile. 79 $instance = instance::get_from_instanceid($bigbluebuttonbnid); 80 $instance->set_group_id($groupid); 81 if (!groups_group_visible($groupid, $instance->get_course(), $instance->get_cm())) { 82 throw new restricted_context_exception(); 83 } 84 $context = $instance->get_context(); 85 86 // Validate that the user has access to this activity and to manage recordings. 87 self::validate_context($context); 88 89 // Check if the BBB server is working. 90 $serverversion = bigbluebutton_proxy::get_server_version(); 91 if ($serverversion === null) { 92 throw new \moodle_exception('general_error_no_answer', 'mod_bigbluebuttonbn', 93 bigbluebutton_proxy::get_server_not_available_url($instance), 94 bigbluebutton_proxy::get_server_not_available_message($instance)); 95 } 96 $meetinginfo = (array) meeting::get_meeting_info_for_instance($instance, $updatecache); 97 98 // Make the structure WS friendly. 99 array_walk($meetinginfo['features'], function(&$value, $key){ 100 $value = ['name' => $key, 'isenabled' => (bool) $value]; 101 }); 102 return $meetinginfo; 103 } 104 105 /** 106 * Describe the return structure of the external service. 107 * 108 * @return external_single_structure 109 * @since Moodle 3.0 110 */ 111 public static function execute_returns(): external_single_structure { 112 return new external_single_structure([ 113 'cmid' => new external_value(PARAM_INT, 'CM id'), 114 'userlimit' => new external_value(PARAM_INT, 'User limit'), 115 'bigbluebuttonbnid' => new external_value(PARAM_RAW, 'bigbluebuttonbn instance id'), 116 'groupid' => new external_value(PARAM_INT, 'bigbluebuttonbn group id', VALUE_DEFAULT, 0), 117 'meetingid' => new external_value(PARAM_RAW, 'Meeting id'), 118 'openingtime' => new external_value(PARAM_INT, 'Opening time', VALUE_OPTIONAL), 119 'closingtime' => new external_value(PARAM_INT, 'Closing time', VALUE_OPTIONAL), 120 'statusrunning' => new external_value(PARAM_BOOL, 'Status running', VALUE_OPTIONAL), 121 'statusclosed' => new external_value(PARAM_BOOL, 'Status closed', VALUE_OPTIONAL), 122 'statusopen' => new external_value(PARAM_BOOL, 'Status open', VALUE_OPTIONAL), 123 'statusmessage' => new external_value(PARAM_TEXT, 'Status message', VALUE_OPTIONAL), 124 'startedat' => new external_value(PARAM_INT, 'Started at', VALUE_OPTIONAL), 125 'moderatorcount' => new external_value(PARAM_INT, 'Moderator count', VALUE_OPTIONAL), 126 'participantcount' => new external_value(PARAM_INT, 'Participant count', VALUE_OPTIONAL), 127 'moderatorplural' => new external_value(PARAM_BOOL, 'Several moderators ?', VALUE_OPTIONAL), 128 'participantplural' => new external_value(PARAM_BOOL, 'Several participants ?', VALUE_OPTIONAL), 129 'canjoin' => new external_value(PARAM_BOOL, 'Can join'), 130 'ismoderator' => new external_value(PARAM_BOOL, 'Is moderator'), 131 'presentations' => new external_multiple_structure( 132 new external_single_structure([ 133 'url' => new external_value(PARAM_URL, 'presentation URL'), 134 'iconname' => new external_value(PARAM_RAW, 'icon name'), 135 'icondesc' => new external_value(PARAM_TEXT, 'icon text'), 136 'name' => new external_value(PARAM_TEXT, 'presentation name'), 137 ]) 138 ), 139 'joinurl' => new external_value(PARAM_URL, 'Join URL'), 140 'guestaccessenabled' => new external_value(PARAM_BOOL, 'Guest access enabled', VALUE_OPTIONAL), 141 'guestjoinurl' => new external_value(PARAM_URL, 'Guest URL', VALUE_OPTIONAL), 142 'guestpassword' => new external_value(PARAM_RAW, 'Guest join password', VALUE_OPTIONAL), 143 'features' => new external_multiple_structure( 144 new external_single_structure([ 145 'name' => new external_value(PARAM_ALPHA, 'Feature name.'), 146 'isenabled' => new external_value(PARAM_BOOL, 'Whether the feature is enabled.'), 147 ]), 'List of features for the instance', VALUE_OPTIONAL 148 ), 149 ] 150 ); 151 } 152 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body