# HG changeset patch # User Zoe Hong # Date 1426861978 -3600 # Node ID 5d0bfd909857ad986836c91d4a25863ca65faee7 # Parent bd46d26a7b18db65e457bfa1dc0bd7c5ff4dd6cf modify updating to sections_index table when deletion/recovery diff -r bd46d26a7b18 -r 5d0bfd909857 edit_section_db.php --- a/edit_section_db.php Fri Mar 20 11:32:06 2015 +0100 +++ b/edit_section_db.php Fri Mar 20 15:32:58 2015 +0100 @@ -176,6 +176,36 @@ $section_id = mysql_insert_id(); } + + if ($deleted == 1) { + // deleted section from sections_index where id = $section_id + $qry = "DELETE FROM sections_index WHERE id=".$section_id; + $rst = mysql_query($qry); + if (!$rst) { + break; // handle to ROLLBACK + } + + } else { + $qry = "SELECT * FROM sections_index WHERE id=".$section_id; + $rst = mysql_query($qry); + if (!$rst) { + break; // handle to ROLLBACK + } + if (mysql_num_rows($rst) == 0) { + $qry = "INSERT INTO sections_index (id,name,books_id,section_after,start_page,end_page,level,split_from) VALUES + (".$section_id.",'".$name."','".$books_id."','".$section_after."',".$start_page. + ",".$end_page.",".$level.",".$split_from.")"; + // recover section in sections_index table where id = $section_id + $rst = mysql_query($qry); + if (!$rst) { + break; // handle to ROLLBACK + } + } + + } + + // query for sections_revisions table + $str="("; $str.="'".$name."',"; $str.="'".$books_id."',"; diff -r bd46d26a7b18 -r 5d0bfd909857 js/check_sections_details.js --- a/js/check_sections_details.js Fri Mar 20 11:32:06 2015 +0100 +++ b/js/check_sections_details.js Fri Mar 20 15:32:58 2015 +0100 @@ -362,7 +362,12 @@ console.log("empty row: "+name+" -- "+startPage+" -- "+endPage); return; // "continue" in jquery } - if($(this).hasClass("deleted")){ deleted="TRUE";} + // bug fix: the type of deleted should be 'int' in database, 0 or 1, rather than TRUE + if($(this).hasClass("deleted")){ // deleted="TRUE"; + deleted = 1; + } else { + deleted = 0; + } var id=$(this).children(".hiddenInfo").children(".id").html(); var booksId=$(this).children(".hiddenInfo").children(".booksId").html(); var sectionAfter=$(this).children(".hiddenInfo").children(".sectionAfter").html()