Skip to:
Content

BuddyPress.org

Changeset 623


Ignore:
Timestamp:
12/06/2008 01:31:08 AM (16 years ago)
Author:
apeatling
Message:

Fixed bp-blogs so that private blogs are not listed in the blogs directory, posts and comments on a private blog are not recorded in any activity feeds. Fixes #141

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-classes.php

    r617 r623  
    4242        global $wpdb, $bp, $current_user;
    4343
    44         if ( !$this->item_id || !$this->user_id )
     44        if ( !$this->item_id || !$this->user_id || $this->is_private )
    4545            return false;
    4646           
     
    110110           
    111111            for ( $i = 0; $i < count( $activities ); $i++ ) {
    112                 $activities_formatted[$i]['content'] = $activities[$i]->content;
    113                 $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link;
    114                 $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
    115                 $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
    116                 $activities_formatted[$i]['is_private'] = $activities[$i]->is_private;
     112                if ( !$activities[$i]->is_private ) {
     113                    $activities_formatted[$i]['content'] = $activities[$i]->content;
     114                    $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link;
     115                    $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
     116                    $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
     117                    $activities_formatted[$i]['is_private'] = $activities[$i]->is_private;
     118                }
    117119            }
    118120                           
     
    128130                    if ( !$content = call_user_func($bp[$activities[$i]->component_name]['format_activity_function'], $activities[$i]->item_id, $activities[$i]->user_id, $activities[$i]->component_action ) )
    129131                        continue;
    130                        
    131                     $activities_formatted[$i]['content'] = $content['content'];
    132                     $activities_formatted[$i]['primary_link'] = $content['primary_link'];
    133                     $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
    134                     $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
    135                     $activities_formatted[$i]['is_private'] = $activities[$i]->is_private;
     132                   
     133                    if ( !$activities[$i]->is_private ) {
     134                        $activities_formatted[$i]['content'] = $content['content'];
     135                        $activities_formatted[$i]['primary_link'] = $content['primary_link'];
     136                        $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
     137                        $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
     138                        $activities_formatted[$i]['is_private'] = $activities[$i]->is_private;
     139                    }
    136140                }
    137141               
     
    170174
    171175            for ( $i = 0; $i < count( $activities ); $i++ ) {
    172                 $activities_formatted[$i]['content'] = $activities[$i]->content;
    173                 $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link;
    174                 $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
    175                 $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
    176                 $activities_formatted[$i]['is_private'] = $activities[$i]->is_private;
     176                if ( !$activities[$i]->is_private ) {
     177                    $activities_formatted[$i]['content'] = $activities[$i]->content;
     178                    $activities_formatted[$i]['primary_link'] = $activities[$i]->primary_link;
     179                    $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
     180                    $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
     181                    $activities_formatted[$i]['is_private'] = $activities[$i]->is_private;
     182                }
    177183            }
    178184       
     
    216222       
    217223        /* Remove entries that are older than 6 months */
    218         $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['activity']['table_name_sitewide'] . " WHERE DATE_ADD(date_recorded, INTERVAL 6 MONTH) <= NOW()" ) );
     224        $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['activity']['table_name_sitewide'] . " WHERE DATE_ADD(date_recorded, INTERVAL 6 MONTHS) <= NOW()" ) );
    219225       
    220226        $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $bp['activity']['table_name_sitewide'] . " ORDER BY date_recorded DESC $limit_sql" ) );
  • trunk/bp-blogs.php

    r606 r623  
    345345    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() );
    346346   
    347     do_action( 'bp_blogs_new_blog', array( 'item_id' => $recorded_blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'is_private' => 0 ) );
     347    $is_private = bp_blogs_is_blog_hidden( $recorded_blog_id );
     348       
     349    do_action( 'bp_blogs_new_blog', array( 'item_id' => $recorded_blog_id, 'component_name' => 'blogs', 'component_action' => 'new_blog', 'is_private' => $is_private ) );
    348350}
    349351add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
     
    391393            bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
    392394           
    393             do_action( 'bp_blogs_new_blog_post', array( 'item_id' => $recorded_post_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'is_private' => 0, 'user_id' => $recorded_post->user_id ) );
     395            $is_private = bp_blogs_is_blog_hidden( $recorded_post->blog_id );
     396               
     397            do_action( 'bp_blogs_new_blog_post', array( 'item_id' => $recorded_post_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_post', 'is_private' => $is_private, 'user_id' => $recorded_post->user_id ) );
    394398        }
    395399    } else {
     
    445449                bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
    446450               
    447                 do_action( 'bp_blogs_new_blog_comment', array( 'item_id' => $recorded_commment_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'is_private' => 0, 'user_id' => $user_id ) );
     451                $is_private = bp_blogs_is_blog_hidden( $recorded_comment->blog_id );
     452
     453                do_action( 'bp_blogs_new_blog_comment', array( 'item_id' => $recorded_commment_id, 'component_name' => 'blogs', 'component_action' => 'new_blog_comment', 'is_private' => $is_private, 'user_id' => $user_id ) );
    448454            }
    449455        } else {
     
    562568add_action( 'bp_homebase_signup_completed', 'bp_blogs_register_existing_content', 10 );
    563569
     570function bp_blogs_get_blogs_for_user( $user_id ) {
     571    return BP_Blogs_Blog::get_blogs_for_user( $user_id );
     572}
     573
     574function bp_blogs_get_posts_for_user( $user_id ) {
     575    return BP_Blogs_Post::get_posts_for_user( $user_id );
     576}
     577
     578function bp_blogs_get_comments_for_user( $user_id ) {
     579    return BP_Blogs_Comment::get_comments_for_user( $user_id );
     580}
     581
    564582function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
    565583    global $bp;
     
    591609}
    592610
     611function bp_blogs_is_blog_hidden( $blog_id ) {
     612    return BP_Blogs_Blog::is_hidden( $blog_id );
     613}
    593614
    594615function bp_blogs_redirect_to_random_blog() {
     
    602623}
    603624add_action( 'wp', 'bp_blogs_redirect_to_random_blog', 6 );
     625
     626
    604627
    605628
  • trunk/bp-blogs/bp-blogs-classes.php

    r599 r623  
    9494        if ( !$user_id )
    9595            $user_id = $bp['current_userid'];
    96            
    97         $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp['blogs']['table_name'] . " WHERE user_id = %d", $user_id) );
     96       
     97        // Show logged in users their hidden blogs.
     98        if ( !bp_is_home() )
     99            $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT b.blog_id FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ", $user_id) );
     100        else
     101            $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT b.blog_id FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ", $user_id) );
     102           
    98103        $total_blog_count = BP_Blogs_Blog::total_blog_count( $user_id );
    99104       
     
    115120        if ( !$user_id )
    116121            $user_id = $bp['current_userid'];
    117        
    118         return $wpdb->get_var( $wpdb->prepare( "SELECT count(blog_id) FROM " . $bp['blogs']['table_name'] . " WHERE user_id = %d", $user_id) );
     122
     123        // If the user is logged in return the blog count including their hidden blogs.
     124        if ( !bp_is_home() )
     125            return $wpdb->get_var( $wpdb->prepare( "SELECT count(b.blog_id) FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
     126        else
     127            return $wpdb->get_var( $wpdb->prepare( "SELECT count(b.blog_id) FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );         
    119128    }
    120129   
     
    124133        if ( $limit && $page ) {
    125134            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    126             $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT count(b.blog_id) FROM " . $bp['blogs']['table_name'] . " b, " . $bp['blogs']['table_name_blogmeta'] . " bm WHERE b.blog_id = bm.blog_id AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
    127         }
    128            
    129         $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT b.blog_id FROM " . $bp['blogs']['table_name']. " b, " . $bp['blogs']['table_name_blogmeta'] . " bm WHERE b.blog_id = bm.blog_id AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
     135            $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT count(b.blog_id) FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN " . $bp['blogs']['table_name_blogmeta'] . " bm ON b.blog_id = bm.blog_id LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
     136        }
     137           
     138        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT b.blog_id FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN " . $bp['blogs']['table_name_blogmeta'] . " bm ON b.blog_id = bm.blog_id LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
    130139
    131140        return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
     
    167176        if ( $limit && $page ) {
    168177            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    169             $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT count(blog_id) FROM " . $bp['blogs']['table_name'] . " ORDER BY rand()" ) );
    170         }
    171        
    172         $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id FROM " . $bp['blogs']['table_name'] . " ORDER BY rand() {$pag_sql}" ) );         
     178            $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT count(b.blog_id) FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY rand()" ) );
     179        }
     180       
     181        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT b.blog_id FROM " . $bp['blogs']['table_name'] . " b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$pag_sql}" ) );         
    173182       
    174183        return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
     184    }
     185   
     186    function is_hidden( $blog_id ) {
     187        global $wpdb;
     188       
     189        if ( $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE blog_id = %d AND public = 1 AND archived = '0' AND spam = 0 AND mature = 0 AND deleted = 0", $blog_id ) ) )
     190            return false;
     191       
     192        return true;
    175193    }
    176194   
     
    266284       
    267285        if ( $blog_id )
    268             $blog_sql = $wpdb->prepare( " WHERE blog_id = %d", $blog_id );
    269        
    270         $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp['blogs']['table_name_blog_posts'] . "$blog_sql ORDER BY date_created DESC LIMIT $limit" ) );
     286            $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
     287       
     288        $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM " . $bp['blogs']['table_name_blog_posts'] . " p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );
    271289
    272290        for ( $i = 0; $i < count($post_ids); $i++ ) {
     
    282300        if ( !$user_id )
    283301            $user_id = $bp['current_userid'];
    284            
    285         $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp['blogs']['table_name_blog_posts'] . " WHERE user_id = %d ORDER BY date_created DESC", $user_id) );
    286         $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(post_id) FROM " . $bp['blogs']['table_name_blog_posts'] . " WHERE user_id = %d", $user_id) );
    287        
     302       
     303        // Show a logged in user their posts on private blogs, but not anyone else.
     304        if ( !bp_is_home() ) {
     305            $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM " . $bp['blogs']['table_name_blog_posts'] . " p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
     306            $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(p.post_id) FROM " . $bp['blogs']['table_name_blog_posts'] . " p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 p.user_id = %d", $user_id) );
     307        } else {
     308            $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM " . $bp['blogs']['table_name_blog_posts'] . " p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
     309            $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(p.post_id) FROM " . $bp['blogs']['table_name_blog_posts'] . " p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 p.user_id = %d", $user_id) );         
     310        }
     311           
     312           
    288313        for ( $i = 0; $i < count($post_ids); $i++ ) {
    289314            $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
     
    433458            $user_id = $bp['current_userid'];
    434459           
    435         $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT comment_id, blog_id FROM " . $bp['blogs']['table_name_blog_comments'] . " WHERE user_id = %d ORDER BY date_created ASC", $user_id) );
    436         $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(comment_id) FROM " . $bp['blogs']['table_name_blog_comments'] . " WHERE user_id = %d", $user_id) );
     460        // Show the logged in user their comments on hidden blogs, but not to anyone else.
     461        if ( !bp_is_home() ) {
     462            $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM " . $bp['blogs']['table_name_blog_comments'] . " c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
     463            $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(c.comment_id) FROM " . $bp['blogs']['table_name_blog_comments'] . " c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
     464        } else {
     465            $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM " . $bp['blogs']['table_name_blog_comments'] . " c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
     466            $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(c.comment_id) FROM " . $bp['blogs']['table_name_blog_comments'] . " c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );           
     467        }
    437468       
    438469        for ( $i = 0; $i < count($comment_ids); $i++ ) {
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r554 r623  
    2424        $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5;
    2525
    26         $this->blogs = BP_Blogs_Blog::get_blogs_for_user( $user_id );
     26        $this->blogs = bp_blogs_get_blogs_for_user( $user_id );
    2727        $this->total_blog_count = (int)$this->blogs['count'];
    2828        $this->blogs = $this->blogs['blogs'];
     
    142142        $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5;
    143143
    144         $this->posts = BP_Blogs_Post::get_posts_for_user( $user_id );
     144        $this->posts = bp_blogs_get_posts_for_user( $user_id );
    145145        $this->total_post_count = (int)$this->posts['count'];
    146146        $this->posts = $this->posts['posts'];
     
    486486        $this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 5;
    487487
    488         $this->comments = BP_Blogs_Comment::get_comments_for_user( $user_id );
     488        $this->comments = bp_blogs_get_comments_for_user( $user_id );
    489489        $this->total_comment_count = (int)$this->comments['count'];
    490490        $this->comments = $this->comments['comments'];
  • trunk/bp-core.php

    r616 r623  
    22
    33/* Define the current version number for checking if DB tables are up to date. */
    4 define( 'BP_CORE_VERSION', '0.2.9.8' );
     4define( 'BP_CORE_VERSION', '0.3' );
    55
    66/* Define the slug for member pages and the members directory (e.g. domain.com/[members] ) */
     
    186186    dbDelta($sql);
    187187   
     188    /* Add names of root components to the banned blog list to avoid conflicts */
     189    bp_core_add_illegal_names();
     190   
    188191    // dbDelta won't change character sets, so we need to do this seperately.
    189192    // This will only be in here pre v1.0
     
    398401 * @param $function The function to run when this sub nav item is selected.
    399402 * @param $css_id The id to give the nav item in the HTML (for css highlighting)
    400  * @param $loggedin_user_only Should only the logged in user be able to access this page?
     403 * @param $user_has_access Should the logged in user be able to access this page?
    401404 * @param $admin_only Should this sub nav item only be visible/accessible to the site admin?
    402405 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    404407function bp_core_add_subnav_item( $parent_id, $slug, $name, $link, $function, $css_id = false, $user_has_access = true, $admin_only = false ) {
    405408    global $bp;
    406    
    407     if ( !$user_has_access && !bp_is_home() )
    408         return false;
    409        
     409
    410410    if ( $admin_only && !is_site_admin() )
    411411        return false;
     
    420420    );
    421421   
    422     if ( function_exists($function) && $bp['current_action'] == $slug && $bp['current_component'] == $parent_id )
     422    if ( function_exists($function) && $user_has_access && $bp['current_action'] == $slug && $bp['current_component'] == $parent_id )
    423423        add_action( 'wp', $function, 3 );
    424424}
     
    998998 *
    999999 * Reorder the core component navigation array items into the desired order.
     1000 * This is done this way because we cannot assume that any one component is present.
    10001001 *
    10011002 * @package BuddyPress Core
     
    10181019                unset($nav_array[$key]);
    10191020            break;
    1020             case 'profile':
     1021            case 'profile': // For profiles without bp-xprofile installed
    10211022                $new_nav[1] = $nav_array[$key];
    10221023                unset($nav_array[$key]);
     
    10421043                unset($nav_array[$key]);
    10431044            break;
    1044             case $bp['gallery']['slug']:
     1045            case $bp['photos']['slug']:
    10451046                $new_nav[7] = $nav_array[$key];
    10461047                unset($nav_array[$key]);
     
    11001101}
    11011102
     1103function bp_core_add_illegal_names() {
     1104    $current = maybe_unserialize( get_site_option( 'illegal_names' ) );
     1105    $bp_illegal_names = explode( ',', BP_CORE_ROOT_COMPONENTS );
     1106   
     1107    if ( is_array( $current ) ) {
     1108        foreach( $bp_illegal_names as $bp_illegal_name ) {
     1109            if ( !in_array( $bp_illegal_name, $current ) )
     1110                $current[] = $bp_illegal_name;
     1111        }
     1112        $new = $current;
     1113    } else {
     1114        $bp_illegal_names[] = $current;
     1115        $new = $bp_illegal_names;
     1116    }
     1117
     1118    update_site_option( 'illegal_names', $new );
     1119}
     1120
    11021121
    11031122/**
  • trunk/bp-core/bp-core-adminbar.php

    r516 r623  
    22
    33function bp_core_admin_bar() {
    4     global $bp, $wpdb, $current_blog;
     4    global $bp, $wpdb, $current_blog, $doing_admin_bar;
     5   
     6    $doing_admin_bar = true;
    57   
    68    if ( !(int)get_site_option( 'show-loggedout-adminbar' ) && !is_user_logged_in() )
     
    169171    echo '</ul>';
    170172    echo '</div>';
     173
     174    $doing_admin_bar = false;
    171175}
    172176
  • trunk/bp-core/bp-core-templatetags.php

    r621 r623  
    182182
    183183function bp_is_home() {
    184     global $bp;
    185    
    186     if ( !is_user_logged_in() || is_null($bp['loggedin_userid']) || is_null($bp['current_userid']) )
    187         return false;
     184    global $bp, $current_blog, $doing_admin_bar;
     185   
     186    if ( is_user_logged_in() && $bp['loggedin_userid'] == $bp['current_userid'] )
     187        return true;
    188188       
    189     if ( $bp['loggedin_userid'] == $bp['current_userid'] )
    190         return true;
    191 
    192189    return false;
    193190}
  • trunk/bp-friends.php

    r612 r623  
    509509    $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
    510510   
    511     if ( BP_Friends_Friendship::accept( $friendship_id ) ) {
     511    if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) {
    512512        friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    513513       
     
    531531function friends_reject_friendship( $friendship_id ) {
    532532    $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
    533    
    534     if ( BP_Friends_Friendship::reject( $friendship_id ) ) {
     533
     534    if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
    535535        // Remove the friend request notice
    536536        bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );   
     
    541541   
    542542    return false;
     543}
     544
     545function friends_is_friendship_confirmed( $friendship_id ) {
     546    $friendship = new BP_Friends_Friendship( $friendship_id );
     547    return $friendship->is_confirmed;
    543548}
    544549
  • trunk/bp-messages.php

    r580 r623  
    149149   
    150150    /* Add the subnav items to the profile */
    151     bp_core_add_subnav_item( $bp['messages']['slug'], 'inbox', __('Inbox', 'buddypress') . $count_indicator, $messages_link, 'messages_screen_inbox' );
    152     bp_core_add_subnav_item( $bp['messages']['slug'], 'sentbox', __('Sent Messages', 'buddypress'), $messages_link, 'messages_screen_sentbox' );
    153     bp_core_add_subnav_item( $bp['messages']['slug'], 'compose', __('Compose', 'buddypress'), $messages_link, 'messages_screen_compose' );
     151    bp_core_add_subnav_item( $bp['messages']['slug'], 'inbox', __('Inbox', 'buddypress') . $count_indicator, $messages_link, 'messages_screen_inbox', false, bp_is_home() );
     152    bp_core_add_subnav_item( $bp['messages']['slug'], 'sentbox', __('Sent Messages', 'buddypress'), $messages_link, 'messages_screen_sentbox', false, bp_is_home() );
     153    bp_core_add_subnav_item( $bp['messages']['slug'], 'compose', __('Compose', 'buddypress'), $messages_link, 'messages_screen_compose', false, bp_is_home() );
    154154    bp_core_add_subnav_item( $bp['messages']['slug'], 'notices', __('Notices', 'buddypress'), $messages_link, 'messages_screen_notices', false, true, true );
    155155
Note: See TracChangeset for help on using the changeset viewer.