Hey all,
I'm trying to create a page that generates a list of threads that have not received any reply from a staff user, specific to a node. I've set up a query to do this as an initial approach, but struggling on generating a list once I have the IDs:
(If there is a better way of doing this, happy to learn - I couldn't see an obvious way to do this with an existing entity.)
The question is that once this supplies an array of thread IDs, with a few extra details, what's the best way of now converting this into a thread object, which can be sent to a thread_list style template?
I'm trying to create a page that generates a list of threads that have not received any reply from a staff user, specific to a node. I've set up a query to do this as an initial approach, but struggling on generating a list once I have the IDs:
PHP:
protected function getThreadsNoStaffReply($nodeid)
{
$db = \XF::db();
$readers = $db->fetchAll('SELECT xf_post.thread_id, xf_thread.node_id, xf_thread.post_date FROM `xf_post`
INNER JOIN xf_thread ON xf_post.thread_id = xf_thread.thread_id
WHERE xf_thread.node_id = ? AND xf_thread.discussion_state = \'visible\'
AND xf_post.thread_id NOT IN (SELECT xf_post.thread_id FROM `xf_post`
INNER JOIN `xf_user` ON xf_post.user_id = xf_user.user_id
INNER JOIN xf_thread ON xf_post.thread_id = xf_thread.thread_id
WHERE xf_thread.node_id = ? AND xf_user.is_staff = 1)
GROUP BY xf_post.thread_id
ORDER BY `xf_thread`.`post_date` DESC',
[$nodeid, $nodeid]);
return $readers;
}
(If there is a better way of doing this, happy to learn - I couldn't see an obvious way to do this with an existing entity.)
The question is that once this supplies an array of thread IDs, with a few extra details, what's the best way of now converting this into a thread object, which can be sent to a thread_list style template?