<!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][12432] trunk: Update BP_Group_Member_Query for Invitation API compatibility.</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 { white-space: pre-line; 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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/12432">12432</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/12432","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dcavins</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-08-12 20:43:44 +0000 (Mon, 12 Aug 2019)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Update BP_Group_Member_Query for Invitation API compatibility.

{U+2022} Update logic in BP_Group_Member_Query to account for the migration of unconfirmed members to the `bp_invitations` table.

See <a href="http://buddypress.trac.wordpress.org/ticket/6210">#6210</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpgroupsclassesclassbpgroupmemberqueryphp">trunk/src/bp-groups/classes/class-bp-group-member-query.php</a></li>
<li><a href="#trunktestsphpunittestcasesgroupsclassbpgroupmemberqueryphp">trunk/tests/phpunit/testcases/groups/class-bp-group-member-query.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpgroupsclassesclassbpgroupmemberqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-groups/classes/class-bp-group-member-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-groups/classes/class-bp-group-member-query.php       2019-08-12 20:43:23 UTC (rev 12431)
+++ trunk/src/bp-groups/classes/class-bp-group-member-query.php 2019-08-12 20:43:44 UTC (rev 12432)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -231,8 +231,62 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $sql['orderby'] = "ORDER BY date_modified";
</span><span class="cx" style="display: block; padding: 0 10px">                $sql['order']   = 'first_joined' === $this->query_vars['type'] ? 'ASC' : 'DESC';
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->group_member_ids = $wpdb->get_col( "{$sql['select']} {$sql['where']} {$sql['orderby']} {$sql['order']}" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $group_member_ids = $wpdb->get_col( "{$sql['select']} {$sql['where']} {$sql['orderby']} {$sql['order']}" );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $invited_member_ids = array();
+
+               // If appropriate, fetch invitations and add them to the results.
+               if ( ! $is_confirmed || ! is_null( $this->query_vars['invite_sent'] ) || ! is_null( $this->query_vars['inviter_id'] ) ) {
+                       $invite_args = array(
+                               'item_id' => $this->query_vars['group_id'],
+                               'fields'  => 'user_ids',
+                               'type'    => 'all',
+                       );
+
+                       if ( ! is_null( $this->query_vars['invite_sent'] ) ) {
+                               $invite_args['invite_sent'] = ! empty( $this->query_vars['invite_sent'] ) ? 'sent' : 'draft';
+                       }
+
+                       // If inviter_id.
+                       if ( ! is_null( $this->query_vars['inviter_id'] ) ) {
+                               $inviter_id = $this->query_vars['inviter_id'];
+
+                               // Empty: inviter_id = 0. (pass false, 0, or empty array).
+                               if ( empty( $inviter_id ) ) {
+                                       $invite_args['type'] = 'request';
+
+                               /*
+                               * The string 'any' matches any non-zero value (inviter_id != 0).
+                               * These are invitations, not requests.
+                               */
+                               } elseif ( 'any' === $inviter_id ) {
+                                       $invite_args['type'] = 'invite';
+
+                               // Assume that a list of inviter IDs has been passed.
+                               } else {
+                                       $invite_args['type'] = 'invite';
+                                       // Parse and sanitize.
+                                       $inviter_ids = wp_parse_id_list( $inviter_id );
+                                       if ( ! empty( $inviter_ids ) ) {
+                                               $invite_args['inviter_id'] = $inviter_ids;
+                                       }
+                               }
+                       }
+
+                       /*
+                        * If first_joined is the "type" of query, sort the oldest
+                        * requests and invitations to the top.
+                        */
+                       if ( 'first_joined' === $this->query_vars['type'] ) {
+                               $invite_args['order_by']   = 'date_modified';
+                               $invite_args['sort_order'] = 'ASC';
+                       }
+
+                       $invited_member_ids = groups_get_invites( $invite_args );
+               }
+
+               $this->group_member_ids = array_merge( $group_member_ids, $invited_member_ids );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Filters the member IDs for the current group member query.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -330,6 +384,45 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Add accurate invitation info from the invitations table.
+               $invites = groups_get_invites( array(
+                       'user_id' => $user_ids_sql,
+                       'item_id' => $this->query_vars['group_id'],
+                       'type'    => 'all',
+               ) );
+               foreach ( $invites as $invite ) {
+                       if ( isset( $this->results[ $invite->user_id ] ) ) {
+                               $this->results[ $invite->user_id ]->comments      = $invite->content;
+                               $this->results[ $invite->user_id ]->is_confirmed  = 0;
+                               $this->results[ $invite->user_id ]->invitation_id = $invite->id;
+                               $this->results[ $invite->user_id ]->invite_sent   = (int) $invite->invite_sent;
+                               $this->results[ $invite->user_id ]->inviter_id    = $invite->inviter_id;
+
+                               // Backfill properties that are not being set above.
+                               if ( ! isset( $this->results[ $invite->user_id ]->user_id ) ) {
+                                       $this->results[ $invite->user_id ]->user_id = $invite->user_id;
+                               }
+                               if ( ! isset( $this->results[ $invite->user_id ]->is_admin ) ) {
+                                       $this->results[ $invite->user_id ]->is_admin = 0;
+                               }
+                               if ( ! isset( $this->results[ $invite->user_id ]->is_mod ) ) {
+                                       $this->results[ $invite->user_id ]->is_mod = 0;
+                               }
+                               if ( ! isset( $this->results[ $invite->user_id ]->is_banned ) ) {
+                                       $this->results[ $invite->user_id ]->is_banned = 0;
+                               }
+                               if ( ! isset( $this->results[ $invite->user_id ]->date_modified ) ) {
+                                       $this->results[ $invite->user_id ]->date_modified = $invite->date_modified;
+                               }
+                               if ( ! isset( $this->results[ $invite->user_id ]->user_title ) ) {
+                                       $this->results[ $invite->user_id ]->user_title = '';
+                               }
+                               if ( ! isset( $this->results[ $invite->user_id ]->membership_id ) ) {
+                                       $this->results[ $invite->user_id ]->membership_id = 0;
+                               }
+                       }
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 // Don't filter other BP_User_Query objects on the same page.
</span><span class="cx" style="display: block; padding: 0 10px">                remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10 );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre></div>
<a id="trunktestsphpunittestcasesgroupsclassbpgroupmemberqueryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/testcases/groups/class-bp-group-member-query.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/testcases/groups/class-bp-group-member-query.php      2019-08-12 20:43:23 UTC (rev 12431)
+++ trunk/tests/phpunit/testcases/groups/class-bp-group-member-query.php        2019-08-12 20:43:44 UTC (rev 12432)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -312,17 +312,26 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_confirmed_members() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $g = self::factory()->group->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $u = self::factory()->user->create();
+               $g = self::factory()->group->create( array( 'status' => 'private', 'creator_id' => $u )  );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $u1 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u2 = self::factory()->user->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $time = time();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $u3 = self::factory()->user->create();
+               $time = time();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u1, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'is_confirmed' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_send_membership_request( array(
+                       'user_id' => $u1,
+                       'group_id' => $g
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u2, $g, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u2,
+                       'group_id'   => $g,
+                       'inviter_id' => $u,
+                       'send_invite' => 1
+               ) );
+
+               $this->add_user_to_group( $u3, $g, array(
</ins><span class="cx" style="display: block; padding: 0 10px">                         'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
</span><span class="cx" style="display: block; padding: 0 10px">                        'is_confirmed' => 1,
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -332,7 +341,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $ids = wp_parse_id_list( array_keys( $query_members->results ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( array( $u2 ), $ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( $u3 ), $ids );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -594,21 +603,23 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @group invite_sent
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_with_invite_sent_true() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $g = self::factory()->group->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $u = self::factory()->user->create();
+               $g = self::factory()->group->create( array( 'status' => 'private', 'creator_id' => $u )  );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $u1 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u2 = self::factory()->user->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $time = time();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u1, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'is_confirmed' => 0,
-                       'invite_sent' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u1,
+                       'group_id'   => $g,
+                       'inviter_id' => $u,
+                       'send_invite' => 0
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u2, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'is_confirmed' => 0,
-                       'invite_sent' => 1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u2,
+                       'group_id'   => $g,
+                       'inviter_id' => $u,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query_members = new BP_Group_Member_Query( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -625,21 +636,23 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @group invite_sent
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_with_invite_sent_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $g = self::factory()->group->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $u = self::factory()->user->create();
+               $g = self::factory()->group->create( array( 'status' => 'private', 'creator_id' => $u )  );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $u1 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u2 = self::factory()->user->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $time = time();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u1, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'is_confirmed' => 0,
-                       'invite_sent' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u1,
+                       'group_id'   => $g,
+                       'inviter_id' => $u,
+                       'send_invite' => 0
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u2, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'is_confirmed' => 0,
-                       'invite_sent' => 1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u2,
+                       'group_id'   => $g,
+                       'inviter_id' => $u,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query_members = new BP_Group_Member_Query( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -656,19 +669,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @group inviter_id
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_with_inviter_id_false() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $g = self::factory()->group->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $u = self::factory()->user->create();
+               $g = self::factory()->group->create( array( 'status' => 'private', 'creator_id' => $u )  );
</ins><span class="cx" style="display: block; padding: 0 10px">                 $u1 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u2 = self::factory()->user->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $time = time();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u1, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'inviter_id' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_send_membership_request( array(
+                       'user_id' => $u1,
+                       'group_id' => $g
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u2, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'inviter_id' => 1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u2,
+                       'group_id'   => $g,
+                       'inviter_id' => $u,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query_members = new BP_Group_Member_Query( array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -684,40 +699,49 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @group inviter_id
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_with_inviter_id_specific() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $g = self::factory()->group->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $a1 = self::factory()->user->create();
+               $a2 = self::factory()->user->create();
+               $a3 = self::factory()->user->create();
+               $g = self::factory()->group->create( array( 'status' => 'private', 'creator_id' => $a1 )  );
+               $this->add_user_to_group( $a2, $g, array( 'is_admin' => 1 ) );
+               $this->add_user_to_group( $a3, $g, array( 'is_admin' => 1 ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $u1 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u2 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u3 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u4 = self::factory()->user->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $time = time();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u1, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'inviter_id' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_send_membership_request( array(
+                       'user_id' => $u1,
+                       'group_id' => $g
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u2, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ),
-                       'inviter_id' => 1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u2,
+                       'group_id'   => $g,
+                       'inviter_id' => $a1,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               $this->add_user_to_group( $u3, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ),
-                       'inviter_id' => 6,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u3,
+                       'group_id'   => $g,
+                       'inviter_id' => $a2,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               $this->add_user_to_group( $u4, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 400 ),
-                       'inviter_id' => 2,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u4,
+                       'group_id'   => $g,
+                       'inviter_id' => $a3,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query_members = new BP_Group_Member_Query( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'group_id' => $g,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'inviter_id' => array( 2, 6 ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 'inviter_id' => array( $a1, $a3 ),
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $ids = wp_parse_id_list( array_keys( $query_members->results ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( array( $u3, $u4 ), $ids );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( array( $u2, $u4 ), $ids );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -724,31 +748,40 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @group inviter_id
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_with_inviter_id_any() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $g = self::factory()->group->create();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $a1 = self::factory()->user->create();
+               $a2 = self::factory()->user->create();
+               $a3 = self::factory()->user->create();
+               $g = self::factory()->group->create( array( 'status' => 'private', 'creator_id' => $a1 )  );
+               $this->add_user_to_group( $a2, $g, array( 'is_admin' => 1 ) );
+               $this->add_user_to_group( $a3, $g, array( 'is_admin' => 1 ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $u1 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u2 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u3 = self::factory()->user->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $u4 = self::factory()->user->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $time = time();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u1, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
-                       'inviter_id' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_send_membership_request( array(
+                       'user_id' => $u1,
+                       'group_id' => $g
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->add_user_to_group( $u2, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 200 ),
-                       'inviter_id' => 1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u2,
+                       'group_id'   => $g,
+                       'inviter_id' => $a1,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               $this->add_user_to_group( $u3, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 300 ),
-                       'inviter_id' => 6,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u3,
+                       'group_id'   => $g,
+                       'inviter_id' => $a2,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               $this->add_user_to_group( $u4, $g, array(
-                       'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 400 ),
-                       'inviter_id' => 2,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         groups_invite_user( array(
+                       'user_id'    => $u4,
+                       'group_id'   => $g,
+                       'inviter_id' => $a3,
+                       'send_invite' => 1
</ins><span class="cx" style="display: block; padding: 0 10px">                 ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $query_members = new BP_Group_Member_Query( array(
</span></span></pre>
</div>
</div>

</body>
</html>