<!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 && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
</span><span class="cx">
</span><del>-                if ( $max )
-                        $max_sql = $wpdb->prepare( "LIMIT %d", $max );
-
</del><span class="cx">                 /* Searching */
</span><span class="cx">                 if ( $search_terms ) {
</span><span class="cx">                         $search_terms = $wpdb->escape( $search_terms );
</span><span class="lines">@@ -248,13 +245,17 @@
</span><span class="cx">                 if ( $per_page && $page && $max )
</span><span class="cx">                         $activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
</span><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} {$max_sql}" ) );
</del><ins>+                        $activities = $wpdb->get_results( $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}" ) );
</ins><span class="cx">
</span><del>-                $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$max_sql}" ) );
</del><ins>+                $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}" ) );
</ins><span class="cx">
</span><span class="cx">                 if ( $activities && $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 ( (int)$total_activities > (int)$max )
+                        $total_activities = $max;
+
</ins><span class="cx">                 return array( 'activities' => $activities, 'total' => (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 && $page )
</span><span class="cx">                         $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
</span><span class="cx">
</span><del>-                if ( $max )
-                        $max_sql = $wpdb->prepare( "LIMIT %d", $max );
-
</del><span class="cx">                 if ( $sort != 'ASC' && $sort != 'DESC' )
</span><span class="cx">                         $sort = 'DESC';
</span><span class="cx">
</span><del>-                $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql $max_sql" ) );
</del><ins>+                $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids}) ORDER BY date_recorded {$sort} $pag_sql" ) );
</ins><span class="cx">                 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE id IN ({$activity_ids})" ) );
</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 > (int)$max )
+                                $total_activities = $max;
+                }
+
</ins><span class="cx">                 return array( 'activities' => $activities, 'total' => (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>+<?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');
+?>
+<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
+
+<rss version="2.0"
+        xmlns:content="http://purl.org/rss/1.0/modules/content/"
+        xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+        xmlns:dc="http://purl.org/dc/elements/1.1/"
+        xmlns:atom="http://www.w3.org/2005/Atom"
+        <?php do_action('bp_activity_mentions_feed'); ?>
+>
+
+<channel>
+        <title><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Favorite Activity', 'buddypress' ) ?></title>
+        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
+        <link><?php echo site_url( BP_ACTIVITY_SLUG . '/#my-favorites/' ) ?></link>
+        <description><?php echo $bp->displayed_user->fullname; ?> - <?php _e( 'Favorite Activity', 'buddypress' ) ?></description>
+        <pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_activity_get_last_updated(), false); ?></pubDate>
+        <generator>http://buddypress.org/?v=<?php echo BP_VERSION ?></generator>
+        <language><?php echo get_option('rss_language'); ?></language>
+        <?php do_action('bp_activity_favorites_feed_head'); ?>
+
+        <?php
+                $favs = bp_activity_get_user_favorites( $bp->displayed_user->id );
+                $fav_ids = implode( ',', (array)$favs );
+        ?>
+
+        <?php if ( bp_has_activities( 'include=' . $fav_ids . '&max=50&display_comments=inline' ) ) : ?>
+                <?php while ( bp_activities() ) : bp_the_activity(); ?>
+                        <item>
+                                <guid><?php bp_activity_thread_permalink() ?></guid>
+                                <title><![CDATA[<?php bp_activity_feed_item_title() ?>]]></title>
+                                <link><?php echo bp_activity_thread_permalink() ?></link>
+                                <pubDate><?php echo mysql2date('D, d M Y H:i:s O', bp_get_activity_feed_item_date(), false); ?></pubDate>
+
+                                <description>
+                                        <![CDATA[
+                                        <?php bp_activity_feed_item_description() ?>
+
+                                        <?php if ( bp_activity_can_comment() ) : ?>
+                                                <p><?php printf( __( 'Comments: %s', 'buddypress' ), bp_activity_get_comment_count() ); ?></p>
+                                        <?php endif; ?>
+
+                                        <?php if ( 'activity_comment' == bp_get_activity_action_name() ) : ?>
+                                                <br /><strong><?php _e( 'In reply to', 'buddypress' ) ?></strong> -
+                                                <?php bp_activity_parent_content() ?>
+                                        <?php endif; ?>
+                                        ]]>
+                                </description>
+                                <?php do_action('bp_activity_favorites_feed_item'); ?>
+                        </item>
+                <?php endwhile; ?>
+
+        <?php endif; ?>
+</channel>
+</rss>
</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->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'favorites' || $bp->action_variables[0] != 'feed' )
+                return false;
+
+        $wp_query->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' => $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->loggedin_user->domain . BP_ACTIVITY_SLUG . '/my-favorites/feed/';
</del><ins>+                                        $feed_url = $bp->loggedin_user->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->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login );
</span></span></pre>
</div>
</div>
</body>
</html>