<!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] [2356] trunk:
  Fixes #1582 - missing activity favorites RSS feed.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2356</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-19 14:06:25 +0000 (Tue, 19 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixes #1582 - missing activity favorites RSS feed.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityclassesphp">trunk/bp-activity/bp-activity-classes.php</a></li>
<li><a href="#trunkbpactivityphp">trunk/bp-activity.php</a></li>
<li><a href="#trunkbpthemesbpdefault_incajaxphp">trunk/bp-themes/bp-default/_inc/ajax.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkbpactivityfeedsbpactivityfavoritesfeedphp">trunk/bp-activity/feeds/bp-activity-favorites-feed.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 (2355 => 2356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-classes.php        2010-01-19 11:59:56 UTC (rev 2355)
+++ trunk/bp-activity/bp-activity-classes.php        2010-01-19 14:06:25 UTC (rev 2356)
</span><span class="lines">@@ -217,9 +217,6 @@
</span><span class="cx">                 if ( $per_page &amp;&amp; $page )
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot;LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
</span><span class="cx"> 
</span><del>-                if ( $max )
-                        $max_sql = $wpdb-&gt;prepare( &quot;LIMIT %d&quot;, $max );
-
</del><span class="cx">                 /* Searching */
</span><span class="cx">                 if ( $search_terms ) {
</span><span class="cx">                         $search_terms = $wpdb-&gt;escape( $search_terms );
</span><span class="lines">@@ -248,13 +245,17 @@
</span><span class="cx">                 if ( $per_page &amp;&amp; $page &amp;&amp; $max )
</span><span class="cx">                         $activities = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}&quot; ) );
</span><span class="cx">                 else
</span><del>-                        $activities = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql} {$max_sql}&quot; ) );
</del><ins>+                        $activities = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}&quot; ) );
</ins><span class="cx"> 
</span><del>-                $total_activities = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT count(a.id) {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$max_sql}&quot; ) );
</del><ins>+                $total_activities = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT count(a.id) {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}&quot; ) );
</ins><span class="cx"> 
</span><span class="cx">                 if ( $activities &amp;&amp; $display_comments )
</span><span class="cx">                         $activities = BP_Activity_Activity::append_comments( &amp;$activities );
</span><span class="cx"> 
</span><ins>+                /* If $max is set, only return up to the max results */
+                if ( (int)$total_activities &gt; (int)$max )
+                        $total_activities = $max;
+
</ins><span class="cx">                 return array( 'activities' =&gt; $activities, 'total' =&gt; (int)$total_activities );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -269,18 +270,21 @@
</span><span class="cx">                 if ( $per_page &amp;&amp; $page )
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot;LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
</span><span class="cx"> 
</span><del>-                if ( $max )
-                        $max_sql = $wpdb-&gt;prepare( &quot;LIMIT %d&quot;, $max );
-
</del><span class="cx">                 if ( $sort != 'ASC' &amp;&amp; $sort != 'DESC' )
</span><span class="cx">                         $sort = 'DESC';
</span><span class="cx"> 
</span><del>-                $activities = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;activity-&gt;table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql $max_sql&quot; ) );
</del><ins>+                $activities = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;activity-&gt;table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql&quot; ) );
</ins><span class="cx">                 $total_activities = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT count(id) FROM {$bp-&gt;activity-&gt;table_name} WHERE id IN ({$activity_ids})&quot; ) );
</span><span class="cx"> 
</span><span class="cx">                 if ( $display_comments )
</span><span class="cx">                         $activities = BP_Activity_Activity::append_comments( $activities );
</span><span class="cx"> 
</span><ins>+                /* If $max is set, only return up to the max results */
+                if ( !empty( $max ) ) {
+                        if ( (int)$total_activities &gt; (int)$max )
+                                $total_activities = $max;
+                }
+
</ins><span class="cx">                 return array( 'activities' =&gt; $activities, 'total' =&gt; (int)$total_activities );
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpactivityfeedsbpactivityfavoritesfeedphp"></a>
<div class="addfile"><h4>Added: trunk/bp-activity/feeds/bp-activity-favorites-feed.php (0 => 2356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/feeds/bp-activity-favorites-feed.php                                (rev 0)
+++ trunk/bp-activity/feeds/bp-activity-favorites-feed.php        2010-01-19 14:06:25 UTC (rev 2356)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+&lt;?php
+/**
+ * RSS2 Feed Template for displaying a member's favorite activity
+ *
+ * @package BuddyPress
+ */
+header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
+header('Status: 200 OK');
+?&gt;
+&lt;?php echo '&lt;?xml version=&quot;1.0&quot; encoding=&quot;'.get_option('blog_charset').'&quot;?'.'&gt;'; ?&gt;
+
+&lt;rss version=&quot;2.0&quot;
+        xmlns:content=&quot;http://purl.org/rss/1.0/modules/content/&quot;
+        xmlns:wfw=&quot;http://wellformedweb.org/CommentAPI/&quot;
+        xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot;
+        xmlns:atom=&quot;http://www.w3.org/2005/Atom&quot;
+        &lt;?php do_action('bp_activity_mentions_feed'); ?&gt;
+&gt;
+
+&lt;channel&gt;
+        &lt;title&gt;&lt;?php echo $bp-&gt;displayed_user-&gt;fullname; ?&gt; - &lt;?php _e( 'Favorite Activity', 'buddypress' ) ?&gt;&lt;/title&gt;
+        &lt;atom:link href=&quot;&lt;?php self_link(); ?&gt;&quot; rel=&quot;self&quot; type=&quot;application/rss+xml&quot; /&gt;
+        &lt;link&gt;&lt;?php echo site_url( BP_ACTIVITY_SLUG . '/#my-favorites/' ) ?&gt;&lt;/link&gt;
+        &lt;description&gt;&lt;?php echo $bp-&gt;displayed_user-&gt;fullname; ?&gt; - &lt;?php _e( 'Favorite Activity', 'buddypress' ) ?&gt;&lt;/description&gt;
+        &lt;pubDate&gt;&lt;?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?&gt;&lt;/pubDate&gt;
+        &lt;generator&gt;http://buddypress.org/?v=&lt;?php echo BP_VERSION ?&gt;&lt;/generator&gt;
+        &lt;language&gt;&lt;?php echo get_option('rss_language'); ?&gt;&lt;/language&gt;
+        &lt;?php do_action('bp_activity_favorites_feed_head'); ?&gt;
+
+        &lt;?php
+                $favs = bp_activity_get_user_favorites( $bp-&gt;displayed_user-&gt;id );
+                $fav_ids = implode( ',', (array)$favs );
+        ?&gt;
+
+        &lt;?php if ( bp_has_activities( 'include=' . $fav_ids . '&amp;max=50&amp;display_comments=inline' ) ) : ?&gt;
+                &lt;?php while ( bp_activities() ) : bp_the_activity(); ?&gt;
+                        &lt;item&gt;
+                                &lt;guid&gt;&lt;?php bp_activity_thread_permalink() ?&gt;&lt;/guid&gt;
+                                &lt;title&gt;&lt;![CDATA[&lt;?php bp_activity_feed_item_title() ?&gt;]]&gt;&lt;/title&gt;
+                                &lt;link&gt;&lt;?php echo bp_activity_thread_permalink() ?&gt;&lt;/link&gt;
+                                &lt;pubDate&gt;&lt;?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?&gt;&lt;/pubDate&gt;
+
+                                &lt;description&gt;
+                                        &lt;![CDATA[
+                                        &lt;?php bp_activity_feed_item_description() ?&gt;
+
+                                        &lt;?php if ( bp_activity_can_comment() ) : ?&gt;
+                                                &lt;p&gt;&lt;?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?&gt;&lt;/p&gt;
+                                        &lt;?php endif; ?&gt;
+
+                                        &lt;?php if ( 'activity_comment' == bp_get_activity_action_name() ) : ?&gt;
+                                                &lt;br /&gt;&lt;strong&gt;&lt;?php _e( 'In reply to', 'buddypress' ) ?&gt;&lt;/strong&gt; -
+                                                &lt;?php bp_activity_parent_content() ?&gt;
+                                        &lt;?php endif; ?&gt;
+                                        ]]&gt;
+                                &lt;/description&gt;
+                                &lt;?php do_action('bp_activity_favorites_feed_item'); ?&gt;
+                        &lt;/item&gt;
+                &lt;?php endwhile; ?&gt;
+
+        &lt;?php endif; ?&gt;
+&lt;/channel&gt;
+&lt;/rss&gt;
</ins></span></pre></div>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (2355 => 2356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2010-01-19 11:59:56 UTC (rev 2355)
+++ trunk/bp-activity.php        2010-01-19 14:06:25 UTC (rev 2356)
</span><span class="lines">@@ -369,7 +369,20 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp', 'bp_activity_action_mentions_feed', 3 );
</span><span class="cx"> 
</span><ins>+function bp_activity_action_favorites_feed() {
+        global $bp, $wp_query;
</ins><span class="cx"> 
</span><ins>+        if ( $bp-&gt;current_component != $bp-&gt;activity-&gt;slug || !$bp-&gt;displayed_user-&gt;id || $bp-&gt;current_action != 'favorites' || $bp-&gt;action_variables[0] != 'feed' )
+                return false;
+
+        $wp_query-&gt;is_404 = false;
+        status_header( 200 );
+
+        include_once( 'bp-activity/feeds/bp-activity-favorites-feed.php' );
+        die;
+}
+add_action( 'wp', 'bp_activity_action_favorites_feed', 3 );
+
</ins><span class="cx"> /********************************************************************************
</span><span class="cx">  * Business Functions
</span><span class="cx">  *
</span><span class="lines">@@ -690,8 +703,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_get_user_favorites( $user_id ) {
</span><del>-        global $bp;
-
</del><span class="cx">         $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
</span><span class="cx">         $existing_favs = bp_activity_get_specific( array( 'activity_ids' =&gt; $my_favs ) );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_incajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/ajax.php (2355 => 2356)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-19 11:59:56 UTC (rev 2355)
+++ trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-19 14:06:25 UTC (rev 2356)
</span><span class="lines">@@ -193,7 +193,7 @@
</span><span class="cx"> 
</span><span class="cx">                                         $favorite_ids = implode( ',', (array)$favs );
</span><span class="cx">                                         $query_string = 'include=' . $favorite_ids;
</span><del>-                                        $feed_url = $bp-&gt;loggedin_user-&gt;domain  . BP_ACTIVITY_SLUG . '/my-favorites/feed/';
</del><ins>+                                        $feed_url = $bp-&gt;loggedin_user-&gt;domain  . BP_ACTIVITY_SLUG . '/favorites/feed/';
</ins><span class="cx">                                         break;
</span><span class="cx">                                 case 'atme':
</span><span class="cx">                                         $query_string = 'search_terms=@' . bp_core_get_username( $bp-&gt;loggedin_user-&gt;id, $bp-&gt;loggedin_user-&gt;userdata-&gt;user_nicename, $bp-&gt;loggedin_user-&gt;userdata-&gt;user_login );
</span></span></pre>
</div>
</div>

</body>
</html>