Skip to content

Commit

Permalink
fix(trunks page): fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Stell0 committed Dec 11, 2024
1 parent 867350c commit 2155f9a
Showing 1 changed file with 135 additions and 135 deletions.
270 changes: 135 additions & 135 deletions freepbx/var/www/html/freepbx/admin/modules/nethcti3/Nethcti3.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,144 +242,144 @@ public function genConfig() {
return $out;
}

// Add custom headers for trunks to trunks module
public static function myGuiHooks() {
return array("core", "INTERCEPT" => array("modules/core/page.trunks.php"));
}
// Add custom headers for trunks to trunks module
public static function myGuiHooks() {
return array("core", "INTERCEPT" => array("modules/core/page.trunks.php"));
}

public function doGuiHook($filename, &$output){}
public function doGuiHook($filename, &$output){}

public function doGuiIntercept($filename, &$output) {
# Show the custom field in the trunks module
if ($filename == "modules/core/page.trunks.php" && $_REQUEST['display'] == "trunks" && strtolower($_REQUEST['tech']) == "pjsip") {
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
$disable_topos_header = $this->getConfig('disable_topos_header', $trunkid);
$disable_srtp_header = $this->getConfig('disable_srtp_header', $trunkid);
$topos_section = '
<!--DISABLE TOPOS-->
<div class="element-container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label class="control-label" for="disable_topos_header">'._("Disable TOPOS proxy header").'</label>
<i class="fa fa-question-circle fpbx-help-icon" data-for="disable_topos_header"></i>
</div>
<div class="col-md-9 radioset">
<input type="radio" name="disable_topos_header" id="disable_topos_headeryes" value="yes" '.($disable_topos_header == 1?"CHECKED":"").'>
<label for="disable_topos_headeryes">'. _("Yes") .'</label>
<input type="radio" name="disable_topos_header" id="disable_topos_headerno" value="no" '.($disable_topos_header == 0 || empty($disable_topos_header) ? "CHECKED" : "").'>
<label for="disable_topos_headerno">'._("No").'</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span id="disable_topos_header-help" class="help-block fpbx-help-block">'. _("If yes, send topos=0 header to nethvoice-proxy to disable TOPOS for this trunk").'</span>
</div>
</div>
</div>
<!--END DISABLE TOPOS-->';
$disable_srtp_header_section = '
<!--DISABLE SRTP-->
<div class="element-container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label class="control-label" for="disable_srtp_header">'._("Disable SRTP proxy header").'</label>
<i class="fa fa-question-circle fpbx-help-icon" data-for="disable_srtp_header"></i>
</div>
<div class="col-md-9 radioset">
<input type="radio" name="disable_srtp_header" id="disable_srtp_headeryes" value="yes" '.($disable_srtp_header == 1?"CHECKED":"").'>
<label for="disable_srtp_headeryes">'. _("Yes") .'</label>
<input type="radio" name="disable_srtp_header" id="disable_srtp_headerno" value="no" '.($disable_srtp_header == 0 || empty($disable_srtp_header) ? "CHECKED" : "").'>
<label for="disable_srtp_headerno">'._("No").'</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span id="disable_srtp_header-help" class="help-block fpbx-help-block">'. _("If yes, send isTrunk=1 header to nethvoice-proxy to disable SRTP for this trunk").'</span>
</div>
</div>
</div>
<!--END DISABLE SRTP-->';
$output = str_replace('<!--END OUTBOUND PROXY-->','<!--END OUTBOUND PROXY-->'.$topos_section.$disable_srtp_header_section,$output);
}
}
public function doGuiIntercept($filename, &$output) {
# Show the custom field in the trunks module
if ($filename == "modules/core/page.trunks.php" && $_REQUEST['display'] == "trunks" && strtolower($_REQUEST['tech']) == "pjsip") {
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
$disable_topos_header = $this->getConfig('disable_topos_header', $trunkid);
$disable_srtp_header = $this->getConfig('disable_srtp_header', $trunkid);
$topos_section = '
<!--DISABLE TOPOS-->
<div class="element-container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label class="control-label" for="disable_topos_header">'._("Disable TOPOS proxy header").'</label>
<i class="fa fa-question-circle fpbx-help-icon" data-for="disable_topos_header"></i>
</div>
<div class="col-md-9 radioset">
<input type="radio" name="disable_topos_header" id="disable_topos_headeryes" value="yes" '.($disable_topos_header == 1?"CHECKED":"").'>
<label for="disable_topos_headeryes">'. _("Yes") .'</label>
<input type="radio" name="disable_topos_header" id="disable_topos_headerno" value="no" '.($disable_topos_header == 0 || empty($disable_topos_header) ? "CHECKED" : "").'>
<label for="disable_topos_headerno">'._("No").'</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span id="disable_topos_header-help" class="help-block fpbx-help-block">'. _("If yes, send topos=0 header to nethvoice-proxy to disable TOPOS for this trunk").'</span>
</div>
</div>
</div>
<!--END DISABLE TOPOS-->';
$disable_srtp_header_section = '
<!--DISABLE SRTP-->
<div class="element-container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="form-group">
<div class="col-md-3">
<label class="control-label" for="disable_srtp_header">'._("Disable SRTP proxy header").'</label>
<i class="fa fa-question-circle fpbx-help-icon" data-for="disable_srtp_header"></i>
</div>
<div class="col-md-9 radioset">
<input type="radio" name="disable_srtp_header" id="disable_srtp_headeryes" value="yes" '.($disable_srtp_header == 1?"CHECKED":"").'>
<label for="disable_srtp_headeryes">'. _("Yes") .'</label>
<input type="radio" name="disable_srtp_header" id="disable_srtp_headerno" value="no" '.($disable_srtp_header == 0 || empty($disable_srtp_header) ? "CHECKED" : "").'>
<label for="disable_srtp_headerno">'._("No").'</label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<span id="disable_srtp_header-help" class="help-block fpbx-help-block">'. _("If yes, send isTrunk=1 header to nethvoice-proxy to disable SRTP for this trunk").'</span>
</div>
</div>
</div>
<!--END DISABLE SRTP-->';
$output = str_replace('<!--END OUTBOUND PROXY-->','<!--END OUTBOUND PROXY-->'.$topos_section.$disable_srtp_header_section,$output);
}
}

public static function myConfigPageInits() {
return array("extensions", "recallonbusy", "trunks");
}
public static function myConfigPageInits() {
return array("extensions", "recallonbusy", "trunks");
}

public function doConfigPageInit($display) {
global $astman;
if ($display == "extensions" && !empty($_REQUEST['recallonbusy'])) {
// Save Recall On Busy option for the extension
$astman->database_put("ROBconfig",$_REQUEST['extdisplay'],$_REQUEST['recallonbusy']);
} elseif ($display == "recallonbusy") {
if (!empty($_REQUEST['default'])) {
$this->setConfig('default',$_REQUEST['default']);
}
if (!empty($_REQUEST['digit'])) {
$this->setConfig('digit',$_REQUEST['digit']);
}
needreload();
} elseif ($display == "trunks") {
global $db;
if ($_REQUEST['action'] == "edittrunk" && !empty($_REQUEST['extdisplay'])) {
if (!empty($_REQUEST['disable_topos_header'])) {
// save topos configuratino for the trunk on trunk edit
$disable_topos_header = $_REQUEST['disable_topos_header'] == "yes" ? 1 : 0;
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
$this->setConfig('disable_topos_header', $disable_topos_header, $trunkid);
}
if (!empty($_REQUEST['disable_srtp_header'])) {
// save srtp configuration for the trunk on trunk edit
$disable_srtp_header = $_REQUEST['disable_srtp_header'] == "yes" ? 1 : 0;
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
$this->setConfig('disable_srtp_header', $disable_srtp_header, $trunkid);
}
} elseif ($_REQUEST['action'] == "addtrunk") {
// Get the future trunk id
$sql = 'SELECT trunkid FROM trunks';
$sth = $db->prepare($sql);
$sth->execute();
$trunkid = 1;
while ($res = $sth->fetchColumn()) {
if ($res > $trunkid) {
break;
}
$trunkid++;
}
if ($res == $trunkid) {
$trunkid++;
}
if (!empty($_REQUEST['disable_topos_header'])){
// save topos configuration for the trunk on trunk add
$disable_topos_header = $_REQUEST['disable_topos_header'] == "yes" ? 1 : 0;
$this->setConfig('disable_topos_header', $disable_topos_header, $trunkid);
}
if (!empty($_REQUEST['disable_srtp_header'])){
// save srtp configuration for the trunk on trunk add
$disable_srtp_header = $_REQUEST['disable_srtp_header'] == "yes" ? 1 : 0;
$this->setConfig('disable_srtp_header', $disable_srtp_header, $trunkid);
}
} elseif ($_REQUEST['action'] == "deltrunk") {
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
// delete topos configuration for the trunk
$this->delConfig('disable_topos_header', $trunkid);
// delete srtp configuration for the trunk
$this->delConfig('disable_srtp_header', $trunkid);
}
}
public function doConfigPageInit($display) {
global $astman;
if ($display == "extensions" && !empty($_REQUEST['recallonbusy'])) {
// Save Recall On Busy option for the extension
$astman->database_put("ROBconfig",$_REQUEST['extdisplay'],$_REQUEST['recallonbusy']);
} elseif ($display == "recallonbusy") {
if (!empty($_REQUEST['default'])) {
$this->setConfig('default',$_REQUEST['default']);
}
if (!empty($_REQUEST['digit'])) {
$this->setConfig('digit',$_REQUEST['digit']);
}
needreload();
} elseif ($display == "trunks") {
global $db;
if ($_REQUEST['action'] == "edittrunk" && !empty($_REQUEST['extdisplay'])) {
if (!empty($_REQUEST['disable_topos_header'])) {
// save topos configuratino for the trunk on trunk edit
$disable_topos_header = $_REQUEST['disable_topos_header'] == "yes" ? 1 : 0;
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
$this->setConfig('disable_topos_header', $disable_topos_header, $trunkid);
}
if (!empty($_REQUEST['disable_srtp_header'])) {
// save srtp configuration for the trunk on trunk edit
$disable_srtp_header = $_REQUEST['disable_srtp_header'] == "yes" ? 1 : 0;
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
$this->setConfig('disable_srtp_header', $disable_srtp_header, $trunkid);
}
} elseif ($_REQUEST['action'] == "addtrunk") {
// Get the future trunk id
$sql = 'SELECT trunkid FROM trunks';
$sth = $db->prepare($sql);
$sth->execute();
$trunkid = 1;
while ($res = $sth->fetchColumn()) {
if ($res > $trunkid) {
break;
}
$trunkid++;
}
if ($res == $trunkid) {
$trunkid++;
}
if (!empty($_REQUEST['disable_topos_header'])){
// save topos configuration for the trunk on trunk add
$disable_topos_header = $_REQUEST['disable_topos_header'] == "yes" ? 1 : 0;
$this->setConfig('disable_topos_header', $disable_topos_header, $trunkid);
}
if (!empty($_REQUEST['disable_srtp_header'])){
// save srtp configuration for the trunk on trunk add
$disable_srtp_header = $_REQUEST['disable_srtp_header'] == "yes" ? 1 : 0;
$this->setConfig('disable_srtp_header', $disable_srtp_header, $trunkid);
}
} elseif ($_REQUEST['action'] == "deltrunk") {
$trunkid = str_replace("OUT_", "", $_REQUEST['extdisplay']);
// delete topos configuration for the trunk
$this->delConfig('disable_topos_header', $trunkid);
// delete srtp configuration for the trunk
$this->delConfig('disable_srtp_header', $trunkid);
}
}
}
}

0 comments on commit 2155f9a

Please sign in to comment.