<!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][3985] trunk/bp-activity: Allow individual activity stream comments and forum replies to appear in favorites listings</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, #logmsg > ol { margin-left: 0; 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">
<dt>Revision</dt> <dd>3985</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-02-01 21:47:50 +0000 (Tue, 01 Feb 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow individual activity stream comments and forum replies to appear in favorites listings</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityactionsphp">trunk/bp-activity/bp-activity-actions.php</a></li>
<li><a href="#trunkbpactivitybpactivityclassesphp">trunk/bp-activity/bp-activity-classes.php</a></li>
<li><a href="#trunkbpactivitybpactivityfunctionsphp">trunk/bp-activity/bp-activity-functions.php</a></li>
<li><a href="#trunkbpactivitybpactivitytemplatephp">trunk/bp-activity/bp-activity-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-actions.php (3984 => 3985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-actions.php        2011-02-01 20:56:01 UTC (rev 3984)
+++ trunk/bp-activity/bp-activity-actions.php        2011-02-01 21:47:50 UTC (rev 3985)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         // Not viewing activity
</span><del>-        if ( ( $bp-&gt;current_component != $bp-&gt;activity-&gt;id ) || ( $bp-&gt;current_action != 'p' ) )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_current_action( 'p' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         // No activity to display
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         // Not viewing activity or action is not delete
</span><del>-        if ( ( $bp-&gt;current_component != $bp-&gt;activity-&gt;id ) || ( $bp-&gt;current_action != 'delete' ) )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_current_action( 'delete' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         // Not viewing a specific activity item
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         // Do not proceed if user is not logged in, not viewing activity, or not posting
</span><del>-        if ( !is_user_logged_in() || ( $bp-&gt;current_component != $bp-&gt;activity-&gt;id ) || ( 'post' != $bp-&gt;current_action ) )
</del><ins>+        if ( !is_user_logged_in() || ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_current_action( 'post' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         // Check the nonce
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx"> function bp_activity_action_post_comment() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !is_user_logged_in() || $bp-&gt;current_component != $bp-&gt;activity-&gt;id || $bp-&gt;current_action != 'reply' )
</del><ins>+        if ( !is_user_logged_in() || ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_current_action( 'reply' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         // Check the nonce
</span><span class="lines">@@ -183,10 +183,10 @@
</span><span class="cx"> function bp_activity_action_mark_favorite() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !is_user_logged_in() || $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || $bp-&gt;current_action != 'favorite' )
</del><ins>+        if ( !is_user_logged_in() || ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_current_action( 'favorite' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        /* Check the nonce */
</del><ins>+        // Check the nonce
</ins><span class="cx">         check_admin_referer( 'mark_favorite' );
</span><span class="cx"> 
</span><span class="cx">         if ( bp_activity_add_user_favorite( $bp-&gt;action_variables[0] ) )
</span><span class="lines">@@ -201,10 +201,10 @@
</span><span class="cx"> function bp_activity_action_remove_favorite() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !is_user_logged_in() || $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || $bp-&gt;current_action != 'unfavorite' )
</del><ins>+        if ( !is_user_logged_in() || ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_current_action( 'unfavorite' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        /* Check the nonce */
</del><ins>+        // Check the nonce
</ins><span class="cx">         check_admin_referer( 'unmark_favorite' );
</span><span class="cx"> 
</span><span class="cx">         if ( bp_activity_remove_user_favorite( $bp-&gt;action_variables[0] ) )
</span><span class="lines">@@ -219,7 +219,7 @@
</span><span class="cx"> function bp_activity_action_sitewide_feed() {
</span><span class="cx">         global $bp, $wp_query;
</span><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || $bp-&gt;current_action != 'feed' || ( isset( $bp-&gt;displayed_user-&gt;id ) &amp;&amp; $bp-&gt;displayed_user-&gt;id ) || isset( $bp-&gt;groups-&gt;current_group ) )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_current_action( 'feed' ) || bp_is_user() || isset( $bp-&gt;groups-&gt;current_group ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         $wp_query-&gt;is_404 = false;
</span><span class="lines">@@ -233,7 +233,7 @@
</span><span class="cx"> function bp_activity_action_personal_feed() {
</span><span class="cx">         global $bp, $wp_query;
</span><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || !$bp-&gt;displayed_user-&gt;id || $bp-&gt;current_action != 'feed' )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_user() || !bp_is_current_action( 'feed' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         $wp_query-&gt;is_404 = false;
</span><span class="lines">@@ -247,7 +247,7 @@
</span><span class="cx"> function bp_activity_action_friends_feed() {
</span><span class="cx">         global $bp, $wp_query;
</span><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || !$bp-&gt;displayed_user-&gt;id || $bp-&gt;current_action != $bp-&gt;friends-&gt;slug || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_user() || !bp_is_current_action( $bp-&gt;friends-&gt;slug ) || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         $wp_query-&gt;is_404 = false;
</span><span class="lines">@@ -261,7 +261,7 @@
</span><span class="cx"> function bp_activity_action_my_groups_feed() {
</span><span class="cx">         global $bp, $wp_query;
</span><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || !$bp-&gt;displayed_user-&gt;id || $bp-&gt;current_action != $bp-&gt;groups-&gt;slug || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_user() || !bp_is_current_action( $bp-&gt;groups-&gt;slug ) || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         $wp_query-&gt;is_404 = false;
</span><span class="lines">@@ -275,7 +275,7 @@
</span><span class="cx"> function bp_activity_action_mentions_feed() {
</span><span class="cx">         global $bp, $wp_query;
</span><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || !$bp-&gt;displayed_user-&gt;id || $bp-&gt;current_action != 'mentions' || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_user() || !bp_is_current_action( 'mentions' ) || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         $wp_query-&gt;is_404 = false;
</span><span class="lines">@@ -289,7 +289,7 @@
</span><span class="cx"> function bp_activity_action_favorites_feed() {
</span><span class="cx">         global $bp, $wp_query;
</span><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || !$bp-&gt;displayed_user-&gt;id || $bp-&gt;current_action != 'favorites' || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</del><ins>+        if ( ( $bp-&gt;activity-&gt;slug != bp_current_component() ) || !bp_is_user() || !bp_is_current_action( 'favorites' ) || !isset( $bp-&gt;action_variables[0] ) || $bp-&gt;action_variables[0] != 'feed' )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         $wp_query-&gt;is_404 = false;
</span></span></pre></div>
<a id="trunkbpactivitybpactivityclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-classes.php (3984 => 3985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-classes.php        2011-02-01 20:56:01 UTC (rev 3984)
+++ trunk/bp-activity/bp-activity-classes.php        2011-02-01 21:47:50 UTC (rev 3985)
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx">                 // Alter the query based on whether we want to show activity item
</span><span class="cx">                 // comments in the stream like normal comments or threaded below
</span><span class="cx">                 // the activity.
</span><del>-                if ( !$display_comments || 'threaded' == $display_comments )
</del><ins>+                if ( false === $display_comments || 'threaded' === $display_comments )
</ins><span class="cx">                         $where_conditions[] = &quot;a.type != 'activity_comment'&quot;;
</span><span class="cx"> 
</span><span class="cx">                 $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
</span></span></pre></div>
<a id="trunkbpactivitybpactivityfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-functions.php (3984 => 3985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-functions.php        2011-02-01 20:56:01 UTC (rev 3984)
+++ trunk/bp-activity/bp-activity-functions.php        2011-02-01 21:47:50 UTC (rev 3985)
</span><span class="lines">@@ -152,16 +152,9 @@
</span><span class="cx">                 $user_id = $bp-&gt;displayed_user-&gt;id;
</span><span class="cx"> 
</span><span class="cx">         // Get favorites for user
</span><del>-        $favs          = get_user_meta( $user_id, 'bp_favorite_activities', true );
-        $existing_favs = bp_activity_get_specific( array( 'activity_ids' =&gt; $favs ) );
</del><ins>+        $favs = get_user_meta( $user_id, 'bp_favorite_activities', true );
</ins><span class="cx"> 
</span><del>-        foreach( (array)$existing_favs['activities'] as $fav )
-                $new_favs[] = $fav-&gt;id;
-
-        $new_favs = array_unique( (array)$new_favs );
-        update_user_meta( $user_id, 'bp_favorite_activities', $new_favs );
-
-        return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
</del><ins>+        return apply_filters( 'bp_activity_get_user_favorites', $favs );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -549,12 +542,13 @@
</span><span class="cx">                 'per_page'         =&gt; false,  // results per page
</span><span class="cx">                 'max'              =&gt; false,  // Maximum number of results to return
</span><span class="cx">                 'sort'             =&gt; 'DESC', // sort ASC or DESC
</span><del>-                'display_comments' =&gt; false   // true or false to display threaded comments for these specific activity items
</del><ins>+                'display_comments' =&gt; false,  // true or false to display threaded comments for these specific activity items
+                'show_hidden'      =&gt; false
</ins><span class="cx">         );
</span><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx"> 
</span><del>-        return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids ) );
</del><ins>+        return apply_filters( 'bp_activity_get_specific', BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, $show_hidden, false, $activity_ids ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_add( $args = '' ) {
</span></span></pre></div>
<a id="trunkbpactivitybpactivitytemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-template.php (3984 => 3985)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-template.php        2011-02-01 20:56:01 UTC (rev 3984)
+++ trunk/bp-activity/bp-activity-template.php        2011-02-01 21:47:50 UTC (rev 3985)
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx"> 
</span><span class="cx">                 // Fetch specific activity items based on ID's
</span><span class="cx">                 if ( !empty( $include ) )
</span><del>-                        $this-&gt;activities = bp_activity_get_specific( array( 'activity_ids' =&gt; explode( ',', $include ), 'max' =&gt; $max, 'page' =&gt; $this-&gt;pag_page, 'per_page' =&gt; $this-&gt;pag_num, 'sort' =&gt; $sort, 'display_comments' =&gt; $display_comments ) );
</del><ins>+                        $this-&gt;activities = bp_activity_get_specific( array( 'activity_ids' =&gt; explode( ',', $include ), 'max' =&gt; $max, 'page' =&gt; $this-&gt;pag_page, 'per_page' =&gt; $this-&gt;pag_num, 'sort' =&gt; $sort, 'display_comments' =&gt; $display_comments, 'show_hidden' =&gt; $show_hidden ) );
</ins><span class="cx">                 // Fetch all activity items
</span><span class="cx">                 else
</span><span class="cx">                         $this-&gt;activities = bp_activity_get( array( 'display_comments' =&gt; $display_comments, 'max' =&gt; $max, 'per_page' =&gt; $this-&gt;pag_num, 'page' =&gt; $this-&gt;pag_page, 'sort' =&gt; $sort, 'search_terms' =&gt; $search_terms, 'filter' =&gt; $filter, 'show_hidden' =&gt; $show_hidden, 'exclude' =&gt; $exclude, 'in' =&gt; $in ) );
</span><span class="lines">@@ -316,12 +316,14 @@
</span><span class="cx">                                         if ( empty( $favs ) )
</span><span class="cx">                                                 return false;
</span><span class="cx"> 
</span><del>-                                        $include = implode( ',', (array)$favs );
</del><ins>+                                        $include          = implode( ',', (array)$favs );
+                                        $show_hidden      = true;
+                                        $display_comments = true;
</ins><span class="cx">                                         break;
</span><span class="cx">                                 case 'mentions':
</span><del>-                                        $user_nicename = ( !empty( $bp-&gt;displayed_user-&gt;id ) ) ? $bp-&gt;displayed_user-&gt;userdata-&gt;user_nicename : $bp-&gt;loggedin_user-&gt;userdata-&gt;user_nicename;
-                                        $user_login = ( !empty( $bp-&gt;displayed_user-&gt;id ) ) ? $bp-&gt;displayed_user-&gt;userdata-&gt;user_login : $bp-&gt;loggedin_user-&gt;userdata-&gt;user_login;
-                                        $search_terms = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '&lt;'; // Start search at @ symbol and stop search at closing tag delimiter.
</del><ins>+                                        $user_nicename    = ( !empty( $bp-&gt;displayed_user-&gt;id ) ) ? $bp-&gt;displayed_user-&gt;userdata-&gt;user_nicename : $bp-&gt;loggedin_user-&gt;userdata-&gt;user_nicename;
+                                        $user_login       = ( !empty( $bp-&gt;displayed_user-&gt;id ) ) ? $bp-&gt;displayed_user-&gt;userdata-&gt;user_login : $bp-&gt;loggedin_user-&gt;userdata-&gt;user_login;
+                                        $search_terms     = '@' . bp_core_get_username( $user_id, $user_nicename, $user_login ) . '&lt;'; // Start search at @ symbol and stop search at closing tag delimiter.
</ins><span class="cx">                                         $display_comments = 'stream';
</span><span class="cx">                                         $user_id = 0;
</span><span class="cx">                                         break;
</span></span></pre>
</div>
</div>

</body>
</html>