Revert "revert getMissedCalls, getTakenCalls and getDialedCalls for test reasons"
authorStricted <info@stricted.de>
Fri, 7 Aug 2015 04:49:39 +0000 (06:49 +0200)
committerStricted <info@stricted.de>
Fri, 7 Aug 2015 04:49:39 +0000 (06:49 +0200)
This reverts commit 87492136014cb8915f6c8d4a047ec095468299c4.

lib/trait/Phone.class.php

index b30571e055f06be266533fba54285997dc1db3b0..618b88c61a9fb1b8e38a9da7d3aa77ee0c7b2bb2 100644 (file)
@@ -108,25 +108,15 @@ trait Phone {
         * @return      array
         */
        public function getMissedCalls() {
-               $lines = $this->exportData('1');
-               $calls = array();
-               $c = count($lines) -2;
+               $data = $this->getData('PhoneCalls');
+               $data = $this->getValues($data);
                
-               foreach ($lines as $line) {
-                       if (empty($line) || strpos($line, 'Date') !== false) continue;
-                       
-                       $exp = explode(' ', $line);
-                       
-                       $data = array();
-                       $data['id'] = $c;
-                       $data['missedcalls_date'] = $exp[0];
-                       $data['missedcalls_time'] = $exp[1];
-                       $data['missedcalls_who'] = $exp[2];
-                       $c--;
-                       $calls[] = $data;
+               if (isset($data['addmissedcalls'])) {
+                       return $data['addmissedcalls'];
+               }
+               else {
+                       return array();
                }
-               
-               return $calls;
        }
        
        /**
@@ -135,27 +125,15 @@ trait Phone {
         * @return      array
         */
        public function getTakenCalls() {
-               $lines = $this->exportData('2');
-               $calls = array();
-               $c = count($lines) -2;
+               $data = $this->getData('PhoneCalls');
+               $data = $this->getValues($data);
                
-               foreach ($lines as $line) {
-                       if (empty($line) || strpos($line, 'Date') !== false) continue;
-                       
-                       $exp = explode(' ', $line);
-                       
-                       $data = array();
-                       $data['id'] = $c;
-                       $data['takencalls_date'] = $exp[0];
-                       $data['takencalls_time'] = $exp[1];
-                       $data['takencalls_who'] = $exp[2];
-                       $data['takencalls_duration'] = $exp[3];
-                       $c--;
-                       $calls[] = $data;
+               if (isset($data['addtakencalls'])) {
+                       return $data['addtakencalls'];
+               }
+               else {
+                       return array();
                }
-               
-               return $calls;
-               
        }
        
        /**
@@ -164,40 +142,14 @@ trait Phone {
         * @return      array
         */
        public function getDialedCalls() {
-               $lines = $this->exportData('3');
-               $calls = array();
-               $c = count($lines) -2;
-               
-               foreach ($lines as $line) {
-                       if (empty($line) || strpos($line, 'Date') !== false) continue;
-                       
-                       $exp = explode(' ', $line);
-                       
-                       $data = array();
-                       $data['id'] = $c;
-                       $data['dialedcalls_date'] = $exp[0];
-                       $data['dialedcalls_time'] = $exp[1];
-                       $data['dialedcalls_who'] = $exp[2];
-                       $data['dialedcalls_duration'] = $exp[3];
-                       $c--;
-                       $calls[] = $data;
+               $data = $this->getData('PhoneCalls');
+               $data = $this->getValues($data);
+
+               if (isset($data['adddialedcalls'])) {
+                       return $data['adddialedcalls'];
+               }
+               else {
+                       return array();
                }
-               
-               return $calls;
-       }
-       
-       /**
-        * export data from router
-        * 
-        * @return      array
-        */
-       private function exportData ($type) {
-               $this->checkLogin();
-               
-               $path = 'data/Syslog.json';
-               $fields = array('exporttype' => $type);
-               $data = $this->sentRequest($path, $fields, true);
-               
-               return explode("\n", $data['body']);
        }
 }