Last active
March 15, 2022 15:08
-
-
Save lgaetz/6b528901e6746391369b79b371bdd71f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
/***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** | |
* | |
* Script: lg-presence.php | |
* | |
* FreePBX script to work with freepbx user presence states | |
* | |
* Latest version: https://gist.github.com/lgaetz/6b528901e6746391369b79b371bdd71f | |
* | |
* Usage: | |
* | |
* | |
* License: GNU/GPL3+ | |
* | |
* History: | |
* 2021-02-25 Basic methods POC, doesn't do anything | |
* 2021-03-01 Update comments, setStateByDevice bug fixed | |
* | |
* | |
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****/ | |
include '/etc/freepbx.conf'; | |
$FreePBX = FreePBX::Create(); | |
$debug=false; | |
// get all presence states defined on system | |
$AllStates=$FreePBX->Presencestate->getAllStates(); | |
print_r($AllStates); | |
// get presence state for all devices | |
$AllDevicesStates=$FreePBX->Presencestate->getAllDevicesStates(); | |
print_r($AllDevicesStates); | |
// get presence state for a single device | |
$DeviceState=$FreePBX->Presencestate->getStateByDevice("6003"); // pass device (ext?) number | |
print_r($DeviceState); | |
/* set single device state | |
* Set Presence State by Device | |
* @method setStateByDevice | |
* @param integer $device The device ID | |
* @param string $state The presence state state by index number, not by name | |
* @param string $message The message to override | |
*/ | |
$SetDeviceState=$FreePBX->Presencestate->setStateByDevice(6003,5,"optional message"); | |
print_r($SetDeviceState); // returns nothing | |
exit; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment