diff --git a/design/privateheader.php b/design/privateheader.php index f8a7489b..e65ebae6 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -180,17 +180,18 @@ //Quotes if($LoggedUser['NotifyOnQuote']) { - $QuoteNotificationsCount = $Cache->get_value('forums_quotes_'.$LoggedUser['ID']); + $QuoteNotificationsCount = $Cache->get_value('notify_quoted_'.$LoggedUser['ID']); if($QuoteNotificationsCount === FALSE) { if ($LoggedUser['CustomForums']) { unset($LoggedUser['CustomForums']['']); $RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0)); $PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1)); } - $sql = "SELECT COUNT(UnRead) FROM users_notify_quoted AS q - LEFT JOIN forums AS f ON f.ID = q.ForumID - WHERE UserID='".$LoggedUser['ID']."' - AND UnRead = '1' AND ((f.MinClassRead <= '$LoggedUser[Class]'"; + $sql = "SELECT COUNT(q.UnRead) + FROM users_notify_quoted AS q + LEFT JOIN forums_topics AS t ON t.ID = q.PageID + LEFT JOIN forums AS f ON f.ID = t.ForumID + WHERE q.UserID='".$LoggedUser['ID']."' AND q.UnRead AND q.Page = 'forums' AND ((f.MinClassRead <= '$LoggedUser[Class]'"; if(!empty($RestrictedForums)) { $sql.=' AND f.ID NOT IN (\''.$RestrictedForums.'\')'; } @@ -201,7 +202,7 @@ $sql .= ')'; $DB->query($sql); list($QuoteNotificationsCount) = $DB->next_record(); - $Cache->cache_value('forums_quotes_'.$LoggedUser['ID'], $QuoteNotificationsCount, 0); + $Cache->cache_value('notify_quoted_'.$LoggedUser['ID'], $QuoteNotificationsCount, 0); } if($QuoteNotificationsCount > 0) { $Alerts[] = ''. 'New quote'. ($QuoteNotificationsCount > 1 ? 's' : '') . ''; diff --git a/gazelle.sql b/gazelle.sql index 0d44d3ce..e7649206 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -301,9 +301,7 @@ CREATE TABLE `forums_last_read_topics` ( `TopicID` int(10) NOT NULL, `PostID` int(10) NOT NULL, PRIMARY KEY (`UserID`,`TopicID`), - KEY `TopicID` (`TopicID`), - KEY `UserID` (`UserID`), - KEY `TopicID_2` (`TopicID`) + KEY `TopicID` (`TopicID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; CREATE TABLE `forums_polls` ( @@ -457,6 +455,13 @@ CREATE TABLE `login_attempts` ( KEY `IP` (`IP`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +CREATE TABLE `new_info_hashes` ( + `TorrentID` int(11) NOT NULL, + `InfoHash` binary(20) DEFAULT NULL, + PRIMARY KEY (`TorrentID`), + KEY `InfoHash` (`InfoHash`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE `news` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `UserID` int(10) unsigned NOT NULL, @@ -1195,6 +1200,15 @@ CREATE TABLE `users_collage_subs` ( KEY `CollageID` (`CollageID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +CREATE TABLE `users_comments_last_read` ( + `UserID` int(10) NOT NULL, + `Page` enum('artist','collages','requests','torrents') COLLATE utf8_swedish_ci NOT NULL, + `PageID` int(10) NOT NULL, + `PostID` int(10) NOT NULL, + PRIMARY KEY (`UserID`,`Page`,`PageID`), + KEY `Page` (`Page`,`PageID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; + CREATE TABLE `users_comments_subscriptions` ( `UserID` int(10) NOT NULL, `GroupID` int(10) NOT NULL, @@ -1434,13 +1448,13 @@ CREATE TABLE `users_notify_filters` ( CREATE TABLE `users_notify_quoted` ( `UserID` int(10) NOT NULL, `QuoterID` int(10) NOT NULL, - `ForumID` int(6) unsigned DEFAULT NULL, - `TopicID` int(10) NOT NULL, + `Page` enum('forums','artist','collages','requests','torrents') COLLATE utf8_swedish_ci NOT NULL, + `PageID` int(10) NOT NULL, `PostID` int(10) NOT NULL, - `UnRead` enum('0','1') NOT NULL DEFAULT '1', + `UnRead` tinyint(1) NOT NULL DEFAULT '1', `Date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', - PRIMARY KEY (`UserID`,`PostID`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; + PRIMARY KEY (`UserID`,`Page`,`PostID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; CREATE TABLE `users_notify_torrents` ( `UserID` int(10) NOT NULL, @@ -1500,6 +1514,13 @@ CREATE TABLE `users_subscriptions` ( PRIMARY KEY (`UserID`,`TopicID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +CREATE TABLE `users_subscriptions_comments` ( + `UserID` int(10) NOT NULL, + `Page` enum('artist','collages','requests','torrents') COLLATE utf8_swedish_ci NOT NULL, + `PageID` int(10) NOT NULL, + PRIMARY KEY (`UserID`,`Page`,`PageID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci; + CREATE TABLE `users_torrent_history` ( `UserID` int(10) unsigned NOT NULL, `NumTorrents` int(6) unsigned NOT NULL, diff --git a/sections/artist/artist.php b/sections/artist/artist.php index fe00d55d..4d4de07e 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -246,9 +246,9 @@ function compare($X, $Y){ foreach ($TorrentList as $GroupID => $Group) { // $Tags array is for the sidebar on the right. // Skip compilations and soundtracks. - $Skip = $Group['ReleaseType'] != 7 && $Group['ReleaseType'] != 3; + $Merge = $Group['ReleaseType'] != 7 && $Group['ReleaseType'] != 3; - $TorrentTags = new Tags($Group['TagList'], !$Skip); + $TorrentTags = new Tags($Group['TagList'], $Merge); foreach ($Group['Torrents'] as $TorrentID => $Torrent) { $NumTorrents++; @@ -293,7 +293,7 @@ function compare($X, $Y){ $HideDiscog = ''; } - $TorrentTags = new Tags($TagList); + $TorrentTags = new Tags($TagList, false); if($ReleaseType!=$LastReleaseType) { switch($ReleaseTypes[$ReleaseType]) { diff --git a/sections/forums/quote_notify.php b/sections/forums/quote_notify.php index 8638739f..2071cbac 100644 --- a/sections/forums/quote_notify.php +++ b/sections/forums/quote_notify.php @@ -37,9 +37,9 @@ $TopicID = db_string($TopicID); $PostID = db_string($PostID); - $DB->query("INSERT IGNORE INTO users_notify_quoted (UserID, QuoterID, ForumID, TopicID, PostID, Date) - VALUES ('$UserID', '$QuoterID', '$ForumID', '$TopicID', '$PostID', '" . sqltime() . "')"); - $Cache->delete_value('forums_quotes_' . $UserID); + $DB->query("INSERT IGNORE INTO users_notify_quoted (UserID, QuoterID, Page, PageID, PostID, Date) + VALUES ('$UserID', '$QuoterID', 'forums', '$TopicID', '$PostID', '" . sqltime() . "')"); + $Cache->delete_value('notify_quoted_' . $UserID); } diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 3f9efdfa..706abcff 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -139,14 +139,14 @@ } -$DB->query("UPDATE users_notify_quoted SET UnRead = '0' WHERE UserID = '$LoggedUser[ID]' AND TopicID = '$ThreadID'"); -$Cache->delete_value('forums_quotes_' . $LoggedUser['ID']); +$DB->query("UPDATE users_notify_quoted SET UnRead = false WHERE UserID = '$LoggedUser[ID]' AND Page = 'forums' AND PageID = '$ThreadID'"); +$Cache->delete_value('notify_quoted_' . $LoggedUser['ID']); /* -$QuoteNotificationsCount = $Cache->get_value('forums_quotes_' . $LoggedUser['ID']); +$QuoteNotificationsCount = $Cache->get_value('notify_quoted_' . $LoggedUser['ID']); if ($QuoteNotificationsCount > 0) { - $Cache->cache_value('forums_quotes_' . $LoggedUser['ID'], $QuoteNotificationsCount - 1, 0); + $Cache->cache_value('notify_quoted_' . $LoggedUser['ID'], $QuoteNotificationsCount - 1, 0); } else { - $Cache->delete_value('forums_quotes_' . $LoggedUser['ID']); + $Cache->delete_value('notify_quoted_' . $LoggedUser['ID']); } */ diff --git a/sections/userhistory/quote_notifications.php b/sections/userhistory/quote_notifications.php index d0ff2dea..c9d6cdbb 100644 --- a/sections/userhistory/quote_notifications.php +++ b/sections/userhistory/quote_notifications.php @@ -3,7 +3,7 @@ error(403); } -$UnreadSQL = "AND q.UnRead = '1'"; +$UnreadSQL = "AND q.UnRead"; if ($_GET['showall']) { $UnreadSQL = ""; } @@ -19,9 +19,11 @@ $RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0)); $PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1)); } -$sql = "SELECT SQL_CALC_FOUND_ROWS f.ID as ForumID, f.Name as ForumName, t.Title, q.TopicID, q.PostID, q.QuoterID - FROM users_notify_quoted AS q LEFT JOIN forums_topics AS t ON t.ID = q.TopicID LEFT JOIN forums AS f ON f.ID = q.ForumID - WHERE q.UserID = $LoggedUser[ID] AND ((f.MinClassRead <= '$LoggedUser[Class]'"; +$sql = "SELECT SQL_CALC_FOUND_ROWS f.ID as ForumID, f.Name as ForumName, t.Title, q.PageID, q.PostID, q.QuoterID + FROM users_notify_quoted AS q + LEFT JOIN forums_topics AS t ON t.ID = q.PageID + LEFT JOIN forums AS f ON f.ID = t.ForumID + WHERE q.UserID = $LoggedUser[ID] AND q.Page = 'forums' AND ((f.MinClassRead <= '$LoggedUser[Class]'"; if (!empty($RestrictedForums)) { $sql .= ' AND f.ID NOT IN (\'' . $RestrictedForums . '\')'; @@ -65,7 +67,7 @@ if (!$NumResults) { ?> -