Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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\output; 18 19 use core\output\notification; 20 use mod_bigbluebuttonbn\instance; 21 use mod_bigbluebuttonbn\local\config; 22 use mod_bigbluebuttonbn\meeting; 23 use renderable; 24 use renderer_base; 25 use stdClass; 26 use templatable; 27 28 /** 29 * View Page template renderable. 30 * 31 * @package mod_bigbluebuttonbn 32 * @copyright 2021 Andrew Lyons <andrew@nicols.co.uk> 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class view_page implements renderable, templatable { 36 37 /** @var instance The instance being rendered */ 38 protected $instance; 39 40 /** 41 * Constructor for the View Page. 42 * 43 * @param instance $instance 44 */ 45 public function __construct(instance $instance) { 46 $this->instance = $instance; 47 } 48 49 /** 50 * Export the content required to render the template. 51 * 52 * @param renderer_base $output 53 * @return stdClass 54 */ 55 public function export_for_template(renderer_base $output): stdClass { 56 $templatedata = (object) [ 57 'instanceid' => $this->instance->get_instance_id(), 58 'groupselector' => $output->render_groups_selector($this->instance), 59 'meetingname' => $this->instance->get_meeting_name(), 60 'description' => $this->instance->get_meeting_description(true), 61 'joinurl' => $this->instance->get_join_url(), 62 ]; 63 64 if ($this->show_default_server_warning()) { 65 $templatedata->serverwarning = (new notification( 66 get_string('view_warning_default_server', 'mod_bigbluebuttonbn'), 67 notification::NOTIFY_WARNING, 68 false 69 ))->export_for_template($output); 70 } 71 72 $viewwarningmessage = config::get('general_warning_message'); 73 if ($this->show_view_warning() && !empty($viewwarningmessage)) { 74 $templatedata->sitenotification = (object) [ 75 'message' => $viewwarningmessage, 76 'type' => config::get('general_warning_box_type'), 77 'icon' => [ 78 'pix' => 'i/bullhorn', 79 'component' => 'core', 80 ], 81 ]; 82 83 if ($url = config::get('general_warning_button_href')) { 84 $templatedata->sitenotification->actions = [[ 85 'url' => $url, 86 'title' => config::get('general_warning_button_text'), 87 ]]; 88 } 89 } 90 91 if ($this->instance->is_feature_enabled('showroom')) { 92 $roomdata = meeting::get_meeting_info_for_instance($this->instance); 93 $roomdata->haspresentations = false; 94 if (!empty($roomdata->presentations)) { 95 $roomdata->haspresentations = true; 96 } 97 $templatedata->room = $roomdata; 98 } 99 100 if ($this->instance->is_feature_enabled('showrecordings') && $this->instance->is_recorded()) { 101 $recordings = new recordings_session($this->instance); 102 $templatedata->recordings = $recordings->export_for_template($output); 103 } else if ($this->instance->is_type_recordings_only()) { 104 $templatedata->recordingwarning = (new notification( 105 get_string('view_message_recordings_disabled', 'mod_bigbluebuttonbn'), 106 notification::NOTIFY_WARNING, 107 false 108 ))->export_for_template($output); 109 } 110 111 return $templatedata; 112 } 113 114 /** 115 * Whether to show the default server warning. 116 * 117 * @return bool 118 */ 119 protected function show_default_server_warning(): bool { 120 if (!$this->instance->is_admin()) { 121 return false; 122 } 123 124 if (config::DEFAULT_SERVER_URL != config::get('server_url')) { 125 return false; 126 } 127 128 return true; 129 } 130 131 /** 132 * Whether to show the view warning. 133 * 134 * @return bool 135 */ 136 protected function show_view_warning(): bool { 137 if ($this->instance->is_admin()) { 138 return true; 139 } 140 141 $generalwarningroles = explode(',', config::get('general_warning_roles')); 142 $userroles = \mod_bigbluebuttonbn\local\helpers\roles::get_user_roles( 143 $this->instance->get_context(), 144 $this->instance->get_user_id() 145 ); 146 147 foreach ($userroles as $userrole) { 148 if (in_array($userrole->shortname, $generalwarningroles)) { 149 return true; 150 } 151 } 152 153 return false; 154 } 155 156 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body