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