Exemplo n.º 1
0
 /** 
  * delete subnet 
  */
 public function deleteSubnets()
 {
     //init subnet class
     $subnet = new Subnet();
     //provide id
     $subnet->id = $this->_params['id'];
     //delete also IPs?
     if (isset($this->_params['addresses'])) {
         if ($this->_params['addresses'] == false) {
             $subnet->addresses = false;
         } else {
             $subnet->addresses = true;
         }
     } else {
         $subnet->addresses = true;
     }
     //fetch results
     $res = $subnet->deleteSubnet();
     //return subnet(s) in array format
     return $res;
 }
Exemplo n.º 2
0
 /**
  *	delete Section
  *		id must be provided
  *
  *		we must also delete all subnets and all IP addresses!
  */
 public function deleteSection()
 {
     //check input
     $this->Common->check_var("int", $this->id, null);
     //verify that it exists
     try {
         $this->readSection();
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     //do we need to delete also subnets?
     if ($this->subnets) {
         $Subnet = new Subnet();
         # get all belonging subnets
         $Subnet->sectionId = $this->id;
         $Subnet->addresses = $this->addresses;
         //flag to delete also IPs
         try {
             $allsubnets = $Subnet->readSubnet();
         } catch (Exception $e) {
             # empty?
             if (substr($e->getMessage(), 0, 32) == "Invalid section Id or no subnets") {
             } else {
                 throw new Exception($e->getMessage());
             }
         }
         # loop
         if (sizeof($allsubnets) > 0) {
             foreach ($allsubnets as $s) {
                 # provide id and parameters
                 $Subnet->id = $s['id'];
                 $Subnet->deleteSubnet();
             }
         }
     }
     //set query and execute
     $this->query = "delete from `sections` where `id` = " . $this->id . ";";
     $this->executeQuery();
     //set result
     $result['result'] = "success";
     $result['response'] = "section " . $this->id . " deleted successfully!";
     //return result
     return $result;
 }