<!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] [3368] trunk: Adds exclude parameter for bp_has_members().</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>3368</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2010-11-06 20:15:27 +0000 (Sat, 06 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Adds exclude parameter for bp_has_members(). Fixes #2620</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreclassesphp">trunk/bp-core/bp-core-classes.php</a></li>
<li><a href="#trunkbpcorebpcoretemplatetagsphp">trunk/bp-core/bp-core-templatetags.php</a></li>
<li><a href="#trunkbpcorephp">trunk/bp-core.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-classes.php (3367 => 3368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-classes.php        2010-11-06 19:19:18 UTC (rev 3367)
+++ trunk/bp-core/bp-core-classes.php        2010-11-06 20:15:27 UTC (rev 3368)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx"> 
</span><span class="cx">         /* Static Functions */
</span><span class="cx"> 
</span><del>-        function get_users( $type, $limit = null, $page = 1, $user_id = false, $include = false, $search_terms = false, $populate_extras = true ) {
</del><ins>+        function get_users( $type, $limit = null, $page = 1, $user_id = false, $include = false, $search_terms = false, $populate_extras = true, $exclude = false ) {
</ins><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><span class="cx">                 $sql = array();
</span><span class="lines">@@ -140,6 +140,9 @@
</span><span class="cx"> 
</span><span class="cx">                 if ( 'alphabetical' == $type )
</span><span class="cx">                         $sql['where_alpha'] = &quot;AND pd.field_id = 1&quot;;
</span><ins>+                
+                if ( !empty( $exclude ) )
+                        $sql['where_exclude'] = &quot;AND u.ID NOT IN ({$exclude})&quot;;
</ins><span class="cx"> 
</span><span class="cx">                 if ( $include ) {
</span><span class="cx">                         if ( is_array( $include ) )
</span><span class="lines">@@ -231,7 +234,7 @@
</span><span class="cx">                 return array( 'users' =&gt; $paged_users, 'total' =&gt; $total_users );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true ) {
</del><ins>+        function get_users_by_letter( $letter, $limit = null, $page = 1, $populate_extras = true, $exclude = false ) {
</ins><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><span class="cx">                 if ( $limit &amp;&amp; $page )
</span><span class="lines">@@ -251,9 +254,11 @@
</span><span class="cx">                 $letter = like_escape( $wpdb-&gt;escape( $letter ) );
</span><span class="cx">                 $status_sql = bp_core_get_status_sql( 'u.' );
</span><span class="cx"> 
</span><del>-                $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb-&gt;prepare( &quot;SELECT COUNT(DISTINCT u.ID) FROM &quot; . CUSTOM_USER_TABLE . &quot; u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
-                $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb-&gt;prepare( &quot;SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM &quot; . CUSTOM_USER_TABLE . &quot; u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
</del><ins>+                $exclude_sql = ( !empty( $exclude ) ) ? &quot; AND u.ID NOT IN ({$exclude})&quot; : &quot;&quot;;
</ins><span class="cx"> 
</span><ins>+                $total_users_sql = apply_filters( 'bp_core_users_by_letter_count_sql', $wpdb-&gt;prepare( &quot;SELECT COUNT(DISTINCT u.ID) FROM &quot; . CUSTOM_USER_TABLE . &quot; u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%'  ORDER BY pd.value ASC&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter );
+                $paged_users_sql = apply_filters( 'bp_core_users_by_letter_sql', $wpdb-&gt;prepare( &quot;SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.user_email FROM &quot; . CUSTOM_USER_TABLE . &quot; u LEFT JOIN {$bp-&gt;profile-&gt;table_name_data} pd ON u.ID = pd.user_id LEFT JOIN {$bp-&gt;profile-&gt;table_name_fields} pf ON pd.field_id = pf.id WHERE {$status_sql} AND pf.name = %s {$exclude_sql} AND pd.value LIKE '$letter%%' ORDER BY pd.value ASC{$pag_sql}&quot;, BP_XPROFILE_FULLNAME_FIELD_NAME ), $letter, $pag_sql );
+                
</ins><span class="cx">                 $total_users = $wpdb-&gt;get_var( $total_users_sql );
</span><span class="cx">                 $paged_users = $wpdb-&gt;get_results( $paged_users_sql );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpcorebpcoretemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-templatetags.php (3367 => 3368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-templatetags.php        2010-11-06 19:19:18 UTC (rev 3367)
+++ trunk/bp-core/bp-core-templatetags.php        2010-11-06 20:15:27 UTC (rev 3368)
</span><span class="lines">@@ -17,7 +17,7 @@
</span><span class="cx">         var $pag_links;
</span><span class="cx">         var $total_member_count;
</span><span class="cx"> 
</span><del>-        function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras ) {
</del><ins>+        function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude ) {
</ins><span class="cx">                 global $bp;
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : $page_number;
</span><span class="lines">@@ -25,11 +25,11 @@
</span><span class="cx">                 $this-&gt;type     = $type;
</span><span class="cx"> 
</span><span class="cx">                 if ( isset( $_REQUEST['letter'] ) &amp;&amp; '' != $_REQUEST['letter'] )
</span><del>-                        $this-&gt;members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this-&gt;pag_num, $this-&gt;pag_page, $populate_extras );
</del><ins>+                        $this-&gt;members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this-&gt;pag_num, $this-&gt;pag_page, $populate_extras, $exclude );
</ins><span class="cx">                 else if ( false !== $include )
</span><span class="cx">                         $this-&gt;members = BP_Core_User::get_specific_users( $include, $this-&gt;pag_num, $this-&gt;pag_page, $populate_extras );
</span><span class="cx">                 else
</span><del>-                        $this-&gt;members = bp_core_get_users( array( 'type' =&gt; $this-&gt;type, 'per_page' =&gt; $this-&gt;pag_num, 'page' =&gt; $this-&gt;pag_page, 'user_id' =&gt; $user_id, 'include' =&gt; $include, 'search_terms' =&gt; $search_terms, 'populate_extras' =&gt; $populate_extras ) );
</del><ins>+                        $this-&gt;members = bp_core_get_users( array( 'type' =&gt; $this-&gt;type, 'per_page' =&gt; $this-&gt;pag_num, 'page' =&gt; $this-&gt;pag_page, 'user_id' =&gt; $user_id, 'include' =&gt; $include, 'search_terms' =&gt; $search_terms, 'populate_extras' =&gt; $populate_extras, 'exclude' =&gt; $exclude ) );
</ins><span class="cx"> 
</span><span class="cx">                 if ( !$max || $max &gt;= (int)$this-&gt;members['total'] )
</span><span class="cx">                         $this-&gt;total_member_count = (int)$this-&gt;members['total'];
</span><span class="lines">@@ -140,7 +140,8 @@
</span><span class="cx">                 'per_page' =&gt; 20,
</span><span class="cx">                 'max' =&gt; false,
</span><span class="cx"> 
</span><del>-                'include' =&gt; false, // Pass a user_id or comma separated list of user_ids to only show these users
</del><ins>+                'include' =&gt; false, // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users
+                'exclude' =&gt; false, // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
</ins><span class="cx"> 
</span><span class="cx">                 'user_id' =&gt; $user_id, // Pass a user_id to only show friends of this user
</span><span class="cx">                 'search_terms' =&gt; $search_terms, // Pass search_terms to filter users by their profile data
</span><span class="lines">@@ -160,7 +161,7 @@
</span><span class="cx">         if ( empty( $include ) &amp;&amp; $bp-&gt;friends-&gt;slug == $bp-&gt;current_component &amp;&amp; 'requests' == $bp-&gt;current_action )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras );
</del><ins>+        $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras, $exclude );
</ins><span class="cx">         return apply_filters( 'bp_has_members', $members_template-&gt;has_members(), &amp;$members_template );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (3367 => 3368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2010-11-06 19:19:18 UTC (rev 3367)
+++ trunk/bp-core.php        2010-11-06 20:15:27 UTC (rev 3368)
</span><span class="lines">@@ -534,6 +534,7 @@
</span><span class="cx">         $defaults = array(
</span><span class="cx">                 'type' =&gt; 'active', // active, newest, alphabetical, random or popular
</span><span class="cx">                 'user_id' =&gt; false, // Pass a user_id to limit to only friend connections for this user
</span><ins>+                'exclude' =&gt; false, // Users to exclude from results
</ins><span class="cx">                 'search_terms' =&gt; false, // Limit to users that match these search terms
</span><span class="cx"> 
</span><span class="cx">                 'include' =&gt; false, // Pass comma separated list of user_ids to limit to only these users
</span><span class="lines">@@ -545,7 +546,7 @@
</span><span class="cx">         $params = wp_parse_args( $args, $defaults );
</span><span class="cx">         extract( $params, EXTR_SKIP );
</span><span class="cx"> 
</span><del>-        return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras ), &amp;$params );
</del><ins>+        return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras, $exclude ), &amp;$params );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>

</body>
</html>