Changeset 1858
- Timestamp:
- 09/11/2009 11:59:16 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
bp-forums.php (modified) (5 diffs)
-
bp-forums/bp-forums-bbpress.php (modified) (1 diff)
-
bp-forums/bp-forums-filters.php (modified) (2 diffs)
-
bp-forums/bp-forums-templatetags.php (modified) (18 diffs)
-
bp-groups.php (modified) (13 diffs)
-
bp-groups/bp-groups-classes.php (modified) (1 diff)
-
bp-groups/bp-groups-filters.php (modified) (1 diff)
-
bp-groups/bp-groups-templatetags.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums.php
r1834 r1858 38 38 } 39 39 40 function bp_forums_setup_root_component() { 41 /* Register 'forums' as a root component */ 42 bp_core_add_root_component( BP_FORUMS_SLUG ); 43 } 44 add_action( 'plugins_loaded', 'bp_forums_setup_root_component', 2 ); 45 46 function bp_forums_directory_forums_setup() { 47 global $bp; 48 49 if ( $bp->current_component == $bp->forums->slug ) { 50 $bp->is_directory = true; 51 52 do_action( 'bp_forums_directory_forums_setup' ); 53 bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'directories/forums/index' ) ); 54 } 55 } 56 add_action( 'wp', 'bp_forums_directory_forums_setup', 2 ); 57 40 58 function bp_forums_add_admin_menu() { 41 59 global $bp; … … 57 75 58 76 function bp_forums_get_forum_topics( $args = '' ) { 59 do_action( 'bbpress_init' ); 60 61 $defaults = array( 77 global $bp; 78 79 do_action( 'bbpress_init' ); 80 81 $defaults = array( 82 'type' => 'newest', 62 83 'forum_id' => false, 63 84 'page' => 1, 64 85 'per_page' => 15, 65 'exclude' => false 66 ); 67 68 $r = wp_parse_args( $args, $defaults ); 69 extract( $r, EXTR_SKIP ); 70 71 return get_latest_topics( array( 'forum' => $forum_id, 'page' => $page_num, 'number' => $per_page, 'exclude' => $exclude ) ); 86 'exclude' => false, 87 'show_stickies' => 'all', 88 'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on. 89 ); 90 91 $r = wp_parse_args( $args, $defaults ); 92 extract( $r, EXTR_SKIP ); 93 94 switch ( $type ) { 95 case 'newest': 96 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'number' => $per_page, 'exclude' => $exclude, 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_latest_topics' ); 97 $topics = $query->results; 98 break; 99 100 case 'popular': 101 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 102 $topics =& $query->results; 103 break; 104 105 case 'unreplied': 106 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) ); 107 $topics =& $query->results; 108 break; 109 110 case 'personal': 111 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'topic_author_id' => $bp->loggedin_user->id, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_recent_user_threads' ); 112 $topics =& $query->results; 113 break; 114 115 case 'tag': 116 $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) ); 117 $topics =& $query->results; 118 break; 119 } 120 121 return apply_filters( 'bp_forums_get_forum_topics', $topics, &$r ); 72 122 } 73 123 … … 135 185 'topic_time' => date( 'Y-m-d H:i:s' ), 136 186 'topic_open' => 1, 187 'topic_tags' => false, // accepts array or comma delim 137 188 'forum_id' => 0 // accepts ids or slugs 138 189 ); … … 144 195 $topic_slug = sanitize_title( $topic_title ); 145 196 146 if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id ) ) )197 if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id, 'tags' => $topic_tags ) ) ) 147 198 return false; 148 199 … … 236 287 237 288 return bb_delete_topic( $topic_id, 1 ); 289 } 290 291 function bp_forums_delete_post( $args = '' ) { 292 global $bp; 293 294 do_action( 'bbpress_init' ); 295 296 $defaults = array( 297 'post_id' => false 298 ); 299 300 $r = wp_parse_args( $args, $defaults ); 301 extract( $r, EXTR_SKIP ); 302 303 return bb_delete_post( $post_id, 1 ); 238 304 } 239 305 -
trunk/bp-forums/bp-forums-bbpress.php
r1812 r1858 158 158 } 159 159 160 /* BBPress needs this function to convert vars */ 161 function backpress_convert_object( &$object, $output ) { 162 if ( is_array( $object ) ) { 163 foreach ( array_keys( $object ) as $key ) 164 backpress_convert_object( $object[$key], $output ); 165 } else { 166 switch ( $output ) { 167 case OBJECT : break; 168 case ARRAY_A : $object = get_object_vars($object); break; 169 case ARRAY_N : $object = array_values(get_object_vars($object)); break; 170 } 171 } 172 } 173 174 160 175 161 176 ?> -
trunk/bp-forums/bp-forums-filters.php
r1759 r1858 4 4 add_filter( 'bp_forums_bbconfig_location', 'wp_filter_kses', 1 ); 5 5 add_filter( 'bp_forums_bbconfig_location', 'attribute_escape', 1 ); 6 7 add_filter( 'bp_get_the_topic_title', 'wp_filter_kses', 1 ); 8 add_filter( 'bp_get_the_topic_post_content', 'wp_filter_kses', 1 ); 9 add_filter( 'bp_get_the_topic_title', 'attribute_escape' ); 10 add_filter( 'bp_get_the_topic_post_content', 'attribute_escape' ); 6 11 7 12 add_filter( 'bp_get_the_topic_title', 'wptexturize' ); … … 36 41 add_filter( 'edit_allowedtags', 'bp_forums_add_allowed_tags' ); 37 42 43 function bp_forums_filter_tag_link( $link, $tag, $page, $context ) { 44 global $bp; 45 46 return apply_filters( 'bp_forums_filter_tag_link', $bp->root_domain . '/' . $bp->forums->slug . '/tag/' . $tag . '/' ); 47 } 48 add_filter( 'bb_get_tag_link', 'bp_forums_filter_tag_link', 10, 4); 49 38 50 ?> -
trunk/bp-forums/bp-forums-templatetags.php
r1844 r1858 19 19 var $order; 20 20 21 function BP_Forums_Template_Forum( $forum_id, $per_page, $max, $no_stickies ) { 22 global $bp; 23 24 $this->pag_page = isset( $_REQUEST['forum_page'] ) ? intval( $_REQUEST['forum_page'] ) : 1; 25 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 26 27 $this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) ); 28 21 function BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter ) { 22 global $bp; 23 24 $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1; 25 $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page; 26 27 /* Only show stickies if we are viewing a single group forum, otherwise we could end up with hundreds globally */ 28 if ( !$forum_id ) 29 $show_stickies = 'no'; // bbPress needs str 'no' 30 31 switch ( $type ) { 32 case 'newest': default: 33 $this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'filter' => $filter, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 34 break; 35 36 case 'popular': 37 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'popular', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 38 break; 39 40 case 'unreplied': 41 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'unreplied', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 42 break; 43 44 case 'personal': 45 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'personal', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 46 break; 47 48 case 'tag': 49 $this->topics = bp_forums_get_forum_topics( array( 'type' => 'tag', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) ); 50 break; 51 } 52 53 $this->topics = apply_filters( 'bp_forums_template_topics', $this->topics, $type, $forum_id, $per_page, $max, $no_stickies ); 54 29 55 if ( !(int)$this->topics ) { 30 56 $this->topic_count = 0; 31 57 $this->total_topic_count = 0; 32 58 } else { 33 $topic_count = bp_forums_get_forum( $forum_id ); 34 $topic_count = (int)$topic_count->topics; 59 if ( $forum_id ) { 60 $topic_count = bp_forums_get_forum( $forum_id ); 61 $topic_count = (int)$topic_count->topics; 62 } else if ( function_exists( 'groups_total_public_forum_topic_count' ) ) { 63 $topic_count = (int)groups_total_public_forum_topic_count( $type ); 64 } else { 65 $topic_count = count( $this->topics ); 66 } 35 67 36 68 if ( !$max || $max >= $topic_count ) … … 48 80 } 49 81 } 50 82 83 $this->topic_count = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies ); 84 $this->total_topic_count = apply_filters( 'bp_forums_template_total_topic_count', $this->total_topic_count, $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies ); 85 51 86 if ( !$no_stickies) { 52 87 /* Place stickies at the top - not sure why bbPress doesn't do this? */ … … 61 96 62 97 $this->pag_links = paginate_links( array( 63 'base' => add_query_arg( array( ' forum_page' => '%#%', 'num' => $this->pag_num ) ),98 'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ), 64 99 'format' => '', 65 100 'total' => ceil($this->total_topic_count / $this->pag_num), … … 117 152 } 118 153 119 function bp_has_ topics( $args = '' ) {154 function bp_has_forum_topics( $args = '' ) { 120 155 global $forum_template, $bp; 121 156 122 157 $defaults = array( 158 'type' => 'newest', 123 159 'forum_id' => false, 124 160 'per_page' => 15, 125 161 'max' => false, 126 'no_stickies' => false 162 'no_stickies' => false, 163 'filter' => false 127 164 ); 128 165 … … 130 167 extract( $r, EXTR_SKIP ); 131 168 132 if ( !$forum_id && $bp->current_component == $bp->groups->slug ) 169 /* If we're in a single group, set this group's forum_id */ 170 if ( !$forum_id && $bp->groups->current_group ) { 133 171 $forum_id = groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ); 134 135 if ( is_numeric( $forum_id ) ) 136 $forum_template = new BP_Forums_Template_Forum( (int)$forum_id, $per_page, $max, $no_stickies ); 137 else 138 return false; 139 140 return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template ); 141 } 142 143 function bp_topics() { 172 173 /* If it turns out there is no forum for this group, return false so we don't fetch all global topics */ 174 if ( !$forum_id ) 175 return false; 176 } 177 178 /* If we're viewing a tag in the directory, let's auto set the filter to the tag name */ 179 if ( $bp->is_directory && 'tag' == $type && !empty( $bp->action_variables[0] ) ) 180 $filter = $bp->action_variables[0]; 181 182 /* If $_GET['s'] is set, let's auto populate the filter var */ 183 if ( $bp->is_directory && !empty( $_GET['s'] ) ) 184 $filter = $_GET['s']; 185 186 $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter ); 187 188 return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template ); 189 } 190 /* DEPRECATED use bp_has_forum_topics() */ 191 function bp_has_topics( $args = '' ) { return bp_has_forum_topics( $args ); } 192 193 function bp_forum_topics() { 144 194 global $forum_template; 145 195 return $forum_template->user_topics(); 146 196 } 147 148 function bp_the_topic() { 197 /* DEPRECATED use bp_has_forum_topics() */ 198 function bp_topics() { return bp_forum_topics(); } 199 200 function bp_the_forum_topic() { 149 201 global $forum_template; 150 202 return $forum_template->the_topic(); 151 203 } 204 /* DEPRECATED use bp_the_forum_topic() */ 205 function bp_the_topic() { return bp_the_forum_topic(); } 152 206 153 207 function bp_the_topic_id() { … … 224 278 } 225 279 280 function bp_the_topic_object_id() { 281 echo bp_get_the_topic_object_id(); 282 } 283 function bp_get_the_topic_object_id() { 284 global $forum_template; 285 286 return apply_filters( 'bp_get_the_topic_object_id', $forum_template->topic->object_id ); 287 } 288 289 function bp_the_topic_object_name() { 290 echo bp_get_the_topic_object_name(); 291 } 292 function bp_get_the_topic_object_name() { 293 global $forum_template; 294 295 return apply_filters( 'bp_get_the_topic_object_name', $forum_template->topic->object_name ); 296 } 297 298 function bp_the_topic_object_slug() { 299 echo bp_get_the_topic_object_slug(); 300 } 301 function bp_get_the_topic_object_slug() { 302 global $forum_template; 303 304 return apply_filters( 'bp_get_the_topic_object_slug', $forum_template->topic->object_slug ); 305 } 306 307 function bp_the_topic_object_permalink() { 308 echo bp_get_the_topic_object_permalink(); 309 } 310 function bp_get_the_topic_object_permalink() { 311 global $forum_template; 312 313 /* Currently this will only work with group forums, extended support in the future */ 314 return apply_filters( 'bp_get_the_topic_object_permalink', $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/' ); 315 } 316 226 317 function bp_the_topic_last_poster_name() { 227 318 echo bp_get_the_topic_last_poster_name(); … … 233 324 } 234 325 235 function bp_the_topic_ last_poster_avatar( $args = '' ) {236 echo bp_get_the_topic_ last_poster_avatar( $args );237 } 238 function bp_get_the_topic_ last_poster_avatar( $args = '' ) {326 function bp_the_topic_object_avatar( $args = '' ) { 327 echo bp_get_the_topic_object_avatar( $args ); 328 } 329 function bp_get_the_topic_object_avatar( $args = '' ) { 239 330 global $forum_template; 240 331 … … 248 339 extract( $r, EXTR_SKIP ); 249 340 341 return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) ); 342 } 343 344 function bp_the_topic_last_poster_avatar( $args = '' ) { 345 echo bp_get_the_topic_last_poster_avatar( $args ); 346 } 347 function bp_get_the_topic_last_poster_avatar( $args = '' ) { 348 global $forum_template; 349 350 $defaults = array( 351 'type' => 'thumb', 352 'width' => false, 353 'height' => false, 354 ); 355 356 $r = wp_parse_args( $args, $defaults ); 357 extract( $r, EXTR_SKIP ); 358 250 359 return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 251 360 } … … 325 434 return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) ); 326 435 } 327 436 437 function bp_the_topic_total_posts() { 438 echo bp_get_the_topic_total_posts(); 439 } 440 function bp_get_the_topic_total_posts() { 441 global $forum_template; 442 443 return $forum_template->topic->topic_posts; 444 } 445 328 446 function bp_the_topic_tag_count() { 329 447 echo bp_get_the_topic_tag_count(); … … 341 459 global $forum_template, $bp; 342 460 343 if ( $bp->is_single_item ) 461 if ( $forum_template->topic->object_slug ) 462 $permalink = $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/'; 463 else if ( $bp->is_single_item ) 344 464 $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/'; 345 465 else 346 $permalink = $bp->root_domain . $bp->current_component . '/' . $bp->current_action . '/';466 $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_action . '/'; 347 467 348 return apply_filters( 'bp_get_the_topic_permalink', $permalink . 'forum/topic/' . $forum_template->topic->topic_slug );468 return apply_filters( 'bp_get_the_topic_permalink', $permalink . 'forum/topic/' . $forum_template->topic->topic_slug . '/' ); 349 469 } 350 470 … … 403 523 extract( $r, EXTR_SKIP ); 404 524 405 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . ' /edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' ';525 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' '; 406 526 407 527 if ( 0 == (int)$forum_template->topic->topic_sticky ) 408 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . ' /stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky', 'buddypress' ) . '</a> ' . $seperator . ' ';528 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky', 'buddypress' ) . '</a> ' . $seperator . ' '; 409 529 else 410 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . ' /unstick', 'bp_forums_unstick_topic' ) . '">' . __( 'Un-stick', 'buddypress' ) . '</a> ' . $seperator . ' ';530 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'unstick', 'bp_forums_unstick_topic' ) . '">' . __( 'Un-stick', 'buddypress' ) . '</a> ' . $seperator . ' '; 411 531 412 532 if ( 0 == (int)$forum_template->topic->topic_open ) 413 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . ' /open', 'bp_forums_open_topic' ) . '">' . __( 'Open', 'buddypress' ) . '</a> ' . $seperator . ' ';533 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'open', 'bp_forums_open_topic' ) . '">' . __( 'Open', 'buddypress' ) . '</a> ' . $seperator . ' '; 414 534 else 415 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . ' /close', 'bp_forums_close_topic' ) . '">' . __( 'Close', 'buddypress' ) . '</a> ' . $seperator . ' ';416 417 $links .= '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . ' /delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>';535 $links .= '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'close', 'bp_forums_close_topic' ) . '">' . __( 'Close', 'buddypress' ) . '</a> ' . $seperator . ' '; 536 537 $links .= '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>'; 418 538 419 539 return $links; … … 429 549 $class = false; 430 550 431 if ( 1 == (int)$forum_template->topic->topic_sticky ) { 432 $class .= 'sticky'; 433 } 434 435 if ( 0 == (int)$forum_template->topic->topic_open ) { 551 if ( $forum_template->current_topic % 2 == 1 ) 552 $class .= 'alt'; 553 554 if ( 1 == (int)$forum_template->topic->topic_sticky ) 555 $class .= ' sticky'; 556 557 if ( 0 == (int)$forum_template->topic->topic_open ) 436 558 $class .= ' closed'; 437 }438 559 439 560 return trim( $class ); 440 561 } 441 562 563 function bp_my_forum_topics_link() { 564 echo bp_get_my_forum_topics_link(); 565 } 566 function bp_get_my_forum_topics_link() { 567 global $bp; 568 569 return apply_filters( 'bp_get_my_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/personal/' ); 570 } 571 572 function bp_unreplied_forum_topics_link() { 573 echo bp_get_unreplied_forum_topics_link(); 574 } 575 function bp_get_unreplied_forum_topics_link() { 576 global $bp; 577 578 return apply_filters( 'bp_get_unreplied_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/unreplied/' ); 579 } 580 581 582 function bp_popular_forum_topics_link() { 583 echo bp_get_popular_forum_topics_link(); 584 } 585 function bp_get_popular_forum_topics_link() { 586 global $bp; 587 588 return apply_filters( 'bp_get_popular_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/popular/' ); 589 } 590 591 function bp_newest_forum_topics_link() { 592 echo bp_get_newest_forum_topics_link(); 593 } 594 function bp_get_newest_forum_topics_link() { 595 global $bp; 596 597 return apply_filters( 'bp_get_newest_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/' ); 598 } 599 600 function bp_forum_topic_type() { 601 echo bp_get_forum_topic_type(); 602 } 603 function bp_get_forum_topic_type() { 604 global $bp; 605 606 if ( !$bp->is_directory || !$bp->current_action ) 607 return 'newest'; 608 609 610 return apply_filters( 'bp_get_forum_topic_type', $bp->current_action ); 611 } 612 613 function bp_forums_tag_name() { 614 echo bp_get_forums_tag_name(); 615 } 616 function bp_get_forums_tag_name() { 617 global $bp; 618 619 if ( $bp->is_directory && $bp->forums->slug == $bp->current_component ) 620 return apply_filters( 'bp_get_forums_tag_name', $bp->action_variables[0] ); 621 } 442 622 443 623 function bp_forum_pagination() { … … 580 760 } 581 761 582 function bp_has_ topic_posts( $args = '' ) {762 function bp_has_forum_topic_posts( $args = '' ) { 583 763 global $topic_template, $bp; 584 764 … … 602 782 return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), &$topic_template ); 603 783 } 604 605 function bp_topic_posts() { 784 /* DEPRECATED use bp_has_forum_topic_posts() */ 785 function bp_has_topic_posts() { return bp_has_forum_topic_posts( $args ); } 786 787 function bp_forum_topic_posts() { 606 788 global $topic_template; 607 789 return $topic_template->user_posts(); 608 790 } 609 610 function bp_the_topic_post() { 791 /* DEPRECATED use bp_forum_topic_posts() */ 792 function bp_topic_posts() { return bp_forum_topic_posts(); } 793 794 function bp_the_forum_topic_post() { 611 795 global $topic_template; 612 796 return $topic_template->the_post(); 613 797 } 798 /* DEPRECATED use bp_the_forum_topic_post() */ 799 function bp_the_topic_post() { return bp_the_forum_topic_post(); } 614 800 615 801 function bp_the_topic_post_id() { … … 695 881 extract( $r, EXTR_SKIP ); 696 882 697 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id . ' /post/' . $topic_template->post->post_id . '/edit/', 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' ';698 $links .= '<a class="confirm" id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . ' /post/' . $topic_template->post->post_id . '/delete/', 'bp_forums_delete_post' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>';883 $links = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id . 'edit/post/' . $topic_template->post->post_id, 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' '; 884 $links .= '<a class="confirm" id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete/post/' . $topic_template->post->post_id, 'bp_forums_delete_post' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>'; 699 885 700 886 return $links; … … 707 893 global $bp; 708 894 709 $post = bp_forums_get_post( $bp->action_variables[ 3] );895 $post = bp_forums_get_post( $bp->action_variables[4] ); 710 896 return attribute_escape( $post->post_text ); 711 897 } … … 732 918 } 733 919 920 function bp_directory_forums_search_form() { 921 global $bp; ?> 922 <form action="<?php echo $bp->root_domain . '/' . $bp->forums->slug . '/'; ?>" method="get" id="search-forums-form"> 923 <label><input type="text" name="s" id="forums_search" value="<?php if ( isset( $_GET['s'] ) ) { echo attribute_escape( $_GET['s'] ); } else { _e( 'Search anything...', 'buddypress' ); } ?>" onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label> 924 <input type="submit" id="forums_search_submit" name="submit" value="<?php _e( 'Search', 'buddypress' ) ?>" /> 925 </form> 926 <?php 927 } 928 734 929 function bp_forum_permalink() { 735 930 echo bp_get_forum_permalink(); … … 746 941 } 747 942 943 function bp_forum_directory_permalink() { 944 echo bp_get_forum_directory_permalink(); 945 } 946 function bp_get_forum_directory_permalink() { 947 global $bp; 948 949 return apply_filters( 'bp_get_forum_directory_permalink', $bp->root_domain . '/' . $bp->forums->slug ); 950 } 951 952 function bp_forums_tag_heat_map( $args = '' ) { 953 $defaults = array( 954 'smallest' => '10', 955 'largest' => '42', 956 'sizing' => 'px', 957 'limit' => '50' 958 ); 959 960 $r = wp_parse_args( $args, $defaults ); 961 extract( $r, EXTR_SKIP ); 962 963 bb_tag_heat_map( $smallest, $largest, $sizing, $limit ); 964 } 965 748 966 function bp_forum_action() { 749 967 echo bp_get_forum_action(); -
trunk/bp-groups.php
r1852 r1858 581 581 582 582 if ( $topic_slug && $topic_id ) { 583 583 584 584 /* Posting a reply */ 585 585 if ( !$bp->action_variables[2] && isset( $_POST['submit_reply'] ) ) { 586 586 /* Check the nonce */ 587 587 check_admin_referer( 'bp_forums_new_reply' ); 588 588 589 /* Auto join this user if they are not yet a member of this group */ 590 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 591 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 592 589 593 if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) ) 590 594 bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' ); … … 593 597 594 598 if ( $_SERVER['QUERY_STRING'] ) 595 $query_vars = '?' . $_SERVER['QUERY_STRING']; 596 599 $query_vars = '?' . $_SERVER['QUERY_STRING']; 600 597 601 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' . $query_vars ); 598 602 } … … 609 613 610 614 do_action( 'groups_stick_topic', $topic_id ); 611 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');615 bp_core_redirect( wp_get_referer() ); 612 616 } 613 617 … … 623 627 624 628 do_action( 'groups_unstick_topic', $topic_id ); 625 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');629 bp_core_redirect( wp_get_referer() ); 626 630 } 627 631 … … 637 641 638 642 do_action( 'groups_close_topic', $topic_id ); 639 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');643 bp_core_redirect( wp_get_referer() ); 640 644 } 641 645 … … 651 655 652 656 do_action( 'groups_open_topic', $topic_id ); 653 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/');657 bp_core_redirect( wp_get_referer() ); 654 658 } 655 659 656 660 /* Delete a topic */ 657 else if ( 'delete' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {661 else if ( 'delete' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 658 662 /* Check the nonce */ 659 663 check_admin_referer( 'bp_forums_delete_topic' ); 660 664 661 if ( !groups_delete_ forum_topic( $topic_id ) )665 if ( !groups_delete_group_forum_topic( $topic_id ) ) 662 666 bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' ); 663 667 else 664 668 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 665 666 do_action( 'groups_delete_topic', $topic_id ); 667 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 669 670 bp_core_redirect( wp_get_referer() ); 668 671 } 669 672 670 673 /* Editing a topic */ 671 else if ( 'edit' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {674 else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 672 675 if ( isset( $_POST['save_changes'] ) ) { 673 676 /* Check the nonce */ … … 691 694 692 695 /* Delete a post */ 693 else if ( 'delete' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 696 697 else if ( 'delete' == $bp->action_variables[2] && $bp->action_variables[4] && ( $bp->is_item_admin || $bp->is_item_mod ) ) { 694 698 /* Check the nonce */ 695 check_admin_referer( 'bp_forums_delete_ topic' );696 697 if ( !groups_delete_ forum_topic($topic_id ) )698 bp_core_add_message( __( 'There was an error deleting th e topic', 'buddypress'), 'error' );699 check_admin_referer( 'bp_forums_delete_post' ); 700 701 if ( !groups_delete_group_forum_post( $bp->action_variables[3], $topic_id ) ) 702 bp_core_add_message( __( 'There was an error deleting that post', 'buddypress'), 'error' ); 699 703 else 700 bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') ); 701 702 do_action( 'groups_delete_topic', $topic_id ); 703 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/' ); 704 } 705 706 704 bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') ); 705 706 bp_core_redirect( wp_get_referer() ); 707 } 708 707 709 /* Editing a post */ 708 else if ( 'edit' == $bp->action_variables[ 4] && $post_id = $bp->action_variables[3] ) {710 else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) { 709 711 if ( isset( $_POST['save_changes'] ) ) { 710 712 /* Check the nonce */ 711 713 check_admin_referer( 'bp_forums_edit_post' ); 712 714 713 715 if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) ) 714 716 bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' ); … … 741 743 check_admin_referer( 'bp_forums_new_topic' ); 742 744 743 if ( !groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) 745 /* Auto join this user if they are not yet a member of this group */ 746 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) 747 groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id ); 748 749 if ( !$topic = groups_new_group_forum_topic( $_POST['topic_title'], $_POST['topic_text'], $_POST['topic_tags'], $forum_id ) ) 744 750 bp_core_add_message( __( 'There was an error when creating the topic', 'buddypress'), 'error' ); 745 751 else 746 752 bp_core_add_message( __( 'The topic was created successfully', 'buddypress') ); 747 753 748 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/ ' );754 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' ); 749 755 } 750 756 … … 2028 2034 $group_desc = $bp->groups->current_group->description; 2029 2035 2030 $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc ription' => $group_desc ) );2031 2036 $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc' => $group_desc ) ); 2037 2032 2038 groups_update_groupmeta( $group_id, 'forum_id', $forum_id ); 2033 2039 … … 2037 2043 function groups_new_group_forum_post( $post_text, $topic_id ) { 2038 2044 global $bp; 2045 2046 if ( empty( $post_text ) ) 2047 return false; 2039 2048 2040 2049 if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) { … … 2063 2072 function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) { 2064 2073 global $bp; 2074 2075 if ( empty( $topic_title ) || empty( $topic_text ) ) 2076 return false; 2065 2077 2066 2078 if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) { … … 2116 2128 } 2117 2129 2118 function groups_delete_forum_topic( $topic_id ) {2119 global $bp;2120 2121 if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {2122 /* Delete the activity stream item */2123 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {2124 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) );2125 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) );2126 }2127 2128 do_action( 'groups_delete_forum_topic', $topic_id );2129 2130 return true;2131 }2132 2133 return false;2134 }2135 2136 2130 function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) { 2137 2131 global $bp; … … 2166 2160 } 2167 2161 2168 // function groups_delete_forum_post( $post_id, $topic_id ) { 2169 // global $bp; 2170 // 2171 // if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) { 2172 // /* Delete the activity stream item */ 2173 // if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2174 // bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'secondary_item_id' => $post_id 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2175 // } 2176 // 2177 // do_action( 'groups_delete_forum_topic', $topic_id ); 2178 // 2179 // return true; 2180 // } 2181 // 2182 // return false; 2183 // } 2162 function groups_delete_group_forum_topic( $topic_id ) { 2163 global $bp; 2164 2165 if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) { 2166 /* Delete the activity stream item */ 2167 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2168 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_topic' ) ); 2169 bp_activity_delete_by_item_id( array( 'item_id' => $topic_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) ); 2170 } 2171 2172 do_action( 'groups_delete_group_forum_topic', $topic_id ); 2173 2174 return true; 2175 } 2176 2177 return false; 2178 } 2179 2180 function groups_delete_group_forum_post( $post_id, $topic_id ) { 2181 global $bp; 2182 2183 if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) { 2184 /* Delete the activity stream item */ 2185 if ( function_exists( 'bp_activity_delete_by_item_id' ) ) { 2186 bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) ); 2187 } 2188 2189 do_action( 'groups_delete_group_forum_post', $post_id, $topic_id ); 2190 2191 return true; 2192 } 2193 2194 return false; 2195 } 2196 2197 2198 function groups_total_public_forum_topic_count( $type = 'newest' ) { 2199 return apply_filters( 'groups_total_public_forum_topic_count', BP_Groups_Group::get_global_forum_topic_count( $type ) ); 2200 } 2184 2201 2185 2202 /*** Group Invitations *********************************************************/ -
trunk/bp-groups/bp-groups-classes.php
r1826 r1858 445 445 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) ); 446 446 } 447 448 function get_global_forum_topic_count( $type ) { 449 global $bbdb, $wpdb, $bp; 450 451 if ( 'unreplied' == $type ) 452 $bp->groups->filter_sql = ' AND t.topic_posts = 1'; 453 454 $extra_sql = apply_filters( 'groups_total_public_forum_topic_count', $bp->groups->filter_sql, $type ); 455 456 return $wpdb->get_var( "SELECT count(t.topic_id) FROM {$bbdb->topics} AS t, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND t.topic_status = '0' AND t.topic_sticky != '2' {$extra_sql} " ); 457 } 447 458 } 448 459 -
trunk/bp-groups/bp-groups-filters.php
r1608 r1858 57 57 add_filter( 'groups_group_news_before_save', 'force_balance_tags' ); 58 58 59 /**** Filters for group forums ****/ 60 function groups_add_forum_privacy_sql() { 61 global $bp; 62 63 if ( !$bp->groups->current_group ) { 64 add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' ); 65 add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' ); 66 add_filter( 'get_topics_where', 'groups_add_forum_where_sql' ); 67 } 68 } 69 add_filter( 'bbpress_init', 'groups_add_forum_privacy_sql' ); 70 71 function groups_add_forum_fields_sql( $sql ) { 72 return $sql . ', g.id as object_id, g.name as object_name, g.slug as object_slug'; 73 } 74 75 function groups_add_forum_tables_sql( $sql ) { 76 global $bp; 77 return ', ' . $bp->groups->table_name . ' AS g LEFT JOIN ' . $bp->groups->table_name_groupmeta . ' AS gm ON g.id = gm.group_id '; 78 } 79 80 function groups_add_forum_where_sql( $sql ) { 81 global $bp; 82 83 $bp->groups->filter_sql = ' AND ' . $sql; 84 return "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND " . $sql; 85 } 86 87 function groups_filter_bbpress_caps( $value, $cap, $args ) { 88 global $bp; 89 90 if ( is_site_admin() ) 91 return true; 92 93 if ( 'add_tag_to' == $cap ) 94 if ( $bp->groups->current_group->user_has_access ) return true; 95 96 if ( 'manage_forums' == $cap && is_user_logged_in() ) 97 return true; 98 99 return $value; 100 } 101 add_filter( 'bb_current_user_can', 'groups_filter_bbpress_caps', 10, 3 ); 102 59 103 ?> -
trunk/bp-groups/bp-groups-templatetags.php
r1844 r1858 405 405 406 406 return apply_filters( 'bp_get_group_type', $type ); 407 } 408 409 function bp_group_status() { 410 echo bp_get_group_status(); 411 } 412 function bp_get_group_status( $group = false ) { 413 global $groups_template; 414 415 if ( !$group ) 416 $group =& $groups_template->group; 417 418 return apply_filters( 'bp_get_group_status', $group->status ); 407 419 } 408 420
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)