Differences Between: [Versions 400 and 402] [Versions 401 and 402]
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_single_structure; 22 use core_external\external_value; 23 use core_external\external_warnings; 24 use core_external\restricted_context_exception; 25 use mod_bigbluebuttonbn\instance; 26 use mod_bigbluebuttonbn\local\exceptions\meeting_join_exception; 27 use mod_bigbluebuttonbn\meeting; 28 29 /** 30 * External service to create the meeting (if needed), check user limit, and return the join URL when we can join. 31 * 32 * This is mainly used by the mobile application. 33 * 34 * @package mod_bigbluebuttonbn 35 * @category external 36 * @copyright 2018 onwards, Blindside Networks Inc 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class get_join_url extends external_api { 40 /** 41 * Returns description of method parameters 42 * 43 * @return external_function_parameters 44 */ 45 public static function execute_parameters(): external_function_parameters { 46 return new external_function_parameters([ 47 'cmid' => new external_value(PARAM_INT, 'course module id', VALUE_REQUIRED), 48 'groupid' => new external_value(PARAM_INT, 'bigbluebuttonbn group id', VALUE_DEFAULT, 0), 49 ]); 50 } 51 52 /** 53 * Updates a recording 54 * 55 * @param int $cmid the bigbluebuttonbn course module id 56 * @param null|int $groupid 57 * @return array (empty array for now) 58 */ 59 public static function execute( 60 int $cmid, 61 ?int $groupid = 0 62 ): array { 63 // Validate the cmid ID. 64 [ 65 'cmid' => $cmid, 66 'groupid' => $groupid, 67 ] = self::validate_parameters(self::execute_parameters(), [ 68 'cmid' => $cmid, 69 'groupid' => $groupid, 70 ]); 71 $result = ['warnings' => []]; 72 73 $instance = instance::get_from_cmid($cmid); 74 if (empty($instance)) { 75 throw new \moodle_exception('nosuchinstance', 'mod_bigbluebuttonbn', null, 76 ['entity' => get_string('module', 'course'), 'id' => $cmid]); 77 } 78 // Validate the groupid. 79 if (!groups_group_visible($groupid, $instance->get_course(), $instance->get_cm())) { 80 throw new restricted_context_exception(); 81 } 82 $instance->set_group_id($groupid); 83 84 self::validate_context($instance->get_context()); 85 86 try { 87 $result['join_url'] = meeting::join_meeting($instance); 88 } catch (meeting_join_exception $e) { 89 $result['warnings'][] = [ 90 'item' => 'mod_bigbluebuttonbn', 91 'itemid' => $instance->get_instance_id(), 92 'warningcode' => $e->errorcode, 93 'message' => $e->getMessage() 94 ]; 95 } 96 return $result; 97 } 98 99 /** 100 * Describe the return structure of the external service. 101 * 102 * @return external_single_structure 103 * @since Moodle 3.3 104 */ 105 public static function execute_returns(): external_single_structure { 106 return new external_single_structure([ 107 'join_url' => new external_value(PARAM_RAW, 'Can join session', VALUE_OPTIONAL), 108 'warnings' => new external_warnings(), 109 ]); 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body