Ticket #2650: 2650.patch
| File 2650.patch, 6.7 KB (added by , 16 years ago) |
|---|
-
bp-forums.php
133 133 'user_id' => false, 134 134 'page' => 1, 135 135 'per_page' => 15, 136 'include' => false, // Comma-separated list of topic IDs. 136 137 'exclude' => false, 137 138 'show_stickies' => 'all', 138 139 'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on. … … 140 141 141 142 $r = wp_parse_args( $args, $defaults ); 142 143 extract( $r, EXTR_SKIP ); 144 145 if ( $exclude ) { 146 $exclude = '-' . str_replace(',', ',-', $exclude); 147 $exclude = str_replace('--', '-', $exclude); 148 if ( $include ) 149 $include = (string) $include . ",$exclude"; 150 else 151 $include = $exclude; 152 } 143 153 144 154 switch ( $type ) { 145 155 case 'newest': 146 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' );156 $query = new BB_Query( 'topic', array( 'forum_id' => 'forum_id', 'topic_id' => $include, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' ); 147 157 $topics =& $query->results; 148 158 break; 149 159 150 160 case 'popular': 151 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_ author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) );161 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_id' => $include, 'topic_author_id' => $user_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 152 162 $topics =& $query->results; 153 163 break; 154 164 155 165 case 'unreplied': 156 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_ author_id' => $user_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) );166 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_id' => $include, 'topic_author_id' => $user_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 157 167 $topics =& $query->results; 158 168 break; 159 169 160 170 case 'tags': 161 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_ author_id' => $user_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) );171 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'topic_id' => $include, 'topic_author_id' => $user_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) ); 162 172 $topics =& $query->results; 163 173 break; 164 174 } -
bp-forums/bp-forums-templatetags.php
18 18 var $sort_by; 19 19 var $order; 20 20 21 function BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms ) {21 function BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $include, $exclude ) { 22 22 global $bp; 23 23 24 24 $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page; … … 28 28 29 29 switch ( $type ) { 30 30 case 'newest': default: 31 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'forum_id' => $forum_id, 'filter' => $search_terms, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );31 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'forum_id' => $forum_id, 'filter' => $search_terms, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'include' => $include, 'exclude' => $exclude ) ); 32 32 break; 33 33 34 34 case 'popular': 35 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'popular', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );35 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'popular', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'include' => $include, 'exclude' => $exclude ) ); 36 36 break; 37 37 38 38 case 'unreplied': 39 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'unreplied', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );39 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'unreplied', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'include' => $include, 'exclude' => $exclude ) ); 40 40 break; 41 41 42 42 case 'tags': 43 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'tags', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies ) );43 $this->topics = bp_forums_get_forum_topics( array( 'user_id' => $user_id, 'type' => 'tags', 'filter' => $search_terms, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $no_stickies, 'include' => $include, 'exclude' => $exclude ) ); 44 44 break; 45 45 } 46 46 … … 166 166 $forum_id = false; 167 167 $search_terms = false; 168 168 $no_stickies = 'all'; 169 $include = false; 170 $exclude = false; 169 171 170 172 /* User filtering */ 171 173 if ( !empty( $bp->displayed_user->id ) ) … … 198 200 'per_page' => 20, 199 201 'max' => false, 200 202 'no_stickies' => $no_stickies, 201 'search_terms' => $search_terms 203 'search_terms' => $search_terms, 204 'include' => $include, 205 'exclude' => $exclude 202 206 ); 203 207 204 208 $r = wp_parse_args( $args, $defaults ); … … 210 214 $type = 'tags'; 211 215 } 212 216 213 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms );217 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $user_id, $page, $per_page, $max, $no_stickies, $search_terms, $include, $exclude ); 214 218 return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template ); 215 219 } 216 220