2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
/*
|
|
|
|
User post history page
|
|
|
|
*/
|
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!empty($LoggedUser['DisableForums'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(403);
|
|
|
|
}
|
|
|
|
|
|
|
|
include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class
|
|
|
|
$Text = new TEXT;
|
|
|
|
|
|
|
|
$UserID = empty($_GET['userid']) ? $LoggedUser['ID'] : $_GET['userid'];
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!is_number($UserID)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
error(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($LoggedUser['PostsPerPage'])) {
|
|
|
|
$PerPage = $LoggedUser['PostsPerPage'];
|
|
|
|
} else {
|
|
|
|
$PerPage = POSTS_PER_PAGE;
|
|
|
|
}
|
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
list($Page,$Limit) = Format::page_limit($PerPage);
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-05-11 08:00:29 +00:00
|
|
|
$UserInfo = Users::user_info($UserID);
|
|
|
|
extract(array_intersect_key($UserInfo, array_flip(array('Username', 'Enabled', 'Title', 'Avatar', 'Donor', 'Warned'))));
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
View::show_header('Post history for '.$Username,'subscriptions,comments,bbcode');
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($LoggedUser['CustomForums']) {
|
2011-05-15 12:06:04 +00:00
|
|
|
unset($LoggedUser['CustomForums']['']);
|
|
|
|
$RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0));
|
2013-05-15 08:00:54 +00:00
|
|
|
$PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1));
|
2011-05-15 12:06:04 +00:00
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
$ViewingOwn = ($UserID == $LoggedUser['ID']);
|
|
|
|
$ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread']));
|
|
|
|
$ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group']));
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ShowGrouped) {
|
2013-05-15 08:00:54 +00:00
|
|
|
$sql = '
|
|
|
|
SELECT
|
|
|
|
SQL_CALC_FOUND_ROWS
|
|
|
|
MAX(p.ID) AS ID
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM forums_posts AS p
|
2013-05-15 08:00:54 +00:00
|
|
|
LEFT JOIN forums_topics AS t ON t.ID = p.TopicID';
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ShowUnread) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql.='
|
2013-05-15 08:00:54 +00:00
|
|
|
LEFT JOIN forums_last_read_topics AS l ON l.TopicID = t.ID AND l.UserID = '.$LoggedUser['ID'];
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
$sql .= '
|
2013-05-15 08:00:54 +00:00
|
|
|
LEFT JOIN forums AS f ON f.ID = t.ForumID
|
2011-03-28 14:21:28 +00:00
|
|
|
WHERE p.AuthorID = '.$UserID.'
|
2013-05-15 08:00:54 +00:00
|
|
|
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!empty($RestrictedForums)) {
|
2011-05-15 12:06:04 +00:00
|
|
|
$sql.='
|
2013-05-15 08:00:54 +00:00
|
|
|
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
|
2011-05-15 12:06:04 +00:00
|
|
|
}
|
2011-10-11 08:00:15 +00:00
|
|
|
$sql .= ')';
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!empty($PermittedForums)) {
|
2011-10-11 08:00:15 +00:00
|
|
|
$sql.='
|
2013-05-15 08:00:54 +00:00
|
|
|
OR f.ID IN (\''.$PermittedForums.'\')';
|
2011-10-11 08:00:15 +00:00
|
|
|
}
|
|
|
|
$sql .= ')';
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ShowUnread) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql .= '
|
2013-05-15 08:00:54 +00:00
|
|
|
AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\')
|
|
|
|
AND (l.PostID<t.LastPostID OR l.PostID IS NULL))';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
$sql .= '
|
|
|
|
GROUP BY t.ID
|
2013-05-15 08:00:54 +00:00
|
|
|
ORDER BY p.ID DESC
|
|
|
|
LIMIT '.$Limit;
|
2011-03-28 14:21:28 +00:00
|
|
|
$PostIDs = $DB->query($sql);
|
|
|
|
$DB->query("SELECT FOUND_ROWS()");
|
|
|
|
list($Results) = $DB->next_record();
|
|
|
|
|
2013-05-15 08:00:54 +00:00
|
|
|
if ($Results > $PerPage * ($Page - 1)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$DB->set_query_id($PostIDs);
|
|
|
|
$PostIDs = $DB->collect('ID');
|
2013-04-20 08:01:01 +00:00
|
|
|
$sql = '
|
|
|
|
SELECT
|
|
|
|
p.ID,
|
|
|
|
p.AddedTime,
|
|
|
|
p.Body,
|
|
|
|
p.EditedUserID,
|
|
|
|
p.EditedTime,
|
|
|
|
ed.Username,
|
|
|
|
p.TopicID,
|
|
|
|
t.Title,
|
|
|
|
t.LastPostID,
|
|
|
|
l.PostID AS LastRead,
|
|
|
|
t.IsLocked,
|
|
|
|
t.IsSticky
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM forums_posts as p
|
2013-04-20 08:01:01 +00:00
|
|
|
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
|
|
|
|
LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID
|
|
|
|
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
|
|
|
|
JOIN forums_topics AS t ON t.ID = p.TopicID
|
|
|
|
JOIN forums AS f ON f.ID = t.ForumID
|
|
|
|
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
|
2011-03-28 14:21:28 +00:00
|
|
|
WHERE p.ID IN ('.implode(',',$PostIDs).')
|
|
|
|
ORDER BY p.ID DESC';
|
|
|
|
$Posts = $DB->query($sql);
|
|
|
|
}
|
|
|
|
} else {
|
2013-05-15 08:00:54 +00:00
|
|
|
$sql = '
|
|
|
|
SELECT SQL_CALC_FOUND_ROWS';
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ShowGrouped) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql.=' * FROM (SELECT';
|
|
|
|
}
|
|
|
|
$sql .= '
|
2013-05-15 08:00:54 +00:00
|
|
|
p.ID,
|
|
|
|
p.AddedTime,
|
|
|
|
p.Body,
|
|
|
|
p.EditedUserID,
|
|
|
|
p.EditedTime,
|
|
|
|
ed.Username,
|
|
|
|
p.TopicID,
|
|
|
|
t.Title,
|
|
|
|
t.LastPostID,';
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($UserID == $LoggedUser['ID']) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql .= '
|
2013-05-15 08:00:54 +00:00
|
|
|
l.PostID AS LastRead,';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
$sql .= '
|
2013-05-15 08:00:54 +00:00
|
|
|
t.IsLocked,
|
|
|
|
t.IsSticky
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM forums_posts as p
|
2013-04-20 08:01:01 +00:00
|
|
|
LEFT JOIN users_main AS um ON um.ID = p.AuthorID
|
|
|
|
LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID
|
|
|
|
LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID
|
|
|
|
JOIN forums_topics AS t ON t.ID = p.TopicID
|
|
|
|
JOIN forums AS f ON f.ID = t.ForumID
|
|
|
|
LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID
|
2011-03-28 14:21:28 +00:00
|
|
|
WHERE p.AuthorID = '.$UserID.'
|
2013-05-15 08:00:54 +00:00
|
|
|
AND ((f.MinClassRead <= '.$LoggedUser['Class'];
|
2011-03-28 14:21:28 +00:00
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!empty($RestrictedForums)) {
|
2011-05-15 12:06:04 +00:00
|
|
|
$sql.='
|
2013-05-15 08:00:54 +00:00
|
|
|
AND f.ID NOT IN (\''.$RestrictedForums.'\')';
|
|
|
|
}
|
|
|
|
$sql .= ')';
|
|
|
|
|
|
|
|
if (!empty($PermittedForums)) {
|
|
|
|
$sql.='
|
|
|
|
OR f.ID IN (\''.$PermittedForums.'\')';
|
2011-05-15 12:06:04 +00:00
|
|
|
}
|
2013-05-15 08:00:54 +00:00
|
|
|
$sql .= ')';
|
2011-05-15 12:06:04 +00:00
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ShowUnread) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql.='
|
2013-05-15 08:00:54 +00:00
|
|
|
AND ( (t.IsLocked=\'0\' OR t.IsSticky=\'1\')
|
|
|
|
AND (l.PostID<t.LastPostID OR l.PostID IS NULL)
|
|
|
|
) ';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql .= '
|
|
|
|
ORDER BY p.ID DESC';
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ShowGrouped) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql.='
|
|
|
|
) AS sub
|
2013-05-15 08:00:54 +00:00
|
|
|
GROUP BY TopicID
|
|
|
|
ORDER BY ID DESC';
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$sql.=' LIMIT '.$Limit;
|
|
|
|
$Posts = $DB->query($sql);
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$DB->query("SELECT FOUND_ROWS()");
|
|
|
|
list($Results) = $DB->next_record();
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
$DB->set_query_id($Posts);
|
|
|
|
}
|
2011-04-13 15:36:33 +00:00
|
|
|
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
|
|
|
<div class="thin">
|
2012-08-19 08:00:19 +00:00
|
|
|
<div class="header">
|
|
|
|
<h2>
|
2011-03-28 14:21:28 +00:00
|
|
|
<?
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ShowGrouped) {
|
|
|
|
echo 'Grouped '.($ShowUnread ? 'unread ' : '')."post history for <a href=\"user.php?id=$UserID\">$Username</a>";
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
2013-04-20 08:01:01 +00:00
|
|
|
elseif ($ShowUnread) {
|
2011-03-28 14:21:28 +00:00
|
|
|
echo "Unread post history for <a href=\"user.php?id=$UserID\">$Username</a>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "Post history for <a href=\"user.php?id=$UserID\">$Username</a>";
|
|
|
|
}
|
|
|
|
?>
|
2012-08-19 08:00:19 +00:00
|
|
|
</h2>
|
|
|
|
<div class="linkbox">
|
2013-04-18 08:00:54 +00:00
|
|
|
<br /><br />
|
2011-03-28 14:21:28 +00:00
|
|
|
<?
|
2013-04-18 08:00:54 +00:00
|
|
|
if ($ViewingOwn) {
|
|
|
|
if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$DB->query("SELECT TopicID FROM users_subscriptions WHERE UserID = '$LoggedUser[ID]'");
|
|
|
|
$UserSubscriptions = $DB->collect(0);
|
|
|
|
$Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0);
|
|
|
|
$DB->set_query_id($Posts);
|
|
|
|
}
|
2013-02-22 08:00:24 +00:00
|
|
|
|
2013-04-18 08:00:54 +00:00
|
|
|
if (!$ShowUnread) {
|
|
|
|
if ($ShowGrouped) { ?>
|
2013-02-09 08:01:01 +00:00
|
|
|
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=0&group=0" class="brackets">Show all posts</a>
|
2013-04-18 08:00:54 +00:00
|
|
|
<? } else { ?>
|
2013-02-09 08:01:01 +00:00
|
|
|
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=0&group=1" class="brackets">Show all posts (grouped)</a>
|
2013-04-18 08:00:54 +00:00
|
|
|
<? } ?>
|
|
|
|
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=1" class="brackets">Only display posts with unread replies (grouped)</a>
|
2011-03-28 14:21:28 +00:00
|
|
|
<? } else { ?>
|
2013-04-18 08:00:54 +00:00
|
|
|
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=0&group=0" class="brackets">Show all posts</a>
|
|
|
|
<? if (!$ShowGrouped) { ?>
|
|
|
|
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=1" class="brackets">Only display posts with unread replies (grouped)</a>
|
|
|
|
<? } else { ?>
|
|
|
|
<a href="userhistory.php?action=posts&userid=<?=$UserID?>&showunread=1&group=0" class="brackets">Only display posts with unread replies</a>
|
|
|
|
<? }
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
?>
|
2013-02-09 08:01:01 +00:00
|
|
|
<a href="userhistory.php?action=subscriptions" class="brackets">Go to subscriptions</a>
|
2011-03-28 14:21:28 +00:00
|
|
|
<?
|
2013-04-18 08:00:54 +00:00
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
<a href="forums.php?action=search&type=body&user=<?=$Username?>" class="brackets">Search</a>
|
|
|
|
<?
|
2011-03-28 14:21:28 +00:00
|
|
|
}
|
|
|
|
?>
|
2012-08-19 08:00:19 +00:00
|
|
|
</div>
|
2011-03-28 14:21:28 +00:00
|
|
|
</div>
|
|
|
|
<?
|
2013-04-20 08:01:01 +00:00
|
|
|
if (empty($Results)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
|
|
|
<div class="center">
|
2013-04-20 08:01:01 +00:00
|
|
|
No topics<?=$ShowUnread ? ' with unread posts' : '' ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
</div>
|
|
|
|
<?
|
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
<div class="linkbox">
|
|
|
|
<?
|
2013-05-15 08:00:54 +00:00
|
|
|
$Pages = Format::get_pages($Page, $Results, $PerPage, 11);
|
2011-03-28 14:21:28 +00:00
|
|
|
echo $Pages;
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<?
|
2013-04-20 08:01:01 +00:00
|
|
|
while (list($PostID, $AddedTime, $Body, $EditedUserID, $EditedTime, $EditedUsername, $TopicID, $ThreadTitle, $LastPostID, $LastRead, $Locked, $Sticky) = $DB->next_record()) {
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
2013-05-01 08:00:16 +00:00
|
|
|
<table class="forum_post vertical_margin<?=!Users::has_avatars_enabled() ? ' noavatar' : '' ?>" id="post<?=$PostID ?>">
|
2012-10-29 08:00:20 +00:00
|
|
|
<colgroup>
|
2013-05-01 08:00:16 +00:00
|
|
|
<? if (Users::has_avatars_enabled()) { ?>
|
2012-10-29 08:00:20 +00:00
|
|
|
<col class="col_avatar" />
|
|
|
|
<? } ?>
|
|
|
|
<col class="col_post_body" />
|
|
|
|
</colgroup>
|
2012-10-09 08:00:17 +00:00
|
|
|
<tr class="colhead_dark">
|
2013-05-01 08:00:16 +00:00
|
|
|
<td colspan="<?=Users::has_avatars_enabled() ? 2 : 1 ?>">
|
2013-04-20 08:01:01 +00:00
|
|
|
<span style="float: left;">
|
2011-03-28 14:21:28 +00:00
|
|
|
<?=time_diff($AddedTime) ?>
|
2012-10-11 08:00:15 +00:00
|
|
|
in <a href="forums.php?action=viewthread&threadid=<?=$TopicID?>&postid=<?=$PostID?>#post<?=$PostID?>" title="<?=display_str($ThreadTitle)?>"><?=Format::cut_string($ThreadTitle, 75)?></a>
|
2011-03-28 14:21:28 +00:00
|
|
|
<?
|
2013-04-20 08:01:01 +00:00
|
|
|
if ($ViewingOwn) {
|
2013-02-07 08:00:47 +00:00
|
|
|
if ((!$Locked || $Sticky) && (!$LastRead || $LastRead < $LastPostID)) { ?>
|
2012-09-05 08:00:24 +00:00
|
|
|
<span class="new">(New!)</span>
|
2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</span>
|
2013-04-20 08:01:01 +00:00
|
|
|
<? if (!empty($LastRead)) { ?>
|
|
|
|
<span style="float: left;" class="last_read" title="Jump to last read">
|
2011-03-28 14:21:28 +00:00
|
|
|
<a href="forums.php?action=viewthread&threadid=<?=$TopicID?>&postid=<?=$LastRead?>#post<?=$LastRead?>"></a>
|
|
|
|
</span>
|
|
|
|
<? }
|
|
|
|
} else {
|
|
|
|
?>
|
|
|
|
</span>
|
|
|
|
<? }
|
|
|
|
?>
|
2013-04-20 08:01:01 +00:00
|
|
|
<span id="bar<?=$PostID ?>" style="float: right;">
|
|
|
|
<? if ($ViewingOwn && !in_array($TopicID, $UserSubscriptions)) { ?>
|
2013-02-09 08:01:01 +00:00
|
|
|
<a href="#" onclick="Subscribe(<?=$TopicID?>);$('.subscribelink<?=$TopicID?>').remove();return false;" class="brackets subscribelink<?=$TopicID?>">Subscribe</a>
|
2011-03-28 14:21:28 +00:00
|
|
|
|
|
|
|
<? } ?>
|
|
|
|
<a href="#">↑</a>
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?
|
2013-04-20 08:01:01 +00:00
|
|
|
if (!$ShowGrouped) {
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
|
|
|
<tr>
|
2013-05-01 08:00:16 +00:00
|
|
|
<? if (Users::has_avatars_enabled()) { ?>
|
2012-10-09 08:00:17 +00:00
|
|
|
<td class="avatar" valign="top">
|
2013-05-01 08:00:16 +00:00
|
|
|
<?=Users::show_avatar($Avatar, $Username, $HeavyInfo['DisableAvatars'])?>
|
2011-03-28 14:21:28 +00:00
|
|
|
</td>
|
2013-05-01 08:00:16 +00:00
|
|
|
<? } ?>
|
2012-10-09 08:00:17 +00:00
|
|
|
<td class="body" valign="top">
|
2011-03-28 14:21:28 +00:00
|
|
|
<div id="content<?=$PostID?>">
|
|
|
|
<?=$Text->full_format($Body)?>
|
2013-04-20 08:01:01 +00:00
|
|
|
<? if ($EditedUserID) { ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
<br />
|
|
|
|
<br />
|
2013-04-20 08:01:01 +00:00
|
|
|
<? if (check_perms('site_moderate_forums')) { ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
<a href="#content<?=$PostID?>" onclick="LoadEdit(<?=$PostID?>, 1)">«</a>
|
2013-02-07 08:00:47 +00:00
|
|
|
<? } ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
Last edited by
|
2012-10-11 08:00:15 +00:00
|
|
|
<?=Users::format_username($EditedUserID, false, false, false) ?> <?=time_diff($EditedTime,2,true,true)?>
|
2013-02-22 08:00:24 +00:00
|
|
|
<? } ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
|
|
|
<? } ?>
|
|
|
|
<div class="linkbox">
|
|
|
|
<?=$Pages?>
|
|
|
|
</div>
|
|
|
|
<? } ?>
|
|
|
|
</div>
|
2013-05-21 08:01:09 +00:00
|
|
|
<? View::show_footer(); ?>
|