<!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] [2322] trunk/bp-themes/bp-default/_inc:
  Better support for plugins to hook into ajax functionality in the default theme
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2322</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-17 20:27:37 +0000 (Sun, 17 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Better support for plugins to hook into ajax functionality in the default theme.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpthemesbpdefault_incajaxphp">trunk/bp-themes/bp-default/_inc/ajax.php</a></li>
<li><a href="#trunkbpthemesbpdefault_incglobaljs">trunk/bp-themes/bp-default/_inc/global.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpthemesbpdefault_incajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/ajax.php (2321 => 2322)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-17 20:02:09 UTC (rev 2321)
+++ trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-17 20:27:37 UTC (rev 2322)
</span><span class="lines">@@ -18,29 +18,31 @@
</span><span class="cx">         $page = esc_attr( $_POST['page'] );
</span><span class="cx">         $search_terms = esc_attr( $_POST['search_terms'] );
</span><span class="cx"> 
</span><ins>+        /* Plugins can pass extra parameters and use the bp_dtheme_ajax_querystring_content_filter filter to parse them */
+        $extras = esc_attr( $_POST['extras'] );
+
</ins><span class="cx">         if ( __( 'Search anything...', 'buddypress' ) == $search_terms || 'false' == $search_terms )
</span><span class="cx">                 $search_terms = false;
</span><span class="cx"> 
</span><span class="cx">         /* Build the querystring */
</span><del>-        if ( 'active' != $filter &amp;&amp; 'newest' != $filter &amp;&amp; 'popular' != $filter &amp;&amp; 'online' != $filter &amp;&amp; 'alphabetical' != $filter )
</del><ins>+        if ( empty( $filter ) )
</ins><span class="cx">                 $filter = 'active';
</span><span class="cx"> 
</span><ins>+        if ( empty( $type ) )
+                $type = 'all';
+
</ins><span class="cx">         $bp-&gt;ajax_querystring = 'type=' . $filter . '&amp;page=' . $page;
</span><span class="cx"> 
</span><del>-        if ( $search_terms )
</del><ins>+        if ( !empty( $search_terms ) )
</ins><span class="cx">                 $bp-&gt;ajax_querystring .= '&amp;search_terms=' . $search_terms;
</span><span class="cx"> 
</span><del>-        if ( !$type )
-                $type = 'all';
-
-        if ( ( 'all' != $type ) &amp;&amp; !is_user_logged_in() )
-                $filter = 'all';
-
-        if ( 'all' != $type || $bp-&gt;displayed_user-&gt;id ) {
</del><ins>+        if ( $bp-&gt;displayed_user-&gt;id ) {
</ins><span class="cx">                 $user_id = ( $bp-&gt;displayed_user-&gt;id ) ? $bp-&gt;displayed_user-&gt;id : $bp-&gt;loggedin_user-&gt;id;
</span><span class="cx">                 $bp-&gt;ajax_querystring .= '&amp;user_id=' . $user_id;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        $bp-&gt;ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_content_filter', $bp-&gt;ajax_querystring, $extras );
+
</ins><span class="cx">         locate_template( array( &quot;$content/$content-loop.php&quot; ), true );
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp_ajax_members_filter', 'bp_dtheme_content_filter' );
</span><span class="lines">@@ -163,7 +165,6 @@
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         if ( !$query_string ) {
</span><del>-
</del><span class="cx">                 /* If we are on a profile page we only want to show that users activity */
</span><span class="cx">                 if ( $bp-&gt;displayed_user-&gt;id ) {
</span><span class="cx">                         $query_string = 'user_id=' . $bp-&gt;displayed_user-&gt;id;
</span><span class="lines">@@ -237,9 +238,9 @@
</span><span class="cx">         }
</span><span class="cx">         $query_string = implode( '&amp;', $new_args ) . '&amp;page=' . $page;
</span><span class="cx"> 
</span><del>-        $bp-&gt;ajax_querystring = $query_string;
</del><ins>+        $bp-&gt;ajax_querystring = apply_filters( 'bp_dtheme_ajax_querystring_activity_filter', $query_string, $type );
</ins><span class="cx">         $result['query_string'] = $bp-&gt;ajax_querystring;
</span><del>-        $result['feed_url'] = $feed_url;
</del><ins>+        $result['feed_url'] = apply_filters( 'bp_dtheme_ajax_feed_url', $feed_url );
</ins><span class="cx"> 
</span><span class="cx">         /* Buffer the loop in the template to a var for JS to spit out. */
</span><span class="cx">         ob_start();
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_incglobaljs"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/global.js (2321 => 2322)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/global.js        2010-01-17 20:02:09 UTC (rev 2321)
+++ trunk/bp-themes/bp-default/_inc/global.js        2010-01-17 20:27:37 UTC (rev 2322)
</span><span class="lines">@@ -11,7 +11,7 @@
</span><span class="cx"> 
</span><span class="cx">         /* Members */
</span><span class="cx">         if ( j('div.members').length )
</span><del>-                bp_filter_request( j.cookie('bp-members-type'), j.cookie('bp-members-filter'), 'members', 'div.members', j.cookie('bp-members-page'), j.cookie('bp-members-search-terms') );
</del><ins>+                bp_filter_request( j.cookie('bp-members-type'), j.cookie('bp-members-filter'), 'members', 'div.members', j.cookie('bp-members-page'), j.cookie('bp-members-search-terms'), 'test' );
</ins><span class="cx"> 
</span><span class="cx">         /* Groups */
</span><span class="cx">         if ( j('div.groups').length )
</span><span class="lines">@@ -553,7 +553,7 @@
</span><span class="cx">                 return false;
</span><span class="cx">         });
</span><span class="cx"> 
</span><del>-        function bp_filter_request( type, filter, id, target, page, search_terms ) {
</del><ins>+        function bp_filter_request( type, filter, id, target, page, search_terms, extras ) {
</ins><span class="cx">                 if ( 'activity' == id )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="lines">@@ -569,6 +569,9 @@
</span><span class="cx">                 if ( null == search_terms )
</span><span class="cx">                         var search_terms = false;
</span><span class="cx"> 
</span><ins>+                if ( null == extras )
+                        var extras = false;
+
</ins><span class="cx">                 if ( j.query.get('s') )
</span><span class="cx">                         search_terms = j.query.get('s');
</span><span class="cx"> 
</span><span class="lines">@@ -593,7 +596,8 @@
</span><span class="cx">                         'filter': filter,
</span><span class="cx">                         'page': page,
</span><span class="cx">                         'content': id,
</span><del>-                        'search_terms': search_terms
</del><ins>+                        'search_terms': search_terms,
+                        'extras': extras
</ins><span class="cx">                 },
</span><span class="cx">                 function(response)
</span><span class="cx">                 {
</span></span></pre>
</div>
</div>

</body>
</html>