array(
"Back to policies" => "policy-main.php",
),
));
# Display delete confirm screen
if ($_POST['frmaction'] == "delete") {
# Check a policy was selected
if (isset($_POST['policy_id'])) {
?>
No policy selected
beginTransaction();
$res = $db->exec("DELETE FROM ${DB_TABLE_PREFIX}policy_members WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
Error clearing policy_members!
errorInfo()) ?>
exec("DELETE FROM ${DB_TABLE_PREFIX}greylisting WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
Error clearing greylisting!
errorInfo()) ?>
exec("DELETE FROM ${DB_TABLE_PREFIX}access_control WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
Error clearing access_control
errorInfo()) ?>
exec("DELETE FROM ${DB_TABLE_PREFIX}checkspf WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
Error clearing checkspf!
errorInfo()) ?>
exec("DELETE FROM ${DB_TABLE_PREFIX}checkhelo WHERE PolicyID = ".$db->quote($_POST['policy_id']));
if ($res === FALSE) {
?>
Error clearing checkhelo!
errorInfo()) ?>
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']);
}
# 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) {
?>
Policy deleted
commit();
} else {
?>
Error deleting policy!
errorInfo()) ?>
rollback();
}
} else {
?>
Policy not deleted, aborted by user
Invocation error, no policy ID
Invalid invocation