$obj_chart = new chart(); /* Load POST Data */ $obj_chart->id = @security_form_input_predefined("int", "id_chart", 1, ""); // these exist to make error handling work right $data["code_chart"] = @security_form_input_predefined("any", "code_chart", 0, ""); $data["description"] = @security_form_input_predefined("any", "description", 0, ""); // confirm deletion $data["delete_confirm"] = @security_form_input_predefined("any", "delete_confirm", 1, "You must confirm the deletion"); /* Error Handling */ // make sure the chart actually exists if (!$obj_chart->verify_id()) { log_write("error", "process", "The account you have attempted to edit - " . $obj_chart->id . " - does not exist in this system."); } // make sure chart is safe to delete if ($obj_chart->check_delete_lock()) { log_write("error", "process", "The account can not be deleted because it is locked."); } // return to the input page in event of an error if ($_SESSION["error"]["message"]) { $_SESSION["error"]["form"]["chart_delete"] = "failed"; header("Location: ../../index.php?page=accounts/charts/delete.php&id=" . $obj_chart->id); exit(0); } /* Delete Account */
function delete_chart($id) { log_debug("charts", "Executing delete_chart_details({$id}, values...)"); if (user_permissions_get("accounts_charts_write")) { $obj_chart = new chart(); /* Load SOAP Data */ $obj_chart->id = @security_script_input_predefined("int", $id); if (!$obj_chart->id || $obj_chart->id == "error") { throw new SoapFault("Sender", "INVALID_INPUT"); } /* Error Handling */ // verify chart ID if (!$obj_chart->verify_id()) { throw new SoapFault("Sender", "INVALID_ID"); } // check that the chart can be safely deleted if ($obj_chart->check_delete_lock()) { throw new SoapFault("Sender", "LOCKED"); } /* Perform Changes */ if ($obj_chart->action_delete()) { return 1; } else { throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR"); } } else { throw new SoapFault("Sender", "ACCESS DENIED"); } }