コード例 #1
0
ファイル: torrents.class.php プロジェクト: Kufirc/Gazelle
 /**
  * Delete a group, called after all of its torrents have been deleted.
  * IMPORTANT: Never call this unless you're certain the group is no longer used by any torrents
  *
  * @param int $GroupID
  */
 public static function delete_group($GroupID)
 {
     $QueryID = G::$DB->get_query_id();
     Misc::write_log("Group {$GroupID} automatically deleted (No torrents have this group).");
     G::$DB->query("\n\t\t\tSELECT CategoryID\n\t\t\tFROM torrents_group\n\t\t\tWHERE ID = '{$GroupID}'");
     list($Category) = G::$DB->next_record();
     if ($Category == 1) {
         G::$Cache->decrement('stats_album_count');
     }
     G::$Cache->decrement('stats_group_count');
     // Collages
     G::$DB->query("\n\t\t\tSELECT CollageID\n\t\t\tFROM collages_torrents\n\t\t\tWHERE GroupID = '{$GroupID}'");
     if (G::$DB->has_results()) {
         $CollageIDs = G::$DB->collect('CollageID');
         G::$DB->query("\n\t\t\t\tUPDATE collages\n\t\t\t\tSET NumTorrents = NumTorrents - 1\n\t\t\t\tWHERE ID IN (" . implode(', ', $CollageIDs) . ')');
         G::$DB->query("\n\t\t\t\tDELETE FROM collages_torrents\n\t\t\t\tWHERE GroupID = '{$GroupID}'");
         foreach ($CollageIDs as $CollageID) {
             G::$Cache->delete_value("collage_{$CollageID}");
         }
         G::$Cache->delete_value("torrent_collages_{$GroupID}");
     }
     // Artists
     // Collect the artist IDs and then wipe the torrents_artist entry
     G::$DB->query("\n\t\t\tSELECT ArtistID\n\t\t\tFROM torrents_artists\n\t\t\tWHERE GroupID = {$GroupID}");
     $Artists = G::$DB->collect('ArtistID');
     G::$DB->query("\n\t\t\tDELETE FROM torrents_artists\n\t\t\tWHERE GroupID = '{$GroupID}'");
     foreach ($Artists as $ArtistID) {
         if (empty($ArtistID)) {
             continue;
         }
         // Get a count of how many groups or requests use the artist ID
         G::$DB->query("\n\t\t\t\tSELECT COUNT(ag.ArtistID)\n\t\t\t\tFROM artists_group AS ag\n\t\t\t\t\tLEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID\n\t\t\t\tWHERE ra.ArtistID IS NOT NULL\n\t\t\t\t\tAND ag.ArtistID = '{$ArtistID}'");
         list($ReqCount) = G::$DB->next_record();
         G::$DB->query("\n\t\t\t\tSELECT COUNT(ag.ArtistID)\n\t\t\t\tFROM artists_group AS ag\n\t\t\t\t\tLEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID\n\t\t\t\tWHERE ta.ArtistID IS NOT NULL\n\t\t\t\t\tAND ag.ArtistID = '{$ArtistID}'");
         list($GroupCount) = G::$DB->next_record();
         if ($ReqCount + $GroupCount == 0) {
             //The only group to use this artist
             Artists::delete_artist($ArtistID);
         } else {
             //Not the only group, still need to clear cache
             G::$Cache->delete_value("artist_groups_{$ArtistID}");
         }
     }
     // Requests
     G::$DB->query("\n\t\t\tSELECT ID\n\t\t\tFROM requests\n\t\t\tWHERE GroupID = '{$GroupID}'");
     $Requests = G::$DB->collect('ID');
     G::$DB->query("\n\t\t\tUPDATE requests\n\t\t\tSET GroupID = NULL\n\t\t\tWHERE GroupID = '{$GroupID}'");
     foreach ($Requests as $RequestID) {
         G::$Cache->delete_value("request_{$RequestID}");
     }
     // comments
     Comments::delete_page('torrents', $GroupID);
     G::$DB->query("\n\t\t\tDELETE FROM torrents_group\n\t\t\tWHERE ID = '{$GroupID}'");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_tags\n\t\t\tWHERE GroupID = '{$GroupID}'");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_tags_votes\n\t\t\tWHERE GroupID = '{$GroupID}'");
     G::$DB->query("\n\t\t\tDELETE FROM bookmarks_torrents\n\t\t\tWHERE GroupID = '{$GroupID}'");
     G::$DB->query("\n\t\t\tDELETE FROM wiki_torrents\n\t\t\tWHERE PageID = '{$GroupID}'");
     G::$Cache->delete_value("torrents_details_{$GroupID}");
     G::$Cache->delete_value("torrent_group_{$GroupID}");
     G::$Cache->delete_value("groups_artists_{$GroupID}");
     G::$DB->set_query_id($QueryID);
 }
コード例 #2
0
ファイル: delete.php プロジェクト: Kufirc/Gazelle
    while (list($RequestName, $RequestID) = $DB->next_record(MYSQLI_NUM, true)) {
        ?>
				<li>
					<a href="requests.php?action=view&amp;id=<?php 
        echo $RequestID;
        ?>
" class="tooltip" title="View request" dir="ltr"><?php 
        echo $RequestName;
        ?>
</a>
				</li>
<?php 
    }
    ?>
			</ul>
		</div>
	</div>
<?php 
}
if ($Count == 0) {
    Artists::delete_artist($ArtistID);
    ?>
	<div class="thin box pad">
		Artist "<?php 
    echo $Name;
    ?>
" deleted!
	</div>
<?php 
}
View::show_footer();