From e28f6707919960ebb05ea0e4060f95e2600dc88d Mon Sep 17 00:00:00 2001 From: Git Date: Thu, 23 Feb 2012 08:00:18 +0000 Subject: [PATCH] Empty commit --- gazelle.sql | 4 +- sections/artist/artist.php | 72 ++++++++++++++++++---------- sections/requests/takefill.php | 8 ++-- sections/torrents/add_alias.php | 22 +++------ sections/torrents/delete_alias.php | 9 ++-- sections/torrents/details.php | 14 +++--- sections/torrents/index.php | 3 ++ sections/torrents/manage_artists.php | 40 +++++++++------- sections/upload/upload.php | 29 ++++++----- static/functions/torrent.js | 4 +- 10 files changed, 119 insertions(+), 86 deletions(-) diff --git a/gazelle.sql b/gazelle.sql index 6eaa406f..9a6b52f8 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -896,8 +896,8 @@ CREATE TABLE `torrents_artists` ( `ArtistID` int(10) NOT NULL, `AliasID` int(10) NOT NULL, `UserID` int(10) unsigned NOT NULL DEFAULT '0', - `Importance` enum('1','2','3','4','5','6','7') DEFAULT NULL, - PRIMARY KEY (`GroupID`,`AliasID`), + `Importance` enum('1','2','3','4','5','6','7') NOT NULL DEFAULT '1', + PRIMARY KEY (`GroupID`,`ArtistID`,`Importance`), KEY `ArtistID` (`ArtistID`), KEY `AliasID` (`AliasID`), KEY `Importance` (`Importance`), diff --git a/sections/artist/artist.php b/sections/artist/artist.php index e8249deb..fea53b3b 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -102,7 +102,7 @@ function compare($X, $Y){ $LastReleaseType = 0; if(empty($Importances) || empty($TorrentList)) { $DB->query("SELECT - DISTINCT ta.GroupID, ta.Importance, tg.VanityHouse + DISTINCTROW ta.GroupID, ta.Importance, tg.VanityHouse FROM torrents_artists AS ta JOIN torrents_group AS tg ON tg.ID=ta.GroupID WHERE ta.ArtistID='$ArtistID' @@ -110,7 +110,8 @@ function compare($X, $Y){ tg.Year DESC, tg.Name DESC"); $GroupIDs = $DB->collect('GroupID'); - $Importances = $DB->to_array('GroupID', MYSQLI_BOTH, false); + $Importances = $DB->to_array(false, MYSQLI_BOTH, false); + if(count($GroupIDs)>0) { $TorrentList = get_groups($GroupIDs, true,true); $TorrentList = $TorrentList['matches']; @@ -128,26 +129,39 @@ function compare($X, $Y){ //Get list of used release types $UsedReleases = array(); -foreach($TorrentList as $GroupID=>$Group) { - if($Importances[$GroupID]['Importance'] == '2') { - $TorrentList[$GroupID]['ReleaseType'] = 1024; - $GuestAlbums = true; - } - if($Importances[$GroupID]['Importance'] == '3') { - $TorrentList[$GroupID]['ReleaseType'] = 1023; - $RemixerAlbums = true; - } - if($Importances[$GroupID]['Importance'] == '4') { - $TorrentList[$GroupID]['ReleaseType'] = 1022; - $ComposerAlbums = true; - } - if($Importances[$GroupID]['Importance'] == '7') { - $TorrentList[$GroupID]['ReleaseType'] = 1021; - $ProducerAlbums = true; - } - if(!in_array($TorrentList[$GroupID]['ReleaseType'], $UsedReleases)) { - $UsedReleases[] = $TorrentList[$GroupID]['ReleaseType']; +foreach($Importances as $ID=>$Group) { + switch ($Importances[$ID]['Importance']) { + case '2': + $Importances[$ID]['ReleaseType'] = 1024; + //$TorrentList[$GroupID]['ReleaseType'] = 1024; + $GuestAlbums = true; + break; + + case '3': + $Importances[$ID]['ReleaseType'] = 1023; + //$TorrentList[$GroupID]['ReleaseType'] = 1023; + $RemixerAlbums = true; + break; + + case '4': + $Importances[$ID]['ReleaseType'] = 1022; + //$TorrentList[$GroupID]['ReleaseType'] = 1022; + $ComposerAlbums = true; + break; + + case '7': + $Importances[$ID]['ReleaseType'] = 1021; + //$TorrentList[$GroupID]['ReleaseType'] = 1021; + $ProducerAlbums = true; + break; + + default: + $Importances[$ID]['ReleaseType'] = $TorrentList[$Group['GroupID']]['ReleaseType']; } + + if(!in_array($Importances[$ID]['ReleaseType'], $UsedReleases)) { + $UsedReleases[] = $Importances[$ID]['ReleaseType']; + } } if(!empty($GuestAlbums)) { @@ -208,10 +222,20 @@ function compare($X, $Y){ $OpenTable = false; $ShowGroups = !isset($LoggedUser['TorrentGrouping']) || $LoggedUser['TorrentGrouping'] == 0; $HideTorrents = ($ShowGroups ? '' : ' hidden'); +$OldGroupID = 0; +$ReleaseType = 0; -foreach ($TorrentList as $GroupID=>$Group) { - list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, $Torrents, $Artists, $ExtendedArtists) = array_values($Group); - $GroupVanityHouse = $Importances[$GroupID]['VanityHouse']; +foreach ($Importances as $Group) { + list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel, $GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse, $Torrents, $Artists, $ExtendedArtists) = array_values($TorrentList[$Group['GroupID']]); + $ReleaseType = $Group['ReleaseType']; + $GroupVanityHouse = $Group['VanityHouse']; + + if ($GroupID == $OldGroupID && $ReleaseType == $OldReleaseType) { + continue; + } else { + $OldGroupID = $GroupID; + $OldReleaseType = $ReleaseType; + } $TagList = explode(' ',str_replace('_','.',$TagList)); diff --git a/sections/requests/takefill.php b/sections/requests/takefill.php index 03000695..7219d386 100644 --- a/sections/requests/takefill.php +++ b/sections/requests/takefill.php @@ -110,9 +110,11 @@ } }*/ - //WEB has no ripping log. - $WEBOverride = ((strpos($MediaList, "WEB") !== false) && $Media == "WEB"); - if($Format == "FLAC" && $LogCue && !$WEBOverride) { + //WEB has no ripping log. Ditto Vinyl - Actually ditto everything but CD + //$WEBOverride = ((strpos($MediaList, "WEB") !== false) && $Media == "WEB"); + //$VinylOverride = ((strpos($MediaList, "Vinyl") !== false) && $Media == "Vinyl"); + //if($Format == "FLAC" && $LogCue && !$WEBOverride && !$VinylOverride) { + if($Format == "FLAC" && $LogCue && $Media == 'CD') { if(strpos($LogCue, "Log") && !$HasLog) { $Err = "This request requires a log"; } diff --git a/sections/torrents/add_alias.php b/sections/torrents/add_alias.php index 227f55de..099a7bee 100644 --- a/sections/torrents/add_alias.php +++ b/sections/torrents/add_alias.php @@ -41,15 +41,13 @@ $DB->query("SELECT Name FROM artists_group WHERE ArtistID=".$ArtistID); list($ArtistName) = $DB->next_record(); - $DB->query("SELECT AliasID FROM torrents_artists WHERE GroupID='$GroupID' AND ArtistID='$ArtistID'"); - if($DB->record_count() == 0) { + $DB->query("INSERT IGNORE INTO torrents_artists + (GroupID, ArtistID, AliasID, Importance, UserID) VALUES + ('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')"); + + if ($DB->affected_rows()) { $Changed = true; - - $DB->query("INSERT INTO torrents_artists - (GroupID, ArtistID, AliasID, Importance, UserID) VALUES - ('$GroupID', '$ArtistID', '$AliasID', '$Importance', '$UserID')"); - $DB->query("INSERT INTO torrents_group (ID, NumArtists) SELECT ta.GroupID, COUNT(ta.ArtistID) FROM torrents_artists AS ta @@ -59,14 +57,8 @@ ON DUPLICATE KEY UPDATE NumArtists=VALUES(NumArtists);"); - write_log("Artist ".$ArtistID." (".$ArtistName.") was added to the group ".$GroupID." (".$GroupName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")"); - write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist ".$ArtistName, 0); - } else { - list($OldAliasID) = $DB->next_record(); - if($OldAliasID == 0) { - $Changed = true; - $DB->query('UPDATE torrents_artists SET AliasID='.$AliasID.' WHERE GroupID='.$GroupID.' AND ArtistID='.$ArtistID); - } + write_log("Artist ".$ArtistID." (".$ArtistName.") was added to the group ".$GroupID." (".$GroupName.") as ".$ArtistTypes[$Importance]." by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")"); + write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist ".$ArtistName." as ".$ArtistTypes[$Importance], 0); } } } diff --git a/sections/torrents/delete_alias.php b/sections/torrents/delete_alias.php index 0c5eef06..461954f2 100644 --- a/sections/torrents/delete_alias.php +++ b/sections/torrents/delete_alias.php @@ -1,15 +1,16 @@ query("DELETE FROM torrents_artists WHERE GroupID='$GroupID' AND ArtistID='$ArtistID'"); +$DB->query("DELETE FROM torrents_artists WHERE GroupID='$GroupID' AND ArtistID='$ArtistID' AND Importance='$Importance'"); $DB->query("SELECT Name FROM artists_group WHERE ArtistID=".$ArtistID); list($ArtistName) = $DB->next_record(); @@ -48,8 +49,8 @@ $Cache->delete_value('torrents_details_'.$GroupID); // Delete torrent group cache $Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache -write_log("Artist ".$ArtistID." (".$ArtistName.") was removed from the group ".$GroupID." (".$GroupName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")"); -write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist ".$ArtistName, 0); +write_log("Artist (".$ArtistTypes[$Importance].") ".$ArtistID." (".$ArtistName.") was removed from the group ".$GroupID." (".$GroupName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")"); +write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist ".$ArtistName." (".$ArtistTypes[$Importance].")", 0); update_hash($GroupID); diff --git a/sections/torrents/details.php b/sections/torrents/details.php index 8a3a358b..0e506df8 100644 --- a/sections/torrents/details.php +++ b/sections/torrents/details.php @@ -151,7 +151,7 @@ function compare($X, $Y){ } ?>  ()  - [X] + [X]  ()  - [X] + [X]  ()  - [X] + [X]  ()  - [X] + [X]  ()  - [X] + [X]  ()  - [X] + [X]  ()  - [X] + [X] 'Main', 2 => 'Guest', 3 => 'Remixer', 4 => 'Composer', 5 => 'Conductor', 6 => 'DJ/Compiler', 7 => 'Producer'); + if(!empty($_REQUEST['action'])) { switch($_REQUEST['action']){ case 'edit': diff --git a/sections/torrents/manage_artists.php b/sections/torrents/manage_artists.php index 272e59a7..916822f4 100644 --- a/sections/torrents/manage_artists.php +++ b/sections/torrents/manage_artists.php @@ -7,27 +7,35 @@ } authorize(); -$Artists = explode(',', $_POST['artists']); -foreach($Artists as &$Artist) { - if(!is_number($Artist)) { - unset($Artist); - } else { - $Cache->delete_value('artist_'.$Artist); +$GroupID = $_POST['groupid']; +$Artists = explode(',',$_POST['artists']); +$CleanArtists = array(); +$ArtistIDs = array(); +$ArtistsString = '0'; + +foreach($Artists as $i => $Artist) { + list($Importance, $ArtistID) = explode(';',$Artist); + if(is_number($ArtistID) && is_number($Importance)) { + $Cache->delete_value('artist_'.$ArtistID); + $CleanArtists[] = array($Importance, $ArtistID); + $ArtistsString .= ",$ArtistID"; + $ArtistIDs[] = $ArtistID; } } -$ArtistsString = implode(',', $Artists); -if(count($Artists) > 0) { +if(count($CleanArtists) > 0) { if($_POST['manager_action'] == 'delete') { $DB->query("SELECT Name FROM torrents_group WHERE ID = '".$_POST['groupid']."'"); list($GroupName) = $DB->next_record(); $DB->query("SELECT ArtistID, Name FROM artists_group WHERE ArtistID IN (".$ArtistsString.")"); $ArtistNames = $DB->to_array('ArtistID'); - foreach($ArtistNames as $ArtistID => $ArtistInfo) { - write_log("Artist ".$ArtistID." (".$ArtistInfo['Name'].") was removed from the group ".$_POST['groupid']." (".$GroupName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")"); + print_r($ArtistNames); + foreach ($CleanArtists AS $Artist) { + list($Importance,$ArtistID) = $Artist; + write_log("Artist (".$ArtistTypes[$Importance].") ".$ArtistID." (".$ArtistNames[$ArtistID]['Name'].") was removed from the group ".$_POST['groupid']." (".$GroupName.") by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].")"); + write_group_log($GroupID, 0, $LoggedUser['ID'], "Removed artist ".$ArtistNames[$ArtistID]['Name']." (".$ArtistTypes[$Importance].")", 0); + $DB->query("DELETE FROM torrents_artists WHERE GroupID = '$GroupID' AND ArtistID = '$ArtistID' AND Importance = '$Importance'"); } - - $DB->query("DELETE FROM torrents_artists WHERE GroupID = '".$_POST['groupid']."' AND ArtistID IN (".$ArtistsString.")"); $DB->query("SELECT ArtistID FROM requests_artists WHERE ArtistID IN (".$ArtistsString.") @@ -35,14 +43,14 @@ FROM torrents_artists WHERE ArtistID IN (".$ArtistsString.")"); $Items = $DB->collect('ArtistID'); - $EmptyArtists = array_diff($Artists, $Items); + $EmptyArtists = array_diff($ArtistIDs, $Items); foreach($EmptyArtists as $ArtistID) { delete_artist($ArtistID); } } else { - $DB->query("UPDATE torrents_artists SET Importance = '".$_POST['importance']."' WHERE GroupID = '".$_POST['groupid']."' AND ArtistID IN (".$ArtistsString.")"); + $DB->query("UPDATE IGNORE torrents_artists SET Importance = '".$_POST['importance']."' WHERE GroupID = '$GroupID' AND ArtistID IN (".$ArtistsString.")"); } - $Cache->delete_value('groups_artists_'.$_POST['groupid']); - header("Location: torrents.php?id=".$_POST['groupid']); + $Cache->delete_value('groups_artists_'.$GroupID); + header("Location: torrents.php?id=".$GroupID); } ?> diff --git a/sections/upload/upload.php b/sections/upload/upload.php index baac9ced..f4993fe9 100644 --- a/sections/upload/upload.php +++ b/sections/upload/upload.php @@ -28,21 +28,24 @@ LEFT JOIN torrents AS t ON t.GroupID = tg.ID WHERE tg.ID=".$_GET['groupid']." GROUP BY tg.ID"); - - list($Properties) = $DB->to_array(false,MYSQLI_BOTH); - $UploadForm = $Categories[$Properties['CategoryID']-1]; - $Properties['CategoryName'] = $Categories[$Properties['CategoryID']-1]; - $Properties['Artists'] = get_artist($_GET['groupid']); - - $DB->query("SELECT - GROUP_CONCAT(tags.Name SEPARATOR ', ') AS TagList - FROM torrents_tags AS tt JOIN tags ON tags.ID=tt.TagID - WHERE tt.GroupID='$_GET[groupid]'"); - - list($Properties['TagList']) = $DB->next_record(); + if ($DB->record_count()) { + list($Properties) = $DB->to_array(false,MYSQLI_BOTH); + $UploadForm = $Categories[$Properties['CategoryID']-1]; + $Properties['CategoryName'] = $Categories[$Properties['CategoryID']-1]; + $Properties['Artists'] = get_artist($_GET['groupid']); + + $DB->query("SELECT + GROUP_CONCAT(tags.Name SEPARATOR ', ') AS TagList + FROM torrents_tags AS tt JOIN tags ON tags.ID=tt.TagID + WHERE tt.GroupID='$_GET[groupid]'"); + + list($Properties['TagList']) = $DB->next_record(); + } else { + unset($_GET['groupid']); + } if (!empty($_GET['requestid']) && is_number($_GET['requestid'])) { $Properties['RequestID'] = $_GET['requestid']; - } + } } elseif (empty($Properties) && !empty($_GET['requestid']) && is_number($_GET['requestid'])) { include(SERVER_ROOT.'/sections/requests/functions.php'); $DB->query("SELECT diff --git a/static/functions/torrent.js b/static/functions/torrent.js index 1005d422..28d06de3 100644 --- a/static/functions/torrent.js +++ b/static/functions/torrent.js @@ -64,7 +64,7 @@ function ArtistManager() { elBox.type = 'checkbox'; elBox.id = 'artistmanager_box'+(i-importance+1); elBox.name = 'artistmanager_box'; - elBox.value = importance+','+ArtistID; + elBox.value = importance+';'+ArtistID; elBox.onclick = function(e) { SelectArtist(e,this); }; elArtistList.children[i].insertBefore(elBox, elArtistList.children[i].children[0]); if(importance == 1 || importance == 4 || importance == 6) { @@ -182,7 +182,7 @@ function ArtistManagerSubmit() { var MainSelectionCount = 0; for(var i = 0, boxes = $('[name="artistmanager_box"]'); boxes.raw(i); i++) { if(boxes.raw(i).checked) { - Selection.push(boxes.raw(i).value.substr(2)); + Selection.push(boxes.raw(i).value); if(boxes.raw(i).value.substr(0,1) == '1') { MainSelectionCount++; }