<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [2394] trunk: Fixes #1611,
#1637 - made hidden blogs visible to logged in user where appropriate.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2394</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-21 13:24:33 +0000 (Thu, 21 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fixes #1611, #1637 - made hidden blogs visible to logged in user where appropriate. Removed blog role from My Blogs admin menu since this is unreliable and too expensive to fetch on each page load.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpblogsbpblogsclassesphp">trunk/bp-blogs/bp-blogs-classes.php</a></li>
<li><a href="#trunkbpblogsphp">trunk/bp-blogs.php</a></li>
<li><a href="#trunkbpcorebpcoreadminbarphp">trunk/bp-core/bp-core-adminbar.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpblogsbpblogsclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs/bp-blogs-classes.php (2393 => 2394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs/bp-blogs-classes.php        2010-01-21 12:28:15 UTC (rev 2393)
+++ trunk/bp-blogs/bp-blogs-classes.php        2010-01-21 13:24:33 UTC (rev 2394)
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx">                 return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name} WHERE user_id = %d", $user_id ) );
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        function get_blogs_for_user( $user_id = false ) {
</del><ins>+        function get_blogs_for_user( $user_id = false, $show_hidden = false ) {
</ins><span class="cx">                 global $bp, $wpdb;
</span><span class="cx">
</span><span class="cx">                 if ( !$bp->blogs )
</span><span class="lines">@@ -114,10 +114,10 @@
</span><span class="cx">                         $user_id = $bp->displayed_user->id;
</span><span class="cx">
</span><span class="cx">                 // Show logged in users their hidden blogs.
</span><del>-                if ( !bp_is_my_profile() )
-                        $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, bm2.meta_value as description, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND b.blog_id = bm2.blog_id AND bm1.meta_key = 'name' AND bm2.meta_key = 'description' AND 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) );
</del><ins>+                if ( !bp_is_my_profile() && !$show_hidden )
+                        $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, bm2.meta_value as description, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND b.blog_id = bm2.blog_id AND bm1.meta_key = 'name' AND bm2.meta_key = 'description' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id) );
</ins><span class="cx">                 else
</span><del>-                        $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, bm2.meta_value as description, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND b.blog_id = bm2.blog_id AND bm1.meta_key = 'name' AND bm2.meta_key = 'description' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ", $user_id) );
</del><ins>+                        $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, bm2.meta_value as description, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1, {$bp->blogs->table_name_blogmeta} bm2 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND b.blog_id = bm2.blog_id AND bm1.meta_key = 'name' AND bm2.meta_key = 'description' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id) );
</ins><span class="cx">
</span><span class="cx">                 $total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
</span><span class="cx">
</span><span class="lines">@@ -175,11 +175,14 @@
</span><span class="cx">                 if ( !$bp->blogs )
</span><span class="cx">                         bp_blogs_setup_globals();
</span><span class="cx">
</span><ins>+                if ( !is_site_admin() )
+                        $hidden_sql = "AND wb.public = 1";
+
</ins><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><del>-                $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT 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}" ) );
-                $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT 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" ) );
</del><ins>+                $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT 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.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql} {$pag_sql}" ) );
+                $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT 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.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 {$hidden_sql}" ) );
</ins><span class="cx">
</span><span class="cx">                 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
</span><span class="cx">         }
</span><span class="lines">@@ -192,11 +195,14 @@
</span><span class="cx">
</span><span class="cx">                 $letter = like_escape( $wpdb->escape( $letter ) );
</span><span class="cx">
</span><ins>+                if ( !is_site_admin() )
+                        $hidden_sql = "AND wb.public = 1";
+
</ins><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><del>-                $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" ) );
-                $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" ) );
</del><ins>+                $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC{$pag_sql}" ) );
+                $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE bm.meta_key = 'name' AND bm.meta_value LIKE '$letter%%' {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY bm.meta_value ASC" ) );
</ins><span class="cx">
</span><span class="cx">                 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
</span><span class="cx">         }
</span><span class="lines">@@ -209,11 +215,14 @@
</span><span class="cx">
</span><span class="cx">                 $filter = like_escape( $wpdb->escape( $filter ) );
</span><span class="cx">
</span><ins>+                if ( !is_site_admin() )
+                        $hidden_sql = "AND wb.public = 1";
+
</ins><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><del>-                $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
-                $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) AND wb.public = 1 AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
</del><ins>+                $paged_blogs = $wpdb->get_results( "SELECT DISTINCT bm.blog_id FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC{$pag_sql}" );
+                $total_blogs = $wpdb->get_var( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name_blogmeta} bm LEFT JOIN {$wpdb->base_prefix}blogs wb ON bm.blog_id = wb.blog_id WHERE ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$hidden_sql} AND wb.mature = 0 AND wb.spam = 0 AND wb.archived = '0' AND wb.deleted = 0 ORDER BY meta_value ASC" );
</ins><span class="cx">
</span><span class="cx">                 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
</span><span class="cx">         }
</span><span class="lines">@@ -224,6 +233,9 @@
</span><span class="cx">                 if ( !$bp->blogs )
</span><span class="cx">                         bp_blogs_setup_globals();
</span><span class="cx">
</span><ins>+                if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
+                        $hidden_sql = "AND wb.public = 1";
+
</ins><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><span class="lines">@@ -244,6 +256,9 @@
</span><span class="cx">                 if ( !$bp->blogs )
</span><span class="cx">                         bp_blogs_setup_globals();
</span><span class="cx">
</span><ins>+                if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
+                        $hidden_sql = "AND wb.public = 1";
+
</ins><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><span class="lines">@@ -258,11 +273,11 @@
</span><span class="cx">
</span><span class="cx">                 if ( !empty( $search_terms ) ) {
</span><span class="cx">                         $filter = like_escape( $wpdb->escape( $search_terms ) );
</span><del>-                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND 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' AND ( ( bm2.meta_key = 'name' OR bm2.meta_key = 'description' ) AND bm2.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
-                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND 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' AND ( ( bm2.meta_key = 'name' OR bm2.meta_key = 'description' ) AND bm2.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
</del><ins>+                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND ( ( bm2.meta_key = 'name' OR bm2.meta_key = 'description' ) AND bm2.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
+                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' AND ( ( bm2.meta_key = 'name' OR bm2.meta_key = 'description' ) AND bm2.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
</ins><span class="cx">                 } else {
</span><del>-                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND 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' {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
-                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND 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' {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
</del><ins>+                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC {$pag_sql}" ) );
+                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT bm.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$hidden_sql} AND bm.meta_key = 'last_activity' {$user_sql} ORDER BY CONVERT(bm.meta_value, SIGNED) DESC" ) );
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
</span><span class="lines">@@ -274,6 +289,9 @@
</span><span class="cx">                 if ( !$bp->blogs )
</span><span class="cx">                         bp_blogs_setup_globals();
</span><span class="cx">
</span><ins>+                if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
+                        $hidden_sql = "AND wb.public = 1";
+
</ins><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><span class="lines">@@ -288,11 +306,11 @@
</span><span class="cx">
</span><span class="cx">                 if ( !empty( $search_terms ) ) {
</span><span class="cx">                         $filter = like_escape( $wpdb->escape( $search_terms ) );
</span><del>-                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id AND 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' AND bm2.meta_key = 'name' AND ( ( bm3.meta_key = 'name' OR bm3.meta_key = 'description' ) AND bm3.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY bm2.meta_value ASC {$pag_sql}" ) );
-                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id AND 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' AND bm2.meta_key = 'name' AND ( ( bm3.meta_key = 'name' OR bm3.meta_key = 'description' ) AND bm3.meta_value LIKE '%%$filter%%' ) {$user_sql}" ) );
</del><ins>+                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND ( ( bm3.meta_key = 'name' OR bm3.meta_key = 'description' ) AND bm3.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY bm2.meta_value ASC {$pag_sql}" ) );
+                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$bp->blogs->table_name_blogmeta} bm3, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND b.blog_id = bm3.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' AND ( ( bm3.meta_key = 'name' OR bm3.meta_key = 'description' ) AND bm3.meta_value LIKE '%%$filter%%' ) {$user_sql}" ) );
</ins><span class="cx">                 } else {
</span><del>-                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND 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' AND bm2.meta_key = 'name' {$user_sql} ORDER BY bm2.meta_value ASC {$pag_sql}" ) );
-                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id AND 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' AND bm2.meta_key = 'name' {$user_sql}" ) );
</del><ins>+                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' {$user_sql} ORDER BY bm2.meta_value ASC {$pag_sql}" ) );
+                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm, {$bp->blogs->table_name_blogmeta} bm2, {$wpdb->base_prefix}blogs wb WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND b.blog_id = bm2.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND bm.meta_key = 'last_activity' AND bm2.meta_key = 'name' {$user_sql}" ) );
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
</span><span class="lines">@@ -304,6 +322,9 @@
</span><span class="cx">                 if ( !$bp->blogs )
</span><span class="cx">                         bp_blogs_setup_globals();
</span><span class="cx">
</span><ins>+                if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
+                        $hidden_sql = "AND wb.public = 1";
+
</ins><span class="cx">                 if ( $limit && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx">
</span><span class="lines">@@ -318,11 +339,11 @@
</span><span class="cx">
</span><span class="cx">                 if ( !empty( $search_terms ) ) {
</span><span class="cx">                         $filter = like_escape( $wpdb->escape( $search_terms ) );
</span><del>-                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY wb.registered DESC {$pag_sql}" ) );
-                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id AND wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY wb.registered DESC" ) );
</del><ins>+                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY wb.registered DESC {$pag_sql}" ) );
+                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b, {$bp->blogs->table_name_blogmeta} bm WHERE b.blog_id = wb.blog_id AND b.blog_id = bm.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 AND ( ( bm.meta_key = 'name' OR bm.meta_key = 'description' ) AND bm.meta_value LIKE '%%$filter%%' ) {$user_sql} ORDER BY wb.registered DESC" ) );
</ins><span class="cx">                 } else {
</span><del>-                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT wb.blog_id FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b WHERE wb.blog_id = b.blog_id AND wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$user_sql} ORDER BY wb.registered DESC {$pag_sql}" ) );
-                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT wb.blog_id) FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b WHERE wb.blog_id = b.blog_id AND wb.public = 1 AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$user_sql} ORDER BY wb.registered DESC" ) );
</del><ins>+                        $paged_blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT wb.blog_id FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b WHERE wb.blog_id = b.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$user_sql} ORDER BY wb.registered DESC {$pag_sql}" ) );
+                        $total_blogs = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT wb.blog_id) FROM {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name} b WHERE wb.blog_id = b.blog_id {$hidden_sql} AND wb.archived = '0' AND wb.spam = 0 AND wb.mature = 0 AND wb.deleted = 0 {$user_sql} ORDER BY wb.registered DESC" ) );
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 return array( 'blogs' => $paged_blogs, 'total' => $total_blogs );
</span></span></pre></div>
<a id="trunkbpblogsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs.php (2393 => 2394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs.php        2010-01-21 12:28:15 UTC (rev 2393)
+++ trunk/bp-blogs.php        2010-01-21 13:24:33 UTC (rev 2394)
</span><span class="lines">@@ -627,8 +627,8 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'delete_blog', 'bp_blogs_remove_data_for_blog', 1 );
</span><span class="cx">
</span><del>-function bp_blogs_get_blogs_for_user( $user_id ) {
-        return BP_Blogs_Blog::get_blogs_for_user( $user_id );
</del><ins>+function bp_blogs_get_blogs_for_user( $user_id, $show_hidden = false ) {
+        return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function bp_blogs_get_posts_for_user( $user_id ) {
</span></span></pre></div>
<a id="trunkbpcorebpcoreadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-adminbar.php (2393 => 2394)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-adminbar.php        2010-01-21 12:28:15 UTC (rev 2393)
+++ trunk/bp-core/bp-core-adminbar.php        2010-01-21 13:24:33 UTC (rev 2394)
</span><span class="lines">@@ -90,31 +90,6 @@
</span><span class="cx">         echo '</li>';
</span><span class="cx"> }
</span><span class="cx">
</span><del>-// return a string indicating user's role in that blog
-function get_blog_role_for_user( $user, $blog ) {
-
-        // If the user is a site admin, just display admin.
-        if ( is_site_admin() )
-                return __( 'Admin', 'buddypress' );
-
-        $roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' );
-
-        if ( isset( $roles['subscriber'] ) )
-                $role = __( 'Subscriber', 'buddypress' );
-        elseif        ( isset( $roles['contributor'] ) )
-                $role = __( 'Contributor', 'buddypress' );
-        elseif        ( isset( $roles['author'] ) )
-                $role = __( 'Author', 'buddypress' );
-        elseif ( isset( $roles['editor'] ) )
-                $role = __( 'Editor', 'buddypress' );
-        elseif ( isset( $roles['administrator'] ) )
-                $role = __( 'Admin', 'buddypress' );
-        else
-                return false;
-
-        return $role;
-}
-
</del><span class="cx"> // *** "My Blogs" Menu ********
</span><span class="cx"> function bp_adminbar_blogs_menu() {
</span><span class="cx">         global $bp;
</span><span class="lines">@@ -122,9 +97,9 @@
</span><span class="cx">         if ( !is_user_logged_in() || !function_exists('bp_blogs_install') )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
-                $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id );
-                wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id, $blogs, 'bp' );
</del><ins>+        if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
+                $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
+                wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
</span><span class="lines">@@ -137,22 +112,18 @@
</span><span class="cx">         if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
</span><span class="cx">                 $counter = 0;
</span><span class="cx">                 foreach ( $blogs['blogs'] as $blog ) {
</span><del>-                        $role = get_blog_role_for_user( $bp->loggedin_user->id, $blog->id );
-
</del><span class="cx">                         $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
</span><ins>+
</ins><span class="cx">                         echo '<li' . $alt . '>';
</span><del>-                        echo '<a href="' . $blog->siteurl . '">' . $blog->name . ' (' . $role . ')</a>';
-                        if ( !( __( 'Subscriber', 'buddypress' ) == $role ) ) { // then they have something to display on the flyout menu
-                                echo '<ul>';
-                                echo '<li class="alt"><a href="' . $blog->siteurl . 'wp-admin/">' . __('Dashboard', 'buddypress') . '</a></li>';
-                                echo '<li><a href="' . $blog->siteurl . 'wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
-                                echo '<li class="alt"><a href="' . $blog->siteurl . 'wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
-                                echo '<li><a href="' . $blog->siteurl . 'wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
-                                if ( 'Admin' == $role ) {
-                                        echo '<li class="alt"><a href="' . $blog->siteurl . 'wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
-                                }
-                                echo '</ul>';
-                        }
</del><ins>+                        echo '<a href="' . esc_attr( $blog->siteurl ) . '">' . esc_html( $blog->name ) . '</a>';
+
+                        echo '<ul>';
+                        echo '<li class="alt"><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
+                        echo '<li><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
+                        echo '<li class="alt"><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
+                        echo '<li><a href="' . esc_attr( $blog->siteurl ) . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
+                        echo '</ul>';
+
</ins><span class="cx">                         echo '</li>';
</span><span class="cx">                         $counter++;
</span><span class="cx">                 }
</span><span class="lines">@@ -162,7 +133,7 @@
</span><span class="cx">
</span><span class="cx">         if ( bp_blog_signup_enabled() ) {
</span><span class="cx">                 echo '<li' . $alt . '>';
</span><del>-                echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __('Create a Blog!', 'buddypress') . '</a>';
</del><ins>+                echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';
</ins><span class="cx">                 echo '</li>';
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>