/** * Deletes subnet and truncates all IP addresses in that subnet * * @access private * @param mixed $id * @return void */ private function subnet_delete($id) { # save old values $old_subnet = $this->fetch_subnet(null, $id); # first truncate it $this->subnet_truncate($id); # delete subnet try { $this->Database->deleteRow("subnets", "id", $id); } catch (Exception $e) { write_log("Subnet delete", "Failed to delete subnet {$old_subnet->name}<hr>" . $e->getMessage(), 2, $this->User->username); $this->Result->show("danger", _("Error: ") . $e->getMessage(), false); return false; } # ok write_log("Subnet delete", "Subnet {$old_subnet->name} deleted<hr>" . array_to_log($old_subnet), 0, $this->User->username); # write changelog write_changelog('subnet', "delete", 'success', array(), $old_subnet); return true; }
/** * Delete section, subsections, subnets and ip addresses * * @access private * @param mixed $values * @return void */ private function section_delete($values) { # subnets class $Subnets = new Subnets($this->Database); # save old values $old_section = $this->fetch_section("id", $values['id']); # check for subsections and store all ids $all_ids = $this->get_all_section_and_subsection_ids($values['id']); //array of section + all subsections # truncate and delete all subnets in all sections, than delete sections foreach ($all_ids as $id) { $section_subnets = $Subnets->fetch_section_subnets($id); if (sizeof($section_subnets) > 0) { foreach ($section_subnets as $ss) { //delete subnet $Subnets->modify_subnet("delete", array("id" => $ss->id)); } } # delete all sections try { $this->Database->deleteRow("sections", "id", $id); } catch (Exception $e) { write_log("Section {$old_section->name} delete", "Failed to delete section {$old_section->name}<hr>" . $e->getMessage() . "<hr>" . array_to_log($values), 2, $this->user->username); $this->Result->show("danger", _("Error: ") . $e->getMessage(), false); return false; } } # write changelog write_changelog('section', "delete", 'success', $old_section, array()); # log write_log("Section {$old_section->name} delete", "Section {$old_section->name} deleted<hr>" . array_to_log($old_section), 0, $this->user->username); return true; }