<!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] [2951] trunk: User join filters.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2951</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-04-24 17:14:47 +0000 (Sat, 24 Apr 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>User join filters.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityclassesphp">trunk/bp-activity/bp-activity-classes.php</a></li>
<li><a href="#trunkbpcorebpcoreclassesphp">trunk/bp-core/bp-core-classes.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsclassesphp">trunk/bp-groups/bp-groups-classes.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-classes.php (2950 => 2951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-classes.php        2010-04-24 15:34:25 UTC (rev 2950)
+++ trunk/bp-activity/bp-activity-classes.php        2010-04-24 17:14:47 UTC (rev 2951)
</span><span class="lines">@@ -130,9 +130,9 @@
</span><span class="cx">
</span><span class="cx">                 if ( $per_page && $page ) {
</span><span class="cx">                         $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
</span><del>-                        $activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
</del><ins>+                        $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) ) );
</ins><span class="cx">                 } else
</span><del>-                        $activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
</del><ins>+                        $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort ) ) );
</ins><span class="cx">
</span><span class="cx">                 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ) );
</span><span class="cx">
</span><span class="lines">@@ -366,7 +366,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         /* Retrieve all descendants of the $root node */
</span><del>-                        $descendants = $wpdb->get_results( $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ) );
</del><ins>+                        $descendants = $wpdb->get_results( apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' AND a.item_id = %d AND a.mptt_left BETWEEN %d AND %d ORDER BY a.date_recorded ASC", $activity_id, $left, $right ), $activity_id, $left, $right ) );
</ins><span class="cx">
</span><span class="cx">                         /* Loop descendants and build an assoc array */
</span><span class="cx">                         foreach ( (array)$descendants as $d ) {
</span></span></pre></div>
<a id="trunkbpcorebpcoreclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-classes.php (2950 => 2951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-classes.php        2010-04-24 15:34:25 UTC (rev 2950)
+++ trunk/bp-core/bp-core-classes.php        2010-04-24 17:14:47 UTC (rev 2951)
</span><span class="lines">@@ -124,9 +124,6 @@
</span><span class="cx">
</span><span class="cx">                 $sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID";
</span><span class="cx">
</span><del>-                if ( $search_terms && bp_is_active( 'xprofile' ) || 'alphabetical' == $type )
-                        $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
-
</del><span class="cx">                 $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
</span><span class="cx">
</span><span class="cx">                 if ( 'active' == $type || 'online' == $type )
</span><span class="lines">@@ -163,9 +160,9 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ( $search_terms && bp_is_active( 'xprofile' ) ) {
</del><ins>+                if ( $search_terms ) {
</ins><span class="cx">                         $search_terms = like_escape( $wpdb->escape( $search_terms ) );
</span><del>-                        $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
</del><ins>+                        $sql['where_searchterms'] = "AND u.display_name LIKE '%%$search_terms%%'";
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch ( $type ) {
</span><span class="lines">@@ -176,7 +173,7 @@
</span><span class="cx">                                 $sql[] = "ORDER BY u.user_registered DESC";
</span><span class="cx">                                 break;
</span><span class="cx">                         case 'alphabetical':
</span><del>-                                $sql[] = "ORDER BY pd.value ASC";
</del><ins>+                                $sql[] = "ORDER BY u.display_name ASC";
</ins><span class="cx">                                 break;
</span><span class="cx">                         case 'random':
</span><span class="cx">                                 $sql[] = "ORDER BY rand()";
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-classes.php (2950 => 2951)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-classes.php        2010-04-24 15:34:25 UTC (rev 2950)
+++ trunk/bp-groups/bp-groups-classes.php        2010-04-24 17:14:47 UTC (rev 2951)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">                         $this->is_member = BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $this->id );
</span><span class="cx">
</span><span class="cx">                         /* Get group admins and mods */
</span><del>-                        $admin_mods = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) );
</del><ins>+                        $admin_mods = $wpdb->get_results( apply_filters( 'bp_group_admin_mods_user_join_filter', $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ), $this->id ) );
</ins><span class="cx">                         foreach( (array)$admin_mods as $user ) {
</span><span class="cx">                                 if ( (int)$user->is_admin )
</span><span class="cx">                                         $this->admins[] = $user;
</span></span></pre>
</div>
</div>
</body>
</html>