<!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] [2267] trunk:
  Making sure private and hidden groups remain that way to non members,
  and displaying message to non members.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2267</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-06 12:35:41 +0000 (Wed, 06 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Making sure private and hidden groups remain that way to non members, and displaying message to non members.</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="#trunkbpthemesbpdefaultgroupssinglehomephp">trunk/bp-themes/bp-default/groups/single/home.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 (2266 => 2267)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-classes.php        2010-01-06 12:07:27 UTC (rev 2266)
+++ trunk/bp-groups/bp-groups-classes.php        2010-01-06 12:35:41 UTC (rev 2267)
</span><span class="lines">@@ -899,6 +899,9 @@
</span><span class="cx">         function check_is_member( $user_id, $group_id ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><ins>+                if ( is_site_admin() )
+                        return true;
+
</ins><span class="cx">                 if ( !$user_id )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-templatetags.php (2266 => 2267)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-templatetags.php        2010-01-06 12:07:27 UTC (rev 2266)
+++ trunk/bp-groups/bp-groups-templatetags.php        2010-01-06 12:35:41 UTC (rev 2267)
</span><span class="lines">@@ -1039,6 +1039,9 @@
</span><span class="cx"> function bp_group_is_member( $group = false ) {
</span><span class="cx">         global $bp, $groups_template;
</span><span class="cx"> 
</span><ins>+        if ( is_site_admin() )
+                return true;
+
</ins><span class="cx">         if ( !$group )
</span><span class="cx">                 $group =&amp; $groups_template-&gt;group;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (2266 => 2267)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2010-01-06 12:07:27 UTC (rev 2266)
+++ trunk/bp-groups.php        2010-01-06 12:35:41 UTC (rev 2267)
</span><span class="lines">@@ -210,7 +210,7 @@
</span><span class="cx"> 
</span><span class="cx">                         // If this is a private or hidden group, does the user have access?
</span><span class="cx">                         if ( 'private' == $bp-&gt;groups-&gt;current_group-&gt;status || 'hidden' == $bp-&gt;groups-&gt;current_group-&gt;status ) {
</span><del>-                                if ( $bp-&gt;groups-&gt;current_group-&gt;is_user_member &amp;&amp; is_user_logged_in() )
</del><ins>+                                if ( $bp-&gt;groups-&gt;current_group-&gt;is_user_member &amp;&amp; is_user_logged_in() || is_site_admin() )
</ins><span class="cx">                                         $bp-&gt;groups-&gt;current_group-&gt;user_has_access = true;
</span><span class="cx">                                 else
</span><span class="cx">                                         $bp-&gt;groups-&gt;current_group-&gt;user_has_access = false;
</span><span class="lines">@@ -232,7 +232,7 @@
</span><span class="cx">                                 bp_core_new_subnav_item( array( 'name' =&gt; __( 'Admin', 'buddypress' ), 'slug' =&gt; 'admin', 'parent_url' =&gt; $group_link, 'parent_slug' =&gt; $bp-&gt;groups-&gt;slug, 'screen_function' =&gt; 'groups_screen_group_admin', 'position' =&gt; 20, 'user_has_access' =&gt; ( $bp-&gt;is_item_admin + (int)$bp-&gt;is_item_mod ), 'item_css_id' =&gt; 'group-admin' ) );
</span><span class="cx"> 
</span><span class="cx">                         // If this is a private group, and the user is not a member, show a &quot;Request Membership&quot; nav item.
</span><del>-                        if ( is_user_logged_in() &amp;&amp; !$bp-&gt;groups-&gt;current_group-&gt;is_user_member &amp;&amp; !groups_check_for_membership_request( $bp-&gt;loggedin_user-&gt;id, $bp-&gt;groups-&gt;current_group-&gt;id ) &amp;&amp; $bp-&gt;groups-&gt;current_group-&gt;status == 'private' )
</del><ins>+                        if ( !is_site_admin() &amp;&amp; is_user_logged_in() &amp;&amp; !$bp-&gt;groups-&gt;current_group-&gt;is_user_member &amp;&amp; !groups_check_for_membership_request( $bp-&gt;loggedin_user-&gt;id, $bp-&gt;groups-&gt;current_group-&gt;id ) &amp;&amp; $bp-&gt;groups-&gt;current_group-&gt;status == 'private' )
</ins><span class="cx">                                 bp_core_new_subnav_item( array( 'name' =&gt; __( 'Request Membership', 'buddypress' ), 'slug' =&gt; 'request-membership', 'parent_url' =&gt; $group_link, 'parent_slug' =&gt; $bp-&gt;groups-&gt;slug, 'screen_function' =&gt; 'groups_screen_group_request_membership', 'position' =&gt; 30 ) );
</span><span class="cx"> 
</span><span class="cx">                         if ( $bp-&gt;groups-&gt;current_group-&gt;enable_forum &amp;&amp; function_exists('bp_forums_setup') )
</span><span class="lines">@@ -1971,6 +1971,10 @@
</span><span class="cx"> 
</span><span class="cx">         $bp-&gt;groups-&gt;current_group = new BP_Groups_Group( $group_id );
</span><span class="cx"> 
</span><ins>+        /* Be sure the user is a member of the group before posting. */
+        if ( !groups_is_user_member( $user_id, $group_id ) )
+                return false;
+
</ins><span class="cx">         /* Record this in activity streams */
</span><span class="cx">         $activity_content = sprintf( __( '%s posted an update in the group %s:', 'buddypress'), bp_core_get_userlink( $user_id ), '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '&quot;&gt;' . attribute_escape( $bp-&gt;groups-&gt;current_group-&gt;name ) . '&lt;/a&gt;' );
</span><span class="cx">         $activity_content .= '&lt;div class=&quot;activity-inner&quot;&gt;' . $content . '&lt;/div&gt;';
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultgroupssinglehomephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/groups/single/home.php (2266 => 2267)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/groups/single/home.php        2010-01-06 12:07:27 UTC (rev 2266)
+++ trunk/bp-themes/bp-default/groups/single/home.php        2010-01-06 12:35:41 UTC (rev 2267)
</span><span class="lines">@@ -42,11 +42,18 @@
</span><span class="cx">                                         &lt;?php locate_template( array( 'groups/single/activity.php' ), true ) ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;?php else : ?&gt;
</span><del>-                                        &lt;p&gt;This group is not visible.&lt;/p&gt;
</del><ins>+                                        &lt;?php /* The group is not visible, show the status message */ ?&gt;
+
+                                        &lt;?php do_action( 'bp_before_group_status_message' ) ?&gt;
+
+                                        &lt;div id=&quot;message&quot; class=&quot;info&quot;&gt;
+                                                &lt;p&gt;&lt;?php bp_group_status_message() ?&gt;&lt;/p&gt;
+                                        &lt;/div&gt;
+
+                                        &lt;?php do_action( 'bp_after_group_status_message' ) ?&gt;
</ins><span class="cx">                                 &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;?php do_action( 'bp_directory_members_content' ) ?&gt;
</span><del>-
</del><span class="cx">                         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;?php endwhile; endif; ?&gt;
</span></span></pre>
</div>
</div>

</body>
</html>