function save_section($connection) { $id = $_REQUEST['id']; $title = $_REQUEST['title']; $type = $_REQUEST['type']; $connection->begin_transaction(); if ($type == "TEXT" || $type == "JOIN" || $type == "MODS" || $type == "INTRO") { $text = $_REQUEST['text']; $insert_update_section_text_stmt = insert_update_section_text_stmt($connection); $insert_update_section_text_stmt->bind_param("iss", $id, $text, $text); catch_execution_error($insert_update_section_text_stmt->execute(), $connection); if ($type == "JOIN" || $type == "MODS") { $button_text = $_REQUEST['buttonText']; $insert_update_section_button_text_stmt = insert_update_section_button_text_stmt($connection); $insert_update_section_button_text_stmt->bind_param("iss", $id, $button_text, $button_text); catch_execution_error($insert_update_section_button_text_stmt->execute(), $connection); } update_section($connection, $id, $type, $title); if ($type != "JOIN" && $type != "MODS") { remove_section_button_text($connection, $id); } remove_section_images($connection, $id); remove_section_youtubes($connection, $id); } else { update_section($connection, $id, $type, $title); remove_section_text($connection, $id); remove_section_button_text($connection, $id); } $connection->commit(); print '[["SUCCESS"],["Section saved successfully"]]'; }
function del_section($connection) { $id = $_REQUEST['id']; $connection->begin_transaction(); if (is_section_referenced($connection, $id)) { print '[["ERROR"],["Can not remove section, section is referenced in a Navigation Item"]]'; exit; } else { remove_section_text($connection, $id); remove_section_button_text($connection, $id); remove_section_images($connection, $id); remove_section_youtubes($connection, $id); $delete_section_stmt = delete_section_stmt($connection); $delete_section_stmt->bind_param("i", $id); catch_execution_error($delete_section_stmt->execute(), $connection); $connection->commit(); print '[["SUCCESS"],["Successfully removed section"]]'; } }