-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjoin.php
executable file
·225 lines (181 loc) · 7.78 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
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
<?php
/**
* @package mod
* @subpackage adobeconnect
* @author Akinsaya Delamarre ([email protected])
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
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;
// Robert Russo - make sure logged in as users can't accidentally (or on purpose) log in to Connect as someone else
if (isset($USER->realuser)) {
error('You are logged in as someone else.<br /> Please log in as yourself or have the real user log in to continue.');
}
if (! $cm = get_coursemodule_from_id('adobeconnect', $id)) {
error('Course Module ID was incorrect');
}
$cond = array('id' => $cm->course);
if (! $course = $DB->get_record('course', $cond)) {
error('Course is misconfigured');
}
$cond = array('id' => $cm->instance);
if (! $adobeconnect = $DB->get_record('adobeconnect', $cond)) {
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);
if (isset($CFG->adobeconnect_email_login) and !empty($CFG->adobeconnect_email_login)) {
$usrobj->username = $usrobj->email;
}
if (0 != $cm->groupmode){
if (empty($groupid)) {
$groups = groups_get_user_groups($course->id, $usrobj->id);
if (array_key_exists(0, $groups)) {
$groupid = current($groups[0]);
}
if (empty($groupid)) {
$groupid = 0;
notify(get_string('usergrouprequired', 'adobeconnect'));
print_footer($course);
die();
}
}
} else {
$groupid = 0;
}
$usrcanjoin = false;
$usrgroups = groups_get_user_groups($cm->course, $usrobj->id);
$usrgroups = $usrgroups[0]; // Just want groups and not groupings
// If separate groups is enabled, check if the user is a part of the selected group
if (0 != $cm->groupmode/*$adobeconnect->meetingpublic*/) {
if (false !== array_search($groupid, $usrgroups)) {
$usrcanjoin = true;
}
}
$context = get_context_instance(CONTEXT_COURSE, $cm->course);
// Make sure the user has a role in the course
$crsroles = get_roles_used_in_context($context);
if (empty($crsroles)) {
$crsroles = array();
}
foreach ($crsroles as $roleid => $crsrole) {
if (user_has_role_assignment($usrobj->id, $roleid, $context->id)) {
$usrcanjoin = true;
}
}
// user has to be in a group
if ($usrcanjoin and confirm_sesskey($sesskey)) {
$usrprincipal = 0;
$validuser = true;
$groupobj = groups_get_group($groupid);
// 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 on the Adobe server
$meetfldscoid = aconnect_get_folder($aconnect, 'my-meetings');
$filter = array('filter-sco-id' => $meetingscoid);
$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;
}
}
$context = get_context_instance(CONTEXT_MODULE, $id);
// 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'));
}
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'));
} 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;
}
add_to_log($course->id, 'adobeconnect', 'join meeting',
"join.php?id=$cm->id&groupid=$groupid&sesskey=$sesskey",
"Joined $adobeconnect->name meeting", $cm->id);
redirect($protocol . $CFG->adobeconnect_meethost . $port
. $meeting->url
. '?session=' . $aconnect->get_cookie());
}
} else {
notice(get_string('usernotenrolled', 'adobeconnect'));
}