forked from ahmadi-akbar/moodle-mod_adobeconnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
locallib.php
1493 lines (1166 loc) · 49.8 KB
/
locallib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package mod_adobeconnect
* @author Akinsaya Delamarre (adelamarre@remote-learner.net)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2015 Remote Learner.net Inc http://www.remote-learner.net
*/
require_once('connect_class.php');
require_once('connect_class_dom.php');
define('ADOBE_VIEW_ROLE', 'view');
define('ADOBE_HOST_ROLE', 'host');
define('ADOBE_MINIADMIN_ROLE', 'mini-host');
define('ADOBE_REMOVE_ROLE', 'remove');
define('ADOBE_PARTICIPANT', 1);
define('ADOBE_PRESENTER', 2);
define('ADOBE_REMOVE', 3);
define('ADOBE_HOST', 4);
define('ADOBE_TEMPLATE_POSTFIX', '- Template');
define('ADOBE_MEETING_POSTFIX', '- Meeting');
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.
define('ADOBE_MEETPERM_PROTECTED', 1); //means the meeting is protected, and only registered users and accepted guests can enter the room.
define('ADOBE_MEETPERM_PRIVATE', 2); // means the meeting is private, and only registered users and participants can enter the room
define('ADOBE_TMZ_LENGTH', 6);
function adobe_connection_test($host = '', $port = 80, $username = '',
$password = '', $httpheader = '',
$emaillogin, $https = false) {
if (empty($host) or
empty($port) or (0 == $port) or
empty($username) or
empty($password) or
empty($httpheader)) {
echo "</p>One of the required parameters is blank or incorrect: <br />".
"Host: $host<br /> Port: $port<br /> Username: $username<br /> Password: $password".
"<br /> HTTP Header: $httpheader</p>";
die();
}
$messages = array();
$aconnectDOM = new connect_class_dom($host,
$port,
$username,
$password,
'',
$https);
$params = array(
'action' => 'common-info'
);
// Send common-info call to obtain the session key
echo '<p>Sending common-info call:</p>';
$aconnectDOM->create_request($params);
if (!empty($aconnectDOM->_xmlresponse)) {
// Get the session key from the XML response
$aconnectDOM->read_cookie_xml($aconnectDOM->_xmlresponse);
$cookie = $aconnectDOM->get_cookie();
if (empty($cookie)) {
echo '<p>unable to obtain session key from common-info call</p>';
echo '<p>xmlrequest:</p>';
$doc = new DOMDocument();
if ($doc->loadXML($aconnectDOM->_xmlrequest)) {
echo '<p>' . htmlspecialchars($doc->saveXML()) . '</p>';
} else {
echo '<p>unable to display the XML request</p>';
}
echo '<p>xmlresponse:</p>';
$doc = new DOMDocument();
if ($doc->loadXML($aconnectDOM->_xmlresponse)) {
echo '<p>' . htmlspecialchars($doc->saveHTML()) . '</p>';
} else {
echo '<p>unable to display the XML response</p>';
}
} else {
// print success
echo '<p style="color:#006633">successfully obtained the session key: ' . $aconnectDOM->get_cookie() . '</p>';
// test logging in as the administrator
$params = array(
'action' => 'login',
'login' => $aconnectDOM->get_username(),
'password' => $aconnectDOM->get_password(),
);
$aconnectDOM->create_request($params);
if ($aconnectDOM->call_success()) {
echo '<p style="color:#006633">successfully logged in as admin user</p>';
//$username
//Test retrevial of folders
echo '<p>Testing retrevial of shared content, recording and meeting folders:</p>';
$folderscoid = aconnect_get_folder($aconnectDOM, 'content');
if ($folderscoid) {
echo '<p style="color:#006633">successfully obtained shared content folder scoid: '. $folderscoid . '</p>';
} else {
echo '<p>error obtaining shared content folder</p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
$folderscoid = aconnect_get_folder($aconnectDOM, 'forced-archives');
if ($folderscoid) {
echo '<p style="color:#006633">successfully obtained forced-archives (meeting recordings) folder scoid: '. $folderscoid . '</p>';
} else {
echo '<p>error obtaining forced-archives (meeting recordings) folder</p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
$folderscoid = aconnect_get_folder($aconnectDOM, 'meetings');
if ($folderscoid) {
echo '<p style="color:#006633">successfully obtained meetings folder scoid: '. $folderscoid . '</p>';
} else {
echo '<p>error obtaining meetings folder</p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
//Test creating a meeting
$folderscoid = aconnect_get_folder($aconnectDOM, 'meetings');
$meeting = new stdClass();
$meeting->name = 'testmeetingtest';
$time = time();
$meeting->starttime = $time;
$time = $time + (60 * 60);
$meeting->endtime = $time;
if (($meetingscoid = aconnect_create_meeting($aconnectDOM, $meeting, $folderscoid))) {
echo '<p style="color:#006633">successfully created meeting <b>testmeetingtest</b> scoid: '. $meetingscoid . '</p>';
} else {
echo '<p>error creating meeting <b>testmeetingtest</b> folder</p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
//Test creating a user
$user = new stdClass();
$user->username = 'testusertest';
$user->firstname = 'testusertest';
$user->lastname = 'testusertest';
$user->email = 'testusertest@test.com';
if (!empty($emaillogin)) {
$user->username = $user->email;
}
$skipdeletetest = false;
if (!($usrprincipal = aconnect_user_exists($aconnectDOM, $user))) {
$usrprincipal = aconnect_create_user($aconnectDOM, $user);
if ($usrprincipal) {
echo '<p style="color:#006633">successfully created user <b>testusertest</b> principal-id: '. $usrprincipal . '</p>';
} else {
echo '<p>error creating user <b>testusertest</b></p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
aconnect_logout($aconnectDOM);
die();
}
} else {
echo '<p>user <b>testusertest</b> already exists skipping delete user test</p>';
$skipdeletetest = true;
}
//Test assigning a user a role to the meeting
if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_PRESENTER, true)) {
echo '<p style="color:#006633">successfully assigned user <b>testusertest</b>'.
' presenter role in meeting <b>testmeetingtest</b>: '. $usrprincipal . '</p>';
} else {
echo '<p>error assigning user <b>testusertest</b> presenter role in meeting <b>testmeetingtest</b></p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
//Test removing role from meeting
if (aconnect_check_user_perm($aconnectDOM, $usrprincipal, $meetingscoid, ADOBE_REMOVE_ROLE, true)) {
echo '<p style="color:#006633">successfully removed presenter role for user <b>testusertest</b>'.
' in meeting <b>testmeetingtest</b>: '. $usrprincipal . '</p>';
} else {
echo '<p>error remove presenter role for user <b>testusertest</b> in meeting <b>testmeetingtest</b></p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
//Test removing user from server
if (!$skipdeletetest) {
if (aconnect_delete_user($aconnectDOM, $usrprincipal)) {
echo '<p style="color:#006633">successfully removed user <b>testusertest</b> principal-id: '. $usrprincipal . '</p>';
} else {
echo '<p>error removing user <b>testusertest</b></p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
}
//Test removing meeting from server
if ($meetingscoid) {
if (aconnect_remove_meeting($aconnectDOM, $meetingscoid)) {
echo '<p style="color:#006633">successfully removed meeting <b>testmeetingtest</b> scoid: '. $meetingscoid . '</p>';
} else {
echo '<p>error removing meeting <b>testmeetingtest</b> folder</p>';
echo '<p style="color:#680000">XML request:<br />'. htmlspecialchars($aconnectDOM->_xmlrequest). '</p>';
echo '<p style="color:#680000">XML response:<br />'. htmlspecialchars($aconnectDOM->_xmlresponse). '</p>';
}
}
} else {
echo '<p style="color:#680000">logging in as '. $username . ' was not successful, check to see if the username and password are correct </p>';
}
}
} else {
echo '<p style="color:#680000">common-info API call returned an empty document. Please check your settings and try again </p>';
}
aconnect_logout($aconnectDOM);
}
/**
* Returns the folder sco-id
* @param object an adobe connection_class object
* @param string $folder name of the folder to get
* (ex. forced-archives = recording folder | meetings = meetings folder
* | content = shared content folder)
* @return mixed adobe connect folder sco-id || false if there was an error
*
*/
function aconnect_get_folder($aconnect, $folder = '') {
$folderscoid = false;
$params = array('action' => 'sco-shortcuts');
$aconnect->create_request($params);
if ($aconnect->call_success()) {
$folderscoid = aconnect_get_folder_sco_id($aconnect->_xmlresponse, $folder);
// $params = array('action' => 'sco-contents', 'sco-id' => $folderscoid);
}
return $folderscoid;
}
/**
* TODO: comment function and return something meaningful
*/
function aconnect_get_folder_sco_id($xml, $folder) {
$scoid = false;
$dom = new DomDocument();
$dom->loadXML($xml);
$domnodelist = $dom->getElementsByTagName('sco');
if (!empty($domnodelist->length)) {
for ($i = 0; $i < $domnodelist->length; $i++) {
$domnode = $domnodelist->item($i)->attributes->getNamedItem('type');
if (!is_null($domnode)) {
if (0 == strcmp($folder, $domnode->nodeValue)) {
$domnode = $domnodelist->item($i)->attributes->getNamedItem('sco-id');
if (!is_null($domnode)) {
$scoid = (int) $domnode->nodeValue;
}
}
}
}
}
return $scoid;
}
/**
* Log in as the admin user. This should only be used to conduct API calls.
*/
function aconnect_login() {
global $CFG, $USER, $COURSE;
if (!isset($CFG->adobeconnect_host) or
!isset($CFG->adobeconnect_admin_login) or
!isset($CFG->adobeconnect_admin_password)) {
if (is_siteadmin($USER->id)) {
notice(get_string('adminnotsetupproperty', 'adobeconnect'),
$CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
} else {
notice(get_string('notsetupproperty', 'adobeconnect'),
'', $COURSE);
}
}
if (isset($CFG->adobeconnect_port) and
!empty($CFG->adobeconnect_port) and
((80 != $CFG->adobeconnect_port) and (0 != $CFG->adobeconnect_port))) {
$port = $CFG->adobeconnect_port;
} else {
$port = 80;
}
$https = false;
if (isset($CFG->adobeconnect_https) and (!empty($CFG->adobeconnect_https))) {
$https = true;
}
$aconnect = new connect_class_dom($CFG->adobeconnect_host,
$CFG->adobeconnect_port,
$CFG->adobeconnect_admin_login,
$CFG->adobeconnect_admin_password,
'',
$https);
$params = array(
'action' => 'common-info'
);
$aconnect->create_request($params);
$aconnect->read_cookie_xml($aconnect->_xmlresponse);
$params = array(
'action' => 'login',
'login' => $aconnect->get_username(),
'password' => $aconnect->get_password(),
);
$aconnect->create_request($params);
if ($aconnect->call_success()) {
$aconnect->set_connection(1);
} else {
$aconnect->set_connection(0);
}
return $aconnect;
}
/**
* Logout
* @param object $aconnect - connection object
* @return true on success else false
*/
function aconnect_logout(&$aconnect) {
if (!$aconnect->get_connection()) {
return true;
}
$params = array('action' => 'logout');
$aconnect->create_request($params);
if ($aconnect->call_success()) {
$aconnect->set_connection(0);
return true;
} else {
$aconnect->set_connection(1);
return false;
}
}
/**
* Calls all operations needed to retrieve and return all
* templates defined in the shared templates folder and meetings
* @param object $aconnect connection object
* @return array $templates an array of templates
*/
function aconnect_get_templates_meetings($aconnect) {
$templates = array();
$meetings = array();
$meetfldscoid = false;
$tempfldscoid = false;
$params = array(
'action' => 'sco-shortcuts',
);
$aconnect->create_request($params);
if ($aconnect->call_success()) {
// Get shared templates folder sco-id
$tempfldscoid = aconnect_get_shared_templates($aconnect->_xmlresponse);
}
if (false !== $tempfldscoid) {
$params = array(
'action' => 'sco-expanded-contents',
'sco-id' => $tempfldscoid,
);
$aconnect->create_request($params);
if ($aconnect->call_success()) {
$templates = aconnect_return_all_templates($aconnect->_xmlresponse);
}
}
// if (false !== $meetfldscoid) {
// $params = array(
// 'action' => 'sco-expanded-contents',
// 'sco-id' => $meetfldscoid,
// 'filter-type' => 'meeting',
// );
//
// $aconnect->create_request($params);
//
// if ($aconnect->call_success()) {
// $meetings = aconnect_return_all_meetings($aconnect->_xmlresponse);
// }
//
// }
return $templates + $meetings;
}
/**
* Parse XML looking for shared-meeting-templates attribute
* and returning the sco-id of the folder
* @param string $xml returned XML from a sco-shortcuts call
* @return mixed sco-id if found or false if not found or error
*/
function aconnect_get_shared_templates($xml) {
$scoid = false;
$dom = new DomDocument();
$dom->loadXML($xml);
$domnodelist = $dom->getElementsByTagName('shortcuts');
if (!empty($domnodelist->length)) {
// for ($i = 0; $i < $domnodelist->length; $i++) {
$innerlist = $domnodelist->item(0)->getElementsByTagName('sco');
if (!empty($innerlist->length)) {
for ($x = 0; $x < $innerlist->length; $x++) {
if ($innerlist->item($x)->hasAttributes()) {
$domnode = $innerlist->item($x)->attributes->getNamedItem('type');
if (!is_null($domnode)) {
if (0 == strcmp('shared-meeting-templates', $domnode->nodeValue)) {
$domnode = $innerlist->item($x)->attributes->getNamedItem('sco-id');
if (!is_null($domnode)) {
$scoid = (int) $domnode->nodeValue;
}
}
}
}
}
}
// }
}
return $scoid;
}
function aconnect_return_all_meetings($xml) {
$meetings = array();
$xml = new SimpleXMLElement($xml);
if (empty($xml)) {
return $meetings;
}
foreach($xml->{'expanded-scos'}[0]->sco as $key => $sco) {
if (0 == strcmp('meeting', $sco['type'])) {
$mkey = (int) $sco['sco-id'];
$meetings[$mkey] = (string) current($sco->name) .' '. ADOBE_MEETING_POSTFIX;
}
}
return $meetings;
}
/**
* Parses XML for meeting templates and returns an array
* with sco-id as the key and template name as the value
* @param strimg $xml XML returned from a sco-expanded-contents call
* @return array of templates sco-id -> key, name -> value
*/
function aconnect_return_all_templates($xml) {
$templates = array();
$dom = new DomDocument();
$dom->loadXML($xml);
$domnodelist = $dom->getElementsByTagName('expanded-scos');
if (!empty($domnodelist->length)) {
$innerlist = $domnodelist->item(0)->getElementsByTagName('sco');
if (!empty($innerlist->length)) {
for ($i = 0; $i < $innerlist->length; $i++) {
if ($innerlist->item($i)->hasAttributes()) {
$domnode = $innerlist->item($i)->attributes->getNamedItem('type');
if (!is_null($domnode) and 0 == strcmp('meeting', $domnode->nodeValue)) {
$domnode = $innerlist->item($i)->attributes->getNamedItem('sco-id');
if (!is_null($domnode)) {
$tkey = (int) $domnode->nodeValue;
$namelistnode = $innerlist->item($i)->getElementsByTagName('name');
if (!is_null($namelistnode)) {
$name = $namelistnode->item(0)->nodeValue;
$templates[$tkey] = (string) $name .' ' . ADOBE_TEMPLATE_POSTFIX;
}
}
}
}
}
}
}
return $templates;
}
/**
* Returns information about all recordings that belong to a specific
* meeting sco-id
*
* @param obj $aconnect a connect_class object
* @param int $folderscoid the recordings folder sco-id
* @param int $sourcescoid the meeting sco-id
*
* @return mixed array an array of object with the recording sco-id
* as the key and the recording properties as properties
*/
function aconnect_get_recordings($aconnect, $folderscoid, $sourcescoid) {
$params = array('action' => 'sco-contents',
'sco-id' => $folderscoid,
//'filter-source-sco-id' => $sourcescoid,
'sort-name' => 'asc',
);
// Check if meeting scoid and folder scoid are the same
// If hey are the same then that means that forced recordings is not
// enabled filter-source-sco-id should not be included. If the
// meeting scoid and folder scoid are not equal then forced recordings
// are enabled and we can use filter by filter-source-sco-id
// Thanks to A. gtdino
if ($sourcescoid != $folderscoid) {
$params['filter-source-sco-id'] = $sourcescoid;
}
$aconnect->create_request($params);
$recordings = array();
if ($aconnect->call_success()) {
$dom = new DomDocument();
$dom->loadXML($aconnect->_xmlresponse);
$domnodelist = $dom->getElementsByTagName('scos');
if (!empty($domnodelist->length)) {
// for ($i = 0; $i < $domnodelist->length; $i++) {
$innernodelist = $domnodelist->item(0)->getElementsByTagName('sco');
if (!empty($innernodelist->length)) {
for ($x = 0; $x < $innernodelist->length; $x++) {
if ($innernodelist->item($x)->hasAttributes()) {
$domnode = $innernodelist->item($x)->attributes->getNamedItem('sco-id');
if (!is_null($domnode)) {
$meetingdetail = $innernodelist->item($x);
$recordingvac9 = $innernodelist->item($x)->attributes->getNamedItem('duration');
$recordingvac8 = $meetingdetail->getElementsByTagName('duration')->item(0);
// Check if the SCO item is a recording or uploaded document. We only want to display recordings
if ((!is_null($recordingvac9) && $recordingvac9->nodeValue !== '') || !is_null($recordingvac8)) {
$j = (int) $domnode->nodeValue;
$value = (!is_null($meetingdetail->getElementsByTagName('name'))) ?
$meetingdetail->getElementsByTagName('name')->item(0)->nodeValue : '';
$recordings[$j]->name = (string) $value;
$value = (!is_null($meetingdetail->getElementsByTagName('url-path'))) ?
$meetingdetail->getElementsByTagName('url-path')->item(0)->nodeValue : '';
$recordings[$j]->url = (string) $value;
$value = (!is_null($meetingdetail->getElementsByTagName('date-begin'))) ?
$meetingdetail->getElementsByTagName('date-begin')->item(0)->nodeValue : '';
$recordings[$j]->startdate = (string) $value;
$value = (!is_null($meetingdetail->getElementsByTagName('date-end'))) ?
$meetingdetail->getElementsByTagName('date-end')->item(0)->nodeValue : '';
$recordings[$j]->enddate = (string) $value;
$value = (!is_null($meetingdetail->getElementsByTagName('date-created'))) ?
$meetingdetail->getElementsByTagName('date-created')->item(0)->nodeValue : '';
$recordings[$j]->createdate = (string) $value;
$value = (!is_null($meetingdetail->getElementsByTagName('date-modified'))) ?
$meetingdetail->getElementsByTagName('date-modified')->item(0)->nodeValue : '';
$recordings[$j]->modified = (string) $value;
$value = (!is_null($recordingvac9) ?
$recordingvac9->nodeValue : $recordingvac8->nodeValue);
$recordings[$j]->duration = (string) $value;
$recordings[$j]->sourcesco = (int) $sourcescoid;
}
}
}
}
}
// }
return $recordings;
} else {
return false;
}
} else {
return false;
}
}
/**
* Parses XML and returns the meeting sco-id
* @param string XML obtained from a sco-update call
*/
function aconnect_get_meeting_scoid($xml) {
$scoid = false;
$dom = new DomDocument();
$dom->loadXML($xml);
$domnodelist = $dom->getElementsByTagName('sco');
if (!empty($domnodelist->length)) {
if ($domnodelist->item(0)->hasAttributes()) {
$domnode = $domnodelist->item(0)->attributes->getNamedItem('sco-id');
if (!is_null($domnode)) {
$scoid = (int) $domnode->nodeValue;
}
}
}
return $scoid;
}
/**
* Update meeting
* @param obj $aconnect connect_class object
* @param obj $meetingobj an adobeconnect module object
* @param int $meetingfdl adobe connect meeting folder sco-id
* @return bool true if call was successful else false
*/
function aconnect_update_meeting($aconnect, $meetingobj, $meetingfdl) {
$params = array('action' => 'sco-update',
'sco-id' => $meetingobj->scoid,
'name' => htmlentities($meetingobj->name, ENT_COMPAT, 'UTF-8'),
'folder-id' => $meetingfdl,
// updating meeting URL using the API corrupts the meeting for some reason
// 'url-path' => '/'.$meetingobj->meeturl,
'date-begin' => $meetingobj->starttime,
'date-end' => $meetingobj->endtime,
);
$aconnect->create_request($params);
if ($aconnect->call_success()) {
return true;
} else {
return false;
}
}
/**
* Update a meeting's access permissions
* @param obj $aconnect connect_class object
* @param int $meetingscoid meeting sco-id
* @param int $perm meeting permission id
* @return bool true if call was successful else false
*/
function aconnect_update_meeting_perm($aconnect, $meetingscoid, $perm) {
$params = array('action' => 'permissions-update',
'acl-id' => $meetingscoid,
'principal-id' => 'public-access',
);
switch ($perm) {
case ADOBE_MEETPERM_PUBLIC:
$params['permission-id'] = 'view-hidden';
break;
case ADOBE_MEETPERM_PROTECTED:
$params['permission-id'] = 'remove';
break;
case ADOBE_MEETPERM_PRIVATE:
default:
$params['permission-id'] = 'denied';
break;
}
$aconnect->create_request($params);
if ($aconnect->call_success()) {
return true;
} else {
return false;
}
}
/** CONTRIB-1976, CONTRIB-1992
* This function adds a fraction of a second to the ISO 8601 date
* @param int $time unix timestamp
* @return mixed a string (ISO 8601) containing the decimal fraction of a second
* or false if it was not able to determine where to put it
*/
function aconnect_format_date_seconds($time) {
$newdate = false;
$date = date("c", $time);
$pos = strrpos($date, '-');
$length = strlen($date);
$diff = $length - $pos;
if ((0 < $diff) and (ADOBE_TMZ_LENGTH == $diff)) {
$firstpart = substr($date, 0, $pos);
$lastpart = substr($date, $pos);
$newdate = $firstpart . '.000' . $lastpart;
return $newdate;
}
$pos = strrpos($date, '+');
$length = strlen($date);
$diff = $length - $pos;
if ((0 < $diff) and (ADOBE_TMZ_LENGTH == $diff)) {
$firstpart = substr($date, 0, $pos);
$lastpart = substr($date, $pos);
$newdate = $firstpart . '.000' . $lastpart;
return $newdate;
}
return false;
}
/**
* Creates a meeting
* @param obj $aconnect connect_class object
* @param obj $meetingobj an adobeconnect module object
* @param int $meetingfdl adobe connect meeting folder sco-id
* @return mixed meeting sco-id on success || false on error
*/
function aconnect_create_meeting($aconnect, $meetingobj, $meetingfdl) {
//date("Y-m-d\TH:i
$starttime = aconnect_format_date_seconds($meetingobj->starttime);
$endtime = aconnect_format_date_seconds($meetingobj->endtime);
if (empty($starttime) or empty($endtime)) {
$message = 'Failure (aconnect_find_timezone) in finding the +/- sign in the date timezone'.
"\n".date("c", $meetingobj->starttime)."\n".date("c", $meetingobj->endtime);
debugging($message, DEBUG_DEVELOPER);
return false;
}
$params = array('action' => 'sco-update',
'type' => 'meeting',
'name' => htmlentities($meetingobj->name, ENT_COMPAT, 'UTF-8'),
'folder-id' => $meetingfdl,
'date-begin' => $starttime,
'date-end' => $endtime,
);
if (!empty($meetingobj->meeturl)) {
$params['url-path'] = $meetingobj->meeturl;
}
if (!empty($meetingobj->templatescoid)) {
$params['source-sco-id'] = $meetingobj->templatescoid;
}
$aconnect->create_request($params);
if ($aconnect->call_success()) {
return aconnect_get_meeting_scoid($aconnect->_xmlresponse);
} else {
return false;
}
}
/**
* Finds a matching meeting sco-id
* @param object $aconnect a connect_class object
* @param int $meetfldscoid Meeting folder sco-id
* @param array $filter array key is the filter and array value is the value
* (ex. array('filter-name' => 'meeting101'))
* @return mixed array of objects with sco-id as key and meeting name and url as object
* properties as value || false if not found or error occured
*/
function aconnect_meeting_exists($aconnect, $meetfldscoid, $filter = array()) {
$matches = array();
$params = array(
'action' => 'sco-contents',
'sco-id' => $meetfldscoid,
'filter-type' => 'meeting',
);
if (empty($filter)) {
return false;
}
$params = array_merge($params, $filter);
$aconnect->create_request($params);
if ($aconnect->call_success()) {
$dom = new DomDocument();
$dom->loadXML($aconnect->_xmlresponse);
$domnodelist = $dom->getElementsByTagName('scos');
if (!empty($domnodelist->length)) {
$innernodelist = $domnodelist->item(0)->getElementsByTagName('sco');
if (!empty($innernodelist->length)) {
for ($i = 0; $i < $innernodelist->length; $i++) {
if ($innernodelist->item($i)->hasAttributes()) {
$domnode = $innernodelist->item($i)->attributes->getNamedItem('sco-id');
if (!is_null($domnode)) {
$key = (int) $domnode->nodeValue;
$meetingdetail = $innernodelist->item($i);
$value = (!is_null($meetingdetail->getElementsByTagName('name'))) ?
$meetingdetail->getElementsByTagName('name')->item(0)->nodeValue : '';
if (!isset($matches[$key])) {
$matches[$key] = new stdClass();
}
$matches[$key]->name = (string) $value;
$value = (!is_null($meetingdetail->getElementsByTagName('url-path'))) ?
$meetingdetail->getElementsByTagName('url-path')->item(0)->nodeValue : '';
$matches[$key]->url = (string) $value;
$matches[$key]->scoid = (int) $key;
$value = (!is_null($meetingdetail->getElementsByTagName('date-begin'))) ?
$meetingdetail->getElementsByTagName('date-begin')->item(0)->nodeValue : '';
$matches[$key]->starttime = (string) $value;
$value = (!is_null($meetingdetail->getElementsByTagName('date-end'))) ?
$meetingdetail->getElementsByTagName('date-end')->item(0)->nodeValue : '';
$matches[$key]->endtime = (string) $value;
}
}
}
}
} else {
return false;
}
} else {
return false;
}
return $matches;
}
/**
* Parse XML and returns the user's principal-id
* @param string $xml XML returned from call to principal-list
* @param mixed user's principal-id or false
*/
function aconnect_get_user_principal_id($xml) {
$usrprincipalid = false;
$dom = new DomDocument();
$dom->loadXML($xml);
$domnodelist = $dom->getElementsByTagName('principal-list');
if (!empty($domnodelist->length)) {
$domnodelist = $domnodelist->item(0)->getElementsByTagName('principal');
if (!empty($domnodelist->length)) {
if ($domnodelist->item(0)->hasAttributes()) {
$domnode = $domnodelist->item(0)->attributes->getNamedItem('principal-id');
if (!is_null($domnode)) {
$usrprincipalid = (int) $domnode->nodeValue;
}
}
}
}
return $usrprincipalid;
}
/**
* Check to see if a user exists on the Adobe connect server
* searching by username
* @param object $aconnect a connection_class object
* @param object $userdata an object with username as a property
* @return mixed user's principal-id of match is found || false if not