add deletePhoneBookEntry
authorStricted <info@stricted.de>
Sun, 26 Jul 2015 17:40:44 +0000 (19:40 +0200)
committerStricted <info@stricted.de>
Sun, 26 Jul 2015 17:40:44 +0000 (19:40 +0200)
SpeedportHybrid.class.php

index c5eed35e850573b5a07bbcb24ed87e22282dedfd..1c0e18f30fcb50d4308bed5eacacbc0e2ce3b2ec 100644 (file)
@@ -271,6 +271,8 @@ class SpeedportHybrid {
         * @return      array
         */
        public function addPhoneBookEntry ($name, $firstname, $private, $work, $mobile, $id = -1) {
+               $this->checkLogin();
+               
                $path = 'data/PhoneBook.json';
                $fields = array(
                                                'csrf_token' => $this->getToken(),
@@ -280,12 +282,12 @@ class SpeedportHybrid {
                                                'phonebook_vorname' => $firstname,
                                                'phonebook_number_p' => $private,
                                                'phonebook_number_a' => $work,
-                                               'phonebook_number_m' => $mobile,
-                                               'action' => '1'
+                                               'phonebook_number_m' => $mobile
                                                );
                
                $data = $this->sentRequest($path, $fields, true);
                $data = $this->getValues($data['body']);
+               
                if ($data['status'] == 'ok') {
                        return $data;
                }
@@ -310,6 +312,36 @@ class SpeedportHybrid {
                return $this->addPhoneBookEntry($name, $firstname, $private, $work, $private, $id);
        }
        
+       /**
+        * delete Phone Book Entry
+        *
+        * @param       integer $id
+        *
+        * @return      array
+        */
+       public function deletePhoneBookEntry ($id) {
+               $this->checkLogin();
+               
+               $path = 'data/PhoneBook.json';
+               $fields = array(
+                                               'csrf_token' => $this->getToken(),
+                                               'id' => $id,
+                                               'deleteEntry' => 'delete'
+                                               );
+               
+               $data = $this->sentRequest($path, $fields, true);
+               $data = $this->getValues($data['body']);
+               print_r($data);
+               
+               if ($data['status'] == 'ok') {
+                       return $data;
+               }
+               else {
+                       throw new RouterException('can not delete Phone Book Entry');
+               }
+               
+       }
+       
        /**
         * get uptime based on online (connection) time
         *