-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.inc.php
More file actions
1157 lines (1040 loc) · 46.2 KB
/
Copy pathlib.inc.php
File metadata and controls
1157 lines (1040 loc) · 46.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
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
/*
Copyright 2008,2009 - Peer Oliver Schmidt
GPLv2 Licensed
*/
error_reporting(E_ALL);
// connectToDCERouter();
global $possyDeviceFromID;
global $limit;
global $currentMediaPlayer;
$possyDeviceFromID = 1;
// $possyDeviceFromID = 45; // Proxy Orbiter
// $limit = " Limit 0,200";
$limit = "";
include_once("libMessageSend.php");
include_once("libVDR.php");
function lightinroom() {
// Returns an array of light devices in the current room
global $currentRoom, $link;
$deviceCategoryLights = 73;
$lights = getDeviceForDeviceCategoryInRoom($link, $deviceCategoryLights);
return $lights;
}
function getMediaStatusOld($room) {
// Checks the media players (Xine and MPlayer) if they have anything playing right now
global $currentMediaPlayer;
$remote = "";
$status ="";
$ipAddress = getMDIP($room);
if ($status == "") { $status = XineMplayerStatus($ipAddress,12000); }
if ($status == "") { $status = XineMplayerStatus($ipAddress,12010); }
if (pvrInstalled() == "VDR") {
if ($status == "") { $status = vdrStatus($ipAddress); }
} else if (pvrInstalled() == "MythTV") {
if ($status == "") { $status = mythTVStatus($ipAddress); }
}
if ($status <> "") {
$remote = "remote.php?type=$currentMediaPlayer";
$status = "<a href='$remote' title='$status'>$status</a>";
}
// $status .= "IP $ipAddress - Room $room<br>";
return $status;
}
function getMediaStatus($room) {
// Checks the media playing based on the JSON Plugin's now_playing information.
global $currentEntertainArea,$currentRoom, $currentUser, $link;
$status = "";
if (isset($_COOKIE["currentUser"])) { $currentUser = $_COOKIE["currentUser"]; }
if (isset($_COOKIE["currentRoom"])) { $currentRoom = $_COOKIE["currentRoom"]; }
if (isset($_GET["currentRoom"])) {
$currentRoom = $_GET["currentRoom"];
$_COOKIE["currentRoom"] = $currentRoom;
}
$currentEntertainArea = getEntertainArea($link,$currentRoom);
$url = "http://192.168.80.1:7230/now_playing?ea=" . $currentEntertainArea;
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$JSONresult=curl_exec($ch);
// Closing
curl_close($ch);
// Make a usable PHP array out of the JSON data
$result = json_decode($JSONresult, true);
$active = $result["active"];
if ($active) {
// JSON plugin returns the MediaType information, whereas iOrbiter differentiates
// between TV and AV remotes only, atm.
$currentMediaType = $result["media_type"];
if ($currentMediaType == "1") {
$currentMediaPlayer = "TV";
} else {
$currentMediaPlayer = "AV";
}
$status = $result["description"];
if ($result["sectiondescription"] != "") {
$status .= " - " . $result["sectiondescription"];
}
$remote = "remote.php?type=$currentMediaPlayer";
$status = "<a href='$remote' title='$status'>$status</a>";
}
return $status;
}
function pvrInstalled() {
// Returns the installed PVR based on the installed plugin
// 36 for MythTV Plugin
// 1704 for VDR Plugin
// If an id ten tea installs both, VDR wins :P
global $link;
$query = "SELECT PK_Device FROM Device WHERE FK_DeviceTemplate = 36;";
if (getMyValue($link,$query) != "") {
$pvrInstalled = "MythTV";
}
$query = "SELECT PK_Device FROM Device WHERE FK_DeviceTemplate = 1704;";
if (getMyValue($link,$query) != "") {
$pvrInstalled = "VDR";
}
return $pvrInstalled;
}
function mythTVStatus($ipAddress) {
global $currentMediaPlayer;
$port = 10001;
$status = "";
$output = "";
$exitCode = 0;
$errorNumber = 0;
$errorString = "";
$timeout = 3;
// We check if a mythfrontend process is running. If it is, we assume, MythTV is running
$currentMediaPlayer = "";
if (($ipAddress == "192.168.80.1") or ($ipAddress == "127.0.0.1")) {
// Checking if mythtv is running on the core
$retVal = exec("ps ax|grep mythfrontend|grep -v grep",$output,$exitCode);
if ($exitCode == 0) {
$currentMediaPlayer = "TV";
$status = "TV";
}
} else {
// Checking a mythfrontend running on an MD, we check for an open port at 10001
$oldStatus = error_reporting(E_ERROR);
$fp = fsockopen($ipAddress, $port, $errorNumber, $errorString, $timeout);
error_reporting($oldStatus);
if ($errorString <> "") {
return "";
}
$currentMediaPlayer = "TV";
$status="TV";
}
return $status;
}
function vdrStatus($ipAddress) {
global $currentMediaPlayer;
$port = 2001;
$status = "";
$output = "";
$exitCode = 0;
$errorNumber = 0;
$errorString = "";
$timeout = 3;
if (($ipAddress != "192.168.80.1") and ($ipAddress != "127.0.0.1")) {
$server = "ssh " . $ipAddress . " ";
} else {
$server = "";
}
// Checking a VDR running on the core, we check for a running vdr-sxfe process
$retVal = exec($server . "ps ax|grep vdr-sxfe|grep -v grep",$output,$exitCode);
if ($exitCode == 0) {
$currentMediaPlayer = "TV";
$status = "TV";
}
}
function xineMplayerStatus($ipAddress,$port) {
// Returns a string containing information about the currently playing media in Xine or MPlayer
$timeout = 5;
global $link, $mediaLink, $currentMediaPlayer;
$errorNumber = 0;
$errorString = "";
$oldStatus = error_reporting(E_ERROR);
$fp = fsockopen($ipAddress, $port, $errorNumber, $errorString, $timeout);
error_reporting($oldStatus);
if ($errorString <> "") {
return "";
}
stream_set_timeout($fp,$timeout);
$printed = 0;
if (($fp) and ($printed == 0)){
while ((!feof($fp)) And ($printed==0)) { // && (!$info['timed_out'])) {
if ($errorNumber != 0) {
print "Error $errorNumber - $errorString";
break;
}
$data = fgets($fp);
if (strlen($data) > 4) {
$tabelle = explode(",",$data);
$attribute = "";
$attributeSQL="SELECT Name FROM pluto_media.Attribute Join pluto_media.File_Attribute ON FK_Attribute = PK_Attribute";
$attributeSQL .= " WHERE FK_File = " . $tabelle[7];
$attributeSQL .= " AND FK_AttributeType = 13"; // Title
$attribute = GetMyValue($link,$attributeSQL);
if ($tabelle[0] == "0") {
$status='Pausing ';
} else {
$status='Playing ';
}
if ($attribute == "") {
$status .= $tabelle[8];
} else {
$status .= $attribute;
}
// print "<br>Geschwindigkeit: " . $tabelle[0];
// print "<br>Position: " . $tabelle[1];
//print "<br>Gesamt: " . $tabelle[2];
// print "<br>unbekannt: " . $tabelle[3];
//print "<br>unbekannt: " . $tabelle[4];
// print "<br>unbekannt: " . $tabelle[5];
// print "<br>unbekannt: " . $tabelle[6];
// print "<br>PK_File: " . $tabelle[7];
// print "<br>Path: " . $tabelle[8];
// if ($tabelle[7]+1 > 1) {
// print "<br>Wir haben jetzt eine PK_File Info";
// }
// print fgets($fp);
// ob_flush();
fclose($fp);
if ($port == 12000) {
$currentMediaPlayer = "AV-Xine";
} elseif ($port == 12010) {
$currentMediaPlayer = "AV-Mplayer";
} else {
$currentMediaPlayer = "AV-unknown";
}
return "$status";
}
$printed = 1;
fclose($fp);
return "";
}
} else {
return "";
}
}
function getMD($room = 0) {
// Return the device id of the MD in the current room
global $currentRoom,$link;
if ($room == 0) {
$room = $currentRoom;
}
$MD = getDeviceForTemplateInRoom(7);
if ($MD == "") {
$MD = getDeviceForTemplateInRoom(28);
}
// $queryMD="SELECT PK_Device FROM Device Where FK_Room = $room AND FK_DeviceTemplate in (7,28);";
// $MD = getMyValue($link,$queryMD);
return $MD;
}
function getMDIP($room = 0) {
// Return the IP address of the MD in the current room
global $currentRoom,$link;
if ($room == 0) {
$room = $currentRoom;
}
$queryMDIP="SELECT IPaddress FROM Device Where FK_Room = $room AND FK_DeviceTemplate in (7,28);";
$MDIP = getMyValue($link,$queryMDIP);
return $MDIP;
}
function getCurrentMediaDevice($room = 0) {
// Return the media device PK_Device of the currently playing device.
global $currentMediaPlayer, $link;
$currentMediaDevice = getDeviceForTemplate($link,2); // Media-Plugin receives all messages.
return $currentMediaDevice;
/* $listOfDevices=getMediaDevices($room);
if ($currentMediaPlayer == "AV-Xine") {
$currentMediaDevice = getDeviceForTemplateInRoom($link,5); // Get Xine Player Device
} elseif ($currentMediaPlayer == "AV-Mplayer") {
$currentMediaDevice = getDeviceForTemplateInRoom($link,1901); // Get Mplayer Device
} elseif ($currentMediaPlayer == "AV-unknown") {
$currentMediaDevice = getDeviceForTemplateInRoom($link,58); // We assume a SqueezeBox
} elseif ($currentMediaPlayer == "TV") {
if (pvrInstalled() == "VDR") {
$currentMediaDevice = getDeviceForTemplateInRoom($link,1705); // We assume a VDR device
} else if (pvrInstalled() == "MythTV") {
$currentMediaDevice = getDeviceForTemplateInRoom($link,35); // The MythTV player device
}
} else {
$currentMediaDevice = getDeviceForTemplate($link,2);
}
return $currentMediaDevice;
*/ }
function getMediaDevices($room = 0) {
// Return a list of Media playback devices in the current room
// At the moment we support
// 5 = Xine Player
// 1901 = MPlayer
// 58 = SqueezeBox
// 1705 = VDR
global $currentRoom,$link;
if ($room == 0) {
$room = $currentRoom;
}
$queryMediaDevices="SELECT PK_Device,FK_Device_Template FROM Device Where FK_Room = $room AND FK_DeviceTemplate in (5,1901,58,1705);";
$mediaDevices = getMyArray($link,$queryMediaDevices);
return $mediaDevices;
}
function sendPlayerCommand($room, $command, $parameter=0) {
global $possyDeviceFromID;
global $currentMediaPlayer;
// The media plugin needs to receive its messages from a device in the current room.
$possyDeviceFromID = getCurrentMD();
$status = getMediaStatus($room);
$socket = commStart("dcerouter",3450,$possyDeviceFromID);
// myMessageSend($socket,$deviceFromID,$deviceToID (10 == media plugin),$messageType,$messageID,$parameter1ID,$parameter1Content,$parameter2ID,$parameter2Content);
$file = fopen("/tmp/test.txt","w");
fwrite($file,"start\n");
// $destinationDevice = getCurrentMediaDevice($room);
$destinationDevice = getCurrentMediaDevice($room); // getDeviceForTemplate(2);
fwrite($file, "from device: $possyDeviceFromID\n");
fwrite($file, "destination device: $destinationDevice\n");
fwrite($file,"room: $room currentmp: $currentMediaPlayer myMessageSend($socket,$possyDeviceFromID,x-$destinationDevice-x,1,$command,". implode($parameter).");");
fclose($file);
// myMessageSend($socket,$possyDeviceFromID,getCurrentMediaDevice($room),1,$command); // ,13,'"' . $filePath . '"', 45, $currentEntertainArea);
myMessageSend($socket,$possyDeviceFromID,$destinationDevice,1,$command,$parameter); // ,13,'"' . $filePath . '"', 45, $currentEntertainArea);
commEnd($socket);
}
function sendCommand($destination, $command, $parameter=0) {
global $link;
// We send the messages from the MD/Hybrid device, instead of our usual
// device. Let's see, if lighting etc works.
$deviceFromID = getMD();
$socket = commStart("dcerouter",3450,$deviceFromID);
if (! is_array($parameter)) {
myMessageSend($socket,$deviceFromID,getDestinationDevice($link,$destination),1,$command); // ,13,'"' . $filePath . '"', 45, $currentEntertainArea);
} else {
myMessageSend($socket,$deviceFromID,getDestinationDevice($link,$destination),1,$command,$parameter);
}
commEnd($socket);
}
function playRecording($recordedFile) {
global $currentRoom,$link,$currentEntertainArea,$possyDeviceFromID;
$vdrServer = getMDIP();
/* $svdrp = new SVDRP($server = $vdrServer);
$svdrp->Command("LSTR");
$svdrp->Command("PLAY $recordedFile");
*/
exec("/usr/bin/svdrpsend -p 2001 -d " . $vdrServer . " LSTR >> /tmp/t");
exec("/usr/bin/svdrpsend -p 2001 -d " . $vdrServer . " PLAY " . $recordedFile . " >> /tmp/t");
}
function playFile($mediaLink, $pk_file) {
global $currentRoom,$link,$currentEntertainArea,$possyDeviceFromID;
/* print "entertain: $currentEntertainArea\n";
print "current room: $currentRoom\n";*/
$currentEntertainArea = getEntertainArea($link,$currentRoom);
// Get the path of the file to play, and call messagesend
// to play it in the current entertainment area
$queryFilePath = "SELECT Concat(Path,'/',Filename) From File Where PK_File = " . $pk_file . ";";
$filePath = getMyValue($mediaLink, $queryFilePath);
/* print "<li>$filePath</li>"; */
// commStart($server, $port, $deviceIDFrom)
$socket = commStart("dcerouter",3450,$possyDeviceFromID);
// myMessageSend($socket,$deviceFromID,$deviceToID (10 == media plugin),$messageType,$messageID,$parameter1ID,$parameter1Content,$parameter2ID,$parameter2Content);
myMessageSend($socket,$possyDeviceFromID,10,1,43,13,'"' . $filePath . '"', 45, $currentEntertainArea);
commEnd($socket);
}
function getEntertainArea($link, $room) {
$query = "SELECT PK_EntertainArea From EntertainArea Where FK_Room = $room";
$return = getMyValue($link,$query);
return $return;
}
function DoParameter29($mediaLink, $parameterValue, $commandGroup) {
// DoParameter29 is called, when ever a file listing needs to
// be presented.
if ($commandGroup == 77) {
buildFileList($mediaLink, $parameterValue);
} elseif ($commandGroup == 41 or $commandGroup == 43 or $commandGroup == 44) // Playlist, Pictures and Docs
{
buildFileList($mediaLink, $parameterValue);
} elseif ($commandGroup == 39 or $commandGroup = 40) // Audio and Video
{
// buildMediaSubTypes($mediaLink, $parameterValue);
buildSortByList($mediaLink, $parameterValue);
// buildFileList($mediaLink, $parameterValue);
} else
{
die("<li>No file listing for commandGroup $commandGroup setup</li>");
}
}
function datagrid($datagrid) {
if ($datagrid == 61) {
$array = getRecentCalls();
}
}
function getPicture($mediaLink, $PK_File) {
// Get a link to the picture associated with the supplied
// file.
$path = "/lmce-admin/mediapics/";
if ( ! file_exists("/var/www/" . $path) ) {
$path = "/pluto-admin/mediapics/";
}
$fileName = "";
$summary = "";
$query = "SELECT FK_Picture From Picture_File Where FK_File = $PK_File";
$fileName = getMyValue($mediaLink,$query);
// Next get the summary of the supplied file
$query = "SELECT Text From LongAttribute WHERE FK_AttributeType = 37 AND FK_File = $PK_File";
$summary = getMyValue($mediaLink,$query);
if ($fileName != "") {
print "<li>"; // style='height: 320px;'>";
print "<img style='float:left;' src='$path" . $fileName . "_tn.jpg' height='320px'>";
print "<p>$summary</p>";
print "</li>\n";
print "<li style='clear:left;'></li>\n";
} else if ($summary != "") {
print "<li>$summary";
print "</li>\n";
}
}
function orbiterDoVariation($link, $mainDesignObj, $currentRoom, $currentEntertainArea, $PK_UI = NULL, $isParent = false) {
// Get the description for the current variation, and the variation designobj containing all other
// objects of the page.
$mainDesignObjVariation = NULL;
$title = NULL;
if (Is_Null($PK_UI)) {
$UI = "FK_UI IS NULL";
$header = "Standard Variation";
} else {
$UI = "FK_UI = $PK_UI";
$header = getMyValue($link,"Select Description From UI Where PK_UI = $PK_UI");
}
// print "<h1>$header</h1>";
$query = "SELECT PK_DesignObjVariation FROM DesignObjVariation Where FK_DesignObj = $mainDesignObj AND $UI";
if (!is_null($mainDesignObj) and !is_null($UI)) {
$mainDesignObjVariation = getMyValue($link,$query);
}
//print "<pre>$UI mainDesignObjVariation $mainDesignObjVariation</pre>\n";
//print "<pre>mainDesignObj $mainDesignObj</pre>\n";
// If we can't find the main DesignObjVariation, we use the supplied designobj direct.
if (is_null($mainDesignObjVariation) or $isParent) {
print "<pre>Setting variation = $mainDesignObj</pre>";
$mainDesignObjVariation = $mainDesignObj;
}
// Try to get a title for the current screen
$query = "SELECT Screen.Description From Screen Where Screen.PK_Screen = (Select FK_Screen From Screen_DesignObj Where FK_DesignObj = $mainDesignObj);";
//print "<pre>$query</pre>";
if (!is_null($mainDesignObj)) {
$title = getMyValue($link,$query);
}
print "<ul id='$title'>\n";
// Each of the objects on the main menu needs to be fetched.
$query = "SELECT FK_DesignObj_Child FROM DesignObjVariation_DesignObj D Where FK_DesignObjVariation_Parent = $mainDesignObjVariation";
//print "<pre>$query</pre>";
if (!is_null($mainDesignObjVariation)) {
$array = getMyArray($link,$query);
// print_r($array);
// Get all screens objects for the current variation.
orbiterTakeCareOfObjects($link, $array, $currentRoom, $currentEntertainArea,$UI);
}
print "</ul>\n";
}
function doPower() {
global $currentScreen,$currentEntertainArea, $currentUser, $currentRoom;
$url = "design.php?currentRoom=$currentRoom¤tUser=$currentUser&CommandGroup_D";
print "<ul id='Power'>\n";
print "<li><a href='" . $url . "=7717'>Display On</a></li>\n";
print "<li><a href='" . $url . "=9803'>Power On</a></li>\n";
print "<li><a href='" . $url . "=7718'>Media Off</a></li>\n";
print "<li><a href='" . $url . "=7725'>Display Off</a></li>\n";
print "<li><a href='" . $url . "=7721'>Power Off</a></li>\n";
}
function doDesignObjVariations($designObjVariation, $link) {
global $currentScreen,$currentEntertainArea, $currentUser, $currentRoom;
$url = "design.php?currentRoom=$currentRoom¤tUser=$currentUser&CommandGroup";
$target = ""; // Set to self to start over. -> For example after room and user selection.
// How do I get to the CommandGroup_Room containing the list of lights?
$query = "SELECT Value FROM DesignObjVariation_DesignObjParameter ";
$query .= "Where FK_DesignObjVariation = $designObjVariation AND FK_DesignObjParameter = 11";
$PK_Array = getMyValue($link,$query);
// $PK_Array = 1;
// print "<ul><li>PK Array $PK_Array</li>\n";
if ($designObjVariation == 3332) {
doPower();
} elseif (! Isset($PK_Array)) {
print "<li><a href='$designObjVariation'>DesignObjVariation $designObjVariation</a></li>\n";
orbiterDoVariation($link, $designObjVariation,$currentRoom,$currentEntertainArea,$isParent = true);
// print "<ul id='Power'>\n";
// print "<li>not yet</li>\n";
} else {
$query = "SELECT Description FROM Array Where PK_Array = $PK_Array";
$buttonDescription = getMyValue($link,$query);
$buttonDescription = preg_replace("/ /","-",$buttonDescription);
print "<ul id='$buttonDescription'>\n";
// $buttonDescription = "Lighting Scenario";
If (in_array($PK_Array,array(1,2,3,4))) {
$query = "SELECT PK_CommandGroup, Description FROM CommandGroup ";
$query .= " JOIN CommandGroup_Room ON CommandGroup_Room.FK_CommandGroup = PK_CommandGroup ";
$query .= " WHERE FK_Array = $PK_Array AND FK_Room = $currentRoom";
} elseif ($PK_Array == 5) {
// Media Scenarios are not room based, but EntertainmentArea based
$query = "SELECT PK_CommandGroup, Description FROM CommandGroup ";
$query .= "JOIN CommandGroup_EntertainArea ON CommandGroup_EntertainArea.FK_CommandGroup = PK_CommandGroup ";
$query .= "WHERE FK_Array = $PK_Array AND CommandGroup_EntertainArea.FK_EntertainArea = $currentEntertainArea ";
$query .= "ORDER BY Sort";
} elseif ($PK_Array == 13) {
// List of users that are not hidden from the Orbiter
$target = " target='_self'";
$url = "setEnvironment.php?setCurrentUser";
$query = "SELECT PK_Users, UserName FROM Users ";
$query .= "Where HideFromOrbiter = 0";
} elseif ($PK_Array == 14) {
// List of rooms that are not hidden from the Orbiter
$target = " target='_self'";
$url = "setEnvironment.php?setCurrentRoom";
$query = "SELECT PK_Room, Description FROM Room ";
$query .= "Where HideFromOrbiter = 0";
} elseif ($PK_Array == 10) {
// List of Media Directors
$query = "SELECT PK_Room, concat('Reset ',Description) As Description From Room ";
$query .= "Where HideFromOrbiter = 0";
} else {
die("<p>Unknown PK_Array $PK_Array</p>\n");
}
$buttonArray = getMyArray($link,$query);
foreach($buttonArray as $buttonDetail) {
print "<li><a href='$url=$buttonDetail[0]' $target>$buttonDetail[1]</a></li>\n";
}
}
print "</ul>";
}
function orbiterTakeCareOfObjects($link, $array, $currentRoom, $currentEntertainArea,$UI) {
// This function takes all the objects in the array
// and displays interesting stuff about it. Creates links
// shows headings, etc.
global $currentUser;
foreach($array as $arrayEntry) {
$designObject = $arrayEntry[0];
$query = "SELECT FK_DesignObjType FROM DesignObj Where PK_DesignObj = $designObject";
$designObjType = getMyValue($link,$query);
print "<p>DesignObjType = $designObjType</p>";
If ($designObjType == 3) {
// Array
$query = "SELECT PK_DesignObjVariation FROM DesignObjVariation WHERE FK_DesignObj = $designObject AND $UI";
$designObjVariation = getMyValue($link,$query);
if (! is_null($designObjVariation)) {
doDesignObjVariations($designObjVariation,$link);
}
// If we are working on a specific UI, we need to include the Standard variation as well
if (is_null($designObjVariation) or $UI != "FK_UI IS NULL") {
$query = "SELECT PK_DesignObjVariation FROM DesignObjVariation WHERE FK_DesignObj = $designObject AND FK_UI IS NULL";
$designObjVariation = getMyValue($link,$query);
doDesignObjVariations($designObjVariation,$link);
}
} else {
// Other design types (than Array)
$query = "SELECT Description FROM DesignObj WHERE PK_DesignObj = $designObject";
$description = getMyValue($link,$query);
$query = "SELECT FK_DesignObjCategory FROM DesignObj WHERE PK_DesignObj = $designObject";
$designObjCategory = getMyValue($link,$query);
// Get the DesignObjVariation for the current UI
$query = "SELECT PK_DesignObjVariation FROM DesignObjVariation WHERE FK_DesignObj = $designObject AND $UI";
$designObjVariation = getMyValue($link,$query);
// If there is not DesignObjVariation for the currentUI, use the variation w/o a FK_UI
if ($UI != "FK_UI IS NULL") {
$query = "SELECT PK_DesignObjVariation FROM DesignObjVariation WHERE FK_DesignObj = $designObject AND FK_UI Is NULL";
$designObjVariation = getMyValue($link,$query);
}
print "<h3>$designObjType - $designObject - $description</h3>";
print "<h4>DesignObjCategory $designObjCategory</h4>\n";
print "<p>DesignObjVariation $designObjVariation</p>";
// Get the commandgroup that gets executed, when someone presses a button or selects an object in a datagrid.
$query = "SELECT FK_CommandGroup_D_OnActivate FROM DesignObjVariation D Where PK_DesignObjVariation = $designObjVariation";
$commandGroup_D_OnActivate = getMyValue($link,$query);
if (is_null($commandGroup_D_OnActivate) or $commandGroup_D_OnActivate == "" or $commandGroup_D_OnActivate == 0) {
// $query = "SELECT FK_CommandGroup
}
print "<a href='design.php?currentUser=$currentUser¤tRoom=$currentRoom&CommandGroup_D=$commandGroup_D_OnActivate'>$commandGroup_D_OnActivate</a>\n";
}
print "</p><hr></hr>\n";
}
}
function listMyArray($link, $query, $label, $groupByField=-1, $addAnEntry=-1, $refURL = '',$withUL = True) {
// listMyArrays displays the contents of a supplied array in a way, the UI can be interpreted.
// $link is the mysql link
// $query contains the query to be executed
// $label contains the prefix for ID to be used
// $groupByField can be set to a field which to group by all the links
// $addAnEntry can contain an array, allowing additional entries be stored into the linked list
// $refURL contains the URL to be executed with the IDs of the MySQL array
// $withUL can be set to false to disable the printing of the UL tag, for example because other
// stuff had already set the UL tag.
global $currentRoom, $currentUser;
$array = getMyArray($link, $query);
$oldGroup = "";
if ($withUL) {
print "<ul>\n";
}
if ($addAnEntry <> -1) {
print "<li class='group'>Commands</li>\n";
if (is_array($addAnEntry[0])) {
foreach ($addAnEntry as $addAnEntrySingle) {
print "<li id='$label"." $addAnEntrySingle[0]" . "'><a href='$addAnEntrySingle[2]¤tUser$currentUser¤tRoom=$currentRoom'>$addAnEntrySingle[1]</a></li>\n";
}
} else {
print "<li id='$label"." $addAnEntry[0]" . "'><a href='$addAnEntry[2]'>$addAnEntry[1]</a></li>\n";
}
}
foreach($array as $member) {
if ($groupByField >= 0) {
if ($oldGroup <> $member[$groupByField]) {
print "<li class='group'>$member[$groupByField]</li>";
$oldGroup = $member[$groupByField];
}
}
if ($refURL == '') {
$ref = $member[2];
} else {
$ref = $refURL . "$label=$member[0]";
}
print "<li id='$label"."_$member[0]" . "'><a href='$ref'>$member[1]</a></li>\n";
}
if ($withUL) {
print "</ul>\n";
}
}
function doGenres($mediaLink, $pk_mediatype = 5) {
// Display a UL of genres for the supplied mediatype
$query = "Select Distinct Attribute.Name, Attribute.Name From File_Attribute Join File On File.PK_File = File_Attribute.FK_File";
$query .= " Join Attribute On File_Attribute.FK_Attribute = Attribute.PK_Attribute";
$query .= " WHERE File.EK_MediaType = $pk_mediatype AND Attribute.FK_AttributeType = 8";
$query .= " ORDER BY Name";
listMyArray($mediaLink, $query, "Genre");
}
function buildSpeedDialList($link) {
// Get a list of speed dial scenarios for the current room
global $currentRoom, $currentUser;
$query = "SELECT CommandGroup.Description,FK_CommandParameter,IK_CommandParameter FROM CommandGroup";
$query .= " JOIN CommandGroup_Command ON CommandGroup_Command.FK_CommandGroup=PK_CommandGroup";
$query .= " JOIN CommandGroup_Command_CommandParameter ON FK_CommandGroup_Command=PK_CommandGroup_Command";
$query .= " JOIN CommandGroup_Room ON CommandGroup_Room.FK_CommandGroup=PK_CommandGroup";
$query .= " WHERE AutoGeneratedDate=0";
$query .= " AND FK_Array=4"; // ARRAY_Communication_Scenarios_CONST
$query .= " AND FK_Room=" . $currentRoom;
$query .= " ORDER BY PK_CommandGroup,FK_CommandParameter";
listMyArray($link,$query,"Speed Dial",-1,-1,"speeddial.php?currentUser=$currentUser¤tRoom=$currentRoom&");
}
function buildVoiceMailList() {
// Scan the voicemail dir of the current user, and return list of new and saved msgs.
global $currentUser, $currentRoom;
global $link;
$extension = getMyValue($link,"SELECT Extension From Users WHERE PK_Users = $currentUser");
$VOICEMAIL_EVENT = "/usr/pluto/bin/SendVoiceMailEvent.sh";
$VOICEMAIL_URL_PARAM = "/usr/pluto/bin/Voicemail_URL_Parm.php";
$VOICEMAIL_URL = "/recordings/misc/audio.php?recording=";
$voicemailUnread = "/var/spool/asterisk/voicemail/default/$extension";
$voicemailSaved = $voicemailUnread . "/Old";
}
function buildRecentCallList($link) {
global $currentUser, $currentRoom;
// Get a list of recent calls - We don't distinguish between users.
$query = "SELECT src, dst, calldate, billsec, channel FROM asteriskcdrdb.cdr";
$query .= " ORDER BY calldate DESC LIMIT 0,20";
listMyArray($link,$query,"Recent Calls",-1,-1,"call.php?currentUser=$currentUser¤tRoom=$currentRoom&");
}
function buildSortByList($mediaLink, $pk_mediatype) {
global $currentUser, $currentRoom;
// Get a list of Attributes to Sort by
$query = "SELECT Distinct PK_AttributeType, Description FROM MediaType_AttributeType ";
$query .= "JOIN AttributeType ON PK_AttributeType = FK_AttributeType ";
$query .= "where MediaSortOption is not null ";
if ($pk_mediatype == 5) {
$query .= "and EK_MediaType in (3,5) ";
} else {
$query .= "and EK_MediaType = $pk_mediatype ";
}
listMyArray($mediaLink,$query,"SortedBy",-1,-1,"findmore.php?currentUser=$currentUser¤tRoom=$currentRoom&mediaType=$pk_mediatype&");
}
function buildMediaSubTypes($mediaLink, $pk_mediatype = 5) {
global $currentUser, $currentRoom;
// Display a list of available media subtypes for the
// provided mediatype.
$query = "SELECT PK_MediaSubType, Description FROM MediaSubType ";
$query .= "JOIN MediaType_MediaSubType ON FK_MediaSubType = PK_MediaSubType ";
if ($pk_mediatype == 5) {
$query .= "AND EK_MediaType IN (3,5)";
} else {
$query .= "AND EK_MediaType = $pk_mediatype ";
}
listMyArray($mediaLink, $query, "Subtype",-1,-1,"findmore.php?currentUser=$currentUser¤tRoom=$currentRoom&");
}
function buildFileList($mediaLink, $pk_mediatype, $commandGroup = -1) {
global $currentUser, $currentRoom,$limit;
// Build a list of files that have the supplied media type. For Video we add MediaType 3 to it.
// the query should return
// 1) The ID
// 2) The name to display
// 3) The URL to call excluding the ID
// 4) The Group-By string.
if ($pk_mediatype == 5) // Video -> sort by filename
{
$query = "SELECT PK_File,Filename,concat('detail.php?currentUser=$currentUser¤tRoom=$currentRoom&PK_File=',PK_File) as Target,Substr(Filename,1,1) ";
$query .= "FROM pluto_media.File ";
$query .= "WHERE EK_MediaType in (3,5) AND EK_Users_Private IS NULL And EK_Device IS NOT NULL And IsDirectory = 0 And Missing = 0 ";
$query .= "ORDER By Filename ";
$query .= $limit;
} elseif ($pk_mediatype == 4) // Audio -> Sort by artist
{
$query = "SELECT PK_File,Filename,concat('detail.php?currentUser=$currentUser¤tRoom=$currentRoom&PK_File=',PK_File) as Target,Substr(Filename,1,1) ";
$query .= "FROM pluto_media.File ";
$query .= "WHERE EK_MediaType = $pk_mediatype AND EK_Users_Private IS NULL And EK_Device IS NOT NULL And IsDirectory = 0 And Missing = 0 ";
$query .= "ORDER By Filename ";
$query .= $limit;
} elseif ($pk_mediatype == 7) // Audio -> Sort by artist
{
$query = "SELECT PK_File,Filename,concat('detail.php?currentUser=$currentUser¤tRoom=$currentRoom&PK_File=',PK_File) as Target,Substr(Filename,1,1) ";
$query .= "FROM pluto_media.File ";
$query .= "WHERE EK_MediaType = $pk_mediatype AND EK_Users_Private IS NULL And EK_Device IS NOT NULL And IsDirectory = 0 And Missing = 0 ";
$query .= "ORDER By Filename ";
$query .= $limit;
} elseif ($pk_mediatype == 21) // Playlist
{
$query = "SELECT PK_Playlist,Name as Filename,concat('detail.php?currentUser=$currentUser¤tRoom=$currentRoom&PK_Playlist=',PK_Playlist) as Target,Substr(Name,1,1) ";
$query .= "FROM pluto_media.Playlist ";
$query .= "WHERE EK_User IS NULL Or EK_User = 0 ";
$query .= "ORDER By Name ";
$query .= $limit;
}
else
{
$query = "SELECT 0,'Media Type $pk_mediatype is currently unsupported' as Filename, '' As Target, ' ' As Heading";
}
listMyArray($mediaLink,$query,"File",3);
}
function buildFileListFromSortedBy($mediaLink, $pk_sortedby,$pk_media = 5) {
global $currentUser, $currentRoom, $limit;
// Build a list of files that have the supplied attribute.
// Get all attributes belonging to a specific media file.
$query = "SELECT Distinct PK_Attribute, Attribute.Name, AttributeType.Description FROM Attribute ";
$query .= "JOIN File_Attribute ON FK_Attribute = PK_Attribute ";
$query .= "JOIN AttributeType ON PK_AttributeType = FK_AttributeType ";
$query .= "JOIN File ON PK_File = FK_File ";
$query .= "WHERE FK_AttributeType = $pk_sortedby And Name <> \"*\" And Name <> \"-\" ";
$query .= "And IsDirectory = 0 And Missing = 0 AND EK_Users_Private Is Null ";
if ($pk_media == 5 or $pk_media == 3) {
$query .= "AND EK_MediaType in (3,5) ";
} else
{
$query .= "AND EK_MediaType = $pk_media ";
}
$query .= "Order By Attribute.Name ";
$query .= $limit;
listMyArray($mediaLink,$query,"Details",2,array($pk_sortedby,"Play All","play-all.php"),"findmore.php?currentUser=$currentUser¤tRoom=$currentRoom&mediaType=$pk_media&");
}
function buildFileListFromAttribute($mediaLink, $pk_attribute) {
global $currentUser, $currentRoom, $limit;
// Build a list of files that have the supplied attribute.
$query = "SELECT Distinct PK_File,Concat(TitleAttribute.Name,'-',EpisodeAttribute.Name,File.Filename) AS Description,";
$query .= "concat('detail.php?currentUser=$currentUser¤tRoom=$currentRoom&PK_File=',PK_File) as Target,";
$query .=" Substr(Filename,1,1) ";
$query .= "FROM pluto_media.File ";
$query .= "JOIN pluto_media.File_Attribute AS MainFA ON MainFA.FK_File = File.PK_File ";
$query .= "JOIN pluto_media.File_Attribute AS TitleFA ON TitleFA.FK_File = File.PK_File ";
$query .= " JOIN pluto_media.Attribute AS TitleAttribute ON TitleFA.FK_Attribute = TitleAttribute.PK_Attribute ";
$query .= "JOIN pluto_media.File_Attribute AS EpisodeFA ON EpisodeFA.FK_File = File.PK_File ";
$query .= " JOIN pluto_media.Attribute as EpisodeAttribute ON EpisodeFA.FK_Attribute = EpisodeAttribute.PK_Attribute ";
$query .= "WHERE EK_Users_Private IS NULL And IsDirectory = 0 And Missing = 0 ";
$query .= " AND MainFA.FK_Attribute = $pk_attribute ";
$query .= " AND TitleAttribute.FK_AttributeType = 13 "; // Title
$query .= " AND EpisodeAttribute.FK_AttributeType = 11 "; // Episode
$query .= " ORDER By Filename ";
// $query .= $limit;
listMyArray($mediaLink,$query,"File",3,array($pk_attribute,"Play All","play-all.php?where=FK_Attribute&content=$pk_attribute"));
}
function buildFileListFromSubtype($mediaLink, $pk_mediatype) {
global $currentUser, $currentRoom, $limit;
// Build a list of files that have the supplied attribute.
$query = "SELECT PK_File,Filename,concat('detail.php?currentUser=$currentUser¤tRoom=$currentRoom&PK_File=',PK_File) as Target,Substr(Filename,1,1) ";
$query .= "FROM pluto_media.File ";
$query .= "JOIN pluto_media.File_Attribute ON PK_File = FK_File ";
$query .= "WHERE EK_Users_Private IS NULL And IsDirectory = 0 And Missing = 0 And FK_Attribute = $pk_attribute ";
$query .= "ORDER By Filename ";
$query .= $limit;
listMyArray($mediaLink,$query,"File",3);
}
function buildAttributeList($mediaLink, $pk_file, $withUL = True) {
// Get all attributes belonging to a specific media file.
global $currentUser, $currentRoom;
$query = "SELECT Distinct PK_Attribute, Attribute.Name, AttributeType.Description FROM Attribute ";
$query .= "JOIN File_Attribute ON FK_Attribute = PK_Attribute ";
$query .= "JOIN AttributeType ON PK_AttributeType = FK_AttributeType ";
$query .= "WHERE File_Attribute.FK_File = $pk_file And Name <> \"*\" ";
$query .= "Order By (Description != \"Title\"),(Description != \"Performer\"), Description";
listMyArray($mediaLink,$query,"Details",2,array(
array($pk_file,"Play","play.php?currentUser=$currentUser¤tRoom=$currentRoom&pk_file=$pk_file"),
array($PK_file,"Play locally","play-locally.php?pk_file=$pk_file")
),
"findmore.php?currentUser=$currentUser¤tRoom=$currentRoom&",$withUL = $withUL);
}
function getMyValue($link,$query) {
$returnValue = array(1);
// Expects a query which returns a single field, and returns such field as a single variable
if (!($result = mysql_query($query,$link))) {
print "<p>Query without result: " . $query . "</p>\n";
} else {
$returnValue = mysql_fetch_array($result);
}
return $returnValue[0];
}
function getMyArray($link,$query) {
// Returns the result set as an array
$returnValue = array();
if (!($result = mysql_query($query,$link))) {
print "<p>Query without result: $query</p>\n";
}
while ($row = mysql_fetch_array($result)) {
array_push($returnValue,$row);
}
return $returnValue;
}
function doCommandGroup($link,$commandGroup) {
global $current, $mediaLink, $possyDeviceFromID;
$messageType = 1; // 1 = COMMAND, 2 = EVENT
$commandGroupDescription = getMyValue($link,"SELECT Description FROM CommandGroup WHERE PK_CommandGroup = $commandGroup");
// print "<h1>CommandGroup $commandGroup - $commandGroupDescription</h1>\n";
$query = "SELECT PK_CommandGroup_Command,FK_Command, FK_Device FROM CommandGroup_Command Where FK_CommandGroup = $commandGroup Order By OrderNum";
// print "<p>query: $query</p>\n";
// print "<ul>$commandGroupDescription</ul>\n";
$commands = getMyArray($link,$query);
$socket = commStart("dcerouter",3450,$possyDeviceFromID);
foreach($commands as $commandDetail) {
$messageToSend = "";
$destinationDeviceDescription = "";
$deviceToID = getDestinationDevice($link,$commandDetail[2]);
$messageID = $commandDetail[1];
$commandDescription = getMyValue($link,"SELECT Description FROM Command Where PK_Command = $messageID");
// print "<h2>Destination: $deviceToID - $destinationDeviceDescription</h2>\n";
// print "<h3>Command: $messageID - $commandDescription</h3>\n";
$commandGroupCommand = $commandDetail[0];
$parameters = getMyArray($link,"SELECT FK_CommandParameter, IK_CommandParameter FROM CommandGroup_Command_CommandParameter C Where FK_CommandGroup_Command = $commandGroupCommand");
$messageToSend = "$deviceToID $messageType $messageID";
// This loop is needed for commands with special needs, like the file listing for media playback.
foreach($parameters as $parameter) {
$parameterType = $parameter[0];
$parameterValue = $parameter[1];
$parameterDescription = getMyValue($link,"SELECT Description FROM CommandParameter C WHERE PK_CommandParameter = $parameterType");
$messageToSend = $messageToSend . " $parameterType \"$parameterValue\"";
if ($messageID == 741) {
// Goto Screen
if ($parameterType == 159) {
// PK_Screen
$currentScreen = $parameterValue;
// print "<li>Goto Screen: $currentScreen</li>\n";
}
if ($parameterType == 2) {
// DeviceID
$deviceIdParamter = $parameterValue;
// print "<li>Device ID: $deviceIdParamter</li>\n";
}
} elseif ($messageID == 401) {
if ($parameterType == 29) {
DoParameter29($mediaLink, $parameterValue, $commandGroup);
}
} else {
print "<li>messageID: $messageID</li>\n";
}
// print "<p>Parameter: $parameterType - $parameterDescription - $parameterValue</p>\n";
}
// 41 = TV
// 43 = Execute Playlist
// 44 = House to sleep
// 193 = Light Off
// 184 = Light On
//
// We send every message for the time being, and no longer limit us
// to known messages.
// $sendMessageArray = array(1 => 41, 43, 44, 193, 184);
// $found = array_search($messageID, $sendMessageArray);
// if ( ! $found) {
// Handled elsewhere.
// } else {
if ($currentScreen == 15) {
// Single Camera View
print "<ul>\n";
print "<li>"; // style='height: 320px;'>";
print "<img style='float:left;' src='/lmce-admin/viewCamera.php?cameraID=" . $deviceIdParamter . "' height='320px'>";
print "</li>\n";
print "<li style='clear:left;'></li>\n";
print "</ul>\n";
} else {
myMessageSend($socket, $possyDeviceFromID,$deviceToID,1,$messageID, $parameters);
}
}
commEnd($socket);
// fclose($socket);
}
function getDestinationDevice($link, $destinationDevice) {
if( $destinationDevice >= 0) {
$destinationDeviceDescription = getMyValue($link,"SELECT Description From Device Where PK_Device = $destinationDevice");
} elseif ($destinationDevice == -100) {
$destinationDevice = getDeviceForTemplate($link,1); // DCERouterDevice
} elseif ($destinationDevice == -101) {
$destinationDevice = getDeviceForTemplate($link,12); // Orbiter Plug-In
} elseif ($destinationDevice == -102) {
$destinationDevice = getDeviceForTemplate($link,9); // DataGrid Plug-In
} elseif ($destinationDevice == -103) {
$destinationDevice = getDeviceForTemplate($link,27); // GeneralInfoPlugin
} elseif ($destinationDevice == -104) {
$destinationDevice = getDeviceForTemplate($link,32); // LightingPlugin
} elseif ($destinationDevice == -105) {
$destinationDevice = getDeviceForTemplate($link,31); // ClimatePlugin
} elseif ($destinationDevice == -106) {
$destinationDevice = getDeviceForTemplate($link,2); // MediaPlugin
} elseif ($destinationDevice == -107) {
$destinationDevice = getDeviceForTemplate($link,34); // TelecomPlugin
} elseif ($destinationDevice == -108) {
$destinationDevice = getDeviceForTemplate($link,33); // SecurityPlugin
} elseif ($destinationDevice == -109) {
$destinationDevice = getDeviceForTemplate($link,52); // EventPlugin
} elseif ($destinationDevice == -110) {
$destinationDevice = getDeviceForTemplate($link,39); // InfraRedPlugin
} elseif ($destinationDevice == -111) {
$destinationDevice = getDeviceForTemplate($link,1809); // Plug And Play Interface
} elseif ($destinationDevice == -150) {
$destinationDevice = getDeviceForTemplateInRoom($link,26); // Local App Server
} elseif ($destinationDevice == -151) {
$destinationDevice = getDeviceForTemplateInRoom($link,28); // Local Media Director
} elseif ($destinationDevice == -152) {
$destinationDevice = getDeviceForTemplateInRoom($link,5); // Local Media Player
} elseif ($destinationDevice == -200) {
$destinationDevice = getDeviceForTemplateInRoom($link,28); // Media Director