XF 1.5 Best way to obtain list of user's watched forums

Miles Gillham

New member
The model XenForo_Model_ThreadWatch has the method getThreadsWatchedByUser. However, I can't find an equivalent within the Forum models. The closest I seem to get is XenForo_Model_Forum which has some useful methods once you have the forums (eg getUnreadThreadCountInForum is helpful for what I'm doing) but you first need the forum list. I have temporarily gotten around it with a manual SQL query:

Code:
return $this->fetchAllKeyed(
                        'SELECT forum.*,node.title
                                FROM xf_forum_watch AS forum_watch
                                INNER JOIN xf_forum AS forum ON
                                        (forum.node_id = forum_watch.node_id)
                                LEFT JOIN xf_node AS node ON
                                        (forum.node_id = node.node_id)
                                WHERE forum_watch.user_id = ?'
                , 'node_id', $userId);

But I'm not sure that is the best approach. Can anyone suggest the best way to retrieve a list of all Forums that a User is subscribed to? Or failing that can anyone advise if there's at least a better way of hitting the above query?

Regards, Miles
 
Back
Top Bottom