Gazelle/sections/userhistory/quote_notifications.php

104 lines
3.3 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]'");
}
2012-10-27 08:00:09 +00:00
2013-01-05 08:00:47 +00:00
list($Page, $Limit) = Format::page_limit(TOPICS_PER_PAGE);
2012-10-27 08:00:09 +00:00
if ($LoggedUser['CustomForums']) {
unset($LoggedUser['CustomForums']['']);
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
}
2013-04-24 08:00:23 +00:00
$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]'";
2012-10-27 08:00:09 +00:00
if (!empty($RestrictedForums)) {
$sql .= ' AND f.ID NOT IN (\'' . $RestrictedForums . '\')';
}
$sql .= ')';
if (!empty($PermittedForums)) {
$sql .= ' OR f.ID IN (\'' . $PermittedForums . '\')';
}
$sql .= ") $UnreadSQL ORDER BY q.Date DESC LIMIT $Limit";
$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-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-04-24 08:00:23 +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-04-24 08:00:23 +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-04-24 08:00:23 +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;
2012-10-27 08:00:09 +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-04-24 08:00:23 +00:00
<?
if (!$NumResults) { ?>
2013-03-21 08:00:33 +00:00
<div class="center">No<?=($UnreadSQL ? ' new' : '')?> quotes.</div>
2013-04-24 08:00:23 +00:00
<? } ?>
2012-10-27 08:00:09 +00:00
<br />
2013-04-24 08:00:23 +00:00
<?
2012-10-27 08:00:09 +00:00
foreach ($Results as $Result) {
?>
2013-04-24 08:00:23 +00:00
<table class="forum_post box vertical_margin noavatar">
<tr class="colhead_dark">
2012-12-27 08:00:27 +00:00
<td colspan="2">
<span style="float: left;">
<a href="forums.php?action=viewforum&amp;forumid=<?=$Result['ForumID'] ?>"><?=$Result['ForumName'] ?></a>
&gt;
2013-03-21 08:00:33 +00:00
<a href="forums.php?action=viewthread&amp;threadid=<?=$Result['PageID'] ?>" title="<?=display_str($Result['Title']) ?>"><?=Format::cut_string($Result['Title'], 75) ?></a>
2012-10-27 08:00:09 +00:00
&gt; Quoted by <?=Users::format_username($Result['QuoterID'], false, false, false, false) ?>
2012-12-27 08:00:27 +00:00
</span>
2013-03-21 08:00:33 +00:00
<span style="float: left;" class="last_read" title="Jump to quote">
<a href="forums.php?action=viewthread&amp;threadid=<?=$Result['PageID'].($Result['PostID'] ? '&amp;postid=' . $Result['PostID'].'#post'.$Result['PostID'] : '') ?>"></a>
2012-12-27 08:00:27 +00:00
</span>
<span id="bar<?=$Result['PostID'] ?>" style="float: right;">
<a href="#">&uarr;</a>
</span>
</td>
2012-10-27 08:00:09 +00:00
</tr>
</table>
2013-04-24 08:00:23 +00:00
<? } ?>
2012-10-27 08:00:09 +00:00
</div>
<? View::show_footer(); ?>