require_once "resources/check_auth.php";
if (permission_exists('ivr_menu_delete')) {
    //access granted
} else {
    echo "access denied";
    exit;
}
//add multi-lingual support
$language = new text();
$text = $language->get();
//get the id
if (count($_GET) > 0) {
    $id = check_str($_GET["id"]);
}
if (strlen($id) > 0) {
    //include the ivr menu class
    require_once "resources/classes/database.php";
    require_once "resources/classes/ivr_menu.php";
    $ivr = new ivr_menu();
    $ivr->domain_uuid = $_SESSION["domain_uuid"];
    $ivr->ivr_menu_uuid = $id;
    $ivr->delete();
    //synchronize the xml config
    save_dialplan_xml();
    //clear the cache
    $cache = new cache();
    $cache->delete("dialplan:" . $_SESSION["context"]);
}
//redirect the user
$_SESSION['message'] = $text['message-delete'];
header("Location: ivr_menus.php");