<!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" />
<title>[BuddyPress][9406] trunk/src: Move `$user_id` abstraction out of `bp_get_activities()` and into their respective scope filters.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/9406">9406</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/9406","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnjamesjacoby</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-01-28 22:50:33 +0000 (Wed, 28 Jan 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Move `$user_id` abstraction out of `bp_get_activities()` and into their respective scope filters.
This fixes a regression from Activity Query scope improvements causing private and hidden group activity queries to intersect with user ID's, resulting in unexpected activity stream items being displayed.
Tests included in <a href="http://buddypress.trac.wordpress.org/changeset/9405">r9405</a>.
Props r-a-y. Fixes <a href="http://buddypress.trac.wordpress.org/ticket/6169">#6169</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpactivitybpactivityfiltersphp">trunk/src/bp-activity/bp-activity-filters.php</a></li>
<li><a href="#trunksrcbpactivitybpactivitytemplatephp">trunk/src/bp-activity/bp-activity-template.php</a></li>
<li><a href="#trunksrcbpfriendsbpfriendsactivityphp">trunk/src/bp-friends/bp-friends-activity.php</a></li>
<li><a href="#trunksrcbpgroupsbpgroupsactivityphp">trunk/src/bp-groups/bp-groups-activity.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpactivitybpactivityfiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/bp-activity-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-filters.php 2015-01-28 22:39:33 UTC (rev 9405)
+++ trunk/src/bp-activity/bp-activity-filters.php 2015-01-28 22:50:33 UTC (rev 9406)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -639,7 +639,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_core_get_js_strings', 'bp_activity_heartbeat_strings', 10, 1 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/** SCOPES **************************************************************/
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/** Scopes ********************************************************************/
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Set up activity arguments for use with the 'just-me' scope.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -650,17 +650,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $filter Current activity arguments
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_activity_filter_just_me_scope( $retval, $filter ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
+
+ // Determine the user_id
+ if ( ! empty( $filter['user_id'] ) ) {
+ $user_id = $filter['user_id'];
+ } else {
+ $user_id = bp_displayed_user_id()
+ ? bp_displayed_user_id()
+ : bp_loggedin_user_id();
+ }
+
+ // Should we show all items regardless of sitewide visibility?
+ $show_hidden = array();
+ if ( ! empty( $user_id ) && $user_id !== bp_loggedin_user_id() ) {
+ $show_hidden = array(
+ 'column' => 'hide_sitewide',
+ 'value' => 0
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $retval = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'column' => 'user_id',
- 'value' => $filter['user_id']
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'relation' => 'AND',
+ array(
+ 'column' => 'user_id',
+ 'value' => $filter['user_id']
+ ),
+ $show_hidden,
+
+ // overrides
+ 'override' => array(
+ 'display_comments' => 'stream',
+ 'filter' => array( 'user_id' => 0 ),
+ 'show_hidden' => true
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $retval['override']['display_comments'] = 'stream';
-
- // wipe out the user ID
- $retval['override']['filter']['user_id'] = 0;
-
</del><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_scope', 10, 2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -674,22 +699,49 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $filter Current activity arguments
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_activity_filter_favorites_scope( $retval, $filter ) {
- $favs = bp_activity_get_user_favorites( $filter['user_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_activity_filter_favorites_scope( $retval = array(), $filter = array() ) {
+
+ // Determine the user_id
+ if ( ! empty( $filter['user_id'] ) ) {
+ $user_id = $filter['user_id'];
+ } else {
+ $user_id = bp_displayed_user_id()
+ ? bp_displayed_user_id()
+ : bp_loggedin_user_id();
+ }
+
+ // Determine the favorites
+ $favs = bp_activity_get_user_favorites( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $favs ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $favs = array( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Should we show all items regardless of sitewide visibility?
+ $show_hidden = array();
+ if ( ! empty( $user_id ) && ( $user_id !== bp_loggedin_user_id() ) ) {
+ $show_hidden = array(
+ 'column' => 'hide_sitewide',
+ 'value' => 0
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $retval = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'column' => 'id',
- 'compare' => 'IN',
- 'value' => (array) $favs
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'relation' => 'AND',
+ array(
+ 'column' => 'id',
+ 'compare' => 'IN',
+ 'value' => (array) $favs
+ ),
+ $show_hidden,
+
+ // overrides
+ 'override' => array(
+ 'display_comments' => true,
+ 'filter' => array( 'user_id' => 0 ),
+ 'show_hidden' => true
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $retval['override']['display_comments'] = true;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // wipe out the user ID
- $retval['override']['filter']['user_id'] = 0;
-
</del><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_activity_set_favorites_scope_args', 'bp_activity_filter_favorites_scope', 10, 2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -704,27 +756,54 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $filter Current activity arguments
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_activity_filter_mentions_scope( $retval, $filter ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_activity_filter_mentions_scope( $retval = array(), $filter = array() ) {
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Are mentions disabled?
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! bp_activity_do_mentions() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Determine the user_id
+ if ( ! empty( $filter['user_id'] ) ) {
+ $user_id = $filter['user_id'];
+ } else {
+ $user_id = bp_displayed_user_id()
+ ? bp_displayed_user_id()
+ : bp_loggedin_user_id();
+ }
+
+ // Should we show all items regardless of sitewide visibility?
+ $show_hidden = array();
+ if ( ! empty( $user_id ) && $user_id !== bp_loggedin_user_id() ) {
+ $show_hidden = array(
+ 'column' => 'hide_sitewide',
+ 'value' => 0
+ );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $retval = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'column' => 'content',
- 'compare' => 'LIKE',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'relation' => 'AND',
+ array(
+ 'column' => 'content',
+ 'compare' => 'LIKE',
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Start search at @ symbol and stop search at closing tag delimiter.
- 'value' => '@' . bp_activity_get_user_mentionname( $filter['user_id'] ) . '<'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Start search at @ symbol and stop search at closing tag delimiter.
+ 'value' => '@' . bp_activity_get_user_mentionname( $user_id ) . '<'
+ ),
+ $show_hidden,
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // wipe out current search terms if any
- // this is so the 'mentions' scope can be combined with other scopes
- $retval['override']['search_terms'] = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // overrides
+ 'override' => array(
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $retval['override']['display_comments'] = 'stream';
- $retval['override']['filter']['user_id'] = 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // clear search terms so 'mentions' scope works with other scopes
+ 'search_terms' => false,
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'display_comments' => 'stream',
+ 'filter' => array( 'user_id' => 0 ),
+ 'show_hidden' => true
+ ),
+ );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_activity_set_mentions_scope_args', 'bp_activity_filter_mentions_scope', 10, 2 );
</span></span></pre></div>
<a id="trunksrcbpactivitybpactivitytemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/bp-activity-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-template.php 2015-01-28 22:39:33 UTC (rev 9405)
+++ trunk/src/bp-activity/bp-activity-template.php 2015-01-28 22:50:33 UTC (rev 9406)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -622,19 +622,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $search_terms ) && ! empty( $_REQUEST['s'] ) )
</span><span class="cx" style="display: block; padding: 0 10px"> $search_terms = $_REQUEST['s'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Set some default arguments when using a scope
- if ( ! empty( $scope ) ) {
- // Determine which user ID applies
- if ( empty( $user_id ) ) {
- $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id();
- }
-
- // Should we show all items regardless of sitewide visibility?
- if ( ! empty( $user_id ) ) {
- $show_hidden = ( $user_id == bp_loggedin_user_id() ) ? 1 : 0;
- }
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Do not exceed the maximum per page
</span><span class="cx" style="display: block; padding: 0 10px"> if ( !empty( $max ) && ( (int) $per_page > (int) $max ) )
</span><span class="cx" style="display: block; padding: 0 10px"> $per_page = $max;
</span></span></pre></div>
<a id="trunksrcbpfriendsbpfriendsactivityphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-friends/bp-friends-activity.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/bp-friends-activity.php 2015-01-28 22:39:33 UTC (rev 9405)
+++ trunk/src/bp-friends/bp-friends-activity.php 2015-01-28 22:50:33 UTC (rev 9406)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -238,34 +238,44 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $filter Current activity arguments
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_friends_filter_activity_scope( $retval, $filter ) {
- $friends = friends_get_friend_user_ids( $filter['user_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_friends_filter_activity_scope( $retval = array(), $filter = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Determine the user_id
+ if ( ! empty( $filter['user_id'] ) ) {
+ $user_id = $filter['user_id'];
+ } else {
+ $user_id = bp_displayed_user_id()
+ ? bp_displayed_user_id()
+ : bp_loggedin_user_id();
+ }
+
+ // Determine friends of user
+ $friends = friends_get_friend_user_ids( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $friends ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $friends = array( 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $retval= array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $retval = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'relation' => 'AND',
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'column' => 'user_id',
</span><span class="cx" style="display: block; padding: 0 10px"> 'compare' => 'IN',
</span><span class="cx" style="display: block; padding: 0 10px"> 'value' => (array) $friends
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // we should only be able to view sitewide activity content for friends
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'column' => 'hide_sitewide',
</span><span class="cx" style="display: block; padding: 0 10px"> 'value' => 0
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // overrides
+ 'override' => array(
+ 'filter' => array( 'user_id' => 0 ),
+ 'show_hidden' => true
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // wipe out the user ID
- $retval['override']['filter']['user_id'] = 0;
-
- // make sure we aren't limiting items by 'hide_sitewide' since we're already
- // limiting it above
- $retval['override']['show_hidden'] = true;
-
</del><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_activity_set_friends_scope_args', 'bp_friends_filter_activity_scope', 10, 2 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -281,7 +291,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $filter Current activity arguments
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_friends_filter_activity_just_me_scope( $retval, $filter ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_friends_filter_activity_just_me_scope( $retval = array(), $filter = array() ) {
+
+ // Determine the user_id
+ if ( ! empty( $filter['user_id'] ) ) {
+ $user_id = $filter['user_id'];
+ } else {
+ $user_id = bp_displayed_user_id()
+ ? bp_displayed_user_id()
+ : bp_loggedin_user_id();
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Get the requested action
</span><span class="cx" style="display: block; padding: 0 10px"> $action = $filter['filter']['action'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -293,25 +313,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $action = array_flip( array_filter( $action ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * If filtering activities for something other than the friendship_created action
- * return without changing anything
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * If filtering activities for something other than the friendship_created
+ * action return without changing anything
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $action ) && ! isset( $action['friendship_created'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Juggle existing override value
+ $override = array();
+ if ( ! empty( $retval['override'] ) ) {
+ $override = $retval['override'];
+ unset( $retval['override'] );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Else make sure to get the friendship_created action, the user is involved in
</span><span class="cx" style="display: block; padding: 0 10px"> * - user initiated the friendship
</span><span class="cx" style="display: block; padding: 0 10px"> * - user has been requested a friendship
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $retval = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'relation' => 'OR',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $retval,
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'column' => 'user_id',
- 'value' => $filter['user_id']
- ),
- array(
</del><span class="cx" style="display: block; padding: 0 10px"> 'relation' => 'AND',
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'column' => 'component',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -319,14 +343,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'column' => 'secondary_item_id',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $filter['user_id'],
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => $user_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ),
- 'override' => array(
- 'display_comments' => 'stream',
- 'filter' => array( 'user_id' => 0 ),
- ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Juggle back override value
+ if ( ! empty( $override ) ) {
+ $retval['override'] = $override;
+ }
+
+ return $retval;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_activity_set_just-me_scope_args', 'bp_friends_filter_activity_just_me_scope', 20, 2 );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcbpgroupsbpgroupsactivityphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-groups/bp-groups-activity.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-groups/bp-groups-activity.php 2015-01-28 22:39:33 UTC (rev 9405)
+++ trunk/src/bp-groups/bp-groups-activity.php 2015-01-28 22:50:33 UTC (rev 9406)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,29 +242,55 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $filter Current activity arguments
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function bp_groups_filter_activity_scope( $retval, $filter ) {
- $groups = groups_get_user_groups( $filter['user_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function bp_groups_filter_activity_scope( $retval = array(), $filter = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Determine the user_id
+ if ( ! empty( $filter['user_id'] ) ) {
+ $user_id = $filter['user_id'];
+ } else {
+ $user_id = bp_displayed_user_id()
+ ? bp_displayed_user_id()
+ : bp_loggedin_user_id();
+ }
+
+ // Determine groups of user
+ $groups = groups_get_user_groups( $user_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $groups['groups'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $groups = array( 'groups' => 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $retval= array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Should we show all items regardless of sitewide visibility?
+ $show_hidden = array();
+ if ( ! empty( $user_id ) && ( $user_id !== bp_loggedin_user_id() ) ) {
+ $show_hidden = array(
+ 'column' => 'hide_sitewide',
+ 'value' => 0
+ );
+ }
+
+ $retval = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'relation' => 'AND',
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'column' => 'component',
- 'value' => buddypress()->groups->id
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'relation' => 'AND',
+ array(
+ 'column' => 'component',
+ 'value' => buddypress()->groups->id
+ ),
+ array(
+ 'column' => 'item_id',
+ 'compare' => 'IN',
+ 'value' => (array) $groups['groups']
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array(
- 'column' => 'item_id',
- 'compare' => 'IN',
- 'value' => (array) $groups['groups']
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $show_hidden,
+
+ // overrides
+ 'override' => array(
+ 'filter' => array( 'user_id' => 0 ),
+ 'show_hidden' => true
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // wipe out the user ID
- $retval['override']['filter']['user_id'] = 0;
-
</del><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'bp_activity_set_groups_scope_args', 'bp_groups_filter_activity_scope', 10, 2 );
</span></span></pre>
</div>
</div>
</body>
</html>