forked from ahmadi-akbar/moodle-mod_adobeconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoin.php
More file actions
227 lines (187 loc) · 8.26 KB
/
join.php
File metadata and controls
227 lines (187 loc) · 8.26 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?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 (adelamarre@remote-learner.net)
* @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); // course_module ID, or
$groupid = required_param('groupid', PARAM_INT);
$sesskey = required_param('sesskey', PARAM_ALPHANUM);
global $CFG, $USER, $DB, $PAGE;
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);
// Check if the user's email is the Connect Pro user's login
$usrobj = new stdClass();
$usrobj = clone($USER);
$usrobj->username = set_username($usrobj->username, $usrobj->email);
$usrcanjoin = false;
$context = context_module::instance($cm->id);
// 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, $usrobj->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;
}
/// 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);
// user has to be in a group
if ($usrcanjoin and confirm_sesskey($sesskey)) {
$usrprincipal = 0;
$validuser = true;
// Get the meeting sco-id
$param = array('instanceid' => $cm->instance, 'groupid' => $groupid);
$meetingscoid = $DB->get_field('adobeconnect_meeting_groups', 'meetingscoid', $param);
$aconnect = aconnect_login();
// Check if the meeting still exists in the shared folder of the Adobe server
$meetfldscoid = aconnect_get_folder($aconnect, 'meetings');
$filter = array('filter-sco-id' => $meetingscoid);
$meeting = aconnect_meeting_exists($aconnect, $meetfldscoid, $filter);
if (!empty($meeting)) {
$meeting = current($meeting);
} else {
/* Check if the module instance has a user associated with it
if so, then check the user's adobe connect folder for existince of the meeting */
if (!empty($adobeconnect->userid)) {
$username = get_connect_username($adobeconnect->userid);
$meetfldscoid = aconnect_get_user_folder_sco_id($aconnect, $username);
$meeting = aconnect_meeting_exists($aconnect, $meetfldscoid, $filter);
if (!empty($meeting)) {
$meeting = current($meeting);
}
}
}
if (!($usrprincipal = aconnect_user_exists($aconnect, $usrobj))) {
if (!($usrprincipal = aconnect_create_user($aconnect, $usrobj))) {
// DEBUG
print_object("error creating user");
print_object($aconnect->_xmlresponse);
$validuser = false;
}
}
// Check the user's capabilities and assign them the Adobe Role
if (!empty($meetingscoid) and !empty($usrprincipal) and !empty($meeting)) {
if (has_capability('mod/adobeconnect:meetinghost', $context, $usrobj->id, false)) {
if (aconnect_check_user_perm($aconnect, $usrprincipal, $meetingscoid, ADOBE_HOST, true)) {
//DEBUG
// echo 'host';
// die();
} else {
//DEBUG
print_object('error assign user adobe host role');
print_object($aconnect->_xmlrequest);
print_object($aconnect->_xmlresponse);
$validuser = false;
}
} elseif (has_capability('mod/adobeconnect:meetingpresenter', $context, $usrobj->id, false)) {
if (aconnect_check_user_perm($aconnect, $usrprincipal, $meetingscoid, ADOBE_PRESENTER, true)) {
//DEBUG
// echo 'presenter';
// die();
} else {
//DEBUG
print_object('error assign user adobe presenter role');
print_object($aconnect->_xmlrequest);
print_object($aconnect->_xmlresponse);
$validuser = false;
}
} elseif (has_capability('mod/adobeconnect:meetingparticipant', $context, $usrobj->id, false)) {
if (aconnect_check_user_perm($aconnect, $usrprincipal, $meetingscoid, ADOBE_PARTICIPANT, true)) {
//DEBUG
// echo 'participant';
// die();
} else {
//DEBUG
print_object('error assign user adobe particpant role');
print_object($aconnect->_xmlrequest);
print_object($aconnect->_xmlresponse);
$validuser = false;
}
} else {
// Check if meeting is public and allow them to join
if ($adobeconnect->meetingpublic) {
// if for a public meeting the user does not not have either of presenter or participant capabilities then give
// the user the participant role for the meeting
aconnect_check_user_perm($aconnect, $usrprincipal, $meetingscoid, ADOBE_PARTICIPANT, true);
$validuser = true;
} else {
$validuser = false;
}
}
} else {
$validuser = false;
notice(get_string('unableretrdetails', 'adobeconnect'), $url);
}
aconnect_logout($aconnect);
// User is either valid or invalid, if valid redirect user to the meeting url
if (empty($validuser)) {
notice(get_string('notparticipant', 'adobeconnect'), $url);
} else {
$protocol = 'http://';
$https = false;
$login = $usrobj->username;
if (isset($CFG->adobeconnect_https) and (!empty($CFG->adobeconnect_https))) {
$protocol = 'https://';
$https = true;
}
$aconnect = new connect_class_dom($CFG->adobeconnect_host, $CFG->adobeconnect_port,
'', '', '', $https);
$aconnect->request_http_header_login(1, $login);
// 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;
}
// Trigger an event for joining a meeting.
$params = array(
'relateduserid' => $USER->id,
'courseid' => $course->id,
'context' => context_module::instance($id),
);
$event = \mod_adobeconnect\event\adobeconnect_join_meeting::create($params);
$event->trigger();
redirect($protocol . $CFG->adobeconnect_meethost . $port
. $meeting->url
. '?session=' . $aconnect->get_cookie());
}
} else {
notice(get_string('usergrouprequired', 'adobeconnect'), $url);
}