Skip to:
Content

Ticket #2343: forum_id_check.patch

File forum_id_check.patch, 1.6 KB (added by johnjamesjacoby, 4 years ago)

Quick patch, needs testing

  • bp-forums-templatetags.php

     
    66        var $topics; 
    77        var $topic; 
    88 
     9        var $forum_id; 
     10 
    911        var $in_the_loop; 
    1012 
    1113        var $pag_page; 
     
    2527                $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page; 
    2628                $this->type = $type; 
    2729                $this->search_terms = $search_terms; 
     30                $this->forum_id = $forum_id; 
    2831 
    2932                switch ( $type ) { 
    3033                        case 'newest': default: 
     
    693696        var $posts; 
    694697        var $post; 
    695698 
     699        var $forum_id; 
    696700        var $topic_id; 
    697701        var $topic; 
    698702 
     
    716720 
    717721                $this->topic_id = $topic_id; 
    718722                $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id ); 
     723                $this->forum_id = $forum_template->topic->forum_id; 
    719724 
    720725                $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) ); 
    721726 
     
    811816        if ( !$topic_id && $bp->current_component == $bp->groups->slug && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] ) 
    812817                $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[1] ); 
    813818 
    814         if ( is_numeric( $topic_id ) ) 
     819        if ( is_numeric( $topic_id ) ) { 
    815820                $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max ); 
    816         else 
     821                if ( $bp->current_component == $bp->groups->slug && $bp->groups->current_group->forum_id != $topic_template->forum_id ) 
     822                        return false; 
     823        } else { 
    817824                return false; 
     825        } 
    818826 
    819827        return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), &$topic_template ); 
    820828}