[Bb-trac] Re: [bbPress] #727: BB_Query has no method to append WHERE - proposal for fix

bbPress bb-trac at lists.bbpress.org
Sat Aug 11 13:39:44 GMT 2007


#727: BB_Query has no method to append WHERE - proposal for fix
----------------------+-----------------------------------------------------
 Reporter:  _ck_      |        Owner:                   
     Type:  defect    |       Status:  new              
 Priority:  high      |    Milestone:                   
Component:  Back-end  |      Version:  1.0-alpha (trunk)
 Severity:  normal    |   Resolution:                   
 Keywords:            |  
----------------------+-----------------------------------------------------
Comment (by _ck_):

 But BB_Query is used for everything now though, not just latest topics -
 are you saying if a "get_latest_topics_where" filter exists, will be used
 for any query passed through BB_Query?

 The #1 plugin I can think of where this is important is "private forums"
 since it's important to return items excluding certain forums. He was
 doing post-filtering but it's much cleaner to do a pre-filter via $where.
 I had to use these filters:

 {{{
 add_filter( 'get_latest_topics_where', 'private_forums_filter_private');
 add_filter( 'get_latest_posts_where', 'private_forums_filter_private');
 add_filter( 'get_recent_user_replies_where',
 'private_forums_filter_private');
 add_filter( 'get_recent_user_threads_where',
 'private_forums_filter_private');
 }}}

 But I was also using the ability to prevent sub-sub-forums from showing up
 just on the front page.

 {{{
 function filter_front_page_topics($where){
 // $exclude_forums=array ("8");   // enable this to manually specify
 specific forums by id #
 $forums = get_forums(); foreach ($forums as $forum) {if
 ($forum->forum_parent) {$exclude_forums[]=$forum->forum_id;}}  // exclude
 ALL sub-forums
 if ( is_front()) {foreach($exclude_forums as $forum) { $where.=" AND
 forum_id != ".$forum."  "; }}
 return  $where;
 }
 add_filter( 'get_latest_topics_where', 'filter_front_page_topics');
 add_filter( 'get_latest_posts_where', 'filter_front_page_topics');
 }}}

 I guess I'll test these tonight in the trunk to see what happens.

-- 
Ticket URL: <http://trac.bbpress.org/ticket/727#comment:2>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list