-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoin.php
150 lines (115 loc) · 5.02 KB
/
join.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Join to a meeting, after registering action.
*
* @package mod_teamsmeeting
* @copyright 2020 Enrique Castro <@ULPGC>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require(__DIR__.'/../../config.php');
require_once(__DIR__.'/lib.php');
// Course_module ID, or
$id = optional_param('id', 0, PARAM_INT);
// ... module instance id.
$t = optional_param('t', 0, PARAM_INT);
if ($id) {
list ($course, $cm) = get_course_and_cm_from_cmid($id, 'teamsmeeting');
$teamsmeeting = $DB->get_record('teamsmeeting', array('id' => $cm->instance), '*', MUST_EXIST);
} else if ($t) {
$teamsmeeting = $DB->get_record('teamsmeeting', array('id' => $t), '*', MUST_EXIST);
list ($course, $cm) = get_course_and_cm_from_instance($t, 'teamsmeeting');
} else {
print_error(get_string('missingidandcmid', 'mod_teamsmeeting'));
}
require_login($course, true, $cm);
$context = context_module::instance($cm->id);
// set url params
$urlparams = array('id' => $cm->id);
/// Check to see if groups are being used in this examboard
$groupmode = groups_get_activity_groupmode($cm);
$groupid = 0;
if ($groupmode) {
$groupid = groups_get_activity_group($cm, true);
}
$oid = 0;
$meetingurl = '';
$rid = optional_param('rid', 0, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHANUMEXT);
if ($rid) {
$recording = $DB->get_record('teamsmeeting_recording', ['id' => $rid], '*', MUST_EXIST);
$oid = $recording->onlinemeetingid;
$meetingurl = $recording->streamurl;
}
if($oid = ($oid) ? $oid : optional_param('oid', 0, PARAM_INT)) {
$onlinemeeting = $DB->get_record('teamsmeeting_onlinemeeting', array('id'=>$oid));
$groupid = $onlinemeeting->groupid;
$action = 'join';
}
if($groupid) {
$urlparams['group'] = $groupid;
}
$baseurl = new moodle_url('/mod/teamsmeeting/view.php', $urlparams);
$PAGE->set_url($baseurl);
$PAGE->set_title(format_string($teamsmeeting->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
$PAGE->set_activity_record($teamsmeeting);
$meetingurl = ($meetingurl) ? $meetingurl : optional_param('joinurl', '', PARAM_URL);
// build common event data
$eventparams = ['context' => $context,
'objectid' => $teamsmeeting->id,
'userid' => $USER->id,
'other' => ['meetingid' => $oid],
];
if($meetingurl && !$action) {
redirect($meetingurl);
} elseif($action == 'join') {
$activate = optional_param('activate', 0, PARAM_INT);
$eventparams['other']['activate'] = $activate;
// sets teacher joined
if($activate && has_capability('mod/teamsmeeting:create', $context)) {
$params = array('teamsmeetingid' => $teamsmeeting->id, 'id' => $oid, 'expired' => 0 );
$DB->set_field('teamsmeeting_onlinemeeting', 'timeactivated', $activate, $params);
}
// sets joined event
$event = \mod_teamsmeeting\event\meeting_joined::create($eventparams);
$event->trigger();
$message = ($meetingurl == $baseurl) ? get_string('errornomeeting', 'teamsmeeting') : '';
redirect($meetingurl, $message);
}
// If action != join, we are viewing a recording
$PAGE->navbar->add(get_string('recording', 'teamsmeeting'), null);
$renderer = $PAGE->get_renderer('mod_teamsmeeting');
echo $renderer->header();
echo $renderer->heading(format_string($teamsmeeting->name), 2, null);
$rid = optional_param('rid', 0, PARAM_INT);
if($recording = $DB->get_record('teamsmeeting_recording', ['id' => $rid, 'onlinemeetingid' => $oid])) {
echo $renderer->heading(format_string($recording->name), 3, null);
// echo DESCRIPTION
// sets joined event
$eventparams['other']['rid'] = $rid;
//$event = \mod_teamsmeeting\event\recording_viewed::create($eventparams);
//$event->trigger();
echo $renderer->show_player_iframe($meetingurl);
} else {
//nothing to see
echo $renderer->box(get_string('nothingtosee', 'teamsmeeting'), 'box centerpara alert-warning text-danger');
}
echo $renderer->single_button($baseurl, get_string('backtomodule', 'teamsmeeting'), 'get', array('class' => 'backtocourse clearfix'));
$back = new moodle_url('/course/view.php', array('id' => $course->id));
echo $renderer->single_button($back, get_string('backtocourse', 'teamsmeeting'), 'get', array('class' => 'backtocourse clearfix'));
echo $renderer->footer();