Empty commit

This commit is contained in:
Git 2013-07-12 08:00:46 +00:00
parent 205cbc3630
commit 633a1b6b43
4 changed files with 95 additions and 47 deletions

View File

@ -31,7 +31,7 @@
$DB->query("
SELECT AliasID, ArtistID, Name, Redirect
FROM artists_alias
WHERE Name = '".$DBAliasName."'");
WHERE Name = '$DBAliasName'");
if ($DB->has_results()) {
while (list($CloneAliasID, $CloneArtistID, $CloneAliasName, $CloneRedirect) = $DB->next_record(MYSQLI_NUM, false)) {
if (!strcasecmp($CloneAliasName, $AliasName)) {
@ -43,8 +43,8 @@
if ($CloneRedirect != 0) {
$DB->query("
UPDATE artists_alias
SET ArtistID='".$ArtistID."', Redirect=0
WHERE AliasID='".$CloneAliasID."'");
SET ArtistID = '$ArtistID', Redirect=0
WHERE AliasID = '$CloneAliasID'");
Misc::write_log("Redirection for the alias $CloneAliasID ($DBAliasName) for the artist $ArtistID was removed by user $LoggedUser[ID] ($LoggedUser[Username])");
} else {
error('No changes were made as the target alias did not redirect anywhere.');
@ -56,7 +56,10 @@
}
if (!$CloneAliasID) {
if ($Redirect) {
$DB->query("SELECT ArtistID, Redirect FROM artists_alias WHERE AliasID = $Redirect");
$DB->query("
SELECT ArtistID, Redirect
FROM artists_alias
WHERE AliasID = $Redirect");
if (!$DB->has_results()) {
error('Cannot redirect to a nonexistent artist alias.');
}
@ -73,7 +76,10 @@
VALUES ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')');
$AliasID = $DB->inserted_id();
$DB->query("SELECT Name FROM artists_group WHERE ArtistID = ".$ArtistID);
$DB->query("
SELECT Name
FROM artists_group
WHERE ArtistID = $ArtistID");
list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
Misc::write_log("The alias $AliasID ($DBAliasName) was added to the artist $ArtistID (".db_string($ArtistName).") by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');

View File

@ -13,39 +13,58 @@
error('Blank artist name.');
}
$DB->query("SELECT ag.ArtistID FROM artists_group AS ag WHERE ag.Name LIKE '$Artist2Name'");
$DB->query("
SELECT ag.ArtistID
FROM artists_group AS ag
WHERE ag.Name LIKE '$Artist2Name'");
list($Artist2ID) = $DB->next_record();
if (!empty($Artist2ID)) { // artist was found in the database
// Let's see if there's already a similar artists field for these two
$DB->query("SELECT
s1.SimilarID
$DB->query("
SELECT s1.SimilarID
FROM artists_similar AS s1
JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID
WHERE s1.ArtistID='$Artist1ID' AND s2.ArtistID='$Artist2ID'");
JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID
WHERE s1.ArtistID = '$Artist1ID'
AND s2.ArtistID = '$Artist2ID'");
list($SimilarID) = $DB->next_record();
if ($SimilarID) { // The similar artists field already exists, just update the score
$DB->query("UPDATE artists_similar_scores SET Score=Score+200 WHERE SimilarID='$SimilarID'");
$DB->query("
UPDATE artists_similar_scores
SET Score = Score + 200
WHERE SimilarID = '$SimilarID'");
} else { // No, it doesn't exist - create it
$DB->query("INSERT INTO artists_similar_scores (Score) VALUES ('200')");
$DB->query("
INSERT INTO artists_similar_scores (Score)
VALUES ('200')");
$SimilarID = $DB->inserted_id();
$DB->query("INSERT INTO artists_similar (ArtistID, SimilarID) VALUES ('$Artist1ID', '$SimilarID')");
$DB->query("INSERT INTO artists_similar (ArtistID, SimilarID) VALUES ('$Artist2ID', '$SimilarID')");
$DB->query("
INSERT INTO artists_similar (ArtistID, SimilarID)
VALUES ('$Artist1ID', '$SimilarID')");
$DB->query("
INSERT INTO artists_similar (ArtistID, SimilarID)
VALUES ('$Artist2ID', '$SimilarID')");
}
$DB->query("SELECT SimilarID FROM artists_similar_votes WHERE SimilarID='$SimilarID' AND UserID='$UserID' AND Way='up'");
$DB->query("
SELECT SimilarID
FROM artists_similar_votes
WHERE SimilarID = '$SimilarID'
AND UserID = '$UserID'
AND Way = 'up'");
if (!$DB->has_results()) {
$DB->query("INSERT INTO artists_similar_votes (SimilarID, UserID, way) VALUES ('$SimilarID', '$UserID', 'up')");
$DB->query("
INSERT INTO artists_similar_votes (SimilarID, UserID, way)
VALUES ('$SimilarID', '$UserID', 'up')");
}
$Cache->delete_value('artist_'.$Artist1ID); // Delete artist cache
$Cache->delete_value('artist_'.$Artist2ID); // Delete artist cache
$Cache->delete_value('similar_positions_'.$Artist1ID); // Delete artist's similar map cache
$Cache->delete_value('similar_positions_'.$Artist2ID); // Delete artist's similar map cache
$Cache->delete_value("artist_$Artist1ID"); // Delete artist cache
$Cache->delete_value("artist_$Artist2ID"); // Delete artist cache
$Cache->delete_value("similar_positions_$Artist1ID"); // Delete artist's similar map cache
$Cache->delete_value("similar_positions_$Artist2ID"); // Delete artist's similar map cache
}
header('Location: '.$_SERVER['HTTP_REFERER']);
?>

View File

@ -51,15 +51,24 @@
}
if ($ArtistID == $NewArtistID) {
error("You cannot merge an artist with itself.");
error('You cannot merge an artist with itself.');
}
if (isset($_POST['confirm'])) {
// Get the information for the cache update
$DB->query("SELECT DISTINCT GroupID FROM torrents_artists WHERE ArtistID = $ArtistID");
$DB->query("
SELECT DISTINCT GroupID
FROM torrents_artists
WHERE ArtistID = $ArtistID");
$Groups = $DB->collect('GroupID');
$DB->query("SELECT DISTINCT RequestID FROM requests_artists WHERE ArtistID = $ArtistID");
$DB->query("
SELECT DISTINCT RequestID
FROM requests_artists
WHERE ArtistID = $ArtistID");
$Requests = $DB->collect('RequestID');
$DB->query("SELECT DISTINCT UserID FROM bookmarks_artists WHERE ArtistID = $ArtistID");
$DB->query("
SELECT DISTINCT UserID
FROM bookmarks_artists
WHERE ArtistID = $ArtistID");
$BookmarkUsers = $DB->collect('UserID');
$DB->query("
SELECT DISTINCT ct.CollageID
@ -75,7 +84,7 @@
WHERE ArtistID = $NewArtistID");
$NewArtistGroups = $DB->collect('GroupID');
$NewArtistGroups[] = '0';
$NewArtistGroups = implode(',',$NewArtistGroups);
$NewArtistGroups = implode(',', $NewArtistGroups);
$DB->query("
SELECT DISTINCT RequestID
@ -83,7 +92,7 @@
WHERE ArtistID = $NewArtistID");
$NewArtistRequests = $DB->collect('RequestID');
$NewArtistRequests[] = '0';
$NewArtistRequests = implode(',',$NewArtistRequests);
$NewArtistRequests = implode(',', $NewArtistRequests);
$DB->query("
SELECT DISTINCT UserID
@ -91,7 +100,7 @@
WHERE ArtistID = $NewArtistID");
$NewArtistBookmarks = $DB->collect('UserID');
$NewArtistBookmarks[] = '0';
$NewArtistBookmarks = implode(',',$NewArtistBookmarks);
$NewArtistBookmarks = implode(',', $NewArtistBookmarks);
// Merge all of this artist's aliases onto the new artist
$DB->query("
@ -105,51 +114,59 @@
SET ArtistID = $NewArtistID
WHERE ArtistID = $ArtistID
AND GroupID NOT IN ($NewArtistGroups)");
$DB->query("DELETE FROM torrents_artists WHERE ArtistID = $ArtistID");
$DB->query("
DELETE FROM torrents_artists
WHERE ArtistID = $ArtistID");
$DB->query("
UPDATE IGNORE requests_artists
SET ArtistID = $NewArtistID
WHERE ArtistID = $ArtistID
AND RequestID NOT IN ($NewArtistRequests)");
$DB->query("DELETE FROM requests_artists WHERE ArtistID = $ArtistID");
$DB->query("
DELETE FROM requests_artists
WHERE ArtistID = $ArtistID");
$DB->query("
UPDATE IGNORE bookmarks_artists
SET ArtistID = $NewArtistID
WHERE ArtistID = $ArtistID
AND UserID NOT IN ($NewArtistBookmarks)");
$DB->query("DELETE FROM bookmarks_artists WHERE ArtistID = $ArtistID");
$DB->query("
DELETE FROM bookmarks_artists
WHERE ArtistID = $ArtistID");
// Cache clearing
if (!empty($Groups)) {
foreach ($Groups as $GroupID) {
$Cache->delete_value('groups_artists_'.$GroupID);
$Cache->delete_value("groups_artists_$GroupID");
Torrents::update_hash($GroupID);
}
}
if (!empty($Requests)) {
foreach ($Requests as $RequestID) {
$Cache->delete_value('request_artist_'.$RequestID);
$Cache->delete_value("request_artist_$RequestID");
Requests::update_sphinx_requests($RequestID);
}
}
if (!empty($BookmarkUsers)) {
foreach ($BookmarkUsers as $UserID) {
$Cache->delete_value('notify_artists_'.$UserID);
$Cache->delete_value("notify_artists_$UserID");
}
}
if (!empty($Collages)) {
foreach ($Collages as $CollageID) {
$Cache->delete_value('collage_'.$CollageID);
$Cache->delete_value("collage_$CollageID");
}
}
$Cache->delete_value('artist_'.$ArtistID);
$Cache->delete_value('artist_'.$NewArtistID);
$Cache->delete_value('artist_groups_'.$ArtistID);
$Cache->delete_value('artist_groups_'.$NewArtistID);
$Cache->delete_value("artist_$ArtistID");
$Cache->delete_value("artist_$NewArtistID");
$Cache->delete_value("artist_groups_$ArtistID");
$Cache->delete_value("artist_groups_$NewArtistID");
// Delete the old artist
$DB->query("DELETE FROM artists_group WHERE ArtistID = $ArtistID");
$DB->query("
DELETE FROM artists_group
WHERE ArtistID = $ArtistID");
Misc::write_log("The artist $ArtistID ($ArtistName) was made into a non-redirecting alias of artist $NewArtistID ($NewArtistName) by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].')');

View File

@ -6,7 +6,10 @@
error(0);
}
$DB->query("SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Featured FROM collages WHERE ID='$CollageID'");
$DB->query("
SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Featured
FROM collages
WHERE ID = '$CollageID'");
list($Name, $Description, $TagList, $UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Featured) = $DB->next_record();
$TagList = implode(', ', explode(' ', $TagList));
@ -38,13 +41,15 @@
<td class="label">Name</td>
<td><input type="text" name="name" size="60" value="<?=$Name?>" /></td>
</tr>
<? }
<?
}
if ($CategoryID > 0 || check_perms('site_collages_delete')) { ?>
<tr>
<td class="label"><strong>Category</strong></td>
<td>
<select name="category">
<? foreach ($CollageCats as $CatID => $CatName) {
<?
foreach ($CollageCats as $CatID => $CatName) {
if (!check_perms('site_collages_delete') && $CatID == 0) {
// Only mod-type get to make things personal
continue;
@ -71,7 +76,8 @@
<td class="label"><span title="A &quot;featured&quot; personal collage will be listed first on your profile, along with a preview of the included torrents.">Featured</span></td>
<td><input type="checkbox" name="featured"<?=($Featured ? ' checked="checked"' : '')?> /></td>
</tr>
<? }
<?
}
if (check_perms('site_collages_delete')) { ?>
<tr>
<td class="label">Locked</td>