Last active
April 7, 2022 14:26
-
-
Save lgaetz/ff7d6806c798086e144396d275f7a8ab 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 | |
if (!isset($argv[1])){ | |
echo " | |
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** | |
* | |
* Script: lgaetz-fmfm.php | |
* | |
* Latest version: https://gist.github.com/lgaetz/ff7d6806c798086e144396d275f7a8ab | |
* | |
* Usage: Run at bash prompt of FreePBX system running FreePBX 13+ with single argument | |
* of extension to display whether FMFM is enabled for the extension. Use optional command | |
* as second argument to change | |
* | |
* # lgaetz-fmfm.php 3002 [command] | |
* | |
* Commands: | |
* enable - if disabled, enable for provided extension | |
* disable - if enabled, disable for provided extension | |
* toggle - either enable or disable depending on current state | |
* list - show all FMFM details | |
* | |
* License: GNU/GPL3+ | |
* | |
* History: | |
* 2017-11-18 First commit by lgaetz | |
* 2020-04-06 Covid-19 Quarantine update - added improvements suggested by https://gist.github.com/t-oster | |
* | |
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** | |
"; | |
exit; | |
} | |
// user params | |
$verbose = true; // set to false to diable all console output | |
// include FreePBX bootstrap environment | |
include '/etc/freepbx.conf'; | |
$FreePBX = FreePBX::Create(); | |
$device=$FreePBX->Findmefollow->get($argv[1],true); | |
// print_r($device); // uncomment for dbug | |
// get current fmfm status | |
if (array_key_exists ("ddial",$device)){ | |
if($device[ddial]=="CHECKED"){ | |
$fmfm=false; | |
} elseif($device[ddial]=="") { | |
$fmfm=true; | |
} | |
} else { | |
// prob an invalid extension | |
verbose_output("Invalid extenion - exiting"); | |
exit; | |
} | |
switch ($argv[2]) { | |
case "enable": | |
if (!$fmfm) { | |
$FreePBX->Findmefollow->setDDial($argv[1], true); | |
verbose_output("FMFM changed to enabled"); | |
} else { | |
verbose_output("FMFM already enabled - no change"); | |
} | |
break; | |
case "disable": | |
if ($fmfm) { | |
$FreePBX->Findmefollow->setDDial($argv[1], false); | |
verbose_output("FMFM changed to diabled"); | |
} else { | |
verbose_output("FMFM already diabled - no change"); | |
} | |
break; | |
case "toggle": | |
if ($fmfm){ | |
$FreePBX->Findmefollow->setDDial($argv[1], false); | |
verbose_output("FMFM changed to diabled"); | |
} else { | |
$FreePBX->Findmefollow->setDDial($argv[1], true); | |
verbose_output("FMFM changed to enabled"); | |
} | |
break; | |
case "list": | |
print_r($device); | |
break; | |
default: // maintain compatibility for previous version | |
if(!$fmfm){ | |
verbose_output("FMFM disabled"); | |
} elseif($device[ddial]=="") { | |
verbose_output("FMFM enabled"); | |
} | |
} | |
function verbose_output($string) { | |
global $quiet, $verbose; | |
if (!$quiet && $verbose) { | |
echo $string."\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See this thread for fix