Returns whether a menu name already exists.
function menu_edit_menu_name_exists($value) {
// 'menu-' is added to the menu name to avoid name-space conflicts.
$value = 'menu-' . $value;
$custom_exists = db_query_range('SELECT 1 FROM {menu_custom} WHERE menu_name = :menu', 0, 1, array(
':menu' => $value,
))
->fetchField();
$link_exists = db_query_range("SELECT 1 FROM {menu_links} WHERE menu_name = :menu", 0, 1, array(
':menu' => $value,
))
->fetchField();
return $custom_exists || $link_exists;
}