Star2Billing/a2billing — Issue #18: asterisk_version isn't forward-compatible
Author: miken32
Created: 2012-02-10 00:24:41+00:00
State: open

Setting this to 1_8 or 1_10 will not have the desired effect, there are many places checking for 1_6 only. Since the setting is used to handle certain versions of Asterisk, this patch makes the code do that more sensibly.

```diff
--- AGI/a2billing.php	2011-05-31 12:39:39.000000000 -0700
+++ AGI/a2billing.php	2012-02-09 16:12:44.000000000 -0800
@@ -888,7 +888,7 @@

$uniqueid = MDP_NUMERIC(5).'-'.MDP_STRING(7);

-	$sep = ($A2B->config['global']['asterisk_version'] == "1_6")?',':'|';
+	$sep = ($A2B->config['global']['asterisk_version'] == "1_2" || $A2B->config['global']['asterisk_version'] == "1_4")?'|':',';

$variable = "IDCONF=$idconfig".$sep."CALLED=".$A2B ->destination.$sep.$CALLING_VAR.$sep.$MODE_VAR.$sep."CBID=$uniqueid".$sep."LEG=".$A2B -> username;

@@ -1032,7 +1032,7 @@

$uniqueid = MDP_NUMERIC(5).'-'.MDP_STRING(7);

-	$sep = ($A2B->config['global']['asterisk_version'] == "1_6")?',':'|';
+	$sep = ($A2B->config['global']['asterisk_version'] == "1_2" || $A2B->config['global']['asterisk_version'] == "1_4")?'|':',';

$variable = "IDCONF=$idconfig".$sep."CALLED=".$A2B ->destination.$sep."MODE=ALL".$sep."CBID=$uniqueid".$sep."TARIFF=".$A2B ->tariff.$sep."LEG=".$A2B -> username;

@@ -1374,7 +1374,7 @@
$account = $A2B -> accountcode;
$uniqueid = $callback_uniqueid.'-'.MDP_NUMERIC(5);

- $sep = ($A2B->config['global']['asterisk_version'] == "1_6")?',':'|';
+ $sep = ($A2B->config['global']['asterisk_version'] == "1_2" || $A2B->config['global']['asterisk_version'] == "1_4")?'|':',';

$variable = "CALLED=$inst_pn_member".$sep."CALLING=$inst_pn_member".$sep."CBID=$callback_uniqueid".$sep."TARIFF=$callback_tariff".$sep.
"LEG=".$A2B -> accountcode.$sep."ACCOUNTCODE=".$A2B -> accountcode.$sep."ROOMNUMBER=".$room_number;
--- common/lib/Class.A2Billing.php	2011-05-31 12:39:39.000000000 -0700
+++ common/lib/Class.A2Billing.php	2012-02-09 16:12:44.000000000 -0800
@@ -3566,7 +3566,7 @@
*/
function format_parameters ($parameters)
{
-	if ($this->agiconfig['asterisk_version'] == "1_6") {
+	if ($this->agiconfig['asterisk_version'] != "1_2" && $this->agiconfig['asterisk_version'] != "1_4") {
$parameters = str_replace("|", ',', $parameters);
}
return $parameters;
--- customer/callback.php	2011-05-31 12:39:39.000000000 -0700
+++ customer/callback.php	2012-02-09 16:12:44.000000000 -0800
@@ -157,10 +157,10 @@
$server_ip = 'localhost';
$num_attempt = 0;

-	if ($A2B->config['global']['asterisk_version'] == "1_6") {
-	$variable = "CALLED=$called,CALLING=$calling,CBID=$uniqueid,LEG=".$A2B->cardnumber;
-	} else {
+	if ($A2B->config['global']['asterisk_version'] == "1_2" || $A2B->config['global']['asterisk_version'] == "1_4") {
$variable = "CALLED=$called|CALLING=$calling|CBID=$uniqueid|LEG=".$A2B->cardnumber;
+	} else {
+	$variable = "CALLED=$called,CALLING=$calling,CBID=$uniqueid,LEG=".$A2B->cardnumber;
}

$QUERY = " INSERT INTO cc_callback_spool (uniqueid, status, server_ip, num_attempt, channel, exten, context, priority," .
--- webservice/SOAP/soap-callback-server.php	2011-05-31 12:39:39.000000000 -0700
+++ webservice/SOAP/soap-callback-server.php	2012-02-09 16:12:44.000000000 -0800
@@ -308,7 +308,7 @@
$server_ip = 'localhost';
$num_attempt = 0;

-	$sep = ($A2B->config['global']['asterisk_version'] == "1_6")?',':'|';
+	$sep = ($A2B->config['global']['asterisk_version'] == "1_2" || $A2B->config['global']['asterisk_version'] == "1_2")?'|':',';

$variable = "CALLED=$called".$sep."CALLING=$calling".$sep."CBID=$uniqueid".$sep."TARIFF=" . $A2B->tariff;
```