Skip to:
Content

BuddyPress.org

Ticket #2651: 2651.patch

File 2651.patch, 2.9 KB (added by boonebgorges, 15 years ago)
  • bp-forums.php

     
    375375
    376376        $defaults = array(
    377377                'topic_id' => false,
     378                'include' => false, // Comma-separated string of post IDs to include
     379                'exclude' => false, // Comma-separated string of post IDs to exclude
    378380                'page' => 1,
    379381                'per_page' => 15,
    380382                'order' => 'ASC'
     
    382384
    383385        $args = wp_parse_args( $args, $defaults );
    384386
     387        if ( $args['include'] ) {
     388                $args['post_id'] = $args['include'];
     389                unset( $args['include'] );
     390        }
     391       
     392        // Format exclude IDs in the bbPress fashion
     393        if ( $args['exclude'] ) {
     394                $exclude = '-' . str_replace( ',', ',-', $args['exclude'] );
     395                $exclude = str_replace( '--', '-', $exclude );
     396                if ( $args['post_id'] )
     397                        $args['post_id'] = (string) $args['post_id'] . ",$exclude";
     398                else
     399                        $args['post_id'] = $exclude;
     400        }
     401
    385402        $query = new BB_Query( 'post', $args, 'get_thread' );
    386403        return bp_forums_get_post_extras( $query->results );
    387404}
  • bp-forums/bp-forums-templatetags.php

     
    711711        var $sort_by;
    712712        var $order;
    713713
    714         function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {
     714        function BP_Forums_Template_Topic( $topic_id, $per_page, $max, $include, $exclude ) {
    715715                global $bp, $current_user, $forum_template;
    716716
    717717                $this->pag_page        = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
    718718                $this->pag_num         = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    719719
     720                $this->include = $include;
     721                $this->exclude = $exclude;
     722
    720723                $this->order           = $order;
    721724                $this->topic_id        = $topic_id;
    722725                $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
    723726
    724                 $this->posts           = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'order' => $this->order ) );
     727                $this->posts           = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'include' => $this->include, 'exclude' => $this->exclude, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'order' => $this->order ) );
    725728
    726729                if ( !$this->posts ) {
    727730                        $this->post_count = 0;
     
    812815
    813816        $defaults = array(
    814817                'topic_id' => false,
     818                'include' => false, // Comma-separated list of post IDs to include
     819                'exclude' => false, // Comma-separated list of post IDs to exclude
    815820                'per_page' => 15,
    816821                'max' => false
    817822        );
     
    823828                $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[1] );
    824829
    825830        if ( is_numeric( $topic_id ) )
    826                 $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max );
     831                $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max, $include, $exclude );
    827832        else
    828833                return false;
    829834