load call details on finished calls, too
authorChristian Weiske <cweiske@cweiske.de>
Sun, 12 Aug 2012 19:50:01 +0000 (21:50 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Sun, 12 Aug 2012 19:50:01 +0000 (21:50 +0200)
src/callnotifier/CallMonitor.php
src/callnotifier/CallMonitor/Detailler/CSV.php
src/callnotifier/CallMonitor/Detailler/LDAP.php
src/callnotifier/CallMonitor/Detailler/OpenGeoDb.php

index f55bfa7..4923967 100644 (file)
@@ -101,6 +101,9 @@ class CallMonitor
         case EDSS1_Message::RELEASE:
         case EDSS1_Message::RELEASE_COMPLETE:
             $call->end = time();
+            //we need to load details here because they might not have been
+            //loaded yet, e.g. for calls to MSNs that have no phones.
+            $this->loadCallDetails($call);
             $this->log->log('finishedCall', array('call' => $call));
             unset($this->currentCalls[$callId]);
             break;
index 2261169..ab881dd 100644 (file)
@@ -66,9 +66,13 @@ class CallMonitor_Detailler_CSV implements CallMonitor_Detailler
     public function loadCallDetails(CallMonitor_Call $call)
     {
         if ($call->type == CallMonitor_Call::INCOMING) {
-            $call->fromName = $this->loadName($call->from);
+            if (!isset($call->fromName) || $call->fromName === null) {
+                $call->fromName = $this->loadName($call->from);
+            }
         } else {
-            $call->toName = $this->loadName($call->to);
+            if (!isset($call->toName) || $call->toName === null) {
+                $call->toName = $this->loadName($call->to);
+            }
         }
     }
 
index 72fe07b..26599f4 100644 (file)
@@ -43,9 +43,13 @@ class CallMonitor_Detailler_LDAP implements CallMonitor_Detailler
     public function loadCallDetails(CallMonitor_Call $call)
     {
         if ($call->type == CallMonitor_Call::INCOMING) {
-            $call->fromName = $this->loadName($call->from);
+            if (!isset($call->fromName) || $call->fromName === null) {
+                $call->fromName = $this->loadName($call->from);
+            }
         } else {
-            $call->toName = $this->loadName($call->to);
+            if (!isset($call->toName) || $call->toName === null) {
+                $call->toName = $this->loadName($call->to);
+            }
         }
     }
 
index 8345128..46711b0 100644 (file)
@@ -58,9 +58,13 @@ class CallMonitor_Detailler_OpenGeoDb implements CallMonitor_Detailler
     public function loadCallDetails(CallMonitor_Call $call)
     {
         if ($call->type == CallMonitor_Call::INCOMING) {
-            $call->fromLocation = $this->loadLocation($call->from);
+            if (!isset($call->fromLocation) || $call->fromLocation === null) {
+                $call->fromLocation = $this->loadLocation($call->from);
+            }
         } else {
-            $call->toLocation = $this->loadLocation($call->to);
+            if (!isset($call->toLocation) || $call->toLocation === null) {
+                $call->toLocation = $this->loadLocation($call->to);
+            }
         }
     }