<!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' => false,
</span><span class="cx">                 'component_name' => false,
</span><del>-                'component_action' => false,
</del><ins>+                'component_action' => false, // optional
</ins><span class="cx">                 'user_id' => false, // optional
</span><span class="cx">                 'secondary_item_id' => 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' => sprintf( __( '%s created the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ),
-                                'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
-                                'component_action' => 'created_group',
-                                'item_id' => $bp->groups->current_group->id,
-                                'user_id' => $user_id
-                        ) );
</del><span class="cx">                 
</span><span class="cx">                         if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_wire' => $group_enable_wire, 'enable_forum' => $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->groups->current_create_step );
</span><span class="cx">                         unset( $bp->groups->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' => sprintf( __( '%s created the group %s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ),
+                                'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
+                                'component_action' => 'created_group',
+                                'item_id' => $bp->groups->new_group_id
+                        ) );
+                        
</ins><span class="cx">                         bp_core_redirect( bp_get_group_permalink( $bp->groups->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->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
</span><span class="cx">                 
</span><del>-                if ( !$bp->is_item_admin )
</del><ins>+                if ( !$bp->is_item_admin && !is_site_admin() )
</ins><span class="cx">                         return false;
</span><span class="cx">                 
</span><span class="cx">                 if ( isset( $_POST['delete-group-button'] ) && 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' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1687,10 +1686,10 @@
</span><span class="cx">         if ( !$group->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' => $group_id, 'component_name' => 'groups', 'component_action' => 'created_group' ) );
-        }        
</del><ins>+                bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component_name' => $bp->groups->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' => $activity_content,
</span><span class="cx">                         'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</span><span class="cx">                         'component_action' => 'new_wire_post',
</span><del>-                        'item_id' => $wire_post->item_id,
-                        'secondary_item_id' => $bp->groups->current_group->id
</del><ins>+                        'item_id' => $bp->groups->current_group->id,
+                        'secondary_item_id' => $wire_post->item_id
</ins><span class="cx">                 ) );
</span><span class="cx">
</span><span class="cx">                 do_action( 'groups_new_wire_post', $group_id, $wire_post->id );
</span><span class="lines">@@ -2049,7 +2048,7 @@
</span><span class="cx">                         'content' => $activity_content,
</span><span class="cx">                         'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</span><span class="cx">                         'component_action' => 'new_forum_post',
</span><del>-                        'item_id' => $topic_id,
</del><ins>+                        'item_id' => $bp->groups->current_group->id,
</ins><span class="cx">                         'secondary_item_id' => $forum_post->id
</span><span class="cx">                 ) );
</span><span class="cx">
</span><span class="lines">@@ -2075,8 +2074,8 @@
</span><span class="cx">                         'content' => $activity_content,
</span><span class="cx">                         'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</span><span class="cx">                         'component_action' => 'new_forum_topic',
</span><del>-                        'item_id' => $topic->topic_id,
-                        'secondary_item_id' => $bp->groups->current_group->id
</del><ins>+                        'item_id' => $bp->groups->current_group->id,
+                        'secondary_item_id' => $topic->topic_id
</ins><span class="cx">                 ) );
</span><span class="cx">                 
</span><span class="cx">                 do_action( 'groups_new_forum_topic', $bp->groups->current_group->id, &$topic );
</span><span class="lines">@@ -2102,9 +2101,9 @@
</span><span class="cx">                         'content' => $activity_content,
</span><span class="cx">                         'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</span><span class="cx">                         'component_action' => 'new_forum_topic',
</span><del>-                        'item_id' => (int)$topic->topic_id,
</del><ins>+                        'item_id' => (int)$bp->groups->current_group->id,
</ins><span class="cx">                         'user_id' => (int)$topic->topic_poster,
</span><del>-                        'secondary_item_id' => $bp->groups->current_group->id,
</del><ins>+                        'secondary_item_id' => $topic->topic_id,
</ins><span class="cx">                         'recorded_time' => bb_gmtstrtotime( $topic->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' => $topic_id, 'secondary_item_id' => $post_id, 'component_name' => 'groups', 'component_action' => 'new_forum_post' ) );
</del><ins>+                bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => 'groups', 'component_action' => '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->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
</span><span class="cx">                 $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>';
</span><span class="lines">@@ -2153,7 +2152,7 @@
</span><span class="cx">                         'content' => $activity_content,
</span><span class="cx">                         'primary_link' => bp_get_group_permalink( $bp->groups->current_group ),
</span><span class="cx">                         'component_action' => 'new_forum_post',
</span><del>-                        'item_id' => $topic_id,
</del><ins>+                        'item_id' => $bp->groups->current_group->id,
</ins><span class="cx">                         'secondary_item_id' => $post_id,
</span><span class="cx">                         'recorded_time' => bb_gmtstrtotime( $post->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>