Gazelle/sections/userhistory/catchup.php

35 lines
965 B
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
2013-08-28 23:08:41 +00:00
$UserSubscriptions = Subscriptions::get_subscriptions();
2013-05-01 08:00:16 +00:00
if (!empty($UserSubscriptions)) {
2013-07-04 08:00:56 +00:00
$DB->query("
INSERT INTO forums_last_read_topics (UserID, TopicID, PostID)
SELECT '$LoggedUser[ID]', ID, LastPostID
FROM forums_topics
WHERE ID IN (".implode(',', $UserSubscriptions).')
2013-09-06 08:00:41 +00:00
ON DUPLICATE KEY UPDATE
PostID = LastPostID');
2011-03-28 14:21:28 +00:00
}
2013-08-28 23:08:41 +00:00
$DB->query("
INSERT INTO users_comments_last_read (UserID, Page, PageID, PostID)
SELECT $LoggedUser[ID], t.Page, t.PageID, t.LastPostID
FROM (
SELECT
s.Page,
s.PageID,
IFNULL(c.ID, 0) AS LastPostID
FROM users_subscriptions_comments AS s
2013-09-06 08:00:41 +00:00
LEFT JOIN comments AS c ON c.Page = s.Page
AND c.ID = (
SELECT MAX(ID)
FROM comments
WHERE Page = s.Page
AND PageID = s.PageID
)
2013-08-28 23:08:41 +00:00
) AS t
2013-09-06 08:00:41 +00:00
ON DUPLICATE KEY UPDATE
PostID = LastPostID");
2011-03-28 14:21:28 +00:00
$Cache->delete_value('subscriptions_user_new_'.$LoggedUser['ID']);
header('Location: userhistory.php?action=subscriptions');
?>