all loggers support call type and MSN filtering now
[auerswald-callnotifier.git] / src / callnotifier / Logger / CallFile.php
index ba45137d41b3ccd9f0c52f99a5957151f469f885..12a5b08f2548eb128a3638a719a4a7b4b0f84188 100644 (file)
@@ -5,8 +5,6 @@ class Logger_CallFile extends Logger_CallBase
 {
     protected $file;
     protected $fileHdl;
-    protected $callTypes;
-    protected $msns;
 
     /**
      * Create a new file call logger. It logs finished calls into a file.
@@ -45,22 +43,10 @@ class Logger_CallFile extends Logger_CallBase
         }
 
         $call = $arData['call'];
-
-        //check if call type matches
-        if ($call->type == CallMonitor_Call::INCOMING && $this->callTypes == 'o') {
+        if (!$this->hasValidType($call)) {
             return;
         }
-        if ($call->type == CallMonitor_Call::OUTGOING && $this->callTypes == 'i') {
-            return;
-        }
-
-        if ($call->type == CallMonitor_Call::INCOMING) {
-            $msn = $call->to;
-        } else {
-            $msn = $call->from;
-        }
-        if (count($this->msns) > 0 && !in_array($msn, $this->msns)) {
-            //msn shall not be logged
+        if (!$this->hasValidMsn($call)) {
             return;
         }
 
@@ -74,18 +60,10 @@ class Logger_CallFile extends Logger_CallBase
         $str = date('Y-m-d H:i:s', $call->start);
         if ($call->type == CallMonitor_Call::INCOMING) {
             $str .= ' ' . $call->to
-                . ' von  ' . $call->fromName;
-            if ($call->fromLocation) {
-                $str .= ' aus ' . $call->fromLocation;
-            }
-            $str .= ' ' . $this->getNumber($call->from);
+                . ' von  ' . $this->getNumberString($call, 'from');
         } else {
             $str .= ' ' . $call->from
-                . ' nach ' . $call->toName;
-            if ($call->toLocation) {
-                $str .= ' aus ' . $call->toLocation;
-            }
-            $str .= ' ' . $this->getNumber($call->to);
+                . ' nach ' . $this->getNumberString($call, 'to');
         }
 
         $str .= ', Dauer ' . date('H:i:s', $call->end - $call->start - 3600);
@@ -93,14 +71,6 @@ class Logger_CallFile extends Logger_CallBase
         return $str . "\n";
     }
 
-    protected function getNumber($number)
-    {
-        if ($number == '') {
-            $number = '*anonym*';
-        }
-        return str_pad($number, 12, ' ', STR_PAD_RIGHT);
-    }
-
 }
 
 ?>