Skip to content

Commit

Permalink
FREEPBX-15972 fix issues in local.ch
Browse files Browse the repository at this point in the history
  • Loading branch information
bhoeneis authored and tm1000 committed Oct 13, 2017
1 parent 49a6b3e commit 8b0e5ee
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sources/source-LocalTel_CH.module
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class LocalTel_CH extends superfecta_base {
//Define vars
$caller_id = null;

$thenumber = str_replace(' ', "00", $thenumber);

//Check the number format
if ((!$this->IsValidNumber('CH', $thenumber)))
{
Expand Down Expand Up @@ -55,12 +57,13 @@ class LocalTel_CH extends superfecta_base {
if(array_key_exists('entry', $array))
{
//Check if there are multiple results
if(isset($array['entry'][0]))
if(isset($array['entry'][1]))
{
$this->DebugPrint("Multiple results found, I took the first one");
//Set callerid
if(empty($array['entry'][0]['title']) || !$caller_id = $array['entry'][0]['title'])
if(empty($array['entry'][1]['title']) || !$caller_id = $array['entry'][1]['title'])
{
$this->DebugPrint(var_export($array) . " /M " );
$this->DebugPrint('Could not parse xml-response from tel.search.ch');
$caller_id = null;
}
Expand All @@ -69,8 +72,9 @@ class LocalTel_CH extends superfecta_base {
{
//Single result, set callerid
$this->DebugPrint("Entry found, try to set callerid:");
if(empty($array['entry'][0]['title']) || !$caller_id = $array['entry'][0]['title'])
if(empty($array['entry']['title']) || !$caller_id = $array['entry']['title'])
{
$this->DebugPrint(var_export($array) . " /S " );
$this->DebugPrint('Could not parse xml-response from tel.search.ch');
$caller_id = null;
}
Expand All @@ -79,6 +83,7 @@ class LocalTel_CH extends superfecta_base {
else
{
//Return empty Callerid
$this->DebugPrint(var_export($array) . " / " );
$this->DebugPrint("not found");
return $caller_id = null;
}
Expand Down

0 comments on commit 8b0e5ee

Please sign in to comment.