exit; break; // TRACK // TRACK case "get_track": $track = new WT_Track($_POST["track_id"]); if (!empty($_POST["track_id"])) { $track->retrieve(); } else { $track->defaults(); } echo json_encode($track->db_out(null, 0)); break; case "insert_track": $track = new WT_Track(); $track->insert($_POST); $track->db_response("json"); break; case "update_track": $track = new WT_Track($_POST["track_id"]); $track->update($_POST); $track->db_response("json"); break; case "quickupdate_track": $track = new WT_Track($_POST["track_id"]); $track->quick_update($_POST); $track->db_response("json"); break; case "delete_track": unset($_POST["action"]); $artist = new WT_Track($_POST["track_id"]);
public function update_tracks($tracks = array(), $album_id, $artist_id) { global $wpdb; $wt_track = new WT_Track(); $attachments = array(); foreach ($tracks as $track) { $is_track = $wpdb->get_row("SELECT * FROM " . WORDTOUR_TRACKS . " WHERE track_title = '" . mysql_real_escape_string($track) . "' AND track_artist_id={$artist_id}"); if (count($is_track) > 0) { $attachments[] = (object) array("action" => "insert", "attachment_type_id" => $is_track->track_id); } else { $insert = $wt_track->insert(array("track_title" => $track, "track_artist_id" => $artist_id, "_nonce" => wp_create_nonce(WT_Track::NONCE_INSERT))); if ($insert) { $attachments[] = (object) array("action" => "insert", "attachment_type_id" => $wt_track->data["track_id"]); } } } $delete = parent::delete_attachments($album_id, "album", "track"); return parent::update_attachments($attachments, $album_id, "album", "track"); }