Skip to content

Commit

Permalink
feat(trunks): automate disable_topos management in wizard
Browse files Browse the repository at this point in the history
- Automatically set the `disable_topos` value for trunks created via the wizard.
- Remove the `disable_topos` value when a trunk is deleted via the wizard.
- Added a new MySQL table to store default `disable_topos` values.
- If no default `disable_topos` value is specified, TOPOS are enabled by default
  • Loading branch information
Stell0 committed Dec 2, 2024
1 parent e5fdae4 commit e81a5dd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions freepbx/var/www/html/freepbx/rest/modules/trunks.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
$trunkid = $route->getArgument('trunkid');
try {
FreePBX::Core()->deleteTrunk($trunkid);
// Delete disable_topos configuration for this trunk
FreePBX::Nethcti3()->delConfig('disable_topos', $trunkid);
system('/var/www/html/freepbx/rest/lib/retrieveHelper.sh > /dev/null &');
return $response->withStatus(200);
} catch (Exception $e) {
Expand Down Expand Up @@ -333,6 +335,13 @@
if (!$res) {
return $response->withStatus(500);
}
// Set topos flag if needed
$sql = "SELECT `value` FROM `rest_pjsip_trunks_custom_flags` WHERE `keyword` = 'disable_topos' AND `provider_id` IN (SELECT `id` FROM `rest_pjsip_providers` WHERE `provider` = ?)";
$sth = $dbh->prepare($sql);
$sth->execute([$params['provider']]);
$disable_topos = $sth->fetchColumn()[0];
Freepbx::Nethcti3()->setConfig('disable_topos', $disable_topos, $trunkid);

system('/var/www/html/freepbx/rest/lib/retrieveHelper.sh > /dev/null &');
return $response->withStatus(200);
});

0 comments on commit e81a5dd

Please sign in to comment.