Skip to content

Commit

Permalink
User CALLERID(pres) instead of CALLERPRES() when using Asterisk 18 or…
Browse files Browse the repository at this point in the history
… higher
  • Loading branch information
asternic committed Nov 8, 2024
1 parent c2d693f commit 53b46dc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
35 changes: 30 additions & 5 deletions core/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,7 @@ function core_do_get_config($engine) {
$ast_lt_161 = version_compare($version, '1.6.1', 'lt');
$ast_ge_162 = version_compare($version, '1.6.2', 'ge');
$ast_ge_10 = version_compare($version, '10', 'ge');
$ast_ge_18 = version_compare($version, '18', 'ge');

if (isset($core_conf) && is_a($core_conf, "core_conf")) {
$section = 'asterisk';
Expand Down Expand Up @@ -2339,7 +2340,11 @@ function core_do_get_config($engine) {
if ($ast_lt_16) {
$ext->add($context, $exten, '', new ext_setvar('__CALLINGPRES_SV','${CALLINGPRES_${CALLINGPRES}}'));
} else {
$ext->add($context, $exten, '', new ext_setvar('__CALLINGPRES_SV','${CALLERPRES()}'));
if($ast_ge_18) {
$ext->add($context, $exten, '', new ext_setvar('__CALLINGPRES_SV','${CALLERID(pres)}'));
} else {
$ext->add($context, $exten, '', new ext_setvar('__CALLINGPRES_SV','${CALLERPRES()}'));
}
}
$ext->add($context, $exten, '', new ext_setcallerpres('allowed_not_screened'));
}
Expand Down Expand Up @@ -2543,7 +2548,11 @@ function core_do_get_config($engine) {
if ($ast_lt_16) {
$ext->add($tcontext,$trunkprops['trunkid'],'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'SetCallerPres', '${CALLINGPRES_SV}'));
} else {
$ext->add($tcontext,$trunkprops['trunkid'],'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}'));
if($ast_ge_18) {
$ext->add($tcontext,$trunkprops['trunkid'],'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERID(pres)=${CALLINGPRES_SV}'));
} else {
$ext->add($tcontext,$trunkprops['trunkid'],'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}'));
}
}
$ext->add($tcontext,$trunkprops['trunkid'],'',new ext_set('DIAL_NUMBER','${FROM_DID}'));
$ext->add($tcontext,$trunkprops['trunkid'],'',new ext_gosubif('$["${PREFIX_TRUNK_'.$trunkprops['trunkid'].'}" != ""]','sub-flp-'.$trunkprops['trunkid'].',s,1'));
Expand Down Expand Up @@ -2594,7 +2603,11 @@ function core_do_get_config($engine) {
if ($ast_lt_16) {
$ext->add($tcontext,$tcustom,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'SetCallerPres', '${CALLINGPRES_SV}'));
} else {
$ext->add($tcontext,$tcustom,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}'));
if($ast_ge_18) {
$ext->add($tcontext,$tcustom,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERID(pres)=${CALLINGPRES_SV}'));
} else {
$ext->add($tcontext,$tcustom,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}'));
}
}
$ext->add($tcontext,$tcustom,'',new ext_set('DIAL_NUMBER','${FROM_DID}'));
$ext->add($tcontext,$tcustom,'',new ext_gosubif('$["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""]','sub-flp-${DIAL_TRUNK},s,1'));
Expand All @@ -2618,7 +2631,11 @@ function core_do_get_config($engine) {
if ($ast_lt_16) {
$ext->add($tcontext,$texten,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'SetCallerPres', '${CALLINGPRES_SV}'));
} else {
if($ast_ge_18) {
$ext->add($tcontext,$texten,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERID(pres)=${CALLINGPRES_SV}'));
} else {
$ext->add($tcontext,$texten,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}'));
}
}
$ext->add($tcontext,$texten,'',new ext_set('DIAL_NUMBER','${FROM_DID}'));
$ext->add($tcontext,$texten,'',new ext_gosubif('$["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""]','sub-flp-${DIAL_TRUNK},s,1'));
Expand Down Expand Up @@ -4056,7 +4073,11 @@ function core_do_get_config($engine) {
if ($ast_lt_16) {
$ext->add($context, $exten, '', new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'SetCallerPres', '${CALLINGPRES_SV}'));
} else {
$ext->add($context, $exten, '', new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}'));
if($ast_ge_18) {
$ext->add($context, $exten, '', new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERID(pres)=${CALLINGPRES_SV}'));
} else {
$ext->add($context, $exten, '', new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}'));
}
}

// Keep the original CallerID number, for failover to the next trunk.
Expand Down Expand Up @@ -4097,7 +4118,11 @@ function core_do_get_config($engine) {
if ($ast_lt_16) {
$ext->add($context, $exten, 'hidecid', new ext_execif('$["${CALLERID(name)}"="hidden"]', 'SetCallerPres', 'prohib_passed_screen'));
} else {
$ext->add($context, $exten, 'hidecid', new ext_execif('$["${CALLERID(name)}"="hidden"]', 'Set', 'CALLERPRES()=prohib_passed_screen'));
if($ast_ge_18) {
$ext->add($context, $exten, 'hidecid', new ext_execif('$["${CALLERID(name)}"="hidden"]', 'Set', 'CALLERID(pres)=prohib_passed_screen'));
} else {
$ext->add($context, $exten, 'hidecid', new ext_execif('$["${CALLERID(name)}"="hidden"]', 'Set', 'CALLERPRES()=prohib_passed_screen'));
}
}
// $has_keepcid_cnum is checked and set when the globals are being generated above
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,11 @@ function output() {
if (version_compare($version, "1.6", "lt")) {
return "SetCallerPres({$this->data})";
} else {
return "Set(CALLERPRES()={$this->data})";
if (version_compare($version, "18", "ge")) {
return "Set(CALLERID(pres)={$this->data})";
} else {
return "Set(CALLERPRES()={$this->data})";
}
}
}
}
Expand Down

0 comments on commit 53b46dc

Please sign in to comment.