Gazelle/sections/userhistory/quote_notifications.php

170 lines
6.2 KiB
PHP
Raw Normal View History

2012-10-27 08:00:09 +00:00
<?php
if (!empty($LoggedUser['DisableForums'])) {
error(403);
}
2013-04-24 08:00:23 +00:00
$UnreadSQL = 'AND q.UnRead';
2012-10-27 08:00:09 +00:00
if ($_GET['showall']) {
2013-04-24 08:00:23 +00:00
$UnreadSQL = '';
2012-10-27 08:00:09 +00:00
}
2013-01-05 08:00:47 +00:00
if ($_GET['catchup']) {
$DB->query("UPDATE users_notify_quoted SET UnRead = '0' WHERE UserID = '$LoggedUser[ID]'");
2013-08-28 23:08:41 +00:00
$Cache->delete_value('notify_quoted_' . $LoggedUser['ID']);
header('Location: userhistory.php?action=quote_notifications');
die();
2013-01-05 08:00:47 +00:00
}
2012-10-27 08:00:09 +00:00
2013-08-28 23:08:41 +00:00
if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
$PerPage = POSTS_PER_PAGE;
2012-10-27 08:00:09 +00:00
}
2013-08-28 23:08:41 +00:00
list($Page, $Limit) = Format::page_limit($PerPage);
// Get $Limit last quote notifications
// We deal with the information about torrents and requests later on...
2013-04-24 08:00:23 +00:00
$sql = "
SELECT
2013-05-29 08:00:51 +00:00
SQL_CALC_FOUND_ROWS
2013-08-28 23:08:41 +00:00
q.Page,
2013-04-24 08:00:23 +00:00
q.PageID,
q.PostID,
2013-08-28 23:08:41 +00:00
q.QuoterID,
q.Date,
q.UnRead,
f.ID as ForumID,
f.Name as ForumName,
t.Title as ForumTitle,
a.Name as ArtistName,
c.Name as CollageName
2013-04-24 08:00:23 +00:00
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
2013-08-28 23:08:41 +00:00
LEFT JOIN artists_group AS a ON a.ArtistID = q.PageID
LEFT JOIN collages AS c ON c.ID = q.PageID
2013-04-24 08:00:23 +00:00
WHERE q.UserID = $LoggedUser[ID]
2013-08-28 23:08:41 +00:00
AND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")
AND (q.Page != 'collages' OR c.Deleted = '0')
$UnreadSQL
ORDER BY q.Date DESC
LIMIT $Limit";
2012-10-27 08:00:09 +00:00
$DB->query($sql);
$Results = $DB->to_array(false, MYSQLI_ASSOC, false);
2013-04-24 08:00:23 +00:00
$DB->query('SELECT FOUND_ROWS()');
2012-10-27 08:00:09 +00:00
list($NumResults) = $DB->next_record();
2013-09-13 08:00:53 +00:00
$TorrentGroups = $Requests = array();
2013-08-28 23:08:41 +00:00
foreach ($Results as $Result) {
if ($Result['Page'] == 'torrents') {
$TorrentGroups[] = $Result['PageID'];
} elseif ($Result['Page'] == 'requests') {
$Requests[] = $Result['PageID'];
}
}
$TorrentGroups = Torrents::get_groups($TorrentGroups, true, true, false);
$Requests = Requests::get_requests($Requests);
2013-01-05 08:00:47 +00:00
//Start printing page
View::show_header('Quote Notifications');
2012-10-27 08:00:09 +00:00
?>
<div class="thin">
<div class="header">
<h2>
Quote notifications
2013-04-24 08:00:23 +00:00
<?=$NumResults && !empty($UnreadSQL) ? " ($NumResults new)" : '' ?>
2012-10-27 08:00:09 +00:00
</h2>
<div class="linkbox pager">
<br />
2013-08-28 23:08:41 +00:00
<? if ($UnreadSQL) { ?>
2013-02-09 08:01:01 +00:00
<a href="userhistory.php?action=quote_notifications&amp;showall=1" class="brackets">Show all quotes</a>&nbsp;&nbsp;&nbsp;
2013-08-28 23:08:41 +00:00
<? } else { ?>
2013-02-09 08:01:01 +00:00
<a href="userhistory.php?action=quote_notifications" class="brackets">Show unread quotes</a>&nbsp;&nbsp;&nbsp;
2013-08-28 23:08:41 +00:00
<? } ?>
2013-02-09 08:01:01 +00:00
<a href="userhistory.php?action=subscriptions" class="brackets">Show subscriptions</a>&nbsp;&nbsp;&nbsp;
<a href="userhistory.php?action=quote_notifications&amp;catchup=1" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;
2013-08-28 23:08:41 +00:00
<br /><br />
2013-04-24 08:00:23 +00:00
<?
2012-10-27 08:00:09 +00:00
$Pages = Format::get_pages($Page, $NumResults, TOPICS_PER_PAGE, 9);
echo $Pages;
?>
</div>
</div>
2013-08-28 23:08:41 +00:00
<? if (!$NumResults) { ?>
2013-03-21 08:00:33 +00:00
<div class="center">No<?=($UnreadSQL ? ' new' : '')?> quotes.</div>
2013-08-28 23:08:41 +00:00
<? } ?>
2012-10-27 08:00:09 +00:00
<br />
2013-04-24 08:00:23 +00:00
<?
2013-08-28 23:08:41 +00:00
foreach ($Results as $Result) {
switch ($Result['Page']) {
case 'forums':
$Links = 'Forums: <a href="forums.php?action=viewforum&amp;forumid=' . $Result['ForumID'] . '">' . display_str($Result['ForumName']) . '</a> &gt; ' .
2013-11-05 08:01:12 +00:00
'<a href="forums.php?action=viewthread&amp;threadid=' . $Result['PageID'] . '" class="tooltip" title="' . display_str($Result['ForumTitle']) . '">' . Format::cut_string($Result['ForumTitle'], 75) . '</a>';
2013-08-28 23:08:41 +00:00
$JumpLink = 'forums.php?action=viewthread&amp;threadid=' . $Result['PageID'] . '&amp;postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
break;
case 'artist':
$Links = 'Artist: <a href="artist.php?id=' . $Result['PageID'] . '">' . display_str($Result['ArtistName']) . '</a>';
$JumpLink = 'artist.php?id=' . $Result['PageID'] . '&amp;postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
break;
case 'collages':
$Links = 'Collage: <a href="collages.php?id=' . $Result['PageID'] . '">' . display_str($Result['CollageName']) . '</a>';
$JumpLink = 'collages.php?action=comments&amp;collageid=' . $Result['PageID'] . '&amp;postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
break;
case 'requests':
2013-09-13 08:00:53 +00:00
if (!isset($Requests[$Result['PageID']])) {
// Deleted request
continue 2;
2013-08-28 23:08:41 +00:00
}
2013-09-13 08:00:53 +00:00
$Request = $Requests[$Result['PageID']];
$CategoryName = $Categories[$Request['CategoryID'] - 1];
2013-08-28 23:08:41 +00:00
$Links = 'Request: ';
2013-09-15 08:00:53 +00:00
if ($CategoryName == 'Music') {
2013-09-13 08:00:53 +00:00
$Links .= Artists::display_artists(Requests::get_artists($Result['PageID'])) . '<a href="requests.php?action=view&amp;id=' . $Result['PageID'] . '" dir="ltr">' . $Request['Title'] . " [" . $Request['Year'] . "]</a>";
2013-09-15 08:00:53 +00:00
} elseif ($CategoryName == "Audiobooks" || $CategoryName == "Comedy") {
2013-09-13 08:00:53 +00:00
$Links .= '<a href="requests.php?action=view&amp;id=' . $Result['PageID'] . '" dir="ltr">' . $Request['Title'] . " [" . $Request['Year'] . "]</a>";
2013-08-28 23:08:41 +00:00
} else {
2013-09-13 08:00:53 +00:00
$Links .= '<a href="requests.php?action=view&amp;id=' . $Result['PageID'] . '">' . $Request['Title'] . "</a>";
2013-08-28 23:08:41 +00:00
}
$JumpLink = 'requests.php?action=view&amp;id=' . $Result['PageID'] . '&amp;postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
break;
case 'torrents':
2013-09-13 08:00:53 +00:00
if (!isset($TorrentGroups[$Result['PageID']])) {
// Deleted or moved torrent group
continue 2;
2013-08-28 23:08:41 +00:00
}
2013-09-13 08:00:53 +00:00
$GroupInfo = $TorrentGroups[$Result['PageID']];
2013-08-28 23:08:41 +00:00
$Links = 'Torrent: ' . Artists::display_artists($GroupInfo['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupInfo['ID'] . '" dir="ltr">' . $GroupInfo['Name'] . '</a>';
2013-09-15 08:00:53 +00:00
if ($GroupInfo['Year'] > 0) {
2013-08-28 23:08:41 +00:00
$Links .= " [" . $GroupInfo['Year'] . "]";
}
if ($GroupInfo['ReleaseType'] > 0) {
$Links .= " [" . $ReleaseTypes[$GroupInfo['ReleaseType']] . "]";
}
$JumpLink = 'torrents.php?id=' . $GroupInfo['ID'] . '&postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
break;
default:
2013-09-13 08:00:53 +00:00
continue 2;
2013-08-28 23:08:41 +00:00
}
?>
2013-04-24 08:00:23 +00:00
<table class="forum_post box vertical_margin noavatar">
2013-08-28 23:08:41 +00:00
<tr class="colhead_dark notify_<?=$Result['Page']?>">
2012-12-27 08:00:27 +00:00
<td colspan="2">
<span style="float: left;">
2013-08-28 23:08:41 +00:00
<?=$Links?>
&gt; Quoted by <?=Users::format_username($Result['QuoterID'], false, false, false, false) . ' ' . time_diff($Result['Date']) ?>
<?=($Result['UnRead'] ? ' <span class="new">(New!)</span>' : '')?>
2012-12-27 08:00:27 +00:00
</span>
2013-08-28 23:08:41 +00:00
<span style="float: left;" class="tooltip last_read" title="Jump to quote">
<a href="<?=$JumpLink?>"></a>
2012-12-27 08:00:27 +00:00
</span>
2013-08-28 23:08:41 +00:00
<span style="float: right;">
2012-12-27 08:00:27 +00:00
<a href="#">&uarr;</a>
</span>
</td>
2012-10-27 08:00:09 +00:00
</tr>
</table>
2013-08-28 23:08:41 +00:00
<? } ?>
2012-10-27 08:00:09 +00:00
</div>
<? View::show_footer(); ?>