<!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] [1763] trunk: Fixes #820</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>1763</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-09-02 20:20:16 +0000 (Wed, 02 Sep 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixes #820</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivityphp">trunk/bp-activity.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsclassesphp">trunk/bp-groups/bp-groups-classes.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (1762 => 1763)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2009-09-02 19:57:46 UTC (rev 1762)
+++ trunk/bp-activity.php        2009-09-02 20:20:16 UTC (rev 1763)
</span><span class="lines">@@ -286,7 +286,7 @@
</span><span class="cx">         $defaults = array(
</span><span class="cx">                 'item_id' =&gt; false,
</span><span class="cx">                 'component_name' =&gt; false,
</span><del>-                'component_action' =&gt; false,
</del><ins>+                'component_action' =&gt; false, // optional
</ins><span class="cx">                 'user_id' =&gt; false, // optional
</span><span class="cx">                 'secondary_item_id' =&gt; false // optional
</span><span class="cx">         );
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-classes.php (1762 => 1763)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-classes.php        2009-09-02 19:57:46 UTC (rev 1762)
+++ trunk/bp-groups/bp-groups-classes.php        2009-09-02 20:20:16 UTC (rev 1763)
</span><span class="lines">@@ -147,14 +147,6 @@
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        function make_private() {
-                
-        }
-        
-        function make_public() {
-                
-        }
-        
</del><span class="cx">         function get_user_dataset() {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx">                 
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (1762 => 1763)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2009-09-02 19:57:46 UTC (rev 1762)
+++ trunk/bp-groups.php        2009-09-02 20:20:16 UTC (rev 1763)
</span><span class="lines">@@ -459,15 +459,6 @@
</span><span class="cx">                                 $group_status = 'private';
</span><span class="cx">                         else if ( 'hidden' == $_POST['group-status'] )
</span><span class="cx">                                 $group_status = 'hidden';
</span><del>-                        
-                        /* Once we get to the second step, record the group creation in the activity stream. As we now know the actual status of the group */
-                        groups_record_activity( array(
-                                'content' =&gt; sprintf( __( '%s created the group %s:', 'buddypress'), bp_core_get_userlink( $bp-&gt;loggedin_user-&gt;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;' ), 
-                                'primary_link' =&gt; bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ),
-                                'component_action' =&gt; 'created_group',
-                                'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
-                                'user_id' =&gt; $user_id
-                        ) );
</del><span class="cx">                 
</span><span class="cx">                         if ( !$bp-&gt;groups-&gt;new_group_id = groups_create_group( array( 'group_id' =&gt; $bp-&gt;groups-&gt;new_group_id, 'status' =&gt; $group_status, 'enable_wire' =&gt; $group_enable_wire, 'enable_forum' =&gt; $group_enable_forum ) ) ) {
</span><span class="cx">                                 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
</span><span class="lines">@@ -499,6 +490,14 @@
</span><span class="cx">                         unset( $bp-&gt;groups-&gt;current_create_step );
</span><span class="cx">                         unset( $bp-&gt;groups-&gt;completed_create_steps );
</span><span class="cx">                         
</span><ins>+                        /* Once we compelete all steps, record the group creation in the activity stream. */
+                        groups_record_activity( array(
+                                'content' =&gt; sprintf( __( '%s created the group %s:', 'buddypress'), bp_core_get_userlink( $bp-&gt;loggedin_user-&gt;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;' ), 
+                                'primary_link' =&gt; bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ),
+                                'component_action' =&gt; 'created_group',
+                                'item_id' =&gt; $bp-&gt;groups-&gt;new_group_id
+                        ) );
+                        
</ins><span class="cx">                         bp_core_redirect( bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) );
</span><span class="cx">                 } else {
</span><span class="cx">                         /**
</span><span class="lines">@@ -1227,7 +1226,7 @@
</span><span class="cx">         
</span><span class="cx">         if ( $bp-&gt;current_component == $bp-&gt;groups-&gt;slug &amp;&amp; 'delete-group' == $bp-&gt;action_variables[0] ) {
</span><span class="cx">                 
</span><del>-                if ( !$bp-&gt;is_item_admin )
</del><ins>+                if ( !$bp-&gt;is_item_admin &amp;&amp; !is_site_admin() )
</ins><span class="cx">                         return false;
</span><span class="cx">                 
</span><span class="cx">                 if ( isset( $_POST['delete-group-button'] ) &amp;&amp; isset( $_POST['delete-group-understand'] ) ) {
</span><span class="lines">@@ -1236,7 +1235,7 @@
</span><span class="cx">                                 return false;
</span><span class="cx">                 
</span><span class="cx">                         // Group admin has deleted the group, now do it.
</span><del>-                        if ( !groups_delete_group( $_POST['group-id']) ) {
</del><ins>+                        if ( !groups_delete_group( $_POST['group-id'] ) ) {
</ins><span class="cx">                                 bp_core_add_message( __( 'There was an error deleting the group, please try again.', 'buddypress' ), 'error' );
</span><span class="cx">                         } else {
</span><span class="cx">                                 bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
</span><span class="lines">@@ -1419,7 +1418,7 @@
</span><span class="cx"> 
</span><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx">         extract( $r, EXTR_SKIP );        
</span><del>-        
</del><ins>+
</ins><span class="cx">         return bp_activity_add( array( 'user_id' =&gt; $user_id, 'content' =&gt; $content, 'primary_link' =&gt; $primary_link, 'component_name' =&gt; $component_name, 'component_action' =&gt; $component_action, 'item_id' =&gt; $item_id, 'secondary_item_id' =&gt; $secondary_item_id, 'recorded_time' =&gt; $recorded_time, 'hide_sitewide' =&gt; $hide_sitewide ) );
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1687,10 +1686,10 @@
</span><span class="cx">         if ( !$group-&gt;delete() )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        /* Delete the activity stream item */
</del><ins>+        /* Delete all group activity from activity streams */
</ins><span class="cx">         if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
</span><del>-                bp_activity_delete_by_item_id( array( 'item_id' =&gt; $group_id, 'component_name' =&gt; 'groups', 'component_action' =&gt; 'created_group' ) );
-        }        
</del><ins>+                bp_activity_delete_by_item_id( array( 'item_id' =&gt; $group_id, 'component_name' =&gt; $bp-&gt;groups-&gt;id ) );
+        }
</ins><span class="cx">  
</span><span class="cx">         // Remove all outstanding invites for this group
</span><span class="cx">         groups_delete_all_group_invites( $group_id );
</span><span class="lines">@@ -1988,8 +1987,8 @@
</span><span class="cx">                         'content' =&gt; $activity_content, 
</span><span class="cx">                         'primary_link' =&gt; bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ),
</span><span class="cx">                         'component_action' =&gt; 'new_wire_post',
</span><del>-                        'item_id' =&gt; $wire_post-&gt;item_id,
-                        'secondary_item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id
</del><ins>+                        'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
+                        'secondary_item_id' =&gt; $wire_post-&gt;item_id
</ins><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="cx">                 do_action( 'groups_new_wire_post', $group_id, $wire_post-&gt;id );
</span><span class="lines">@@ -2049,7 +2048,7 @@
</span><span class="cx">                         'content' =&gt; $activity_content, 
</span><span class="cx">                         'primary_link' =&gt; bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ),
</span><span class="cx">                         'component_action' =&gt; 'new_forum_post',
</span><del>-                        'item_id' =&gt; $topic_id,
</del><ins>+                        'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
</ins><span class="cx">                         'secondary_item_id' =&gt; $forum_post-&gt;id
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="lines">@@ -2075,8 +2074,8 @@
</span><span class="cx">                         'content' =&gt; $activity_content, 
</span><span class="cx">                         'primary_link' =&gt; bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ),
</span><span class="cx">                         'component_action' =&gt; 'new_forum_topic',
</span><del>-                        'item_id' =&gt; $topic-&gt;topic_id,
-                        'secondary_item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id
</del><ins>+                        'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
+                        'secondary_item_id' =&gt; $topic-&gt;topic_id
</ins><span class="cx">                 ) );
</span><span class="cx">                 
</span><span class="cx">                 do_action( 'groups_new_forum_topic', $bp-&gt;groups-&gt;current_group-&gt;id, &amp;$topic );
</span><span class="lines">@@ -2102,9 +2101,9 @@
</span><span class="cx">                         'content' =&gt; $activity_content, 
</span><span class="cx">                         'primary_link' =&gt; bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ),
</span><span class="cx">                         'component_action' =&gt; 'new_forum_topic',
</span><del>-                        'item_id' =&gt; (int)$topic-&gt;topic_id,
</del><ins>+                        'item_id' =&gt; (int)$bp-&gt;groups-&gt;current_group-&gt;id,
</ins><span class="cx">                         'user_id' =&gt; (int)$topic-&gt;topic_poster,
</span><del>-                        'secondary_item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
</del><ins>+                        'secondary_item_id' =&gt; $topic-&gt;topic_id,
</ins><span class="cx">                         'recorded_time' =&gt; bb_gmtstrtotime( $topic-&gt;topic_time )
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><span class="lines">@@ -2143,7 +2142,7 @@
</span><span class="cx">                 $topic = bp_forums_get_topic_details( $topic_id );
</span><span class="cx"> 
</span><span class="cx">                 /* Update the activity stream item */
</span><del>-                bp_activity_delete_by_item_id( array( 'item_id' =&gt; $topic_id, 'secondary_item_id' =&gt; $post_id, 'component_name' =&gt; 'groups', 'component_action' =&gt; 'new_forum_post' ) );
</del><ins>+                bp_activity_delete_by_item_id( array( 'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id, 'secondary_item_id' =&gt; $post_id, 'component_name' =&gt; 'groups', 'component_action' =&gt; 'new_forum_post' ) );
</ins><span class="cx">                 
</span><span class="cx">                 $activity_content = sprintf( __( '%s posted on the forum topic %s in the group %s:', 'buddypress'), bp_core_get_userlink( $post-&gt;poster_id ), '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '/forum/topic/' . $topic-&gt;topic_slug .'&quot;&gt;' . attribute_escape( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&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;blockquote&gt;' . bp_create_excerpt( attribute_escape( $post_text ) ) . '&lt;/blockquote&gt;';
</span><span class="lines">@@ -2153,7 +2152,7 @@
</span><span class="cx">                         'content' =&gt; $activity_content, 
</span><span class="cx">                         'primary_link' =&gt; bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ),
</span><span class="cx">                         'component_action' =&gt; 'new_forum_post',
</span><del>-                        'item_id' =&gt; $topic_id,
</del><ins>+                        'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
</ins><span class="cx">                         'secondary_item_id' =&gt; $post_id,
</span><span class="cx">                         'recorded_time' =&gt; bb_gmtstrtotime( $post-&gt;post_time )
</span><span class="cx">                 ) );
</span><span class="lines">@@ -2560,13 +2559,13 @@
</span><span class="cx"> 
</span><span class="cx"> /*** Group Cleanup Functions ****************************************************/
</span><span class="cx"> 
</span><del>-function groups_remove_data( $user_id ) {
</del><ins>+function groups_remove_data_for_user( $user_id ) {
</ins><span class="cx">         BP_Groups_Member::delete_all_for_user($user_id);
</span><span class="cx">         
</span><del>-        do_action( 'groups_remove_data', $user_id );
</del><ins>+        do_action( 'groups_remove_data_for_user', $user_id );
</ins><span class="cx"> }
</span><del>-add_action( 'wpmu_delete_user', 'groups_remove_data', 1 );
-add_action( 'delete_user', 'groups_remove_data', 1 );
</del><ins>+add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 );
+add_action( 'delete_user', 'groups_remove_data_for_user', 1 );
</ins><span class="cx"> 
</span><span class="cx"> function groups_clear_group_object_cache( $group_id ) {
</span><span class="cx">         wp_cache_delete( 'groups_group_nouserdata_' . $group_id, 'bp' );
</span></span></pre>
</div>
</div>

</body>
</html>