$visibility = 'b_visibility = "' . intval($_POST["visibility"][$i]) . '",'; } else { // By default, Private. $visibility = 'b_visibility = "0",'; } if (!empty($_POST['rating'][$i])) { $rating = 'b_rating = "' . intval($_POST["rating"][$i]) . '",'; } if (!empty($_POST['review'][$i])) { $review = 'b_review = "' . $wpdb->escape($_POST["review"][$i]) . '",'; } if (!empty($_POST['image'][$i])) { $image = 'b_image = "' . $wpdb->escape($_POST['image'][$i]) . '",'; } if (!empty($_POST['tags'][$i])) { set_book_tags($id, $_POST['tags'][$i]); } $current_status = $wpdb->get_var("\r\r\n\t\t\tSELECT b_status\r\r\n\t\t\tFROM {$wpdb->prefix}now_reading\r\r\n\t\t\tWHERE b_id = {$id}\r\r\n "); // If the book is currently "unread" but is being changed to "reading", and the user didn't set a started date, we need to add a b_started value. if ($current_status == 'unread' && $status == 'reading' && empty($started)) { $started = 'b_started = "' . date('Y-m-d H:i:s') . '",'; } else { $started = "b_started = '{$started}',"; } // If the book is currently "reading" but is being changed to "read", and the user didn't set a finished date, we need to add a b_finished value. if ($current_status == 'reading' && $status == 'read' && empty($finished)) { $finished = 'b_finished = "' . date('Y-m-d H:i:s') . '",'; } else { $finished = "b_finished = '{$finished}',"; } $query = "\r\r\n\t\t\tUPDATE {$wpdb->prefix}now_reading\r\r\n\t\t\tSET\r\r\n {$started}\r\r\n {$finished}\r\r\n {$rating}\r\r\n {$review}\r\r\n {$image}\r\r\n {$post}\r\r\n\t\t\t\t{$post_op}\r\r\n\t\t\t\t{$visibility}\r\r\n\t\t\t\tb_author = '{$author}',\r\r\n\t\t\t\tb_asin = '{$asin}',\r\r\n\t\t\t\tb_title = '{$title}',\r\r\n\t\t\t\tb_nice_author = '{$nice_author}',\r\r\n\t\t\t\tb_nice_title = '{$nice_title}',\r\r\n\t\t\t\tb_status = '{$status}',\r\r\n\t\t\t\tb_added = '{$added}'\r\r\n\t\t\tWHERE\r\r\n\t\t\t\tb_id = {$id}\r\r\n ";
/** * Tags the book with the given tag. */ function tag_book( $id, $tag ) { return set_book_tags($id, $tag, true); }