I think both of your suggestions would be improvements to A2B, but they could use a little more work.
middletn wrote:
First, when the user is presented with options to divert the call, without the tech (SIP, IAX) the call would fail.
Code:
$tech_SIP_check="SIP/";
To save on memory I don't think there's any need to place the prefixes you're going to check into variables; just use literals. Also I believe the channel technology is case-sensitive so we can use the faster strpos() PHP function to match. It's quite possible other technologies like ZAP or H323 may be used. Like this perhaps:
Code:
if (strpos($dialstr,'SIP/')===FALSE && strpos($dialstr,'IAX2/')===FALSE && strpos($dialstr,'ZAP/')===FALSE &&
strpos($dialstr,'H323/')===FALSE && strpos($dialstr,'OH323/')===FALSE && strpos($dialstr,'Local/')===FALSE)
{
$dialstr = "SIP/".$dialstr;
}
Quote:
Second, if the last destination is the user's own phone, logic would dictate that this would be a good point to go to voicemail.
Are you sure you want to be using '$buddy="u".$this->destination;' rather than useralias or username as discussed
here.
I like your placement of it though, before all the other tests to minimize the duplication.
Razametal's post in the same thread to support voicemail when SIP friend calling could use the same treatment I think.
Added after 31 minutes: Actually even better code for the technology matching would probably look like:
Code:
$dialtech = explode('/', strtoupper($dialstr), -1); # grab everything before the first / and convert to upper case
if (!in_array($dialtech[0], array('SIP','IAX2','ZAP','H323','OH323','LOCAL','MISDN','SKINNY','MCGP')))
{
$dialstr = 'SIP/'.$dialstr;
}
Added after 19 minutes: Or probably quicker and definately less memory hungry without resorting to using a temporary array:
Code:
// ENSURE A VALID CHANNEL TECHNOLOGY IS PRESENT, OR DEFAULT TO SIP (thanks middletn)
if (!in_array(strtoupper(substr($dialstr, 0, strpos($dialstr,'/'))), array('SIP', 'IAX2', 'ZAP', 'H323', 'OH323', 'LOCAL', 'MISDN', 'SKINNY', 'MCGP')))
{
$dialstr = 'SIP/'.$dialstr;
}