diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..9933a58 --- /dev/null +++ b/config.ini @@ -0,0 +1,4 @@ +target_extensions = 334,338 +list_filter_type = whitelist +extension_list = 404,911 +blacklisted_terms = vestibule, inpatient diff --git a/extensions.ini b/extensions.ini deleted file mode 100644 index 6ec6126..0000000 --- a/extensions.ini +++ /dev/null @@ -1 +0,0 @@ -extensions = 334,338 diff --git a/gen_pc_sidecar.php b/gen_pc_sidecar.php index 723f9f3..4297d41 100755 --- a/gen_pc_sidecar.php +++ b/gen_pc_sidecar.php @@ -5,15 +5,15 @@ $bootstrap_settings['freepbx_auth'] = false; require_once('/etc/freepbx.conf'); function main(): void { + $TARGET_EXTENSIONS = "target_extensions"; $provision_dir = '/tftpboot'; $argv = $_SERVER['argv'] ?? []; $do_notify = in_array('--notify', $argv, true); - $pbdb = trim_db(pull_db()); - $ext_list = read_extension_ini(); + $ext_list = read_config_ini($TARGET_EXTENSIONS); $mac_list = pull_mac_list(); foreach ($ext_list as $ext) { @@ -64,6 +64,8 @@ function pull_db(): array { } function trim_db($pbdb): array { + $BLACKLISTED_TERMS = "blacklisted_terms"; + $pbdb_prepend = [ [ 'name' => 'Night Hours', 'extension' => '*271', ], [ 'name' => 'Overhead Page', 'extension' => '900', ], @@ -73,11 +75,8 @@ function trim_db($pbdb): array { ]; array_unshift($pbdb, ...$pbdb_prepend); - - $remove_names = [ - 'inpatient', - 'vestibule' - ]; + + $remove_names = read_config_ini($BLACKLISTED_TERMS); $filtered = array_filter($pbdb, function ($item) use ($remove_names) { if (!is_array($item) || !isset($item['name'])) { @@ -114,9 +113,9 @@ function pull_mac_list(): array { return array_column($mac_db, 'mac', 'ext'); } -function read_extension_ini(): array { - $extensions = parse_ini_file('extensions.ini'); - $ext_list = array_map('intval', explode(',', $extensions['extensions'])); +function read_config_ini($CONFIG_KEY): array { + $extensions = parse_ini_file('config.ini'); + $ext_list = array_map('intval', explode(',', $extensions[$CONFIG_KEY])); return $ext_list; }