コード例 #1
0
 public function delete($nonce = "", $id = 0, $validate = 1)
 {
     global $wpdb;
     # When using delete_all no need to check every time nonce. nd add id
     $is_valid = 1;
     if ($validate) {
         $is_valid = $this->validate($nonce, self::NONCE_DELETE);
     }
     if ($is_valid) {
         $artist_id = $id ? $id : $this->id;
         // Check if artist assigned to event
         $wpdb->get_row("SELECT event_id FROM " . WORDTOUR_EVENTS . " WHERE event_artist_id={$artist_id} LIMIT 1", "ARRAY_A");
         if (!$wpdb->num_rows) {
             $wpdb->query($wpdb->prepare("DELETE FROM " . WORDTOUR_ARTISTS . " WHERE artist_id={$artist_id}"));
             if ($wpdb->result) {
                 $attachments = new WT_Attachment();
                 $attachments->delete("attachment_target_id={$artist_id}&attachment_target=artist");
                 $this->db_result("success", $wpdb);
             } else {
                 $this->db_result("error", $wpdb, array("msg" => "Error delete artist, please try again<br>" . $wpdb->last_error));
             }
             return $wpdb->result;
         } else {
             $this->db_result("error", $wpdb, array("msg" => "Can't Delete artist because it's attached to event."));
         }
     }
     return false;
 }
コード例 #2
0
ファイル: template.php プロジェクト: Ashleyotero/oldest-old
function get_track_row_html($row)
{
    global $wpdb, $_wt_options;
    $row = (array) $row;
    $track_id = $row["track_id"];
    $track_title = $row["track_title"];
    $track_label = $row["track_label"];
    $artist = new WT_Artist();
    $artist = $artist->db_out($row);
    $artist_name = $artist["artist_name"];
    $artist_id = $artist["artist_id"];
    $attachment = new WT_Attachment();
    $track_attached = $attachment->query("attachment_target=album&attachment_type=track&attachment_type_id={$track_id}");
    //print_r($track_attached);
    //echo "<br/>";
    $album_attached = array();
    foreach ($track_attached as $track_a) {
        if (!in_array($track_a["attachment_target_id"], $album_attached)) {
            $album_id = $track_a["attachment_target_id"];
            $album_title = $wpdb->get_var("SELECT album_title FROM " . WORDTOUR_ALBUMS . " WHERE album_id={$album_id}");
            $album_attached[] = array("id" => $album_id, "title" => $album_title);
        }
    }
    //$num_of_albums = $wpdb->get_var("SELECT COUNT(*) FROM ".WORDTOUR_EVENTS." WHERE event_artist_id=".$row["artist_id"]);
    $delete_class = "action-delete_track:track_id-{$track_id}:_nonce-" . wp_create_nonce(WT_Track::NONCE_DELETE);
    $edit_class = "track_id-{$track_id}";
    $edit_link = admin_url("admin.php?page=wt_tracks&action=edit&track_id=" . $row["track_id"]);
    $html = "<tr>\n\t\t\t\t<th class='check-column'>";
    if ($num_of_events == 0) {
        $html .= "<input type='checkbox' value='{$track_id}'/>";
    }
    $html .= "</th>\n\t\t\t\t<td>{$track_id}</td>\n\t\t\t\t<td>\n\t\t\t\t\t<strong><a title='Edit' href='{$edit_link}' class='row-title'>{$track_title}</a></strong>\n\t\t\t\t\t<br>\n\t\t\t\t\t<span class='quickedit'>\n\t\t\t\t\t\t<a class='{$edit_class}' title='Edit this track' href='#'>Quick Edit</a> |\n\t\t\t\t\t</span>\n\t\t\t\t\t<span>\n\t\t\t\t\t\t<a title='Edit this track' href='" . admin_url("admin.php?page=wt_tracks&action=edit&track_id=" . $row["track_id"]) . "'>Edit</a>\n\t\t\t\t\t</span>";
    $html .= "| <span class='delete'>\n\t\t\t\t\t\t<a title='Delete this track' class='{$delete_class}' href='#'>Delete</a>\n\t\t\t\t\t</span>";
    $html .= "</td>\n\t\t\t\t<td>";
    $albums = array();
    foreach ($album_attached as $album) {
        $albums[] = "<a href='" . admin_url("admin.php?page=wt_albums&action=edit&album_id=" . $album["id"]) . "'>{$album['title']}</a>";
    }
    $html .= implode(", ", $albums);
    $html .= "</td>\n\t\t\t\t<td><a href='" . admin_url("admin.php?page=wt_artists&action=edit&artist_id=" . $artist_id) . "'>{$artist_name}</a></td>\n\t\t\t\t<td>{$track_label}</td>\n\t\t\t</tr>";
    return $html;
}
コード例 #3
0
 public function delete($nonce = "", $id = 0, $validate = 1)
 {
     global $wpdb;
     # When using delete_all no need to check every time nonce. nd add id
     $is_valid = 1;
     if ($validate) {
         $is_valid = $this->validate($nonce, self::NONCE_DELETE);
     }
     if ($is_valid) {
         $venue_id = $id ? $id : $this->id;
         $wpdb->get_row("SELECT event_id FROM " . WORDTOUR_EVENTS . " WHERE event_venue_id={$venue_id}", "ARRAY_A");
         if (!$wpdb->num_rows) {
             $wpdb->query($wpdb->prepare("DELETE FROM " . WORDTOUR_VENUES . " WHERE venue_id = {$venue_id}"));
             if ($wpdb->result) {
                 $attachments = new WT_Attachment();
                 $attachments->delete("attachment_target_id={$venue_id}&attachment_target=venue");
                 $wpdb->query("DELETE FROM " . WORDTOUR_SOCIAL . " WHERE social_parent_id = {$venue_id} AND social_parent_type = 'venue'");
                 $this->db_result("success", $wpdb);
             } else {
                 $this->db_result("error", $wpdb, array("msg" => "Error delete venue, please try again<br>" . $wpdb->last_error));
             }
             return $wpdb->result;
         } else {
             $this->db_result("error", $wpdb, array("msg" => "Error delete venue, already assigned to event<br>"));
         }
     }
     return false;
 }
コード例 #4
0
 public function update_attachments($attachments = array(), $id = 0, $target_type = "", $type = "")
 {
     $id = $id ? $id : $this->id;
     if ($id && !empty($target_type)) {
         foreach ($attachments as $attachment) {
             $attachment->attachment_target = $target_type;
             $attachment->attachment_type = $type;
             $attachment->attachment_target_id = $id;
         }
         $attachment = new WT_Attachment();
         $attachment->delete("attachment_target_type={$target_type}&attachment_target_id={$target_id}&attachment_type={$type}");
         return $attachment->insert($attachments);
     }
     return array();
 }
コード例 #5
0
ファイル: class.tour.php プロジェクト: Ashleyotero/oldest-old
 public function delete($nonce = "", $id = 0, $validate = 1)
 {
     global $wpdb;
     $is_valid = 1;
     if ($validate) {
         $is_valid = $this->validate($nonce, self::NONCE_DELETE);
     }
     #
     if ($is_valid) {
         $tour_id = $id ? $id : $this->id;
         $wpdb->query($wpdb->prepare("DELETE FROM " . WORDTOUR_TOUR . " WHERE tour_id={$tour_id}"));
         if ($wpdb->result) {
             $attachments = new WT_Attachment();
             $attachments->delete("attachment_target_id={$tour_id}&attachment_target=tour");
             $this->db_result("success", $wpdb);
         } else {
             $this->db_result("error", $wpdb, array("msg" => "Error delete comment, please try again<br>" . $wpdb->last_error));
         }
         return $wpdb->result;
     }
     return false;
 }