Commit 4c84f8975026979126cf2d936a161c56cfeabc53

Authored by DFNVC
1 parent f35759a7b3
Exists in master

Anpassung für PHP 7. Funktion split() durch preg_split() ersetzt.

Showing 1 changed file with 9 additions and 6 deletions Inline Diff

1 <?php 1 <?php
2 2
3 /** 3 /**
4 * @package mod 4 * @package mod
5 * @subpackage adobeconnect 5 * @subpackage adobeconnect
6 * @author Akinsaya Delamarre (adelamarre@remote-learner.net) 6 * @author Akinsaya Delamarre (adelamarre@remote-learner.net)
7 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 7 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
8 */ 8 */
9 9
10 require_once('connect_class.php'); 10 require_once('connect_class.php');
11 require_once('connect_class_dom.php'); 11 require_once('connect_class_dom.php');
12 12
13 define('ADOBE_VIEW_ROLE', 'view'); 13 define('ADOBE_VIEW_ROLE', 'view');
14 define('ADOBE_HOST_ROLE', 'host'); 14 define('ADOBE_HOST_ROLE', 'host');
15 define('ADOBE_MINIADMIN_ROLE', 'mini-host'); 15 define('ADOBE_MINIADMIN_ROLE', 'mini-host');
16 define('ADOBE_REMOVE_ROLE', 'remove'); 16 define('ADOBE_REMOVE_ROLE', 'remove');
17 17
18 define('ADOBE_PARTICIPANT', 1); 18 define('ADOBE_PARTICIPANT', 1);
19 define('ADOBE_PRESENTER', 2); 19 define('ADOBE_PRESENTER', 2);
20 define('ADOBE_REMOVE', 3); 20 define('ADOBE_REMOVE', 3);
21 define('ADOBE_HOST', 4); 21 define('ADOBE_HOST', 4);
22 22
23 define('ADOBE_TEMPLATE_POSTFIX', '- Template'); 23 define('ADOBE_TEMPLATE_POSTFIX', '- Template');
24 define('ADOBE_MEETING_POSTFIX', '- Meeting'); 24 define('ADOBE_MEETING_POSTFIX', '- Meeting');
25 25
26 define('ADOBE_MEETPERM_PUBLIC', 0); //means the Acrobat Connect meeting is public, and anyone who has the URL for the meeting can enter the room. 26 define('ADOBE_MEETPERM_PUBLIC', 0); //means the Acrobat Connect meeting is public, and anyone who has the URL for the meeting can enter the room.
27 define('ADOBE_MEETPERM_PROTECTED', 1); //means the meeting is protected, and only registered users and accepted guests can enter the room. 27 define('ADOBE_MEETPERM_PROTECTED', 1); //means the meeting is protected, and only registered users and accepted guests can enter the room.
28 define('ADOBE_MEETPERM_PRIVATE', 2); // means the meeting is private, and only registered users and participants can enter the room 28 define('ADOBE_MEETPERM_PRIVATE', 2); // means the meeting is private, and only registered users and participants can enter the room
29 29
30 define('ADOBE_TMZ_LENGTH', 6); 30 define('ADOBE_TMZ_LENGTH', 6);
31 31
32 /* DFNVC 32 /* DFNVC
33 function adobe_connection_test($host = '', $port = 80, $username = '', 33 function adobe_connection_test($host = '', $port = 80, $username = '',
34 $password = '', $httpheader = '', 34 $password = '', $httpheader = '',
35 $emaillogin, $https = false) { 35 $emaillogin, $https = false) {
36 */ 36 */
37 37
38 function adobe_connection_test($host = '', $port = 80, $username = '', 38 function adobe_connection_test($host = '', $port = 80, $username = '',
39 $password = '', 39 $password = '',
40 $emaillogin, $https = false) { 40 $emaillogin, $https = false) {
41 global $CFG; 41 global $CFG;
42 if (empty($host) or 42 if (empty($host) or
43 empty($port) or (0 == $port) or 43 empty($port) or (0 == $port) or
44 empty($username) or 44 empty($username) or
45 empty($password)) 45 empty($password))
46 /* DFNVC 46 /* DFNVC
47 or empty($httpheader)) { */ 47 or empty($httpheader)) { */
48 { 48 {
49 49
50 echo "</p>One of the required parameters is blank or incorrect: <br />". 50 echo "</p>One of the required parameters is blank or incorrect: <br />".
51 "Host: $host<br /> Port: $port<br /> Username: $username<br /> Password: $password". 51 "Host: $host<br /> Port: $port<br /> Username: $username<br /> Password: $password".
52 "<br /> HTTP Header: $httpheader</p>"; 52 "<br /> HTTP Header: $httpheader</p>";
53 53
54 die(); 54 die();
55 } 55 }
56 56
57 $messages = array(); 57 $messages = array();
58 58
59 $aconnectDOM = new connect_class_dom($host, 59 $aconnectDOM = new connect_class_dom($host,
60 $port, 60 $port,
61 $username, 61 $username,
62 $password, 62 $password,
63 '', 63 '',
64 $https); 64 $https);
65 65
66 $params = array( 66 $params = array(
67 'action' => 'common-info' 67 'action' => 'common-info'
68 ); 68 );
69 69
70 // Send common-info call to obtain the session key 70 // Send common-info call to obtain the session key
71 echo '<p><b>Sending common-info call:</b></p>'; 71 echo '<p><b>Sending common-info call:</b></p>';
72 $aconnectDOM->create_request($params); 72 $aconnectDOM->create_request($params);
73 73
74 if (!empty($aconnectDOM->_xmlresponse)) { 74 if (!empty($aconnectDOM->_xmlresponse)) {
75 75
76 // Get the session key from the XML response 76 // Get the session key from the XML response
77 $aconnectDOM->read_cookie_xml($aconnectDOM->_xmlresponse); 77 $aconnectDOM->read_cookie_xml($aconnectDOM->_xmlresponse);
78 78
79 $cookie = $aconnectDOM->get_cookie(); 79 $cookie = $aconnectDOM->get_cookie();
80 if (empty($cookie)) { 80 if (empty($cookie)) {
81 81
82 echo '<p>unable to obtain session key from common-info call</p>'; 82 echo '<p>unable to obtain session key from common-info call</p>';
83 echo '<p>xmlrequest:</p>'; 83 echo '<p>xmlrequest:</p>';
84 $doc = new DOMDocument(); 84 $doc = new DOMDocument();
85 85
86 if ($doc->loadXML($aconnectDOM->_xmlrequest)) { 86 if ($doc->loadXML($aconnectDOM->_xmlrequest)) {
87 echo '<p>' . htmlspecialchars($doc->saveXML()) . '</p>'; 87 echo '<p>' . htmlspecialchars($doc->saveXML()) . '</p>';
88 } else { 88 } else {
89 echo '<p>unable to display the XML request</p>'; 89 echo '<p>unable to display the XML request</p>';
90 90
91 } 91 }
92 92
93 echo '<p>xmlresponse:</p>'; 93 echo '<p>xmlresponse:</p>';
94 $doc = new DOMDocument(); 94 $doc = new DOMDocument();
95 95
96 if ($doc->loadXML($aconnectDOM->_xmlresponse)) { 96 if ($doc->loadXML($aconnectDOM->_xmlresponse)) {
97 echo '<p>' . htmlspecialchars($doc->saveHTML()) . '</p>'; 97 echo '<p>' . htmlspecialchars($doc->saveHTML()) . '</p>';
98 } else { 98 } else {
99 echo '<p>unable to display the XML response</p>'; 99 echo '<p>unable to display the XML response</p>';
100 } 100 }
101 } else { 101 } else {
102 102
103 // print success 103 // print success
104 echo '<p style="color:#006633">successfully obtained the session key: ' . $aconnectDOM->get_cookie() . '</p>'; 104 echo '<p style="color:#006633">successfully obtained the session key: ' . $aconnectDOM->get_cookie() . '</p>';
105 $sessionkey = $aconnectDOM->get_cookie(); 105 $sessionkey = $aconnectDOM->get_cookie();
106 106
107 // Test logging in as the administrator 107 // Test logging in as the administrator
108 echo '<p><b>Test logging in as administrator.</b></p>'; 108 echo '<p><b>Test logging in as administrator.</b></p>';
109 $params = array( 109 $params = array(
110 'action' => 'login', 110 'action' => 'login',
111 'login' => $aconnectDOM->get_username(), 111 'login' => $aconnectDOM->get_username(),
112 'password' => $aconnectDOM->get_password() . '', 112 'password' => $aconnectDOM->get_password() . '',
113 ); 113 );
114 $aconnectDOM->create_request($params); 114 $aconnectDOM->create_request($params);
115 115
116 116
117 if ($aconnectDOM->call_success()) { 117 if ($aconnectDOM->call_success()) {
118 echo '<p style="color:#006633">successfully logged in as '. $username . '</p>'; 118 echo '<p style="color:#006633">successfully logged in as '. $username . '</p>';
119 // DFNVC 119 // DFNVC
120 // Test header login 120 // Test header login
121 // 121 //
122 /* echo '<p><b>Testing header login:</b><p>'; */ 122 /* echo '<p><b>Testing header login:</b><p>'; */
123 /* if ($aconnectDOM->request_http_header_login(1, $username)) { */ 123 /* if ($aconnectDOM->request_http_header_login(1, $username)) { */
124 /* echo '<p style="color:#006633">successfully logged in as user ' . $username . '</p>'; */ 124 /* echo '<p style="color:#006633">successfully logged in as user ' . $username . '</p>'; */
125 /* echo '<p>cookie:' . $aconnectDOM->get_cookie() .'<p>'; */ 125 /* echo '<p>cookie:' . $aconnectDOM->get_cookie() .'<p>'; */
126 126
127 /* } */ 127 /* } */
128 /* else { */ 128 /* else { */
129 /* echo '<p>header login for user ' . $username . ' failed<p>'; */ 129 /* echo '<p>header login for user ' . $username . ' failed<p>'; */
130 /* } */ 130 /* } */
131 131
132 // Test retrevial of folders 132 // Test retrevial of folders
133 echo '<p><b>Testing retrevial of content folder:</b></p>'; 133 echo '<p><b>Testing retrevial of content folder:</b></p>';
134 $folderscoid = aconnect_get_content_folder($aconnectDOM); 134 $folderscoid = aconnect_get_content_folder($aconnectDOM);
135 135
136 if ($folderscoid) { 136 if ($folderscoid) {
137 echo '<p style="color:#006633">successfully obtained content folder scoid '. $folderscoid . '</p>'; 137 echo '<p style="color:#006633">successfully obtained content folder scoid '. $folderscoid . '</p>';
138 } else { 138 } else {
139 139
140 echo '<p>error obtaining shared content folder</p>'; 140 echo '<p>error obtaining shared content folder</p>';
141 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 141 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
142 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 142 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
143 143
144 } 144 }
145 145
146 // DFNVC 146 // DFNVC
147 // Testing retrieval of meeting folder sco-id 147 // Testing retrieval of meeting folder sco-id
148 // 148 //
149 echo '<p><b>Testing retrevial of meetings folder:</b></p>'; 149 echo '<p><b>Testing retrevial of meetings folder:</b></p>';
150 $meetingfolderscoid = aconnect_get_meeting_folder($aconnectDOM); 150 $meetingfolderscoid = aconnect_get_meeting_folder($aconnectDOM);
151 if ($meetingfolderscoid) { 151 if ($meetingfolderscoid) {
152 echo '<p style="color:#006633">successfully obtained meeting folder scoid '. $meetingfolderscoid . '</p>'; 152 echo '<p style="color:#006633">successfully obtained meeting folder scoid '. $meetingfolderscoid . '</p>';
153 } else { 153 } else {
154 echo '<p>error obtaining meeting folder sco-id</p>'; 154 echo '<p>error obtaining meeting folder sco-id</p>';
155 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 155 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
156 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 156 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
157 } 157 }
158 // DFNVC 158 // DFNVC
159 // Testing retrieval of shared template folder 159 // Testing retrieval of shared template folder
160 // TODO 160 // TODO
161 echo '<p><b>Testing retrevial of shared meeting templates:</b></p>'; 161 echo '<p><b>Testing retrevial of shared meeting templates:</b></p>';
162 $templates = aconnect_get_templates_meetings($aconnectDOM); 162 $templates = aconnect_get_templates_meetings($aconnectDOM);
163 if ($templates) { 163 if ($templates) {
164 echo '<p style="color:#006633">successfully obtained shared templates :</p>'; 164 echo '<p style="color:#006633">successfully obtained shared templates :</p>';
165 echo '<p style="color:#006633">'; 165 echo '<p style="color:#006633">';
166 foreach (array_keys($templates) as $key) { 166 foreach (array_keys($templates) as $key) {
167 echo $templates[$key] . '<br>'; 167 echo $templates[$key] . '<br>';
168 } 168 }
169 echo '</p>'; 169 echo '</p>';
170 } else { 170 } else {
171 echo '<p>error obtaining shared templates.</p>'; 171 echo '<p>error obtaining shared templates.</p>';
172 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 172 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
173 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 173 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
174 } 174 }
175 175
176 // DFNVC 176 // DFNVC
177 // Test creating a meeting 177 // Test creating a meeting
178 // 178 //
179 echo '<p><b>Test creating a meeting:</b></p>'; 179 echo '<p><b>Test creating a meeting:</b></p>';
180 list($dummy, $testdomain) = split('@',$username); 180 $res = preg_split('/@/',$username);
181 $testdomain = $res[1];
181 182
182 $meeting = new stdClass(); 183 $meeting = new stdClass();
183 $meeting->name = "MoodleTestMeeting for $testdomain"; 184 $meeting->name = "MoodleTestMeeting for $testdomain";
184 $time = time(); 185 $time = time();
185 $meeting->starttime = $time; 186 $meeting->starttime = $time;
186 $time = $time + (60 * 60); 187 $time = $time + (60 * 60);
187 $meeting->endtime = $time; 188 $meeting->endtime = $time;
188 189
189 if (($meetingscoid = aconnect_create_meeting($aconnectDOM, $meeting, $meetingfolderscoid))) { 190 if (($meetingscoid = aconnect_create_meeting($aconnectDOM, $meeting, $meetingfolderscoid))) {
190 echo '<p style="color:#006633">successfully created meeting <b>\'' . $meeting->name . '\'</b> with scoid '. $meetingscoid . '</p>'; 191 echo '<p style="color:#006633">successfully created meeting <b>\'' . $meeting->name . '\'</b> with scoid '. $meetingscoid . '</p>';
191 } else { 192 } else {
192 echo '<p>error creating meeting <b>' . $meeting->name . '</b> folder</p>'; 193 echo '<p>error creating meeting <b>' . $meeting->name . '</b> folder</p>';
193 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 194 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
194 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 195 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
195 } 196 }
196 197
197 // DFNVC 198 // DFNVC
198 // Test making meeting public 199 // Test making meeting public
199 // 200 //
200 echo '<p><b>Test making meeting public:</b></p>'; 201 echo '<p><b>Test making meeting public:</b></p>';
201 if (aconnect_update_meeting_perm($aconnectDOM, $meetingscoid, 'ADOBE_MEETPERM_PUBLIC')) { 202 if (aconnect_update_meeting_perm($aconnectDOM, $meetingscoid, 'ADOBE_MEETPERM_PUBLIC')) {
202 echo '<p style="color:#006633">successfully made meeting <b>\'' . $meeting->name . '\'</b> public</p>'; 203 echo '<p style="color:#006633">successfully made meeting <b>\'' . $meeting->name . '\'</b> public</p>';
203 } 204 }
204 else { 205 else {
205 echo '<p>error makeing meeting public:</p>'; 206 echo '<p>error makeing meeting public:</p>';
206 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 207 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
207 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 208 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
208 } 209 }
209 210
210 // Test creating a user 211 // Test creating a user
211 // DFNVC 212 // DFNVC
212 // 213 //
213 echo '<p><b>Test creating a user:</b></p>'; 214 echo '<p><b>Test creating a user:</b></p>';
214 $user = new stdClass(); 215 $user = new stdClass();
215 list($dummy, $apiuserdomain) = split('@',$username); 216 $res = preg_split('/@/',$username);
217 $apiuserdomain = $res[1];
218
216 $user->email = 'MoodleTestUser@' . $apiuserdomain; 219 $user->email = 'MoodleTestUser@' . $apiuserdomain;
217 $user->username = $user->email; 220 $user->username = $user->email;
218 $user->firstname = 'Moodle Test User'; 221 $user->firstname = 'Moodle Test User';
219 $user->lastname = 'GROUP'; 222 $user->lastname = 'GROUP';
220 223
221 if (!($usrprincipal = lms_user_exists($aconnectDOM, $user))) { 224 if (!($usrprincipal = lms_user_exists($aconnectDOM, $user))) {
222 $usrprincipal = aconnect_create_user($aconnectDOM, $user); 225 $usrprincipal = aconnect_create_user($aconnectDOM, $user);
223 if ($usrprincipal) { 226 if ($usrprincipal) {
224 echo '<p style="color:#006633">successfully created user <b>' . $user->username . '</b> with principal-id '. $usrprincipal . '</p>'; 227 echo '<p style="color:#006633">successfully created user <b>' . $user->username . '</b> with principal-id '. $usrprincipal . '</p>';
225 } else { 228 } else {
226 echo '<p style="color:#680000">error creating testuser user <b>' . $user->username . '</b></p>'; 229 echo '<p style="color:#680000">error creating testuser user <b>' . $user->username . '</b></p>';
227 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 230 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
228 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 231 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
229 aconnect_logout($aconnectDOM); 232 aconnect_logout($aconnectDOM);
230 die(); 233 die();
231 } 234 }
232 } else { 235 } else {
233 echo '<p style="color:#006633">user ' . $user->username . ' already exists, skipping ... </p>'; 236 echo '<p style="color:#006633">user ' . $user->username . ' already exists, skipping ... </p>';
234 } 237 }
235 238
236 // Test roles 239 // Test roles
237 // 240 //
238 echo '<p><b>Test creating and removing meeting role for user ' . $user->username . ' :</b></p>'; 241 echo '<p><b>Test creating and removing meeting role for user ' . $user->username . ' :</b></p>';
239 // Assign test user a meeting role 242 // Assign test user a meeting role
240 if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_PRESENTER, true)) { 243 if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_PRESENTER, true)) {
241 echo '<p style="color:#006633">successfully assigned ' . 244 echo '<p style="color:#006633">successfully assigned ' .
242 ' presenter role to user in meeting <b>\'' . $meeting->name . '\'</b>.</p>'; 245 ' presenter role to user in meeting <b>\'' . $meeting->name . '\'</b>.</p>';
243 } else { 246 } else {
244 echo '<p style="color:#680000">error assigning user presenter role in meeting <b>' . $meeting->name . '</b></p>'; 247 echo '<p style="color:#680000">error assigning user presenter role in meeting <b>' . $meeting->name . '</b></p>';
245 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 248 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
246 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 249 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
247 } 250 }
248 251
249 // Remove meeting role from user 252 // Remove meeting role from user
250 // 253 //
251 if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_REMOVE_ROLE, true)) { 254 if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_REMOVE_ROLE, true)) {
252 echo '<p style="color:#006633">successfully removed presenter role from user '. 255 echo '<p style="color:#006633">successfully removed presenter role from user '.
253 ' in meeting <b>\'' . $meeting->name . '\'</b>.</p>'; 256 ' in meeting <b>\'' . $meeting->name . '\'</b>.</p>';
254 } else { 257 } else {
255 echo '<p style="color:#680000">error removing presenter role for user <b>' . $user->username . '</b> in meeting <b>\'' . $meeting->name . '\'</b></p>'; 258 echo '<p style="color:#680000">error removing presenter role for user <b>' . $user->username . '</b> in meeting <b>\'' . $meeting->name . '\'</b></p>';
256 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 259 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
257 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 260 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
258 } 261 }
259 262
260 // Get session key for test user 263 // Get session key for test user
261 // 264 //
262 echo '<p><b>Test getting a session key for user ' . $user->username . ':</b></p>'; 265 echo '<p><b>Test getting a session key for user ' . $user->username . ':</b></p>';
263 266
264 if ($session_cookie = $aconnectDOM->user_session_cookie($user->username)) { 267 if ($session_cookie = $aconnectDOM->user_session_cookie($user->username)) {
265 echo '<p style="color:#006633">Successfully got session cookie <b>'. $session_cookie . '</b> for user'; 268 echo '<p style="color:#006633">Successfully got session cookie <b>'. $session_cookie . '</b> for user';
266 } 269 }
267 else { 270 else {
268 echo '<p style="color:#680000">Getting session key for user ' . $user->username . ' failed<p>'; 271 echo '<p style="color:#680000">Getting session key for user ' . $user->username . ' failed<p>';
269 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 272 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
270 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 273 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
271 } 274 }
272 275
273 // Test removing user from server 276 // Test removing user from server
274 // 277 //
275 echo '<p><b>Test removing user from server:</b></p>'; 278 echo '<p><b>Test removing user from server:</b></p>';
276 if ($usrprincipal) { 279 if ($usrprincipal) {
277 if (aconnect_delete_user($aconnectDOM, $usrprincipal)) { 280 if (aconnect_delete_user($aconnectDOM, $usrprincipal)) {
278 echo '<p style="color:#006633">successfully removed user with principal-id '. $usrprincipal . '</p>'; 281 echo '<p style="color:#006633">successfully removed user with principal-id '. $usrprincipal . '</p>';
279 } else { 282 } else {
280 echo '<p>error removing user <b>' . $user->username . '</b></p>'; 283 echo '<p>error removing user <b>' . $user->username . '</b></p>';
281 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 284 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
282 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 285 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
283 } 286 }
284 } 287 }
285 288
286 // Test removing meeting from server 289 // Test removing meeting from server
287 // 290 //
288 echo '<p><b>Test removing a meeting from server:</b></p>'; 291 echo '<p><b>Test removing a meeting from server:</b></p>';
289 if ($meetingscoid) { 292 if ($meetingscoid) {
290 if (aconnect_remove_meeting($aconnectDOM, $meetingscoid)) { 293 if (aconnect_remove_meeting($aconnectDOM, $meetingscoid)) {
291 echo '<p style="color:#006633">successfully removed meeting <b>' . $meeting->name . '</b> ('. $meetingscoid . ')</p>'; 294 echo '<p style="color:#006633">successfully removed meeting <b>' . $meeting->name . '</b> ('. $meetingscoid . ')</p>';
292 } else { 295 } else {
293 echo '<p>error removing meeting <b>' . $meeting->name . '</b> folder</p>'; 296 echo '<p>error removing meeting <b>' . $meeting->name . '</b> folder</p>';
294 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>'; 297 echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
295 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>'; 298 echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
296 } 299 }
297 } 300 }
298 301
299 // Test removing dummy meeting from server 302 // Test removing dummy meeting from server
300 // 303 //
301 echo '<p><b>Test removing dummy meeting from server:</b></p>'; 304 echo '<p><b>Test removing dummy meeting from server:</b></p>';
302 if (aconnect_remove_meeting($aconnectDOM, '134737')) { 305 if (aconnect_remove_meeting($aconnectDOM, '134737')) {
303 echo '<p style="color:#680000">error: successfully removed dummy meeting</p>'; 306 echo '<p style="color:#680000">error: successfully removed dummy meeting</p>';
304 } else { 307 } else {
305 echo '<p style="color:#006633">success: could not remove dummy meeting</p>'; 308 echo '<p style="color:#006633">success: could not remove dummy meeting</p>';
306 } 309 }
307 310
308 // Test removing dummy recording from server 311 // Test removing dummy recording from server
309 // 312 //
310 echo '<p><b>Test removing dummy recording from server:</b></p>'; 313 echo '<p><b>Test removing dummy recording from server:</b></p>';
311 if (aconnect_remove_meeting($aconnectDOM, '134763')) { 314 if (aconnect_remove_meeting($aconnectDOM, '134763')) {
312 echo '<p style="color:#680000">error: successfully removed dummy recording</p>'; 315 echo '<p style="color:#680000">error: successfully removed dummy recording</p>';
313 } else { 316 } else {
314 echo '<p style="color:#006633">success: could not remove dummy recording</p>'; 317 echo '<p style="color:#006633">success: could not remove dummy recording</p>';
315 } 318 }
316 319
317 } else { 320 } else {
318 echo '<p style="color:#680000">logging in as '. $username . ' was not successful, check to see if the username and password are correct </p>'; 321 echo '<p style="color:#680000">logging in as '. $username . ' was not successful, check to see if the username and password are correct </p>';
319 } 322 }
320 } 323 }
321 324
322 } else { 325 } else {
323 echo '<p style="color:#680000">common-info API call returned an empty document. Please check your settings and try again </p>'; 326 echo '<p style="color:#680000">common-info API call returned an empty document. Please check your settings and try again </p>';
324 } 327 }
325 echo '<p><hr><p>'; 328 echo '<p><hr><p>';
326 aconnect_logout($aconnectDOM); 329 aconnect_logout($aconnectDOM);
327 330
328 } 331 }
329 332
330 /** 333 /**
331 * Returns the folder sco-id 334 * Returns the folder sco-id
332 * @param object an adobe connection_class object 335 * @param object an adobe connection_class object
333 * @param string $folder name of the folder to get 336 * @param string $folder name of the folder to get
334 * (ex. forced-archives = recording folder | meetings = meetings folder 337 * (ex. forced-archives = recording folder | meetings = meetings folder
335 * | content = shared content folder) 338 * | content = shared content folder)
336 * @return mixed adobe connect folder sco-id || false if there was an error 339 * @return mixed adobe connect folder sco-id || false if there was an error
337 * 340 *
338 */ 341 */
339 function aconnect_get_folder($aconnect, $folder = '') { 342 function aconnect_get_folder($aconnect, $folder = '') {
340 $folderscoid = false; 343 $folderscoid = false;
341 $params = array('action' => 'sco-shortcuts'); 344 $params = array('action' => 'sco-shortcuts');
342 345
343 $aconnect->create_request($params); 346 $aconnect->create_request($params);
344 347
345 if ($aconnect->call_success()) { 348 if ($aconnect->call_success()) {
346 $folderscoid = aconnect_get_folder_sco_id($aconnect->_xmlresponse, $folder); 349 $folderscoid = aconnect_get_folder_sco_id($aconnect->_xmlresponse, $folder);
347 // $params = array('action' => 'sco-contents', 'sco-id' => $folderscoid); 350 // $params = array('action' => 'sco-contents', 'sco-id' => $folderscoid);
348 } 351 }
349 352
350 return $folderscoid; 353 return $folderscoid;
351 } 354 }
352 355
353 /** 356 /**
354 * TODO: comment function and return something meaningful 357 * TODO: comment function and return something meaningful
355 */ 358 */
356 function aconnect_get_folder_sco_id($xml, $folder) { 359 function aconnect_get_folder_sco_id($xml, $folder) {
357 $scoid = false; 360 $scoid = false;
358 361
359 $dom = new DomDocument(); 362 $dom = new DomDocument();
360 $dom->loadXML($xml); 363 $dom->loadXML($xml);
361 364
362 $domnodelist = $dom->getElementsByTagName('sco'); 365 $domnodelist = $dom->getElementsByTagName('sco');
363 366
364 if (!empty($domnodelist->length)) { 367 if (!empty($domnodelist->length)) {
365 368
366 for ($i = 0; $i < $domnodelist->length; $i++) { 369 for ($i = 0; $i < $domnodelist->length; $i++) {
367 370
368 $domnode = $domnodelist->item($i)->attributes->getNamedItem('type'); 371 $domnode = $domnodelist->item($i)->attributes->getNamedItem('type');
369 372
370 if (!is_null($domnode)) { 373 if (!is_null($domnode)) {
371 374
372 if (0 == strcmp($folder, $domnode->nodeValue)) { 375 if (0 == strcmp($folder, $domnode->nodeValue)) {
373 $domnode = $domnodelist->item($i)->attributes->getNamedItem('sco-id'); 376 $domnode = $domnodelist->item($i)->attributes->getNamedItem('sco-id');
374 377
375 if (!is_null($domnode)) { 378 if (!is_null($domnode)) {
376 $scoid = (int) $domnode->nodeValue; 379 $scoid = (int) $domnode->nodeValue;
377 380
378 } 381 }
379 } 382 }
380 } 383 }
381 } 384 }
382 } 385 }
383 386
384 return $scoid; 387 return $scoid;
385 388
386 } 389 }
387 390
388 // 391 //
389 // DFNVC 392 // DFNVC
390 // Get user's meetings folder sco-id 393 // Get user's meetings folder sco-id
391 // 394 //
392 function aconnect_get_user_folder($aconnect, $meetingsscoid, $folder = '') { 395 function aconnect_get_user_folder($aconnect, $meetingsscoid, $folder = '') {
393 $folderscoid = false; 396 $folderscoid = false;
394 $params = array('action' => 'sco-contents', 397 $params = array('action' => 'sco-contents',
395 'sco-id' => $meetingsscoid, 398 'sco-id' => $meetingsscoid,
396 'filter-name' => $folder, 399 'filter-name' => $folder,
397 ); 400 );
398 $aconnect->create_request($params); 401 $aconnect->create_request($params);
399 402
400 if ($aconnect->call_success()) { 403 if ($aconnect->call_success()) {
401 $xmldoc = new DomDocument(); 404 $xmldoc = new DomDocument();
402 $xmldoc->loadXML($aconnect->_xmlresponse); 405 $xmldoc->loadXML($aconnect->_xmlresponse);
403 $xpath = new DomXpath($xmldoc); 406 $xpath = new DomXpath($xmldoc);
404 $folderscoid = $xpath->query("//sco/@sco-id")->item(0)->nodeValue; 407 $folderscoid = $xpath->query("//sco/@sco-id")->item(0)->nodeValue;
405 } 408 }
406 return $folderscoid; 409 return $folderscoid;
407 } 410 }
408 411
409 // 412 //
410 // DFNVC 413 // DFNVC
411 // 414 //
412 function aconnect_get_meeting_folder($aconnect) { 415 function aconnect_get_meeting_folder($aconnect) {
413 global $DB; 416 global $DB;
414 $ac = new stdClass(); 417 $ac = new stdClass();
415 $param = array('name' => 'adobeconnect_admin_login'); 418 $param = array('name' => 'adobeconnect_admin_login');
416 $username = $DB->get_field('config', 'value', $param); 419 $username = $DB->get_field('config', 'value', $param);
417 $folderscoid = aconnect_get_folder($aconnect, 'user-meetings'); 420 $folderscoid = aconnect_get_folder($aconnect, 'user-meetings');
418 $folderscoid = aconnect_get_user_folder($aconnect, $folderscoid, $username); 421 $folderscoid = aconnect_get_user_folder($aconnect, $folderscoid, $username);
419 return $folderscoid; 422 return $folderscoid;
420 } 423 }
421 424
422 // 425 //
423 // DFNVC 426 // DFNVC
424 // 427 //
425 function aconnect_get_content_folder($aconnect) { 428 function aconnect_get_content_folder($aconnect) {
426 global $DB; 429 global $DB;
427 $ac = new stdClass(); 430 $ac = new stdClass();
428 $param = array('name' => 'adobeconnect_admin_login'); 431 $param = array('name' => 'adobeconnect_admin_login');
429 $username = $DB->get_field('config', 'value', $param); 432 $username = $DB->get_field('config', 'value', $param);
430 $folderscoid = aconnect_get_folder($aconnect, 'user-content'); 433 $folderscoid = aconnect_get_folder($aconnect, 'user-content');
431 $folderscoid = aconnect_get_user_folder($aconnect, $folderscoid, $username); 434 $folderscoid = aconnect_get_user_folder($aconnect, $folderscoid, $username);
432 return $folderscoid; 435 return $folderscoid;
433 } 436 }
434 437
435 /** 438 /**
436 * Log in as the admin user. This should only be used to conduct API calls. 439 * Log in as the admin user. This should only be used to conduct API calls.
437 */ 440 */
438 function aconnect_login() { 441 function aconnect_login() {
439 global $CFG, $USER, $COURSE; 442 global $CFG, $USER, $COURSE;
440 443
441 if (!isset($CFG->adobeconnect_host) or 444 if (!isset($CFG->adobeconnect_host) or
442 !isset($CFG->adobeconnect_admin_login) or 445 !isset($CFG->adobeconnect_admin_login) or
443 !isset($CFG->adobeconnect_admin_password)) { 446 !isset($CFG->adobeconnect_admin_password)) {
444 if (is_siteadmin($USER->id)) { 447 if (is_siteadmin($USER->id)) {
445 notice(get_string('adminnotsetupproperty', 'adobeconnect'), 448 notice(get_string('adminnotsetupproperty', 'adobeconnect'),
446 $CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect'); 449 $CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
447 } else { 450 } else {
448 notice(get_string('notsetupproperty', 'adobeconnect'), 451 notice(get_string('notsetupproperty', 'adobeconnect'),
449 '', $COURSE); 452 '', $COURSE);
450 } 453 }
451 } 454 }
452 455
453 if (isset($CFG->adobeconnect_port) and 456 if (isset($CFG->adobeconnect_port) and
454 !empty($CFG->adobeconnect_port) and 457 !empty($CFG->adobeconnect_port) and
455 ((80 != $CFG->adobeconnect_port) and (0 != $CFG->adobeconnect_port))) { 458 ((80 != $CFG->adobeconnect_port) and (0 != $CFG->adobeconnect_port))) {
456 $port = $CFG->adobeconnect_port; 459 $port = $CFG->adobeconnect_port;
457 } else { 460 } else {
458 $port = 80; 461 $port = 80;
459 } 462 }
460 463
461 $https = false; 464 $https = false;
462 465
463 if (isset($CFG->adobeconnect_https) and (!empty($CFG->adobeconnect_https))) { 466 if (isset($CFG->adobeconnect_https) and (!empty($CFG->adobeconnect_https))) {
464 $https = true; 467 $https = true;
465 } 468 }
466 469
467 470
468 $aconnect = new connect_class_dom($CFG->adobeconnect_host, 471 $aconnect = new connect_class_dom($CFG->adobeconnect_host,
469 $CFG->adobeconnect_port, 472 $CFG->adobeconnect_port,
470 $CFG->adobeconnect_admin_login, 473 $CFG->adobeconnect_admin_login,
471 $CFG->adobeconnect_admin_password, 474 $CFG->adobeconnect_admin_password,
472 '', 475 '',
473 $https); 476 $https);
474 477
475 $params = array( 478 $params = array(
476 'action' => 'common-info' 479 'action' => 'common-info'
477 ); 480 );
478 481
479 $aconnect->create_request($params); 482 $aconnect->create_request($params);
480 483
481 $aconnect->read_cookie_xml($aconnect->_xmlresponse); 484 $aconnect->read_cookie_xml($aconnect->_xmlresponse);
482 485
483 $params = array( 486 $params = array(
484 'action' => 'login', 487 'action' => 'login',
485 'login' => $aconnect->get_username(), 488 'login' => $aconnect->get_username(),
486 'password' => $aconnect->get_password(), 489 'password' => $aconnect->get_password(),
487 ); 490 );
488 491
489 $aconnect->create_request($params); 492 $aconnect->create_request($params);
490 493
491 if ($aconnect->call_success()) { 494 if ($aconnect->call_success()) {
492 $aconnect->set_connection(1); 495 $aconnect->set_connection(1);
493 } else { 496 } else {
494 $aconnect->set_connection(0); 497 $aconnect->set_connection(0);
495 } 498 }
496 499
497 return $aconnect; 500 return $aconnect;
498 } 501 }
499 502
500 503
501 /** 504 /**
502 * Logout 505 * Logout
503 * @param object $aconnect - connection object 506 * @param object $aconnect - connection object
504 * @return true on success else false 507 * @return true on success else false
505 */ 508 */
506 function aconnect_logout(&$aconnect) { 509 function aconnect_logout(&$aconnect) {
507 if (!$aconnect->get_connection()) { 510 if (!$aconnect->get_connection()) {
508 return true; 511 return true;
509 } 512 }
510 513
511 $params = array('action' => 'logout'); 514 $params = array('action' => 'logout');
512 $aconnect->create_request($params); 515 $aconnect->create_request($params);
513 516
514 if ($aconnect->call_success()) { 517 if ($aconnect->call_success()) {
515 $aconnect->set_connection(0); 518 $aconnect->set_connection(0);
516 return true; 519 return true;
517 } else { 520 } else {
518 $aconnect->set_connection(1); 521 $aconnect->set_connection(1);
519 return false; 522 return false;
520 } 523 }
521 } 524 }
522 525
523 /** 526 /**
524 * Calls all operations needed to retrieve and return all 527 * Calls all operations needed to retrieve and return all
525 * templates defined in the shared templates folder and meetings 528 * templates defined in the shared templates folder and meetings
526 * @param object $aconnect connection object 529 * @param object $aconnect connection object
527 * @return array $templates an array of templates 530 * @return array $templates an array of templates
528 */ 531 */
529 function aconnect_get_templates_meetings($aconnect) { 532 function aconnect_get_templates_meetings($aconnect) {
530 $templates = array(); 533 $templates = array();
531 $meetings = array(); 534 $meetings = array();
532 $meetfldscoid = false; 535 $meetfldscoid = false;
533 $tempfldscoid = false; 536 $tempfldscoid = false;
534 537
535 $params = array( 538 $params = array(
536 'action' => 'sco-shortcuts', 539 'action' => 'sco-shortcuts',
537 ); 540 );
538 541
539 $aconnect->create_request($params); 542 $aconnect->create_request($params);
540 543
541 if ($aconnect->call_success()) { 544 if ($aconnect->call_success()) {
542 // Get shared templates folder sco-id 545 // Get shared templates folder sco-id
543 $tempfldscoid = aconnect_get_shared_templates($aconnect->_xmlresponse); 546 $tempfldscoid = aconnect_get_shared_templates($aconnect->_xmlresponse);
544 } 547 }
545 548
546 if (false !== $tempfldscoid) { 549 if (false !== $tempfldscoid) {
547 $params = array( 550 $params = array(
548 'action' => 'sco-expanded-contents', 551 'action' => 'sco-expanded-contents',
549 'sco-id' => $tempfldscoid, 552 'sco-id' => $tempfldscoid,
550 ); 553 );
551 554
552 $aconnect->create_request($params); 555 $aconnect->create_request($params);
553 556
554 if ($aconnect->call_success()) { 557 if ($aconnect->call_success()) {
555 $templates = aconnect_return_all_templates($aconnect->_xmlresponse); 558 $templates = aconnect_return_all_templates($aconnect->_xmlresponse);
556 } 559 }
557 } 560 }
558 561
559 // if (false !== $meetfldscoid) { 562 // if (false !== $meetfldscoid) {
560 // $params = array( 563 // $params = array(
561 // 'action' => 'sco-expanded-contents', 564 // 'action' => 'sco-expanded-contents',
562 // 'sco-id' => $meetfldscoid, 565 // 'sco-id' => $meetfldscoid,
563 // 'filter-type' => 'meeting', 566 // 'filter-type' => 'meeting',
564 // ); 567 // );
565 // 568 //
566 // $aconnect->create_request($params); 569 // $aconnect->create_request($params);
567 // 570 //
568 // if ($aconnect->call_success()) { 571 // if ($aconnect->call_success()) {
569 // $meetings = aconnect_return_all_meetings($aconnect->_xmlresponse); 572 // $meetings = aconnect_return_all_meetings($aconnect->_xmlresponse);
570 // } 573 // }
571 // 574 //
572 // } 575 // }
573 576
574 return $templates + $meetings; 577 return $templates + $meetings;
575 } 578 }
576 579
577 /** 580 /**
578 * Parse XML looking for shared-meeting-templates attribute 581 * Parse XML looking for shared-meeting-templates attribute
579 * and returning the sco-id of the folder 582 * and returning the sco-id of the folder
580 * @param string $xml returned XML from a sco-shortcuts call 583 * @param string $xml returned XML from a sco-shortcuts call
581 * @return mixed sco-id if found or false if not found or error 584 * @return mixed sco-id if found or false if not found or error
582 */ 585 */
583 function aconnect_get_shared_templates($xml) { 586 function aconnect_get_shared_templates($xml) {
584 $scoid = false; 587 $scoid = false;
585 588
586 $dom = new DomDocument(); 589 $dom = new DomDocument();
587 $dom->loadXML($xml); 590 $dom->loadXML($xml);
588 591
589 $domnodelist = $dom->getElementsByTagName('shortcuts'); 592 $domnodelist = $dom->getElementsByTagName('shortcuts');
590 593
591 if (!empty($domnodelist->length)) { 594 if (!empty($domnodelist->length)) {
592 595
593 // for ($i = 0; $i < $domnodelist->length; $i++) { 596 // for ($i = 0; $i < $domnodelist->length; $i++) {
594 597
595 $innerlist = $domnodelist->item(0)->getElementsByTagName('sco'); 598 $innerlist = $domnodelist->item(0)->getElementsByTagName('sco');
596 599
597 if (!empty($innerlist->length)) { 600 if (!empty($innerlist->length)) {
598 601
599 for ($x = 0; $x < $innerlist->length; $x++) { 602 for ($x = 0; $x < $innerlist->length; $x++) {
600 603
601 if ($innerlist->item($x)->hasAttributes()) { 604 if ($innerlist->item($x)->hasAttributes()) {
602 605
603 $domnode = $innerlist->item($x)->attributes->getNamedItem('type'); 606 $domnode = $innerlist->item($x)->attributes->getNamedItem('type');
604 607
605 if (!is_null($domnode)) { 608 if (!is_null($domnode)) {
606 609
607 if (0 == strcmp('shared-meeting-templates', $domnode->nodeValue)) { 610 if (0 == strcmp('shared-meeting-templates', $domnode->nodeValue)) {
608 $domnode = $innerlist->item($x)->attributes->getNamedItem('sco-id'); 611 $domnode = $innerlist->item($x)->attributes->getNamedItem('sco-id');
609 612
610 if (!is_null($domnode)) { 613 if (!is_null($domnode)) {
611 $scoid = (int) $domnode->nodeValue; 614 $scoid = (int) $domnode->nodeValue;
612 } 615 }
613 } 616 }
614 } 617 }
615 } 618 }
616 } 619 }
617 } 620 }
618 // } 621 // }
619 622
620 } 623 }
621 624
622 return $scoid; 625 return $scoid;
623 } 626 }
624 627
625 function aconnect_return_all_meetings($xml) { 628 function aconnect_return_all_meetings($xml) {
626 $meetings = array(); 629 $meetings = array();
627 $xml = new SimpleXMLElement($xml); 630 $xml = new SimpleXMLElement($xml);
628 631
629 if (empty($xml)) { 632 if (empty($xml)) {
630 return $meetings; 633 return $meetings;
631 } 634 }
632 635
633 foreach($xml->{'expanded-scos'}[0]->sco as $key => $sco) { 636 foreach($xml->{'expanded-scos'}[0]->sco as $key => $sco) {
634 if (0 == strcmp('meeting', $sco['type'])) { 637 if (0 == strcmp('meeting', $sco['type'])) {
635 $mkey = (int) $sco['sco-id']; 638 $mkey = (int) $sco['sco-id'];
636 $meetings[$mkey] = (string) current($sco->name) .' '. ADOBE_MEETING_POSTFIX; 639 $meetings[$mkey] = (string) current($sco->name) .' '. ADOBE_MEETING_POSTFIX;
637 } 640 }
638 } 641 }
639 642
640 return $meetings; 643 return $meetings;
641 } 644 }
642 645
643 /** 646 /**
644 * Parses XML for meeting templates and returns an array 647 * Parses XML for meeting templates and returns an array
645 * with sco-id as the key and template name as the value 648 * with sco-id as the key and template name as the value
646 * @param strimg $xml XML returned from a sco-expanded-contents call 649 * @param strimg $xml XML returned from a sco-expanded-contents call
647 * @return array of templates sco-id -> key, name -> value 650 * @return array of templates sco-id -> key, name -> value
648 */ 651 */
649 function aconnect_return_all_templates($xml) { 652 function aconnect_return_all_templates($xml) {
650 $templates = array(); 653 $templates = array();
651 654
652 $dom = new DomDocument(); 655 $dom = new DomDocument();
653 $dom->loadXML($xml); 656 $dom->loadXML($xml);
654 657
655 $domnodelist = $dom->getElementsByTagName('expanded-scos'); 658 $domnodelist = $dom->getElementsByTagName('expanded-scos');
656 659
657 if (!empty($domnodelist->length)) { 660 if (!empty($domnodelist->length)) {
658 661
659 $innerlist = $domnodelist->item(0)->getElementsByTagName('sco'); 662 $innerlist = $domnodelist->item(0)->getElementsByTagName('sco');
660 663
661 if (!empty($innerlist->length)) { 664 if (!empty($innerlist->length)) {
662 665
663 for ($i = 0; $i < $innerlist->length; $i++) { 666 for ($i = 0; $i < $innerlist->length; $i++) {
664 667
665 if ($innerlist->item($i)->hasAttributes()) { 668 if ($innerlist->item($i)->hasAttributes()) {
666 $domnode = $innerlist->item($i)->attributes->getNamedItem('type'); 669 $domnode = $innerlist->item($i)->attributes->getNamedItem('type');
667 670
668 if (!is_null($domnode) and 0 == strcmp('meeting', $domnode->nodeValue)) { 671 if (!is_null($domnode) and 0 == strcmp('meeting', $domnode->nodeValue)) {
669 $domnode = $innerlist->item($i)->attributes->getNamedItem('sco-id'); 672 $domnode = $innerlist->item($i)->attributes->getNamedItem('sco-id');
670 673
671 if (!is_null($domnode)) { 674 if (!is_null($domnode)) {
672 $tkey = (int) $domnode->nodeValue; 675 $tkey = (int) $domnode->nodeValue;
673 $namelistnode = $innerlist->item($i)->getElementsByTagName('name'); 676 $namelistnode = $innerlist->item($i)->getElementsByTagName('name');
674 677
675 if (!is_null($namelistnode)) { 678 if (!is_null($namelistnode)) {
676 $name = $namelistnode->item(0)->nodeValue; 679 $name = $namelistnode->item(0)->nodeValue;
677 $templates[$tkey] = (string) $name .' ' . ADOBE_TEMPLATE_POSTFIX; 680 $templates[$tkey] = (string) $name .' ' . ADOBE_TEMPLATE_POSTFIX;
678 } 681 }
679 } 682 }
680 } 683 }
681 } 684 }
682 } 685 }
683 } 686 }
684 } 687 }
685 688
686 return $templates; 689 return $templates;
687 } 690 }
688 691
689 // DFNVC 692 // DFNVC
690 // Get Recording url-path 693 // Get Recording url-path
691 // 694 //
692 function aconnect_get_recording_urlpath($aconnect, $meetingscoid, $recordingscoid) { 695 function aconnect_get_recording_urlpath($aconnect, $meetingscoid, $recordingscoid) {
693 $params = array('action' => 'sco-contents', 696 $params = array('action' => 'sco-contents',
694 'sco-id' => $meetingscoid, 697 'sco-id' => $meetingscoid,
695 'filter-sco-id' => $recordingscoid 698 'filter-sco-id' => $recordingscoid
696 ); 699 );
697 $aconnect->create_request($params); 700 $aconnect->create_request($params);
698 701
699 if ($aconnect->call_success()) { 702 if ($aconnect->call_success()) {
700 $xmldoc = new DomDocument(); 703 $xmldoc = new DomDocument();
701 $xmldoc->loadXML($aconnect->_xmlresponse); 704 $xmldoc->loadXML($aconnect->_xmlresponse);
702 $xpath = new DomXpath($xmldoc); 705 $xpath = new DomXpath($xmldoc);
703 $url = $xpath->query("//sco/url-path")->item(0)->nodeValue; 706 $url = $xpath->query("//sco/url-path")->item(0)->nodeValue;
704 return $url; 707 return $url;
705 } 708 }
706 else { 709 else {
707 return ''; 710 return '';
708 } 711 }
709 } 712 }
710 713
711 /** 714 /**
712 * Returns information about all recordings that belong to a specific 715 * Returns information about all recordings that belong to a specific
713 * meeting sco-id 716 * meeting sco-id
714 * 717 *
715 * @param obj $aconnect a connect_class object 718 * @param obj $aconnect a connect_class object
716 * @param int $folderscoid the recordings folder sco-id 719 * @param int $folderscoid the recordings folder sco-id
717 * @param int $sourcescoid the meeting sco-id 720 * @param int $sourcescoid the meeting sco-id
718 * 721 *
719 * @return mixed array an array of object with the recording sco-id 722 * @return mixed array an array of object with the recording sco-id
720 * as the key and the recording properties as properties 723 * as the key and the recording properties as properties
721 */ 724 */
722 function aconnect_get_recordings($aconnect, $folderscoid, $sourcescoid) { 725 function aconnect_get_recordings($aconnect, $folderscoid, $sourcescoid) {
723 $params = array('action' => 'sco-contents', 726 $params = array('action' => 'sco-contents',
724 'sco-id' => $folderscoid, 727 'sco-id' => $folderscoid,
725 //'filter-source-sco-id' => $sourcescoid, 728 //'filter-source-sco-id' => $sourcescoid,
726 // 729 //
727 // DFNVC Quickfix - 29.08.2013 730 // DFNVC Quickfix - 29.08.2013
728 // Nur Aufnahemen anzeigen 731 // Nur Aufnahemen anzeigen
729 'filter-icon' => 'archive', 732 'filter-icon' => 'archive',
730 // 733 //
731 'sort-name' => 'asc', 734 'sort-name' => 'asc',
732 ); 735 );
733 736
734 // Check if meeting scoid and folder scoid are the same 737 // Check if meeting scoid and folder scoid are the same
735 // If hey are the same then that means that forced recordings is not 738 // If hey are the same then that means that forced recordings is not
736 // enabled filter-source-sco-id should not be included. If they the 739 // enabled filter-source-sco-id should not be included. If they the
737 // meeting scoid and folder scoid are not equal then forced recordings 740 // meeting scoid and folder scoid are not equal then forced recordings
738 // are enabled and we can use filter by filter-source-sco-id 741 // are enabled and we can use filter by filter-source-sco-id
739 // Thanks to A. gtdino 742 // Thanks to A. gtdino
740 if ($sourcescoid != $folderscoid) { 743 if ($sourcescoid != $folderscoid) {
741 $params['filter-source-sco-id'] = $sourcescoid; 744 $params['filter-source-sco-id'] = $sourcescoid;
742 } 745 }
743 746
744 $aconnect->create_request($params); 747 $aconnect->create_request($params);
745 748
746 $recordings = array(); 749 $recordings = array();
747 750
748 if ($aconnect->call_success()) { 751 if ($aconnect->call_success()) {
749 $dom = new DomDocument(); 752 $dom = new DomDocument();
750 $dom->loadXML($aconnect->_xmlresponse); 753 $dom->loadXML($aconnect->_xmlresponse);
751 754
752 $domnodelist = $dom->getElementsByTagName('scos'); 755 $domnodelist = $dom->getElementsByTagName('scos');
753 756
754 if (!empty($domnodelist->length)) { 757 if (!empty($domnodelist->length)) {
755 758
756 // for ($i = 0; $i < $domnodelist->length; $i++) { 759 // for ($i = 0; $i < $domnodelist->length; $i++) {
757 760
758 $innernodelist = $domnodelist->item(0)->getElementsByTagName('sco'); 761 $innernodelist = $domnodelist->item(0)->getElementsByTagName('sco');
759 762
760 if (!empty($innernodelist->length)) { 763 if (!empty($innernodelist->length)) {
761 764
762 for ($x = 0; $x < $innernodelist->length; $x++) { 765 for ($x = 0; $x < $innernodelist->length; $x++) {
763 766
764 if ($innernodelist->item($x)->hasAttributes()) { 767 if ($innernodelist->item($x)->hasAttributes()) {
765 768
766 $domnode = $innernodelist->item($x)->attributes->getNamedItem('sco-id'); 769 $domnode = $innernodelist->item($x)->attributes->getNamedItem('sco-id');
767 770
768 if (!is_null($domnode)) { 771 if (!is_null($domnode)) {
769 $meetingdetail = $innernodelist->item($x); 772 $meetingdetail = $innernodelist->item($x);
770 773
771 // Check if the SCO item is a recording or uploaded document. We only want to display recordings 774 // Check if the SCO item is a recording or uploaded document. We only want to display recordings
772 // 775 //
773 // DFNVC - 24.5.2012 776 // DFNVC - 24.5.2012
774 // 777 //
775 //In AC9, the recording length info is stored as an attributed of 'sco' 778 //In AC9, the recording length info is stored as an attributed of 'sco'
776 $recordingvac9 = $innernodelist->item($x)->attributes->getNamedItem('duration'); 779 $recordingvac9 = $innernodelist->item($x)->attributes->getNamedItem('duration');
777 //In AC-8 and before, the recording length info is stored as its own element 780 //In AC-8 and before, the recording length info is stored as its own element
778 $recordingvac8 = $meetingdetail->getElementsByTagName('duration')->item(0); 781 $recordingvac8 = $meetingdetail->getElementsByTagName('duration')->item(0);
779 782
780 if (!is_null($recordingvac9) || !is_null($recordingvac8)) { 783 if (!is_null($recordingvac9) || !is_null($recordingvac8)) {
781 784
782 $j = (int) $domnode->nodeValue; 785 $j = (int) $domnode->nodeValue;
783 $value = (!is_null($meetingdetail->getElementsByTagName('name'))) ? 786 $value = (!is_null($meetingdetail->getElementsByTagName('name'))) ?
784 $meetingdetail->getElementsByTagName('name')->item(0)->nodeValue : ''; 787 $meetingdetail->getElementsByTagName('name')->item(0)->nodeValue : '';
785 788
786 $recordings[$j]->name = (string) $value; 789 $recordings[$j]->name = (string) $value;
787 790
788 $value = (!is_null($meetingdetail->getElementsByTagName('url-path'))) ? 791 $value = (!is_null($meetingdetail->getElementsByTagName('url-path'))) ?
789 $meetingdetail->getElementsByTagName('url-path')->item(0)->nodeValue : ''; 792 $meetingdetail->getElementsByTagName('url-path')->item(0)->nodeValue : '';
790 793
791 $recordings[$j]->url = (string) $value; 794 $recordings[$j]->url = (string) $value;
792 795
793 $value = (!is_null($meetingdetail->getElementsByTagName('date-begin'))) ? 796 $value = (!is_null($meetingdetail->getElementsByTagName('date-begin'))) ?
794 $meetingdetail->getElementsByTagName('date-begin')->item(0)->nodeValue : ''; 797 $meetingdetail->getElementsByTagName('date-begin')->item(0)->nodeValue : '';
795 798
796 $recordings[$j]->startdate = (string) $value; 799 $recordings[$j]->startdate = (string) $value;
797 800
798 $value = (!is_null($meetingdetail->getElementsByTagName('date-end'))) ? 801 $value = (!is_null($meetingdetail->getElementsByTagName('date-end'))) ?
799 $meetingdetail->getElementsByTagName('date-end')->item(0)->nodeValue : ''; 802 $meetingdetail->getElementsByTagName('date-end')->item(0)->nodeValue : '';
800 803
801 $recordings[$j]->enddate = (string) $value; 804 $recordings[$j]->enddate = (string) $value;
802 805
803 $value = (!is_null($meetingdetail->getElementsByTagName('date-created'))) ? 806 $value = (!is_null($meetingdetail->getElementsByTagName('date-created'))) ?
804 $meetingdetail->getElementsByTagName('date-created')->item(0)->nodeValue : ''; 807 $meetingdetail->getElementsByTagName('date-created')->item(0)->nodeValue : '';
805 808
806 $recordings[$j]->createdate = (string) $value; 809 $recordings[$j]->createdate = (string) $value;
807 810
808 $value = (!is_null($meetingdetail->getElementsByTagName('date-modified'))) ? 811 $value = (!is_null($meetingdetail->getElementsByTagName('date-modified'))) ?
809 $meetingdetail->getElementsByTagName('date-modified')->item(0)->nodeValue : ''; 812 $meetingdetail->getElementsByTagName('date-modified')->item(0)->nodeValue : '';
810 813
811 $recordings[$j]->modified = (string) $value; 814 $recordings[$j]->modified = (string) $value;
812 815
813 $value = (!is_null($recordingvac9) ? 816 $value = (!is_null($recordingvac9) ?
814 $recordingvac9->nodeValue : $recordingvac8->nodeValue); 817 $recordingvac9->nodeValue : $recordingvac8->nodeValue);
815 818
816 $recordings[$j]->duration = (string) $value; 819 $recordings[$j]->duration = (string) $value;
817 } 820 }
818 821
819 } 822 }
820 } 823 }
821 } 824 }
822 } 825 }
823 // } 826 // }
824 827
825 return $recordings; 828 return $recordings;
826 } else { 829 } else {
827 return false; 830 return false;
828 } 831 }
829 } else { 832 } else {
830 return false; 833 return false;
831 } 834 }
832 835
833 } 836 }
834 837
835 /** 838 /**
836 * Parses XML and returns the meeting sco-id 839 * Parses XML and returns the meeting sco-id
837 * @param string XML obtained from a sco-update call 840 * @param string XML obtained from a sco-update call
838 */ 841 */
839 function aconnect_get_meeting_scoid($xml) { 842 function aconnect_get_meeting_scoid($xml) {
840 $scoid = false; 843 $scoid = false;
841 844
842 $dom = new DomDocument(); 845 $dom = new DomDocument();
843 $dom->loadXML($xml); 846 $dom->loadXML($xml);
844 847
845 $domnodelist = $dom->getElementsByTagName('sco'); 848 $domnodelist = $dom->getElementsByTagName('sco');
846 849
847 if (!empty($domnodelist->length)) { 850 if (!empty($domnodelist->length)) {
848 if ($domnodelist->item(0)->hasAttributes()) { 851 if ($domnodelist->item(0)->hasAttributes()) {
849 $domnode = $domnodelist->item(0)->attributes->getNamedItem('sco-id'); 852 $domnode = $domnodelist->item(0)->attributes->getNamedItem('sco-id');
850 853
851 if (!is_null($domnode)) { 854 if (!is_null($domnode)) {
852 $scoid = (int) $domnode->nodeValue; 855 $scoid = (int) $domnode->nodeValue;
853 } 856 }
854 } 857 }
855 } 858 }
856 859
857 return $scoid; 860 return $scoid;
858 } 861 }
859 862
860 /** 863 /**
861 * Update meeting 864 * Update meeting
862 * @param obj $aconnect connect_class object 865 * @param obj $aconnect connect_class object
863 * @param obj $meetingobj an adobeconnect module object 866 * @param obj $meetingobj an adobeconnect module object
864 * @param int $meetingfdl adobe connect meeting folder sco-id 867 * @param int $meetingfdl adobe connect meeting folder sco-id
865 * @return bool true if call was successful else false 868 * @return bool true if call was successful else false
866 */ 869 */
867 function aconnect_update_meeting($aconnect, $meetingobj, $meetingfdl) { 870 function aconnect_update_meeting($aconnect, $meetingobj, $meetingfdl) {
868 $params = array('action' => 'sco-update', 871 $params = array('action' => 'sco-update',
869 'sco-id' => $meetingobj->scoid, 872 'sco-id' => $meetingobj->scoid,
870 'name' => $meetingobj->name, 873 'name' => $meetingobj->name,
871 'folder-id' => $meetingfdl, 874 'folder-id' => $meetingfdl,
872 // updating meeting URL using the API corrupts the meeting for some reason 875 // updating meeting URL using the API corrupts the meeting for some reason
873 // 'url-path' => '/'.$meetingobj->meeturl, 876 // 'url-path' => '/'.$meetingobj->meeturl,
874 'date-begin' => $meetingobj->starttime, 877 'date-begin' => $meetingobj->starttime,
875 'date-end' => $meetingobj->endtime, 878 'date-end' => $meetingobj->endtime,
876 ); 879 );
877 880
878 $aconnect->create_request($params); 881 $aconnect->create_request($params);
879 882
880 if ($aconnect->call_success()) { 883 if ($aconnect->call_success()) {
881 return true; 884 return true;
882 } else { 885 } else {
883 return false; 886 return false;
884 } 887 }
885 888
886 } 889 }
887 890
888 /** 891 /**
889 * Update a meeting's access permissions 892 * Update a meeting's access permissions
890 * @param obj $aconnect connect_class object 893 * @param obj $aconnect connect_class object
891 * @param int $meetingscoid meeting sco-id 894 * @param int $meetingscoid meeting sco-id
892 * @param int $perm meeting permission id 895 * @param int $perm meeting permission id
893 * @return bool true if call was successful else false 896 * @return bool true if call was successful else false
894 */ 897 */
895 function aconnect_update_meeting_perm($aconnect, $meetingscoid, $perm) { 898 function aconnect_update_meeting_perm($aconnect, $meetingscoid, $perm) {
896 $params = array('action' => 'permissions-update', 899 $params = array('action' => 'permissions-update',
897 'acl-id' => $meetingscoid, 900 'acl-id' => $meetingscoid,
898 'principal-id' => 'public-access', 901 'principal-id' => 'public-access',
899 ); 902 );
900 903
901 switch ($perm) { 904 switch ($perm) {
902 case ADOBE_MEETPERM_PUBLIC: 905 case ADOBE_MEETPERM_PUBLIC:
903 $params['permission-id'] = 'view-hidden'; 906 $params['permission-id'] = 'view-hidden';
904 break; 907 break;
905 case ADOBE_MEETPERM_PROTECTED: 908 case ADOBE_MEETPERM_PROTECTED:
906 $params['permission-id'] = 'remove'; 909 $params['permission-id'] = 'remove';
907 break; 910 break;
908 case ADOBE_MEETPERM_PRIVATE: 911 case ADOBE_MEETPERM_PRIVATE:
909 default: 912 default:
910 $params['permission-id'] = 'denied'; 913 $params['permission-id'] = 'denied';
911 break; 914 break;
912 } 915 }
913 916
914 $aconnect->create_request($params); 917 $aconnect->create_request($params);
915 918
916 if ($aconnect->call_success()) { 919 if ($aconnect->call_success()) {
917 return true; 920 return true;
918 } else { 921 } else {
919 return false; 922 return false;
920 } 923 }
921 924
922 925
923 } 926 }
924 927
925 /** CONTRIB-1976, CONTRIB-1992 928 /** CONTRIB-1976, CONTRIB-1992
926 * This function adds a fraction of a second to the ISO 8601 date 929 * This function adds a fraction of a second to the ISO 8601 date
927 * @param int $time unix timestamp 930 * @param int $time unix timestamp
928 * @return mixed a string (ISO 8601) containing the decimal fraction of a second 931 * @return mixed a string (ISO 8601) containing the decimal fraction of a second
929 * or false if it was not able to determine where to put it 932 * or false if it was not able to determine where to put it
930 */ 933 */
931 function aconnect_format_date_seconds($time) { 934 function aconnect_format_date_seconds($time) {
932 935
933 $newdate = false; 936 $newdate = false;
934 $date = date("c", $time); 937 $date = date("c", $time);
935 938
936 $pos = strrpos($date, '-'); 939 $pos = strrpos($date, '-');
937 $length = strlen($date); 940 $length = strlen($date);
938 941
939 $diff = $length - $pos; 942 $diff = $length - $pos;
940 943
941 if ((0 < $diff) and (ADOBE_TMZ_LENGTH == $diff)) { 944 if ((0 < $diff) and (ADOBE_TMZ_LENGTH == $diff)) {
942 $firstpart = substr($date, 0, $pos); 945 $firstpart = substr($date, 0, $pos);
943 $lastpart = substr($date, $pos); 946 $lastpart = substr($date, $pos);
944 $newdate = $firstpart . '.000' . $lastpart; 947 $newdate = $firstpart . '.000' . $lastpart;
945 948
946 return $newdate; 949 return $newdate;
947 } 950 }
948 951
949 $pos = strrpos($date, '+'); 952 $pos = strrpos($date, '+');
950 $length = strlen($date); 953 $length = strlen($date);
951 954
952 $diff = $length - $pos; 955 $diff = $length - $pos;
953 956
954 if ((0 < $diff) and (ADOBE_TMZ_LENGTH == $diff)) { 957 if ((0 < $diff) and (ADOBE_TMZ_LENGTH == $diff)) {
955 $firstpart = substr($date, 0, $pos); 958 $firstpart = substr($date, 0, $pos);
956 $lastpart = substr($date, $pos); 959 $lastpart = substr($date, $pos);
957 $newdate = $firstpart . '.000' . $lastpart; 960 $newdate = $firstpart . '.000' . $lastpart;
958 961
959 return $newdate; 962 return $newdate;
960 963
961 } 964 }
962 965
963 return false; 966 return false;
964 } 967 }
965 968
966 /** 969 /**
967 * Creates a meeting 970 * Creates a meeting
968 * @param obj $aconnect connect_class object 971 * @param obj $aconnect connect_class object
969 * @param obj $meetingobj an adobeconnect module object 972 * @param obj $meetingobj an adobeconnect module object
970 * @param int $meetingfdl adobe connect meeting folder sco-id 973 * @param int $meetingfdl adobe connect meeting folder sco-id
971 * @return mixed meeting sco-id on success || false on error 974 * @return mixed meeting sco-id on success || false on error
972 */ 975 */
973 function aconnect_create_meeting($aconnect, $meetingobj, $meetingfdl) { 976 function aconnect_create_meeting($aconnect, $meetingobj, $meetingfdl) {
974 //date("Y-m-d\TH:i 977 //date("Y-m-d\TH:i
975 978
976 // DFNVC 979 // DFNVC
977 // Meeting soll Kurssprache übernehmen 980 // Meeting soll Kurssprache übernehmen
978 // 981 //
979 global $COURSE; 982 global $COURSE;
980 $clang = $COURSE->lang; 983 $clang = $COURSE->lang;
981 if (! ($clang == 'de' || $clang == 'en' || $clang =='it')) { 984 if (! ($clang == 'de' || $clang == 'en' || $clang =='it')) {
982 $meetinglang = 'de'; 985 $meetinglang = 'de';
983 } 986 }
984 else { 987 else {
985 $meetinglang = $clang; 988 $meetinglang = $clang;
986 } 989 }
987 990
988 $starttime = aconnect_format_date_seconds($meetingobj->starttime); 991 $starttime = aconnect_format_date_seconds($meetingobj->starttime);
989 $endtime = aconnect_format_date_seconds($meetingobj->endtime); 992 $endtime = aconnect_format_date_seconds($meetingobj->endtime);
990 993
991 if (empty($starttime) or empty($endtime)) { 994 if (empty($starttime) or empty($endtime)) {
992 $message = 'Failure (aconnect_find_timezone) in finding the +/- sign in the date timezone'. 995 $message = 'Failure (aconnect_find_timezone) in finding the +/- sign in the date timezone'.
993 "\n".date("c", $meetingobj->starttime)."\n".date("c", $meetingobj->endtime); 996 "\n".date("c", $meetingobj->starttime)."\n".date("c", $meetingobj->endtime);
994 debugging($message, DEBUG_DEVELOPER); 997 debugging($message, DEBUG_DEVELOPER);
995 return false; 998 return false;
996 } 999 }
997 1000
998 $params = array('action' => 'sco-update', 1001 $params = array('action' => 'sco-update',
999 'type' => 'meeting', 1002 'type' => 'meeting',
1000 'name' => $meetingobj->name, 1003 'name' => $meetingobj->name,
1001 'folder-id' => $meetingfdl, 1004 'folder-id' => $meetingfdl,
1002 'date-begin' => $starttime, 1005 'date-begin' => $starttime,
1003 'date-end' => $endtime, 1006 'date-end' => $endtime,
1004 'lang' => $meetinglang 1007 'lang' => $meetinglang
1005 ); 1008 );
1006 1009
1007 if (!empty($meetingobj->meeturl)) { 1010 if (!empty($meetingobj->meeturl)) {
1008 $params['url-path'] = $meetingobj->meeturl; 1011 $params['url-path'] = $meetingobj->meeturl;
1009 } 1012 }
1010 1013
1011 if (!empty($meetingobj->templatescoid)) { 1014 if (!empty($meetingobj->templatescoid)) {
1012 $params['source-sco-id'] = $meetingobj->templatescoid; 1015 $params['source-sco-id'] = $meetingobj->templatescoid;
1013 } 1016 }
1014 1017
1015 $aconnect->create_request($params); 1018 $aconnect->create_request($params);
1016 1019
1017 1020
1018 if ($aconnect->call_success()) { 1021 if ($aconnect->call_success()) {
1019 return aconnect_get_meeting_scoid($aconnect->_xmlresponse); 1022 return aconnect_get_meeting_scoid($aconnect->_xmlresponse);
1020 } else { 1023 } else {
1021 return false; 1024 return false;
1022 } 1025 }
1023 } 1026 }
1024 1027
1025 /** 1028 /**
1026 * Finds a matching meeting sco-id 1029 * Finds a matching meeting sco-id
1027 * @param object $aconnect a connect_class object 1030 * @param object $aconnect a connect_class object
1028 * @param int $meetfldscoid Meeting folder sco-id 1031 * @param int $meetfldscoid Meeting folder sco-id
1029 * @param array $filter array key is the filter and array value is the value 1032 * @param array $filter array key is the filter and array value is the value
1030 * (ex. array('filter-name' => 'meeting101')) 1033 * (ex. array('filter-name' => 'meeting101'))
1031 * @return mixed array of objects with sco-id as key and meeting name and url as object 1034 * @return mixed array of objects with sco-id as key and meeting name and url as object
1032 * properties as value || false if not found or error occured 1035 * properties as value || false if not found or error occured
1033 */ 1036 */
1034 function aconnect_meeting_exists($aconnect, $meetfldscoid, $filter = array()) { 1037 function aconnect_meeting_exists($aconnect, $meetfldscoid, $filter = array()) {
1035 $matches = array(); 1038 $matches = array();
1036 1039
1037 $params = array( 1040 $params = array(
1038 'action' => 'sco-contents', 1041 'action' => 'sco-contents',
1039 'sco-id' => $meetfldscoid, 1042 'sco-id' => $meetfldscoid,
1040 'filter-type' => 'meeting', 1043 'filter-type' => 'meeting',
1041 ); 1044 );
1042 1045
1043 if (empty($filter)) { 1046 if (empty($filter)) {
1044 return false; 1047 return false;
1045 } 1048 }
1046 1049
1047 $params = array_merge($params, $filter); 1050 $params = array_merge($params, $filter);
1048 $aconnect->create_request($params); 1051 $aconnect->create_request($params);
1049 1052
1050 if ($aconnect->call_success()) { 1053 if ($aconnect->call_success()) {
1051 $dom = new DomDocument(); 1054 $dom = new DomDocument();
1052 $dom->loadXML($aconnect->_xmlresponse); 1055 $dom->loadXML($aconnect->_xmlresponse);
1053 1056
1054 $domnodelist = $dom->getElementsByTagName('scos'); 1057 $domnodelist = $dom->getElementsByTagName('scos');
1055 1058
1056 if (!empty($domnodelist->length)) { 1059 if (!empty($domnodelist->length)) {
1057 1060
1058 $innernodelist = $domnodelist->item(0)->getElementsByTagName('sco'); 1061 $innernodelist = $domnodelist->item(0)->getElementsByTagName('sco');
1059 1062
1060 if (!empty($innernodelist->length)) { 1063 if (!empty($innernodelist->length)) {
1061 1064
1062 for ($i = 0; $i < $innernodelist->length; $i++) { 1065 for ($i = 0; $i < $innernodelist->length; $i++) {
1063 1066
1064 if ($innernodelist->item($i)->hasAttributes()) { 1067 if ($innernodelist->item($i)->hasAttributes()) {
1065 1068
1066 $domnode = $innernodelist->item($i)->attributes->getNamedItem('sco-id'); 1069 $domnode = $innernodelist->item($i)->attributes->getNamedItem('sco-id');
1067 1070
1068 if (!is_null($domnode)) { 1071 if (!is_null($domnode)) {
1069 1072
1070 $key = (int) $domnode->nodeValue; 1073 $key = (int) $domnode->nodeValue;
1071 1074
1072 $meetingdetail = $innernodelist->item($i); 1075 $meetingdetail = $innernodelist->item($i);
1073 1076
1074 $value = (!is_null($meetingdetail->getElementsByTagName('name'))) ? 1077 $value = (!is_null($meetingdetail->getElementsByTagName('name'))) ?
1075 $meetingdetail->getElementsByTagName('name')->item(0)->nodeValue : ''; 1078 $meetingdetail->getElementsByTagName('name')->item(0)->nodeValue : '';
1076 1079
1077 $matches[$key]->name = (string) $value; 1080 $matches[$key]->name = (string) $value;
1078 1081
1079 $value = (!is_null($meetingdetail->getElementsByTagName('url-path'))) ? 1082 $value = (!is_null($meetingdetail->getElementsByTagName('url-path'))) ?
1080 $meetingdetail->getElementsByTagName('url-path')->item(0)->nodeValue : ''; 1083 $meetingdetail->getElementsByTagName('url-path')->item(0)->nodeValue : '';
1081 1084
1082 $matches[$key]->url = (string) $value; 1085 $matches[$key]->url = (string) $value;
1083 1086
1084 $matches[$key]->scoid = (int) $key; 1087 $matches[$key]->scoid = (int) $key;
1085 1088
1086 $value = (!is_null($meetingdetail->getElementsByTagName('date-begin'))) ? 1089 $value = (!is_null($meetingdetail->getElementsByTagName('date-begin'))) ?
1087 $meetingdetail->getElementsByTagName('date-begin')->item(0)->nodeValue : ''; 1090 $meetingdetail->getElementsByTagName('date-begin')->item(0)->nodeValue : '';
1088 1091
1089 $matches[$key]->starttime = (string) $value; 1092 $matches[$key]->starttime = (string) $value;
1090 1093
1091 $value = (!is_null($meetingdetail->getElementsByTagName('date-end'))) ? 1094 $value = (!is_null($meetingdetail->getElementsByTagName('date-end'))) ?
1092 $meetingdetail->getElementsByTagName('date-end')->item(0)->nodeValue : ''; 1095 $meetingdetail->getElementsByTagName('date-end')->item(0)->nodeValue : '';
1093 1096
1094 $matches[$key]->endtime = (string) $value; 1097 $matches[$key]->endtime = (string) $value;
1095 1098
1096 } 1099 }
1097 1100
1098 } 1101 }
1099 } 1102 }
1100 } 1103 }
1101 } else { 1104 } else {
1102 return false; 1105 return false;
1103 } 1106 }
1104 1107
1105 } else { 1108 } else {
1106 return false; 1109 return false;
1107 } 1110 }
1108 1111
1109 return $matches; 1112 return $matches;
1110 } 1113 }
1111 1114
1112 /** 1115 /**
1113 * Parse XML and returns the user's principal-id 1116 * Parse XML and returns the user's principal-id
1114 * @param string $xml XML returned from call to principal-list 1117 * @param string $xml XML returned from call to principal-list
1115 * @param mixed user's principal-id or false 1118 * @param mixed user's principal-id or false
1116 */ 1119 */
1117 function aconnect_get_user_principal_id($xml) { 1120 function aconnect_get_user_principal_id($xml) {
1118 $usrprincipalid = false; 1121 $usrprincipalid = false;
1119 1122
1120 $dom = new DomDocument(); 1123 $dom = new DomDocument();
1121 $dom->loadXML($xml); 1124 $dom->loadXML($xml);
1122 1125
1123 $domnodelist = $dom->getElementsByTagName('principal-list'); 1126 $domnodelist = $dom->getElementsByTagName('principal-list');
1124 1127
1125 if (!empty($domnodelist->length)) { 1128 if (!empty($domnodelist->length)) {
1126 $domnodelist = $domnodelist->item(0)->getElementsByTagName('principal'); 1129 $domnodelist = $domnodelist->item(0)->getElementsByTagName('principal');
1127 1130
1128 if (!empty($domnodelist->length)) { 1131 if (!empty($domnodelist->length)) {
1129 if ($domnodelist->item(0)->hasAttributes()) { 1132 if ($domnodelist->item(0)->hasAttributes()) {
1130 $domnode = $domnodelist->item(0)->attributes->getNamedItem('principal-id'); 1133 $domnode = $domnodelist->item(0)->attributes->getNamedItem('principal-id');
1131 1134
1132 if (!is_null($domnode)) { 1135 if (!is_null($domnode)) {
1133 $usrprincipalid = (int) $domnode->nodeValue; 1136 $usrprincipalid = (int) $domnode->nodeValue;
1134 } 1137 }
1135 } 1138 }
1136 } 1139 }
1137 } 1140 }
1138 1141
1139 return $usrprincipalid; 1142 return $usrprincipalid;
1140 } 1143 }
1141 1144
1142 /** 1145 /**
1143 * Check to see if a user exists on the Adobe connect server 1146 * Check to see if a user exists on the Adobe connect server
1144 * searching by username 1147 * searching by username
1145 * @param object $aconnect a connection_class object 1148 * @param object $aconnect a connection_class object
1146 * @param object $userdata an object with username as a property 1149 * @param object $userdata an object with username as a property
1147 * @return mixed user's principal-id of match is found || false if not 1150 * @return mixed user's principal-id of match is found || false if not
1148 * found or error occured 1151 * found or error occured
1149 */ 1152 */
1150 function aconnect_user_exists($aconnect, $usrdata) { 1153 function aconnect_user_exists($aconnect, $usrdata) {
1151 $params = array( 1154 $params = array(
1152 'action' => 'principal-list', 1155 'action' => 'principal-list',
1153 'filter-login' => $usrdata->username, 1156 'filter-login' => $usrdata->username,
1154 // 'filter-type' => 'meeting', 1157 // 'filter-type' => 'meeting',
1155 // add more filters if this process begins to get slow 1158 // add more filters if this process begins to get slow
1156 ); 1159 );
1157 1160
1158 $aconnect->create_request($params); 1161 $aconnect->create_request($params);
1159 1162
1160 if ($aconnect->call_success()) { 1163 if ($aconnect->call_success()) {
1161 return aconnect_get_user_principal_id($aconnect->_xmlresponse); 1164 return aconnect_get_user_principal_id($aconnect->_xmlresponse);
1162 } else { 1165 } else {
1163 return false; 1166 return false;
1164 } 1167 }
1165 1168
1166 1169
1167 } 1170 }
1168 1171
1169 // DFNVC 1172 // DFNVC
1170 function lms_user_exists($aconnect, $usrdata) { 1173 function lms_user_exists($aconnect, $usrdata) {
1171 $params = array( 1174 $params = array(
1172 'action' => 'lms-user-exists', 1175 'action' => 'lms-user-exists',
1173 'login' => $usrdata->username, 1176 'login' => $usrdata->username,
1174 ); 1177 );
1175 1178
1176 $aconnect->create_request($params); 1179 $aconnect->create_request($params);
1177 1180
1178 if ($aconnect->call_success()) { 1181 if ($aconnect->call_success()) {
1179 return aconnect_get_user_principal_id($aconnect->_xmlresponse); 1182 return aconnect_get_user_principal_id($aconnect->_xmlresponse);
1180 } else { 1183 } else {
1181 return false; 1184 return false;
1182 } 1185 }
1183 } 1186 }
1184 1187
1185 // 1188 //
1186 // DFNVC 1189 // DFNVC
1187 // 1190 //
1188 function aconnect_delete_user($aconnect, $principalid = 0) { 1191 function aconnect_delete_user($aconnect, $principalid = 0) {
1189 1192
1190 if (empty($principalid)) { 1193 if (empty($principalid)) {
1191 return false; 1194 return false;
1192 } 1195 }
1193 1196
1194 $params = array( 1197 $params = array(
1195 'action' => 'lms-testuser-delete', 1198 'action' => 'lms-testuser-delete',
1196 'principal-id' => $principalid, 1199 'principal-id' => $principalid,
1197 ); 1200 );
1198 1201
1199 $aconnect->create_request($params); 1202 $aconnect->create_request($params);
1200 1203
1201 if ($aconnect->call_success()) { 1204 if ($aconnect->call_success()) {
1202 return true; 1205 return true;
1203 } else { 1206 } else {
1204 return false; 1207 return false;
1205 } 1208 }
1206 1209
1207 } 1210 }
1208 1211
1209 /** 1212 /**
1210 * Creates a new user on the Adobe Connect server. 1213 * Creates a new user on the Adobe Connect server.
1211 * Parses XML from a principal-update call and returns 1214 * Parses XML from a principal-update call and returns
1212 * the principal-id of the new user. 1215 * the principal-id of the new user.
1213 * 1216 *
1214 * @param object $aconnet a connect_class object 1217 * @param object $aconnet a connect_class object
1215 * @param object $usrdata an object with firstname,lastname, 1218 * @param object $usrdata an object with firstname,lastname,
1216 * username and email properties. 1219 * username and email properties.
1217 * @return mixed principal-id of the new user or false 1220 * @return mixed principal-id of the new user or false
1218 */ 1221 */
1219 function aconnect_create_user_old($aconnect, $usrdata) { 1222 function aconnect_create_user_old($aconnect, $usrdata) {
1220 $principal_id = false; 1223 $principal_id = false;
1221 1224
1222 $params = array( 1225 $params = array(
1223 'action' => 'principal-update', 1226 'action' => 'principal-update',
1224 'first-name' => $usrdata->firstname, 1227 'first-name' => $usrdata->firstname,
1225 'last-name' => $usrdata->lastname, 1228 'last-name' => $usrdata->lastname,
1226 'login' => $usrdata->username, 1229 'login' => $usrdata->username,
1227 'password' => strtoupper(md5($usrdata->username . time())), 1230 'password' => strtoupper(md5($usrdata->username . time())),
1228 'extlogin' => $usrdata->username, 1231 'extlogin' => $usrdata->username,
1229 'type' => 'user', 1232 'type' => 'user',
1230 'send-email' => 'false', 1233 'send-email' => 'false',
1231 'has-children' => 0, 1234 'has-children' => 0,
1232 'email' => $usrdata->email, 1235 'email' => $usrdata->email,
1233 ); 1236 );
1234 1237
1235 $aconnect->create_request($params); 1238 $aconnect->create_request($params);
1236 1239
1237 if ($aconnect->call_success()) { 1240 if ($aconnect->call_success()) {
1238 $dom = new DomDocument(); 1241 $dom = new DomDocument();
1239 $dom->loadXML($aconnect->_xmlresponse); 1242 $dom->loadXML($aconnect->_xmlresponse);
1240 1243
1241 $domnodelist = $dom->getElementsByTagName('principal'); 1244 $domnodelist = $dom->getElementsByTagName('principal');
1242 1245
1243 if (!empty($domnodelist->length)) { 1246 if (!empty($domnodelist->length)) {
1244 if ($domnodelist->item(0)->hasAttributes()) { 1247 if ($domnodelist->item(0)->hasAttributes()) {
1245 $domnode = $domnodelist->item(0)->attributes->getNamedItem('principal-id'); 1248 $domnode = $domnodelist->item(0)->attributes->getNamedItem('principal-id');
1246 1249
1247 if (!is_null($domnode)) { 1250 if (!is_null($domnode)) {
1248 $principal_id = (int) $domnode->nodeValue; 1251 $principal_id = (int) $domnode->nodeValue;
1249 } 1252 }
1250 } 1253 }
1251 } 1254 }
1252 } 1255 }
1253 1256
1254 return $principal_id; 1257 return $principal_id;
1255 } 1258 }
1256 1259
1257 function aconnect_create_user($aconnect, $usrdata) { 1260 function aconnect_create_user($aconnect, $usrdata) {
1258 $principal_id = false; 1261 $principal_id = false;
1259 1262
1260 $params = array( 1263 $params = array(
1261 'action' => 'lms-user-create', 1264 'action' => 'lms-user-create',
1262 'first-name' => $usrdata->firstname, 1265 'first-name' => $usrdata->firstname,
1263 'last-name' => $usrdata->lastname, 1266 'last-name' => $usrdata->lastname,
1264 'login' => $usrdata->username, 1267 'login' => $usrdata->username,
1265 ); 1268 );
1266 1269
1267 $aconnect->create_request($params); 1270 $aconnect->create_request($params);
1268 1271
1269 if ($aconnect->call_success()) { 1272 if ($aconnect->call_success()) {
1270 $dom = new DomDocument(); 1273 $dom = new DomDocument();
1271 $dom->loadXML($aconnect->_xmlresponse); 1274 $dom->loadXML($aconnect->_xmlresponse);
1272 1275
1273 $domnodelist = $dom->getElementsByTagName('principal'); 1276 $domnodelist = $dom->getElementsByTagName('principal');
1274 1277
1275 if (!empty($domnodelist->length)) { 1278 if (!empty($domnodelist->length)) {
1276 if ($domnodelist->item(0)->hasAttributes()) { 1279 if ($domnodelist->item(0)->hasAttributes()) {
1277 $domnode = $domnodelist->item(0)->attributes->getNamedItem('principal-id'); 1280 $domnode = $domnodelist->item(0)->attributes->getNamedItem('principal-id');
1278 1281
1279 if (!is_null($domnode)) { 1282 if (!is_null($domnode)) {
1280 $principal_id = (int) $domnode->nodeValue; 1283 $principal_id = (int) $domnode->nodeValue;
1281 } 1284 }
1282 } 1285 }
1283 } 1286 }
1284 } 1287 }
1285 1288
1286 return $principal_id; 1289 return $principal_id;
1287 } 1290 }
1288 1291
1289 function aconnect_assign_user_perm($aconnect, $usrprincipal, $meetingscoid, $type) { 1292 function aconnect_assign_user_perm($aconnect, $usrprincipal, $meetingscoid, $type) {
1290 $params = array( 1293 $params = array(
1291 'action' => 'permissions-update', 1294 'action' => 'permissions-update',
1292 'acl-id' => $meetingscoid, //sco-id of meeting || principal id of user 11209, 1295 'acl-id' => $meetingscoid, //sco-id of meeting || principal id of user 11209,
1293 'permission-id' => $type, // host, mini-host, view 1296 'permission-id' => $type, // host, mini-host, view
1294 'principal-id' => $usrprincipal, // principal id of user you are looking at 1297 'principal-id' => $usrprincipal, // principal id of user you are looking at
1295 ); 1298 );
1296 1299
1297 $aconnect->create_request($params); 1300 $aconnect->create_request($params);
1298 1301
1299 if ($aconnect->call_success()) { 1302 if ($aconnect->call_success()) {
1300 return true; 1303 return true;
1301 // print_object($aconnect->_xmlresponse); 1304 // print_object($aconnect->_xmlresponse);
1302 } else { 1305 } else {
1303 return false; 1306 return false;
1304 // print_object($aconnect->_xmlresponse); 1307 // print_object($aconnect->_xmlresponse);
1305 } 1308 }
1306 } 1309 }
1307 1310
1308 function aconnect_remove_user_perm($aconnect, $usrprincipal, $meetingscoid) { 1311 function aconnect_remove_user_perm($aconnect, $usrprincipal, $meetingscoid) {
1309 $params = array( 1312 $params = array(
1310 'action' => 'permissions-update', 1313 'action' => 'permissions-update',
1311 'acl-id' => $meetingscoid, //sco-id of meeting || principal id of user 11209, 1314 'acl-id' => $meetingscoid, //sco-id of meeting || principal id of user 11209,
1312 'permission-id' => ADOBE_REMOVE_ROLE, // host, mini-host, view 1315 'permission-id' => ADOBE_REMOVE_ROLE, // host, mini-host, view
1313 'principal-id' => $usrprincipal, // principal id of user you are looking at 1316 'principal-id' => $usrprincipal, // principal id of user you are looking at
1314 ); 1317 );
1315 1318
1316 $aconnect->create_request($params); 1319 $aconnect->create_request($params);
1317 1320
1318 if ($aconnect->call_success()) { 1321 if ($aconnect->call_success()) {
1319 // print_object($aconnect->_xmlresponse); 1322 // print_object($aconnect->_xmlresponse);
1320 } else { 1323 } else {
1321 // print_object($aconnect->_xmlresponse); 1324 // print_object($aconnect->_xmlresponse);
1322 } 1325 }
1323 1326
1324 } 1327 }
1325 1328
1326 1329
1327 /** 1330 /**
1328 * Check if a user has a permission 1331 * Check if a user has a permission
1329 * @param object $aconnect a connect_class object 1332 * @param object $aconnect a connect_class object
1330 * @param int $usrprincipal user principal-id 1333 * @param int $usrprincipal user principal-id
1331 * @param int $meetingscoid meeting sco-id 1334 * @param int $meetingscoid meeting sco-id
1332 * @param int $roletype can be ADOBE_PRESENTER, ADOBE_PARTICIPANT or ADOBE_REMOVE 1335 * @param int $roletype can be ADOBE_PRESENTER, ADOBE_PARTICIPANT or ADOBE_REMOVE
1333 * @param bool $assign set to true if you want to assign the user the role type 1336 * @param bool $assign set to true if you want to assign the user the role type
1334 * set to false to just check the user's permission. $assign parameter is ignored 1337 * set to false to just check the user's permission. $assign parameter is ignored
1335 * if $roletype is ADOBE_REMOVE 1338 * if $roletype is ADOBE_REMOVE
1336 * @return TODO 1339 * @return TODO
1337 * 1340 *
1338 */ 1341 */
1339 function aconnect_check_user_perm($aconnect, $usrprincipal, $meetingscoid, $roletype, $assign = false) { 1342 function aconnect_check_user_perm($aconnect, $usrprincipal, $meetingscoid, $roletype, $assign = false) {
1340 $perm_type = ''; 1343 $perm_type = '';
1341 $hasperm = false; 1344 $hasperm = false;
1342 1345
1343 switch ($roletype) { 1346 switch ($roletype) {
1344 case ADOBE_PRESENTER: 1347 case ADOBE_PRESENTER:
1345 $perm_type = ADOBE_MINIADMIN_ROLE; 1348 $perm_type = ADOBE_MINIADMIN_ROLE;
1346 break; 1349 break;
1347 case ADOBE_PARTICIPANT: 1350 case ADOBE_PARTICIPANT:
1348 $perm_type = ADOBE_VIEW_ROLE; 1351 $perm_type = ADOBE_VIEW_ROLE;
1349 break; 1352 break;
1350 case ADOBE_HOST: 1353 case ADOBE_HOST:
1351 $perm_type = ADOBE_HOST_ROLE; 1354 $perm_type = ADOBE_HOST_ROLE;
1352 break; 1355 break;
1353 case ADOBE_REMOVE: 1356 case ADOBE_REMOVE:
1354 $perm_type = ADOBE_REMOVE_ROLE; 1357 $perm_type = ADOBE_REMOVE_ROLE;
1355 break; 1358 break;
1356 default: 1359 default:
1357 break; 1360 break;
1358 } 1361 }
1359 1362
1360 $params = array( 1363 $params = array(
1361 'action' => 'permissions-info', 1364 'action' => 'permissions-info',
1362 // 'filter-permission-id' => 'mini-host', 1365 // 'filter-permission-id' => 'mini-host',
1363 'acl-id' => $meetingscoid, //sco-id of meeting || principal id of user 11209, 1366 'acl-id' => $meetingscoid, //sco-id of meeting || principal id of user 11209,
1364 // 'filter-permission-id' => $perm_type, // host, mini-host, view 1367 // 'filter-permission-id' => $perm_type, // host, mini-host, view
1365 'filter-principal-id' => $usrprincipal, // principal id of user you are looking at 1368 'filter-principal-id' => $usrprincipal, // principal id of user you are looking at
1366 ); 1369 );
1367 1370
1368 if (ADOBE_REMOVE_ROLE != $perm_type) { 1371 if (ADOBE_REMOVE_ROLE != $perm_type) {
1369 $params['filter-permission-id'] = $perm_type; 1372 $params['filter-permission-id'] = $perm_type;
1370 } 1373 }
1371 1374
1372 $aconnect->create_request($params); 1375 $aconnect->create_request($params);
1373 1376
1374 if ($aconnect->call_success()) { 1377 if ($aconnect->call_success()) {
1375 $dom = new DomDocument(); 1378 $dom = new DomDocument();
1376 $dom->loadXML($aconnect->_xmlresponse); 1379 $dom->loadXML($aconnect->_xmlresponse);
1377 1380
1378 $domnodelist = $dom->getElementsByTagName('permissions'); 1381 $domnodelist = $dom->getElementsByTagName('permissions');
1379 1382
1380 if (!empty($domnodelist->length)) { 1383 if (!empty($domnodelist->length)) {
1381 $domnodelist = $domnodelist->item(0)->getElementsByTagName('principal'); 1384 $domnodelist = $domnodelist->item(0)->getElementsByTagName('principal');
1382 1385
1383 if (!empty($domnodelist->length)) { 1386 if (!empty($domnodelist->length)) {
1384 $hasperm = true; 1387 $hasperm = true;
1385 } 1388 }
1386 } 1389 }
1387 1390
1388 if (ADOBE_REMOVE_ROLE != $perm_type and $assign and !$hasperm) { 1391 if (ADOBE_REMOVE_ROLE != $perm_type and $assign and !$hasperm) {
1389 // TODO: check return values of the two functions below 1392 // TODO: check return values of the two functions below
1390 // Assign permission to user 1393 // Assign permission to user
1391 return aconnect_assign_user_perm($aconnect, $usrprincipal, $meetingscoid, $perm_type); 1394 return aconnect_assign_user_perm($aconnect, $usrprincipal, $meetingscoid, $perm_type);
1392 } elseif (ADOBE_REMOVE_ROLE == $perm_type) { 1395 } elseif (ADOBE_REMOVE_ROLE == $perm_type) {
1393 // Remove user's permission 1396 // Remove user's permission
1394 return aconnect_remove_user_perm($aconnect, $usrprincipal, $meetingscoid); 1397 return aconnect_remove_user_perm($aconnect, $usrprincipal, $meetingscoid);
1395 } else { 1398 } else {
1396 return $hasperm; 1399 return $hasperm;
1397 } 1400 }
1398 } 1401 }
1399 } 1402 }
1400 1403
1401 /** 1404 /**
1402 * Remove a meeting 1405 * Remove a meeting
1403 * @param obj $aconnect adobe connection object 1406 * @param obj $aconnect adobe connection object
1404 * @param int $scoid sco-id of the meeting 1407 * @param int $scoid sco-id of the meeting
1405 * @return bool true of success false on failure 1408 * @return bool true of success false on failure
1406 */ 1409 */
1407 function aconnect_remove_meeting($aconnect, $scoid) { 1410 function aconnect_remove_meeting($aconnect, $scoid) {
1408 $params = array( 1411 $params = array(
1409 'action' => 'sco-delete', 1412 'action' => 'sco-delete',
1410 'sco-id' => $scoid, 1413 'sco-id' => $scoid,
1411 ); 1414 );
1412 1415
1413 $aconnect->create_request($params); 1416 $aconnect->create_request($params);
1414 1417
1415 if ($aconnect->call_success()) { 1418 if ($aconnect->call_success()) {
1416 return true; 1419 return true;
1417 } else { 1420 } else {
1418 return false; 1421 return false;
1419 } 1422 }
1420 } 1423 }
1421 1424
1422 /** 1425 /**
1423 * Move SCOs to the shared content folder 1426 * Move SCOs to the shared content folder
1424 * @param obj $aconnect a connect_class object 1427 * @param obj $aconnect a connect_class object
1425 * @param array sco-ids as array keys 1428 * @param array sco-ids as array keys
1426 * @return bool false if error or nothing to move true if a move occured 1429 * @return bool false if error or nothing to move true if a move occured
1427 */ 1430 */
1428 function aconnect_move_to_shared($aconnect, $scolist) { 1431 function aconnect_move_to_shared($aconnect, $scolist) {
1429 // Get shared folder sco-id 1432 // Get shared folder sco-id
1430 $shscoid = aconnect_get_folder($aconnect, 'content'); 1433 $shscoid = aconnect_get_folder($aconnect, 'content');
1431 1434
1432 // Iterate through list of sco and move them all to the shared folder 1435 // Iterate through list of sco and move them all to the shared folder
1433 if (!empty($shscoid)) { 1436 if (!empty($shscoid)) {
1434 1437
1435 foreach ($scolist as $scoid => $data) { 1438 foreach ($scolist as $scoid => $data) {
1436 $params = array( 1439 $params = array(
1437 'action' => 'sco-move', 1440 'action' => 'sco-move',
1438 'folder-id' => $shscoid, 1441 'folder-id' => $shscoid,
1439 'sco-id' => $scoid, 1442 'sco-id' => $scoid,
1440 ); 1443 );
1441 1444
1442 $aconnect->create_request($params); 1445 $aconnect->create_request($params);
1443 1446
1444 } 1447 }
1445 1448
1446 return true; 1449 return true;
1447 } else { 1450 } else {
1448 return false; 1451 return false;
1449 } 1452 }
1450 } 1453 }
1451 1454
1452 /** 1455 /**
1453 * Gets a list of roles that this user can assign in this context 1456 * Gets a list of roles that this user can assign in this context
1454 * 1457 *
1455 * @param object $context the context. 1458 * @param object $context the context.
1456 * @param int $rolenamedisplay the type of role name to display. One of the 1459 * @param int $rolenamedisplay the type of role name to display. One of the
1457 * ROLENAME_X constants. Default ROLENAME_ALIAS. 1460 * ROLENAME_X constants. Default ROLENAME_ALIAS.
1458 * @param bool $withusercounts if true, count the number of users with each role. 1461 * @param bool $withusercounts if true, count the number of users with each role.
1459 * @param integer|object $user A user id or object. By default (null) checks the permissions of the current user. 1462 * @param integer|object $user A user id or object. By default (null) checks the permissions of the current user.
1460 * @return array if $withusercounts is false, then an array $roleid => $rolename. 1463 * @return array if $withusercounts is false, then an array $roleid => $rolename.
1461 * if $withusercounts is true, returns a list of three arrays, 1464 * if $withusercounts is true, returns a list of three arrays,
1462 * $rolenames, $rolecounts, and $nameswithcounts. 1465 * $rolenames, $rolecounts, and $nameswithcounts.
1463 */ 1466 */
1464 function adobeconnect_get_assignable_roles($context, $rolenamedisplay = ROLENAME_ALIAS, $withusercounts = false, $user = null) { 1467 function adobeconnect_get_assignable_roles($context, $rolenamedisplay = ROLENAME_ALIAS, $withusercounts = false, $user = null) {
1465 global $USER, $DB; 1468 global $USER, $DB;
1466 1469
1467 // make sure there is a real user specified 1470 // make sure there is a real user specified
1468 if ($user === null) { 1471 if ($user === null) {
1469 $userid = !empty($USER->id) ? $USER->id : 0; 1472 $userid = !empty($USER->id) ? $USER->id : 0;
1470 } else { 1473 } else {
1471 $userid = !empty($user->id) ? $user->id : $user; 1474 $userid = !empty($user->id) ? $user->id : $user;
1472 } 1475 }
1473 1476
1474 if (!has_capability('moodle/role:assign', $context, $userid)) { 1477 if (!has_capability('moodle/role:assign', $context, $userid)) {
1475 if ($withusercounts) { 1478 if ($withusercounts) {
1476 return array(array(), array(), array()); 1479 return array(array(), array(), array());
1477 } else { 1480 } else {
1478 return array(); 1481 return array();
1479 } 1482 }
1480 } 1483 }
1481 1484
1482 $parents = get_parent_contexts($context, true); 1485 $parents = get_parent_contexts($context, true);
1483 $contexts = implode(',' , $parents); 1486 $contexts = implode(',' , $parents);
1484 1487
1485 $params = array(); 1488 $params = array();
1486 $extrafields = ''; 1489 $extrafields = '';
1487 if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT or $rolenamedisplay == ROLENAME_SHORT) { 1490 if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT or $rolenamedisplay == ROLENAME_SHORT) {
1488 $extrafields .= ', r.shortname'; 1491 $extrafields .= ', r.shortname';
1489 } 1492 }
1490 1493
1491 if ($withusercounts) { 1494 if ($withusercounts) {
1492 $extrafields = ', (SELECT count(u.id) 1495 $extrafields = ', (SELECT count(u.id)
1493 FROM {role_assignments} cra JOIN {user} u ON cra.userid = u.id 1496 FROM {role_assignments} cra JOIN {user} u ON cra.userid = u.id
1494 WHERE cra.roleid = r.id AND cra.contextid = :conid AND u.deleted = 0 1497 WHERE cra.roleid = r.id AND cra.contextid = :conid AND u.deleted = 0
1495 ) AS usercount'; 1498 ) AS usercount';
1496 $params['conid'] = $context->id; 1499 $params['conid'] = $context->id;
1497 } 1500 }
1498 1501
1499 if (is_siteadmin($userid)) { 1502 if (is_siteadmin($userid)) {
1500 // show all roles allowed in this context to admins 1503 // show all roles allowed in this context to admins
1501 $assignrestriction = ""; 1504 $assignrestriction = "";
1502 } else { 1505 } else {
1503 $assignrestriction = "JOIN (SELECT DISTINCT raa.allowassign AS id 1506 $assignrestriction = "JOIN (SELECT DISTINCT raa.allowassign AS id
1504 FROM {role_allow_assign} raa 1507 FROM {role_allow_assign} raa
1505 JOIN {role_assignments} ra ON ra.roleid = raa.roleid 1508 JOIN {role_assignments} ra ON ra.roleid = raa.roleid
1506 WHERE ra.userid = :userid AND ra.contextid IN ($contexts) 1509 WHERE ra.userid = :userid AND ra.contextid IN ($contexts)
1507 ) ar ON ar.id = r.id"; 1510 ) ar ON ar.id = r.id";
1508 $params['userid'] = $userid; 1511 $params['userid'] = $userid;
1509 } 1512 }
1510 $params['contextlevel'] = $context->contextlevel; 1513 $params['contextlevel'] = $context->contextlevel;
1511 $sql = "SELECT r.id, r.name $extrafields 1514 $sql = "SELECT r.id, r.name $extrafields
1512 FROM {role} r 1515 FROM {role} r
1513 $assignrestriction 1516 $assignrestriction
1514 JOIN {role_context_levels} rcl ON r.id = rcl.roleid 1517 JOIN {role_context_levels} rcl ON r.id = rcl.roleid
1515 WHERE rcl.contextlevel = :contextlevel 1518 WHERE rcl.contextlevel = :contextlevel
1516 ORDER BY r.sortorder ASC"; 1519 ORDER BY r.sortorder ASC";
1517 $roles = $DB->get_records_sql($sql, $params); 1520 $roles = $DB->get_records_sql($sql, $params);
1518 1521
1519 // Only include Adobe Connect roles 1522 // Only include Adobe Connect roles
1520 $param = array('shortname' => 'adobeconnectpresenter'); 1523 $param = array('shortname' => 'adobeconnectpresenter');
1521 $presenterid = $DB->get_field('role', 'id', $param); 1524 $presenterid = $DB->get_field('role', 'id', $param);
1522 1525
1523 $param = array('shortname' => 'adobeconnectparticipant'); 1526 $param = array('shortname' => 'adobeconnectparticipant');
1524 $participantid = $DB->get_field('role', 'id', $param); 1527 $participantid = $DB->get_field('role', 'id', $param);
1525 1528
1526 $param = array('shortname' => 'adobeconnecthost'); 1529 $param = array('shortname' => 'adobeconnecthost');
1527 $hostid = $DB->get_field('role', 'id', $param); 1530 $hostid = $DB->get_field('role', 'id', $param);
1528 1531
1529 foreach ($roles as $key => $data) { 1532 foreach ($roles as $key => $data) {
1530 if ($key != $participantid and $key != $presenterid and $key != $hostid) { 1533 if ($key != $participantid and $key != $presenterid and $key != $hostid) {
1531 unset($roles[$key]); 1534 unset($roles[$key]);
1532 } 1535 }
1533 } 1536 }
1534 1537
1535 $rolenames = array(); 1538 $rolenames = array();
1536 foreach ($roles as $role) { 1539 foreach ($roles as $role) {
1537 if ($rolenamedisplay == ROLENAME_SHORT) { 1540 if ($rolenamedisplay == ROLENAME_SHORT) {
1538 $rolenames[$role->id] = $role->shortname; 1541 $rolenames[$role->id] = $role->shortname;
1539 continue; 1542 continue;
1540 } 1543 }
1541 $rolenames[$role->id] = $role->name; 1544 $rolenames[$role->id] = $role->name;
1542 if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT) { 1545 if ($rolenamedisplay == ROLENAME_ORIGINALANDSHORT) {
1543 $rolenames[$role->id] .= ' (' . $role->shortname . ')'; 1546 $rolenames[$role->id] .= ' (' . $role->shortname . ')';
1544 } 1547 }
1545 } 1548 }
1546 if ($rolenamedisplay != ROLENAME_ORIGINALANDSHORT and $rolenamedisplay != ROLENAME_SHORT) { 1549 if ($rolenamedisplay != ROLENAME_ORIGINALANDSHORT and $rolenamedisplay != ROLENAME_SHORT) {
1547 $rolenames = role_fix_names($rolenames, $context, $rolenamedisplay); 1550 $rolenames = role_fix_names($rolenames, $context, $rolenamedisplay);
1548 } 1551 }
1549 1552
1550 if (!$withusercounts) { 1553 if (!$withusercounts) {
1551 return $rolenames; 1554 return $rolenames;
1552 } 1555 }
1553 1556
1554 $rolecounts = array(); 1557 $rolecounts = array();
1555 $nameswithcounts = array(); 1558 $nameswithcounts = array();
1556 foreach ($roles as $role) { 1559 foreach ($roles as $role) {
1557 $nameswithcounts[$role->id] = $rolenames[$role->id] . ' (' . $roles[$role->id]->usercount . ')'; 1560 $nameswithcounts[$role->id] = $rolenames[$role->id] . ' (' . $roles[$role->id]->usercount . ')';
1558 $rolecounts[$role->id] = $roles[$role->id]->usercount; 1561 $rolecounts[$role->id] = $roles[$role->id]->usercount;
1559 } 1562 }
1560 return array($rolenames, $rolecounts, $nameswithcounts); 1563 return array($rolenames, $rolecounts, $nameswithcounts);
1561 } 1564 }
1562 1565