forked from ahmadi-akbar/moodle-mod_adobeconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
joinrecording.php
153 lines (120 loc) · 4.86 KB
/
joinrecording.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
151
152
153
<?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/>.
/**
* @package mod_adobeconnect
* @author Akinsaya Delamarre ([email protected])
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2015 Remote Learner.net Inc http://www.remote-learner.net
*/
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/connect_class.php');
require_once(dirname(__FILE__).'/connect_class_dom.php');
$id = required_param('id', PARAM_INT);
$groupid = required_param('groupid', PARAM_INT);
$recscoid = required_param('recording', PARAM_INT);
global $CFG, $USER, $DB;
// Do the usual Moodle setup
if (! $cm = get_coursemodule_from_id('adobeconnect', $id)) {
print_error('Course Module ID was incorrect');
}
$cond = array('id' => $cm->course);
if (! $course = $DB->get_record('course', $cond)) {
print_error('Course is misconfigured');
}
$cond = array('id' => $cm->instance);
if (! $adobeconnect = $DB->get_record('adobeconnect', $cond)) {
print_error('Course module is incorrect');
}
require_login($course, true, $cm);
// ---------- //
// Get HTTPS setting
$https = false;
$protocol = 'http://';
if (isset($CFG->adobeconnect_https) and (!empty($CFG->adobeconnect_https))) {
$https = true;
$protocol = 'https://';
}
// Create a Connect Pro login session for this user
$usrobj = new stdClass();
$usrobj = clone($USER);
$login = $usrobj->username = set_username($usrobj->username, $usrobj->email);
$params = array('instanceid' => $cm->instance, 'groupid' => $groupid);
$sql = "SELECT meetingscoid FROM {adobeconnect_meeting_groups} amg WHERE ".
"amg.instanceid = :instanceid AND amg.groupid = :groupid";
$meetscoid = $DB->get_record_sql($sql, $params);
// Get the Meeting recording details
$aconnect = aconnect_login();
$recording = array();
$fldid = aconnect_get_folder($aconnect, 'content');
$usrcanjoin = false;
$context = context_module::instance($cm->id);
$data = aconnect_get_recordings($aconnect, $fldid, $meetscoid->meetingscoid);
/// Set page global
$url = new moodle_url('/mod/adobeconnect/view.php', array('id' => $cm->id));
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_title(format_string($adobeconnect->name));
$PAGE->set_heading($course->fullname);
if (!empty($data) && array_key_exists($recscoid, $data)) {
$recording = $data[$recscoid];
} else {
// If at first you don't succeed ...
$data2 = aconnect_get_recordings($aconnect, $meetscoid->meetingscoid, $meetscoid->meetingscoid);
if (!empty($data2) && array_key_exists($recscoid, $data2)) {
$recording = $data2[$recscoid];
}
}
aconnect_logout($aconnect);
if (empty($recording) and confirm_sesskey()) {
notify(get_string('errormeeting', 'adobeconnect'));
die();
}
// If separate groups is enabled, check if the user is a part of the selected group
if (NOGROUPS != $cm->groupmode) {
$usrgroups = groups_get_user_groups($cm->course, $USER
->id);
$usrgroups = $usrgroups[0]; // Just want groups and not groupings
$group_exists = false !== array_search($groupid, $usrgroups);
$aag = has_capability('moodle/site:accessallgroups', $context);
if ($group_exists || $aag) {
$usrcanjoin = true;
}
} else {
$usrcanjoin = true;
}
if (!$usrcanjoin) {
notice(get_string('usergrouprequired', 'adobeconnect'), $url);
}
// Trigger an event for viewing a recording.
$params = array(
'relateduserid' => $USER->id,
'courseid' => $course->id,
'context' => context_module::instance($id),
);
$event = \mod_adobeconnect\event\adobeconnect_view_recording::create($params);
$event->trigger();
// Include the port number only if it is a port other than 80
$port = '';
if (!empty($CFG->adobeconnect_port) and (80 != $CFG->adobeconnect_port)) {
$port = ':' . $CFG->adobeconnect_port;
}
$aconnect = new connect_class_dom($CFG->adobeconnect_host, $CFG->adobeconnect_port,
'', '', '', $https);
$aconnect->request_http_header_login(1, $login);
$adobesession = $aconnect->get_cookie();
redirect($protocol . $CFG->adobeconnect_meethost . $port
. $recording->url . '?session=' . $aconnect->get_cookie());