<!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] [2702] trunk: Fixing up API so it is consistent for get_users,
  get_groups and get_blogs.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2702</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-02-12 14:14:20 +0000 (Fri, 12 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixing up API so it is consistent for get_users, get_groups and get_blogs.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpblogsbpblogstemplatetagsphp">trunk/bp-blogs/bp-blogs-templatetags.php</a></li>
<li><a href="#trunkbpblogsphp">trunk/bp-blogs.php</a></li>
<li><a href="#trunkbpcorebpcoretemplatetagsphp">trunk/bp-core/bp-core-templatetags.php</a></li>
<li><a href="#trunkbpcorephp">trunk/bp-core.php</a></li>
<li><a href="#trunkbpgroupsbpgroupstemplatetagsphp">trunk/bp-groups/bp-groups-templatetags.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpblogsbpblogstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs/bp-blogs-templatetags.php (2701 => 2702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs/bp-blogs-templatetags.php        2010-02-12 14:11:06 UTC (rev 2701)
+++ trunk/bp-blogs/bp-blogs-templatetags.php        2010-02-12 14:14:20 UTC (rev 2702)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx">                 if ( isset( $_REQUEST['letter'] ) &amp;&amp; '' != $_REQUEST['letter'] )
</span><span class="cx">                         $this-&gt;blogs = BP_Blogs_Blog::get_by_letter( $_REQUEST['letter'], $this-&gt;pag_num, $this-&gt;pag_page );
</span><span class="cx">                 else
</span><del>-                        $this-&gt;blogs = BP_Blogs_Blog::get( $type, $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms );
</del><ins>+                        $this-&gt;blogs = bp_blogs_get_blogs( array( 'type' =&gt; $type, 'per_page' =&gt; $this-&gt;pag_num, 'page' =&gt; $this-&gt;pag_page, 'user_id' =&gt; $user_id, 'search_terms' =&gt; $search_terms ) );
</ins><span class="cx"> 
</span><span class="cx">                 if ( !$max || $max &gt;= (int)$this-&gt;blogs['total'] )
</span><span class="cx">                         $this-&gt;total_blog_count = (int)$this-&gt;blogs['total'];
</span></span></pre></div>
<a id="trunkbpblogsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-blogs.php (2701 => 2702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-blogs.php        2010-02-12 14:11:06 UTC (rev 2701)
+++ trunk/bp-blogs.php        2010-02-12 14:14:20 UTC (rev 2702)
</span><span class="lines">@@ -313,6 +313,25 @@
</span><span class="cx">  * true or false on success or failure.
</span><span class="cx">  */
</span><span class="cx"> 
</span><ins>+function bp_blogs_get_blogs( $args = '' ) {
+        global $bp;
+
+        $defaults = array(
+                'type' =&gt; 'active', // active, alphabetical, newest, or random.
+                'user_id' =&gt; false, // Pass a user_id to limit to only blogs that this user has privilages higher than subscriber on.
+                'search_terms' =&gt; false, // Limit to blogs that match these search terms
+
+                'per_page' =&gt; 20, // The number of results to return per page
+                'page' =&gt; 1, // The page to return if limiting per page
+        );
+
+        $params = wp_parse_args( $args, $defaults );
+        extract( $params, EXTR_SKIP );
+
+        return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms ), &amp;$params );
+}
+
+
</ins><span class="cx"> function bp_blogs_record_existing_blogs() {
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpcorebpcoretemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-templatetags.php (2701 => 2702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-templatetags.php        2010-02-12 14:11:06 UTC (rev 2701)
+++ trunk/bp-core/bp-core-templatetags.php        2010-02-12 14:14:20 UTC (rev 2702)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx">                         $this-&gt;members = BP_Core_User::get_specific_users( $include, $this-&gt;pag_num, $this-&gt;pag_page, $populate_extras );
</span><span class="cx">                 }
</span><span class="cx">                 else {
</span><del>-                        $this-&gt;members = BP_Core_User::get_users( $this-&gt;type, $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
</del><ins>+                        $this-&gt;members = bp_core_get_users( array( 'type' =&gt; $this-&gt;type, 'per_page' =&gt; $this-&gt;pag_num, 'page' =&gt; $this-&gt;pag_page, 'user_id' =&gt; $user_id, 'search_terms' =&gt; $search_terms, 'populate_extras' =&gt; $populate_extras ) );
</ins><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 if ( !$max || $max &gt;= (int)$this-&gt;members['total'] )
</span></span></pre></div>
<a id="trunkbpcorephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core.php (2701 => 2702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core.php        2010-02-12 14:11:06 UTC (rev 2701)
+++ trunk/bp-core.php        2010-02-12 14:14:20 UTC (rev 2702)
</span><span class="lines">@@ -519,6 +519,32 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * bp_core_get_users()
+ *
+ * Return an array of users IDs based on the parameters passed.
+ *
+ * @package BuddyPress Core
+ */
+function bp_core_get_users( $args = '' ) {
+        global $bp;
+
+        $defaults = array(
+                'type' =&gt; 'active', // active, newest, alphabetical, random or popular
+                'user_id' =&gt; false, // Pass a user_id to limit to only friend connections for this user
+                'search_terms' =&gt; false, // Limit to users that match these search terms
+
+                'per_page' =&gt; 20, // The number of results to return per page
+                'page' =&gt; 1, // The page to return if limiting per page
+                'populate_extras' =&gt; true, // Fetch the last active, where the user is a friend, total friend count, latest update
+        );
+
+        $params = wp_parse_args( $args, $defaults );
+        extract( $params, EXTR_SKIP );
+
+        return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $search_terms, $populate_extras ), &amp;$params );
+}
+
+/**
</ins><span class="cx">  * bp_core_get_user_domain()
</span><span class="cx">  *
</span><span class="cx">  * Returns the domain for the passed user:
</span><span class="lines">@@ -953,7 +979,7 @@
</span><span class="cx">         global $bp, $wpdb;
</span><span class="cx"> 
</span><span class="cx">         if ( isset( $_GET['random-member'] ) ) {
</span><del>-                $user = BP_Core_User::get_users( 'random', 1 );
</del><ins>+                $user = bp_core_get_users( array( 'type' =&gt; 'random', 'per_page' =&gt; 1 ) );
</ins><span class="cx">                 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]-&gt;id ) );
</span><span class="cx">         }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-templatetags.php (2701 => 2702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-templatetags.php        2010-02-12 14:11:06 UTC (rev 2701)
+++ trunk/bp-groups/bp-groups-templatetags.php        2010-02-12 14:14:20 UTC (rev 2702)
</span><span class="lines">@@ -28,57 +28,15 @@
</span><span class="cx">                 $this-&gt;pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page;
</span><span class="cx">                 $this-&gt;pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
</span><span class="cx"> 
</span><del>-                switch ( $type ) {
-                        case 'active': default:
-                                $this-&gt;groups = groups_get_active( $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
-                                break;
</del><ins>+                if ( 'invites' == $type )
+                        $this-&gt;groups = groups_get_invites_for_user( $user_id, $this-&gt;pag_num, $this-&gt;pag_page );
+                else if ( 'single-group' == $type ) {
+                        $group = new stdClass;
+                        $group-&gt;group_id = BP_Groups_Group::get_id_from_slug($slug);
+                        $this-&gt;groups = array( $group );
+                } else
+                        $this-&gt;groups = groups_get_groups( array( 'type' =&gt; $type, 'per_page' =&gt; $this-&gt;pag_num, 'page' =&gt;$this-&gt;pag_page, 'user_id' =&gt; $user_id, 'search_terms' =&gt; $search_terms, 'populate_extras' =&gt; $populate_extras ) );
</ins><span class="cx"> 
</span><del>-                        case 'alphabetical': default:
-                                $this-&gt;groups = groups_get_alphabetically( $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
-                                break;
-
-                        case 'random':
-                                $this-&gt;groups = groups_get_random_groups( $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
-                                break;
-
-                        case 'newest':
-                                $this-&gt;groups = groups_get_newest( $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
-                                break;
-
-                        case 'popular':
-                                $this-&gt;groups = groups_get_popular( $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
-                                break;
-
-                        case 'most-forum-topics':
-                                $this-&gt;groups = groups_get_by_most_forum_topics( $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
-                                break;
-
-                        case 'most-forum-posts':
-                                $this-&gt;groups = groups_get_by_most_forum_posts( $this-&gt;pag_num, $this-&gt;pag_page, $user_id, $search_terms, $populate_extras );
-                                break;
-
-                        case 'invites':
-                                $this-&gt;groups = groups_get_invites_for_user( $user_id, $this-&gt;pag_num, $this-&gt;pag_page );
-                                break;
-
-                        case 'single-group':
-                                $group = new stdClass;
-                                $group-&gt;group_id = BP_Groups_Group::get_id_from_slug($slug);
-                                $this-&gt;groups = array( $group );
-                                break;
-
-
-                        case 'admin-of':
-                                if ( $user_id )
-                                        $this-&gt;groups = groups_get_user_is_admin_of( $user_id, $this-&gt;pag_num, $this-&gt;pag_page, $search_terms );
-                                break;
-
-                        case 'mod-of':
-                                if ( $user_id )
-                                        $this-&gt;groups = groups_get_user_is_mod_of( $user_id, $this-&gt;pag_num, $this-&gt;pag_page, $filter );
-                                break;
-                }
-
</del><span class="cx">                 if ( 'invites' == $type ) {
</span><span class="cx">                         $this-&gt;total_group_count = (int)$this-&gt;groups['total'];
</span><span class="cx">                         $this-&gt;group_count = (int)$this-&gt;groups['total'];
</span><span class="lines">@@ -187,15 +145,9 @@
</span><span class="cx"> 
</span><span class="cx">         /* Type */
</span><span class="cx">         if ( 'my-groups' == $bp-&gt;current_action ) {
</span><del>-                if ( 'recently-joined' == $order )
-                        $type = 'recently-joined';
-                else if ( 'most-popular' == $order )
</del><ins>+                if ( 'most-popular' == $order )
</ins><span class="cx">                         $type = 'popular';
</span><del>-                else if ( 'admin-of' == $order ) {
-                        $type = 'admin-of';
-                } else if ( 'mod-of' == $order ) {
-                        $type = 'mod-of';
-                } else if ( 'alphabetically' == $order )
</del><ins>+                else if ( 'alphabetically' == $order )
</ins><span class="cx">                         $type = 'alphabetical';
</span><span class="cx">         } else if ( 'invites' == $bp-&gt;current_action ) {
</span><span class="cx">                 $type = 'invites';
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (2701 => 2702)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2010-02-12 14:11:06 UTC (rev 2701)
+++ trunk/bp-groups.php        2010-02-12 14:14:20 UTC (rev 2702)
</span><span class="lines">@@ -1720,43 +1720,49 @@
</span><span class="cx"> 
</span><span class="cx"> /*** Group Fetching, Filtering &amp; Searching  *************************************/
</span><span class="cx"> 
</span><del>-function groups_get_all( $limit = null, $page = 1, $only_public = false, $sort_by = false, $order = false ) {
-        return BP_Groups_Group::get_all( $limit, $page, $only_public, $sort_by, $order );
-}
</del><ins>+function groups_get_groups( $args = '' ) {
+        global $bp;
</ins><span class="cx"> 
</span><del>-/***
- * All of the following get_() functions will return groups for the site globally.
- * If you pass a $user_id then the groups will be restricted to only those that the
- * user has joined.
- */
-function groups_get_newest( $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
-        return BP_Groups_Group::get_newest( $limit, $page, $user_id, $search_terms, $populate_extras );
-}
</del><ins>+        $defaults = array(
+                'type' =&gt; 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
+                'user_id' =&gt; false, // Pass a user_id to limit to only groups that this user is a member of
+                'search_terms' =&gt; false, // Limit to groups that match these search terms
</ins><span class="cx"> 
</span><del>-function groups_get_active( $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
-        return BP_Groups_Group::get_active( $limit, $page, $user_id, $search_terms, $populate_extras );
-}
</del><ins>+                'per_page' =&gt; 20, // The number of results to return per page
+                'page' =&gt; 1, // The page to return if limiting per page
+                'populate_extras' =&gt; true, // Fetch meta such as is_banned and is_member
+        );
</ins><span class="cx"> 
</span><del>-function groups_get_popular( $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
-        return BP_Groups_Group::get_popular( $limit, $page, $user_id, $search_terms, $populate_extras );
-}
</del><ins>+        $params = wp_parse_args( $args, $defaults );
+        extract( $params, EXTR_SKIP );
</ins><span class="cx"> 
</span><del>-function groups_get_random_groups( $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
-        return BP_Groups_Group::get_random( $limit, $page, $user_id, $search_terms, $populate_extras );
-}
</del><ins>+        switch ( $type ) {
+                case 'active': default:
+                        $groups = BP_Groups_Group::get_active( $limit, $page, $user_id, $search_terms, $populate_extras );
+                        break;
+                case 'newest':
+                        $groups = BP_Groups_Group::get_newest( $limit, $page, $user_id, $search_terms, $populate_extras );
+                        break;
+                case 'popular':
+                        $groups = BP_Groups_Group::get_popular( $limit, $page, $user_id, $search_terms, $populate_extras );
+                        break;
+                case 'alphabetical':
+                        $groups = BP_Groups_Group::get_alphabetically( $limit, $page, $user_id, $search_terms, $populate_extras );
+                        break;
+                case 'random':
+                        $groups = BP_Groups_Group::get_random( $limit, $page, $user_id, $search_terms, $populate_extras );
+                        break;
+                case 'most-forum-topics':
+                        $groups = BP_Groups_Group::get_by_most_forum_topics( $limit, $page, $user_id, $search_terms, $populate_extras );
+                        break;
+                case 'most-forum-posts':
+                        $groups = BP_Groups_Group::get_by_most_forum_posts( $limit, $page, $user_id, $search_terms, $populate_extras );
+                        break;
+        }
</ins><span class="cx"> 
</span><del>-function groups_get_alphabetically( $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
-        return BP_Groups_Group::get_alphabetically( $limit, $page, $user_id, $search_terms, $populate_extras );
</del><ins>+        return apply_filters( 'groups_get_groups', $groups, &amp;$params );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-function groups_get_by_most_forum_topics( $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
-        return BP_Groups_Group::get_by_most_forum_topics( $limit, $page, $user_id, $search_terms, $populate_extras );
-}
-
-function groups_get_by_most_forum_posts( $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
-        return BP_Groups_Group::get_by_most_forum_posts( $limit, $page, $user_id, $search_terms, $populate_extras );
-}
-
</del><span class="cx"> function groups_get_total_group_count() {
</span><span class="cx">         if ( !$count = wp_cache_get( 'bp_total_group_count', 'bp' ) ) {
</span><span class="cx">                 $count = BP_Groups_Group::get_total_group_count();
</span><span class="lines">@@ -1775,33 +1781,6 @@
</span><span class="cx">         return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
-        global $bp;
-
-        if ( !$user_id )
-                $user_id = $bp-&gt;displayed_user-&gt;id;
-
-        return BP_Groups_Member::get_recently_joined( $user_id, $pag_num, $pag_page, $filter );
-}
-
-function groups_get_user_is_admin_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
-        global $bp;
-
-        if ( !$user_id )
-                $user_id = $bp-&gt;displayed_user-&gt;id;
-
-        return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter );
-}
-
-function groups_get_user_is_mod_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
-        global $bp;
-
-        if ( !$user_id )
-                $user_id = $bp-&gt;displayed_user-&gt;id;
-
-        return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter );
-}
-
</del><span class="cx"> function groups_total_groups_for_user( $user_id = false ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -1816,14 +1795,6 @@
</span><span class="cx">         return $count;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function groups_search_groups( $search_terms, $pag_num_per_page = 5, $pag_page = 1, $sort_by = false, $order = false ) {
-        return BP_Groups_Group::search_groups( $search_terms, $pag_num_per_page, $pag_page, $sort_by, $order );
-}
-
-function groups_filter_user_groups( $filter, $user_id = false, $order = false, $pag_num_per_page = 5, $pag_page = 1 ) {
-        return BP_Groups_Group::filter_user_groups( $filter, $user_id, $order, $pag_num_per_page, $pag_page );
-}
-
</del><span class="cx"> /*** Group Avatars *************************************************************/
</span><span class="cx"> 
</span><span class="cx"> function groups_avatar_upload_dir( $group_id = false ) {
</span></span></pre>
</div>
</div>

</body>
</html>