Removed old forum read checking code.
This commit is contained in:
parent
cd259a96a6
commit
696e646d6e
1 changed files with 8 additions and 41 deletions
|
@ -304,48 +304,18 @@ function forum_read_status(int $forumId, int $userId): bool
|
||||||
return $memoized[$memoId] = false;
|
return $memoized[$memoId] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function forum_read_status_sql(
|
|
||||||
string $user_param_sub,
|
|
||||||
string $forum_id_param = 'f.`forum_id`',
|
|
||||||
string $user_param = '`target_user_id`'
|
|
||||||
): string {
|
|
||||||
return sprintf(
|
|
||||||
'
|
|
||||||
SELECT
|
|
||||||
%1$s > 0
|
|
||||||
AND (
|
|
||||||
SELECT COUNT(ti.`topic_id`)
|
|
||||||
FROM `msz_forum_topics` AS ti
|
|
||||||
LEFT JOIN `msz_forum_topics_track` AS tt
|
|
||||||
ON tt.`topic_id` = ti.`topic_id` AND tt.`user_id` = %3$s
|
|
||||||
WHERE ti.`forum_id` = %2$s
|
|
||||||
AND ti.`topic_deleted` IS NULL
|
|
||||||
AND ti.`topic_bumped` >= NOW() - INTERVAL 1 MONTH
|
|
||||||
AND (
|
|
||||||
tt.`track_last_read` IS NULL
|
|
||||||
OR tt.`track_last_read` < ti.`topic_bumped`
|
|
||||||
)
|
|
||||||
)
|
|
||||||
',
|
|
||||||
$user_param,
|
|
||||||
$forum_id_param,
|
|
||||||
$user_param_sub
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
define(
|
define(
|
||||||
'MSZ_FORUM_GET_CHILDREN_QUERY_SMALL',
|
'MSZ_FORUM_GET_CHILDREN_QUERY_SMALL',
|
||||||
'
|
'
|
||||||
SELECT
|
SELECT
|
||||||
:user_id AS `target_user_id`,
|
:user_id AS `target_user_id`,
|
||||||
f.`forum_id`, f.`forum_name`,
|
f.`forum_id`, f.`forum_name`,
|
||||||
(%1$s) AS `forum_unread`,
|
(%3$s) AS `forum_permissions`
|
||||||
(%4$s) AS `forum_permissions`
|
|
||||||
FROM `msz_forum_categories` AS f
|
FROM `msz_forum_categories` AS f
|
||||||
WHERE `forum_parent` = :parent_id
|
WHERE `forum_parent` = :parent_id
|
||||||
AND `forum_hidden` = false
|
AND `forum_hidden` = false
|
||||||
GROUP BY f.`forum_id`
|
GROUP BY f.`forum_id`
|
||||||
HAVING (`forum_permissions` & %5$d) > 0
|
HAVING (`forum_permissions` & %4$d) > 0
|
||||||
ORDER BY f.`forum_order`
|
ORDER BY f.`forum_order`
|
||||||
'
|
'
|
||||||
);
|
);
|
||||||
|
@ -364,15 +334,14 @@ define(
|
||||||
u.`user_id` AS `recent_post_user_id`,
|
u.`user_id` AS `recent_post_user_id`,
|
||||||
u.`username` AS `recent_post_username`,
|
u.`username` AS `recent_post_username`,
|
||||||
COALESCE(u.`user_colour`, r.`role_colour`) AS `recent_post_user_colour`,
|
COALESCE(u.`user_colour`, r.`role_colour`) AS `recent_post_user_colour`,
|
||||||
(%1$s) AS `forum_unread`,
|
(%3$s) AS `forum_permissions`
|
||||||
(%4$s) AS `forum_permissions`
|
|
||||||
FROM `msz_forum_categories` AS f
|
FROM `msz_forum_categories` AS f
|
||||||
LEFT JOIN `msz_forum_topics` AS t
|
LEFT JOIN `msz_forum_topics` AS t
|
||||||
ON t.`topic_id` = (
|
ON t.`topic_id` = (
|
||||||
SELECT `topic_id`
|
SELECT `topic_id`
|
||||||
FROM `msz_forum_topics`
|
FROM `msz_forum_topics`
|
||||||
WHERE `forum_id` = f.`forum_id`
|
WHERE `forum_id` = f.`forum_id`
|
||||||
%6$s
|
%5$s
|
||||||
ORDER BY `topic_bumped` DESC
|
ORDER BY `topic_bumped` DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
)
|
)
|
||||||
|
@ -381,7 +350,7 @@ define(
|
||||||
SELECT `post_id`
|
SELECT `post_id`
|
||||||
FROM `msz_forum_posts`
|
FROM `msz_forum_posts`
|
||||||
WHERE `topic_id` = t.`topic_id`
|
WHERE `topic_id` = t.`topic_id`
|
||||||
%7$s
|
%6$s
|
||||||
ORDER BY `post_id` DESC
|
ORDER BY `post_id` DESC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
)
|
)
|
||||||
|
@ -392,11 +361,11 @@ define(
|
||||||
WHERE f.`forum_parent` = :parent_id
|
WHERE f.`forum_parent` = :parent_id
|
||||||
AND f.`forum_hidden` = 0
|
AND f.`forum_hidden` = 0
|
||||||
AND (
|
AND (
|
||||||
(f.`forum_parent` = %2$d AND f.`forum_type` != %3$d)
|
(f.`forum_parent` = %1$d AND f.`forum_type` != %2$d)
|
||||||
OR f.`forum_parent` != %2$d
|
OR f.`forum_parent` != %1$d
|
||||||
)
|
)
|
||||||
GROUP BY f.`forum_id`
|
GROUP BY f.`forum_id`
|
||||||
HAVING (`forum_permissions` & %5$d) > 0
|
HAVING (`forum_permissions` & %4$d) > 0
|
||||||
ORDER BY f.`forum_order`
|
ORDER BY f.`forum_order`
|
||||||
'
|
'
|
||||||
);
|
);
|
||||||
|
@ -407,7 +376,6 @@ function forum_get_children_query(bool $showDeleted = false, bool $small = false
|
||||||
$small
|
$small
|
||||||
? MSZ_FORUM_GET_CHILDREN_QUERY_SMALL
|
? MSZ_FORUM_GET_CHILDREN_QUERY_SMALL
|
||||||
: MSZ_FORUM_GET_CHILDREN_QUERY_STANDARD,
|
: MSZ_FORUM_GET_CHILDREN_QUERY_STANDARD,
|
||||||
forum_read_status_sql(':user_for_check'),
|
|
||||||
MSZ_FORUM_ROOT,
|
MSZ_FORUM_ROOT,
|
||||||
MSZ_FORUM_TYPE_CATEGORY,
|
MSZ_FORUM_TYPE_CATEGORY,
|
||||||
forum_perms_get_user_sql(MSZ_FORUM_PERMS_GENERAL, 'f.`forum_id`'),
|
forum_perms_get_user_sql(MSZ_FORUM_PERMS_GENERAL, 'f.`forum_id`'),
|
||||||
|
@ -423,7 +391,6 @@ function forum_get_children(int $parentId, int $userId, bool $showDeleted = fals
|
||||||
$getListing->bindValue('user_id', $userId);
|
$getListing->bindValue('user_id', $userId);
|
||||||
$getListing->bindValue('perm_user_id_user', $userId);
|
$getListing->bindValue('perm_user_id_user', $userId);
|
||||||
$getListing->bindValue('perm_user_id_role', $userId);
|
$getListing->bindValue('perm_user_id_role', $userId);
|
||||||
$getListing->bindValue('user_for_check', $userId);
|
|
||||||
$getListing->bindValue('parent_id', $parentId);
|
$getListing->bindValue('parent_id', $parentId);
|
||||||
|
|
||||||
$listing = db_fetch_all($getListing);
|
$listing = db_fetch_all($getListing);
|
||||||
|
|
Loading…
Add table
Reference in a new issue