Commit 6665dda6 authored by Robert Anderson's avatar Robert Anderson
Browse files

Merged and fixed date



Change-Id: Ia420b2c8911fdbdab7dd79e38b1e5610a7b7d58e
Signed-off-by: default avatarRobert Anderson <randerson@lbsd.net>
parent 92274415
<?php
# Module: Policy delete
# Copyright (C) 2009-2011, AllWorldIT
# Copyright (C) 2009-2012, AllWorldIT
# Copyright (C) 2008, LinuxRulz
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
......@@ -50,7 +50,7 @@ if ($_POST['frmaction'] == "delete") {
<input type="hidden" name="frmaction" value="delete2" />
<input type="hidden" name="policy_id" value="<?php echo $_POST['policy_id']; ?>" />
</div>
<div class="textcenter">
Are you very sure? <br />
<input type="submit" name="confirm" value="yes" />
......@@ -63,50 +63,112 @@ if ($_POST['frmaction'] == "delete") {
<div class="warning">No policy selected</div>
<?php
}
# SQL Updates
} elseif ($_POST['frmaction'] == "delete2") {
?>
<p class="pageheader">Policy Delete Results</p>
<?php
if (isset($_POST['policy_id'])) {
if ($_POST['confirm'] == "yes") {
if ($_POST['confirm'] == "yes") {
$db->beginTransaction();
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policy_members WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res !== FALSE) {
if ($res === FALSE) {
?>
<div class="notice">Policy members deleted</div>
<div class="warning">Error clearing policy_members!</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
} else {
}
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}greylisting WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
<div class="warning">Error deleting policy members!</div>
<div class="warning">Error clearing greylisting!</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
$db->rollback();
}
if ($res !== FALSE) {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policies WHERE ID = ".$db->quote($_POST['policy_id']));
if ($res) {
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}access_control WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
<div class="warning">Error clearing access_control </div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
}
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}checkspf WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
<div class="notice">Policy deleted</div>
<div class="warning">Error clearing checkspf!</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
} else {
}
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}checkhelo WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
<div class="warning">Error deleting policy!</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<div class="warning">Error clearing checkhelo!</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
$db->rollback();
}
# Grab quotas we need to delete
$quotas_to_delete = array();
foreach ($db->query("SELECT ID FROM ${DB_TABLE_PREFIX}quotas WHERE PolicyID = ".$db->quote($_POST['policy_id'])) as $row) {
array_push($quotas_to_delete, $row['id']);
}
# Proceed if we actually have quotas
if (count($quotas_to_delete) > 0) {
$quotas_to_delete = implode(",",$quotas_to_delete);
# Grab limits we need to delete
$limits_to_delete = array();
foreach ($db->query("SELECT ID FROM ${DB_TABLE_PREFIX}quotas_limits WHERE QuotasID IN (".$quotas_to_delete.")") as $row) {
array_push($limits_to_delete, $row['id']);
}
# Proceed if we actually have limits
if (count($limits_to_delete) > 0) {
$limits_to_delete = implode(",",$limits_to_delete);
# Do delete of quotas
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}quotas_tracking WHERE QuotasLimitsID IN (".$limits_to_delete.")");
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}quotas_limits WHERE ID IN (".$limits_to_delete.")");
}
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}quotas WHERE ID IN (".$quotas_to_delete.")");
}
# Grab accounting we need to delete
$accounting_to_delete = array();
foreach ($db->query("SELECT ID FROM ${DB_TABLE_PREFIX}accounting WHERE PolicyID = ".$db->quote($_POST['policy_id'])) as $row) {
array_push($accounting_to_delete, $row['id']);
}
if ($res) {
# Proceed if we actually have accounting
if (count($accounting_to_delete) > 0) {
$accounting_to_delete = implode(",",$accounting_to_delete);
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}accounting_tracking WHERE AccountingID IN (".$accounting_to_delete.")");
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}accounting WHERE ID IN (".$accounting_to_delete.")");
}
# Main policy
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policies WHERE ID = ".$db->quote($_POST['policy_id']));
if ($res !== FALSE) {
?>
<div class="notice">Policy deleted</div>
<?php
$db->commit();
} else {
?>
<div class="warning">Error deleting policy!</div>
<div class="warning"><?php print_r($db->errorInfo()) ?></div>
<?php
$db->rollback();
}
} else {
?>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment