<!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] [2268] trunk:
  Fixing duplicate membership requests bug and private forum threads bug.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2268</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-06 14:05:13 +0000 (Wed, 06 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixing duplicate membership requests bug and private forum threads bug.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpgroupsbpgroupsfiltersphp">trunk/bp-groups/bp-groups-filters.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
<li><a href="#trunkbpthemesbpdefault_incajaxphp">trunk/bp-themes/bp-default/_inc/ajax.php</a></li>
<li><a href="#trunkbpthemesbpdefault_inccssdefaultcss">trunk/bp-themes/bp-default/_inc/css/default.css</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpgroupsbpgroupsfiltersphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-filters.php (2267 => 2268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-filters.php        2010-01-06 12:35:41 UTC (rev 2267)
+++ trunk/bp-groups/bp-groups-filters.php        2010-01-06 14:05:13 UTC (rev 2268)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         /* Only filter the forum SQL on group pages or on the forums directory */
</span><del>-        if ( ( $bp-&gt;groups-&gt;current_group &amp;&amp; 'public' == $bp-&gt;groups-&gt;current_group-&gt;status ) || $bp-&gt;is_directory ) {
</del><ins>+        if ( ( $bp-&gt;groups-&gt;current_group &amp;&amp; 'public' == $bp-&gt;groups-&gt;current_group-&gt;status ) || !$bp-&gt;groups-&gt;current_group ) {
</ins><span class="cx">                 add_filter( 'get_topics_fields', 'groups_add_forum_fields_sql' );
</span><span class="cx">                 add_filter( 'get_topics_index_hint', 'groups_add_forum_tables_sql' );
</span><span class="cx">                 add_filter( 'get_topics_where', 'groups_add_forum_where_sql' );
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (2267 => 2268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2010-01-06 12:35:41 UTC (rev 2267)
+++ trunk/bp-groups.php        2010-01-06 14:05:13 UTC (rev 2268)
</span><span class="lines">@@ -916,12 +916,6 @@
</span><span class="cx">                 if ( 'demote' == $bp-&gt;action_variables[1] &amp;&amp; is_numeric( $bp-&gt;action_variables[2] ) ) {
</span><span class="cx">                         $user_id = $bp-&gt;action_variables[2];
</span><span class="cx"> 
</span><del>-                        /* Check if the user is the group admin first. */
-                        if ( groups_is_user_admin( $bp-&gt;loggedin_user-&gt;id, $bp-&gt;groups-&gt;current_group-&gt;id ) ) {
-                                bp_core_add_message(  __('As the only group administrator, you cannot demote yourself.', 'buddypress'), 'error' );
-                                bp_core_redirect( bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) );
-                        }
-
</del><span class="cx">                         /* Check the nonce first. */
</span><span class="cx">                         if ( !check_admin_referer( 'groups_demote_member' ) )
</span><span class="cx">                                 return false;
</span><span class="lines">@@ -941,12 +935,6 @@
</span><span class="cx">                 if ( 'ban' == $bp-&gt;action_variables[1] &amp;&amp; is_numeric( $bp-&gt;action_variables[2] ) ) {
</span><span class="cx">                         $user_id = $bp-&gt;action_variables[2];
</span><span class="cx"> 
</span><del>-                        /* Check if the user is the group admin first. */
-                        if ( groups_is_user_admin( $bp-&gt;loggedin_user-&gt;id, $bp-&gt;groups-&gt;current_group-&gt;id ) ) {
-                                bp_core_add_message(  __('As the only group administrator, you cannot ban yourself.', 'buddypress'), 'error' );
-                                bp_core_redirect( bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) );
-                        }
-
</del><span class="cx">                         /* Check the nonce first. */
</span><span class="cx">                         if ( !check_admin_referer( 'groups_ban_member' ) )
</span><span class="cx">                                 return false;
</span><span class="lines">@@ -1764,9 +1752,18 @@
</span><span class="cx">         if ( !$user_id )
</span><span class="cx">                 $user_id = $bp-&gt;loggedin_user-&gt;id;
</span><span class="cx"> 
</span><ins>+        /* Check if the user has an outstanding invite, is so delete it. */
</ins><span class="cx">         if ( groups_check_user_has_invite( $user_id, $group_id ) )
</span><span class="cx">                 groups_delete_invite( $user_id, $group_id );
</span><span class="cx"> 
</span><ins>+        /* Check if the user has an outstanding request, is so delete it. */
+        if ( groups_check_for_membership_request( $user_id, $group_id ) )
+                groups_delete_membership_request( $user_id, $group_id );
+
+        /* User is already a member, just return true */
+        if ( groups_is_user_member( $user_id, $group_id ) )
+                return true;
+
</ins><span class="cx">         if ( !$bp-&gt;groups-&gt;current_group )
</span><span class="cx">                 $bp-&gt;groups-&gt;current_group = new BP_Groups_Group( $group_id, false, false );
</span><span class="cx"> 
</span><span class="lines">@@ -2405,6 +2402,14 @@
</span><span class="cx"> function groups_send_membership_request( $requesting_user_id, $group_id ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><ins>+        /* Prevent duplicate requests */
+        if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) )
+                return false;
+
+        /* Check if the user is already a member or is banned */
+        if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) )
+                return false;
+
</ins><span class="cx">         $requesting_user = new BP_Groups_Member;
</span><span class="cx">         $requesting_user-&gt;group_id = $group_id;
</span><span class="cx">         $requesting_user-&gt;user_id = $requesting_user_id;
</span><span class="lines">@@ -2470,12 +2475,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {
</span><del>-        if ( $user_id &amp;&amp; $group_id )
-                $membership = new BP_Groups_Member( $user_id, $group_id );
-        else
-                $membership = new BP_Groups_Member( false, false, $membership_id );
-
-        if ( !BP_Groups_Member::delete( $membership-&gt;user_id, $membership-&gt;group_id ) )
</del><ins>+        if ( !$membership = groups_delete_membership_request( $membership_id, $user_id, $group_id ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         // Send a notification to the user.
</span><span class="lines">@@ -2487,6 +2487,18 @@
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+function groups_delete_membership_request( $membership_id, $user_id = false, $group_id = false ) {
+        if ( $user_id &amp;&amp; $group_id )
+                $membership = new BP_Groups_Member( $user_id, $group_id );
+        else
+                $membership = new BP_Groups_Member( false, false, $membership_id );
+
+        if ( !BP_Groups_Member::delete( $membership-&gt;user_id, $membership-&gt;group_id ) )
+                return false;
+
+        return $membership;
+}
+
</ins><span class="cx"> function groups_check_for_membership_request( $user_id, $group_id ) {
</span><span class="cx">         return BP_Groups_Member::check_for_membership_request( $user_id, $group_id );
</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 (2267 => 2268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-06 12:35:41 UTC (rev 2267)
+++ trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-06 14:05:13 UTC (rev 2268)
</span><span class="lines">@@ -41,7 +41,6 @@
</span><span class="cx">                 $bp-&gt;ajax_querystring .= '&amp;user_id=' . $user_id;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $bp-&gt;is_directory = true;
</del><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></pre></div>
<a id="trunkbpthemesbpdefault_inccssdefaultcss"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/css/default.css (2267 => 2268)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/css/default.css        2010-01-06 12:35:41 UTC (rev 2267)
+++ trunk/bp-themes/bp-default/_inc/css/default.css        2010-01-06 14:05:13 UTC (rev 2268)
</span><span class="lines">@@ -382,9 +382,11 @@
</span><span class="cx">                         margin: 0 10px 10px 0;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                ul.item-list li div.item-title {
</del><ins>+                ul.item-list li div.item-title, ul.item-list li h4 {
+                        font-weight: normal;
</ins><span class="cx">                         font-size: 14px;
</span><span class="cx">                         width: 75%;
</span><ins>+                        margin: 0;
</ins><span class="cx">                 }
</span><span class="cx">                         ul.item-list li div.item-title span {
</span><span class="cx">                                 font-size: 12px;
</span><span class="lines">@@ -484,8 +486,11 @@
</span><span class="cx">                                 background-image: url( ../images/ajax-loader.gif );
</span><span class="cx">                                 background-position: 92% 50%;
</span><span class="cx">                                 background-repeat: no-repeat;
</span><del>-                                padding-right: 30px;
</del><ins>+                                padding-right: 30px !important;
</ins><span class="cx">                         }
</span><ins>+                                div#item-nav ul li.loading a {
+                                        background-position: 88% 50%;
+                                }
</ins><span class="cx"> 
</span><span class="cx">         div.item-list-tabs#user-subnav,
</span><span class="cx">         div.item-list-tabs#group-subnav {
</span><span class="lines">@@ -631,6 +636,11 @@
</span><span class="cx">                 color: #555;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        div.accept, div.reject {
+                float: left;
+                margin-left: 10px;
+        }
+
</ins><span class="cx"> ul.button-nav li {
</span><span class="cx">         float: left;
</span><span class="cx">         margin: 0 10px 10px 0;
</span></span></pre>
</div>
</div>

</body>
</html>