<!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] [2339] trunk:
Fixes to group invite interface and template loop.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2339</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-18 15:52:16 +0000 (Mon, 18 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fixes to group invite interface and template loop.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpgroupsbpgroupsclassesphp">trunk/bp-groups/bp-groups-classes.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>
<li><a href="#trunkbpthemesbpdefaultgroupssinglesendinvitesphp">trunk/bp-themes/bp-default/groups/single/send-invites.php</a></li>
<li><a href="#trunkbpthemesbpdefaultmemberssinglegroupsinvitesphp">trunk/bp-themes/bp-default/members/single/groups/invites.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpgroupsbpgroupsclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-classes.php (2338 => 2339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-classes.php        2010-01-18 15:01:11 UTC (rev 2338)
+++ trunk/bp-groups/bp-groups-classes.php        2010-01-18 15:52:16 UTC (rev 2339)
</span><span class="lines">@@ -852,12 +852,16 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        function get_invites( $user_id ) {
</del><ins>+        function get_invites( $user_id, $limit = false, $page = false ) {
</ins><span class="cx">                 global $wpdb, $bp;
</span><span class="cx">
</span><del>-                $group_ids = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d and is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id ) );
</del><ins>+                if ( $limit && $page )
+                        $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
</ins><span class="cx">
</span><del>-                return $group_ids;
</del><ins>+                $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d ORDER BY m.date_modified ASC {$pag_sql}", $user_id ) );
+                $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d ORDER BY date_modified ASC", $user_id ) );
+
+                return array( 'groups' => $paged_groups, 'total' => $total_groups );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function check_has_invite( $user_id, $group_id ) {
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-templatetags.php (2338 => 2339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-templatetags.php        2010-01-18 15:01:11 UTC (rev 2338)
+++ trunk/bp-groups/bp-groups-templatetags.php        2010-01-18 15:52:16 UTC (rev 2339)
</span><span class="lines">@@ -68,8 +68,7 @@
</span><span class="cx">                                 break;
</span><span class="cx">
</span><span class="cx">                         case 'invites':
</span><del>-                                if ( $user_id )
-                                        $this->groups = groups_get_invites_for_user();
</del><ins>+                                $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page );
</ins><span class="cx">                                 break;
</span><span class="cx">
</span><span class="cx">                         case 'single-group':
</span><span class="lines">@@ -80,8 +79,9 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ( 'invites' == $type ) {
</span><del>-                        $this->total_group_count = count($this->groups);
-                        $this->group_count = count($this->groups);
</del><ins>+                        $this->total_group_count = (int)$this->groups['total'];
+                        $this->group_count = (int)$this->groups['total'];
+                        $this->groups = $this->groups['groups'];
</ins><span class="cx">                 } else if ( 'single-group' == $type ) {
</span><span class="cx">                         $this->single_group = true;
</span><span class="cx">                         $this->total_group_count = 1;
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (2338 => 2339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2010-01-18 15:01:11 UTC (rev 2338)
+++ trunk/bp-groups.php        2010-01-18 15:52:16 UTC (rev 2339)
</span><span class="lines">@@ -2260,13 +2260,13 @@
</span><span class="cx">
</span><span class="cx"> /*** Group Invitations *********************************************************/
</span><span class="cx">
</span><del>-function groups_get_invites_for_user( $user_id = false ) {
</del><ins>+function groups_get_invites_for_user( $user_id = false, $limit = false, $page = false ) {
</ins><span class="cx">         global $bp;
</span><span class="cx">
</span><span class="cx">         if ( !$user_id )
</span><span class="cx">                 $user_id = $bp->loggedin_user->id;
</span><span class="cx">
</span><del>-        return BP_Groups_Member::get_invites( $user_id );
</del><ins>+        return BP_Groups_Member::get_invites( $user_id, $limit, $page );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function groups_invite_user( $args = '' ) {
</span><span class="lines">@@ -2286,21 +2286,20 @@
</span><span class="cx">         if ( !$user_id || !$group_id )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( groups_is_user_member( $user_id, $group_id ) )
-                return false;
</del><ins>+        if ( !groups_is_user_member( $user_id, $group_id ) && !groups_check_user_has_invite( $user_id, $group_id ) ) {
+                $invite = new BP_Groups_Member;
+                $invite->group_id = $group_id;
+                $invite->user_id = $user_id;
+                $invite->date_modified = $date_modified;
+                $invite->inviter_id = $inviter_id;
+                $invite->is_confirmed = $is_confirmed;
</ins><span class="cx">
</span><del>-        $invite = new BP_Groups_Member;
-        $invite->group_id = $group_id;
-        $invite->user_id = $user_id;
-        $invite->date_modified = $date_modified;
-        $invite->inviter_id = $inviter_id;
-        $invite->is_confirmed = $is_confirmed;
</del><ins>+                if ( !$invite->save() )
+                        return false;
</ins><span class="cx">
</span><del>-        if ( !$invite->save() )
-                return false;
</del><ins>+                do_action( 'groups_invite_user', $args );
+        }
</ins><span class="cx">
</span><del>-        do_action( 'groups_invite_user', $args );
-
</del><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultgroupssinglesendinvitesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/groups/single/send-invites.php (2338 => 2339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/groups/single/send-invites.php        2010-01-18 15:01:11 UTC (rev 2338)
+++ trunk/bp-themes/bp-default/groups/single/send-invites.php        2010-01-18 15:52:16 UTC (rev 2339)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> <?php do_action( 'bp_before_group_send_invites_content' ) ?>
</span><span class="cx">
</span><del>-<?php if ( bp_has_friends_to_invite() ) : ?>
</del><ins>+<?php if ( bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
</ins><span class="cx">
</span><span class="cx">         <form action="<?php bp_group_send_invite_form_action() ?>" method="post" id="send-invite-form" class="standard-form">
</span><span class="cx">
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> <?php else : ?>
</span><span class="cx">
</span><span class="cx">         <div id="message" class="info">
</span><del>-                <p><?php _e( 'You either need to build up your friends list, or your friends have already been invited or are current members.', 'buddypress' ); ?></p>
</del><ins>+                <p><?php _e( 'Once you have built up friend connections you will be able to invite others to your group. You can send invites any time in the future by selecting the "Send Invites" option when viewing your new group.', 'buddypress' ); ?></p>
</ins><span class="cx">         </div>
</span><span class="cx">
</span><span class="cx"> <?php endif; ?>
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultmemberssinglegroupsinvitesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/members/single/groups/invites.php (2338 => 2339)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/members/single/groups/invites.php        2010-01-18 15:01:11 UTC (rev 2338)
+++ trunk/bp-themes/bp-default/members/single/groups/invites.php        2010-01-18 15:52:16 UTC (rev 2339)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> <?php do_action( 'bp_before_group_invites_content' ) ?>
</span><span class="cx">
</span><del>-<?php if ( bp_has_groups() ) : ?>
</del><ins>+<?php if ( bp_has_groups( 'type=invites&user_id=' . bp_loggedin_user_id() ) ) : ?>
</ins><span class="cx">
</span><span class="cx">         <ul id="group-list" class="invites item-list">
</span><span class="cx">
</span><span class="lines">@@ -23,7 +23,6 @@
</span><span class="cx">                                         <?php do_action( 'bp_group_invites_item_action' ) ?>
</span><span class="cx">
</span><span class="cx">                                 </div>
</span><del>-                                <hr />
</del><span class="cx">                         </li>
</span><span class="cx">
</span><span class="cx">                 <?php endwhile; ?>
</span></span></pre>
</div>
</div>
</body>
</html>