<!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] [2471] trunk:
  Merged activity delete functions for better usability.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2471</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-28 18:01:42 +0000 (Thu, 28 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged activity delete functions for better usability. Fixed some issues with the group extension API and plugin compatibility in 1.2</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityclassesphp">trunk/bp-activity/bp-activity-classes.php</a></li>
<li><a href="#trunkbpactivitybpactivitytemplatetagsphp">trunk/bp-activity/bp-activity-templatetags.php</a></li>
<li><a href="#trunkbpactivityphp">trunk/bp-activity.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="#trunkbpthemesbpdefault_incajaxphp">trunk/bp-themes/bp-default/_inc/ajax.php</a></li>
<li><a href="#trunkbpthemesbpdefaultactivitypostformphp">trunk/bp-themes/bp-default/activity/post-form.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-classes.php (2470 => 2471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-classes.php        2010-01-27 14:11:11 UTC (rev 2470)
+++ trunk/bp-activity/bp-activity-classes.php        2010-01-28 18:01:42 UTC (rev 2471)
</span><span class="lines">@@ -70,153 +70,17 @@
</span><span class="cx"> 
</span><span class="cx">         /* Static Functions */
</span><span class="cx"> 
</span><del>-        function delete( $item_id, $component, $type, $user_id = false, $secondary_item_id = false ) {
-                global $wpdb, $bp;
-
-                if ( $secondary_item_id )
-                        $secondary_sql = $wpdb-&gt;prepare( &quot;AND secondary_item_id = %s&quot;, $secondary_item_id );
-
-                if ( $type )
-                        $type_sql = $wpdb-&gt;prepare( &quot;AND type = %s&quot;, $type );
-
-                if ( $user_id )
-                        $user_sql = $wpdb-&gt;prepare( &quot;AND user_id = %d&quot;, $user_id );
-
-                /* Fetch the activity IDs so we can delete any comments for this activity item */
-                $activity_ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;activity-&gt;table_name} WHERE item_id = %s {$secondary_sql} AND component = %s {$type_sql} {$user_sql}&quot;, $item_id, $component ) );
-
-                error_log( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE item_id = %s {$secondary_sql} AND component = %s {$type_sql} {$user_sql}&quot;, $item_id, $component ) );
-
-                if ( !$wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE item_id = %s {$secondary_sql} AND component = %s {$type_sql} {$user_sql}&quot;, $item_id, $component ) ) )
-                        return false;
-
-                if ( $activity_ids ) {
-                        BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
-                        BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
-
-                        return $activity_ids;
-                }
-
-                return true;
-        }
-
-        function delete_by_item_id( $item_id, $component, $type, $user_id = false, $secondary_item_id = false ) {
-                return BP_Activity_Activity::delete( $item_id, $component, $type, $user_id, $secondary_item_id );
-        }
-
-        function delete_by_activity_id( $activity_id ) {
-                global $bp, $wpdb;
-
-                if ( !$wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE id = %d&quot;, $activity_id ) ) )
-                        return false;
-
-                /* Delete the comments for this activity ID */
-                BP_Activity_Activity::delete_activity_item_comments( $activity_id );
-                BP_Activity_Activity::delete_activity_meta_entries( $activity_id );
-
-                return true;
-        }
-
-        function delete_by_content( $user_id, $content, $component, $type ) {
-                global $bp, $wpdb;
-
-                /* Fetch the activity ID so we can delete any comments for this activity item */
-                $activity_ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;activity-&gt;table_name} WHERE user_id = %d AND content = %s AND component = %s AND type = %s&quot;, $user_id, $content, $component, $type ) );
-
-                if ( !$wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE user_id = %d AND content = %s AND component = %s AND type = %s&quot;, $user_id, $content, $component, $type ) ) )
-                        return false;
-
-                if ( $activity_ids ) {
-                        BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
-                        BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
-
-                        return $activity_ids;
-                }
-
-                return true;
-        }
-
-        function delete_for_user_by_component( $user_id, $component ) {
-                global $bp, $wpdb;
-
-                /* Fetch the activity IDs so we can delete any comments for this activity item */
-                $activity_ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;activity-&gt;table_name} WHERE user_id = %d AND component = %s&quot;, $user_id, $component ) );
-
-                if ( !$wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE user_id = %d AND component = %s&quot;, $user_id, $component ) ) )
-                        return false;
-
-                if ( $activity_ids ) {
-                        BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
-                        BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
-
-                        return $activity_ids;
-                }
-
-                return true;
-        }
-
-        function delete_for_user( $user_id ) {
-                global $wpdb, $bp;
-
-                /* Fetch the activity IDs so we can delete any comments for this activity item */
-                $activity_ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;activity-&gt;table_name} WHERE user_id = %d&quot;, $user_id ) );
-
-                if ( !$wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE user_id = %d&quot;, $user_id ) ) )
-                        return false;
-
-                if ( $activity_ids ) {
-                        BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
-                        BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
-
-                        return $activity_ids;
-                }
-        }
-
-        function delete_activity_item_comments( $activity_ids ) {
-                global $bp, $wpdb;
-
-                if ( is_array($activity_ids) )
-                        $activity_ids = implode( ',', $activity_ids );
-
-                $activity_ids = $wpdb-&gt;escape( $activity_ids );
-
-                return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})&quot; ) );
-        }
-
-        function delete_activity_meta_entries( $activity_ids ) {
-                global $bp, $wpdb;
-
-                if ( is_array($activity_ids) )
-                        $activity_ids = implode( ',', $activity_ids );
-
-                $activity_ids = $wpdb-&gt;escape( $activity_ids );
-
-                return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name_meta} WHERE activity_id IN ({$activity_ids})&quot; ) );
-        }
-
</del><span class="cx">         function get( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><span class="cx">                 /* Select conditions */
</span><span class="cx">                 $select_sql = &quot;SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name&quot;;
</span><span class="cx"> 
</span><del>-                if ( function_exists( 'xprofile_install' ) )
-                        $select_sql .= &quot;, pd.value as user_fullname&quot;;
</del><ins>+                $from_sql = &quot; FROM {$bp-&gt;activity-&gt;table_name} a LEFT JOIN {$wpdb-&gt;users} u ON a.user_id = u.ID&quot;;
</ins><span class="cx"> 
</span><del>-                $from_sql = &quot; FROM {$bp-&gt;activity-&gt;table_name} a, {$wpdb-&gt;users} u&quot;;
-
-                if ( function_exists( 'xprofile_install' ) )
-                        $from_sql .= &quot;, {$bp-&gt;profile-&gt;table_name_data} pd&quot;;
-
</del><span class="cx">                 /* Where conditions */
</span><span class="cx">                 $where_conditions = array();
</span><del>-                $where_conditions['user_join'] = &quot;a.user_id = u.ID&quot;;
</del><span class="cx"> 
</span><del>-                if ( function_exists( 'xprofile_install' ) ) {
-                        $where_conditions['xprofile_join'] = &quot;a.user_id = pd.user_id&quot;;
-                        $where_conditions['xprofile_filter'] = &quot;pd.field_id = 1&quot;;
-                }
-
</del><span class="cx">                 if ( $per_page &amp;&amp; $page )
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot;LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
</span><span class="cx"> 
</span><span class="lines">@@ -252,6 +116,30 @@
</span><span class="cx"> 
</span><span class="cx">                 $total_activities = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT count(a.id) {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}&quot; ) );
</span><span class="cx"> 
</span><ins>+                /* Get the fullnames of users so we don't have to query in the loop */
+                if ( function_exists( 'xprofile_install' ) &amp;&amp; $activities ) {
+                        foreach ( (array)$activities as $activity ) {
+                                if ( (int)$activity-&gt;user_id )
+                                        $activity_user_ids[] = $activity-&gt;user_id;
+                        }
+
+                        $activity_user_ids = implode( ',', (array)$activity_user_ids );
+                        if ( !empty( $activity_user_ids ) ) {
+                                if ( $names = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT user_id, value AS user_fullname FROM {$bp-&gt;profile-&gt;table_name_data} WHERE field_id = 1 AND user_id IN ({$activity_user_ids})&quot; ) ) ) {
+                                        foreach ( (array)$names as $name )
+                                                $tmp_names[$name-&gt;user_id] = $name-&gt;user_fullname;
+
+                                        foreach ( (array)$activities as $i =&gt; $activity ) {
+                                                if ( !empty( $tmp_names[$activity-&gt;user_id] ) )
+                                                        $activities[$i]-&gt;user_fullname = $tmp_names[$activity-&gt;user_id];
+                                        }
+
+                                        unset( $names );
+                                        unset( $tmp_names );
+                                }
+                        }
+                }
+
</ins><span class="cx">                 if ( $activities &amp;&amp; $display_comments )
</span><span class="cx">                         $activities = BP_Activity_Activity::append_comments( &amp;$activities );
</span><span class="cx"> 
</span><span class="lines">@@ -294,7 +182,7 @@
</span><span class="cx">                 return array( 'activities' =&gt; $activities, 'total' =&gt; (int)$total_activities );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function get_id( $user_id, $component, $type, $item_id, $secondary_item_id ) {
</del><ins>+        function get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) {
</ins><span class="cx">                 global $bp, $wpdb;
</span><span class="cx"> 
</span><span class="cx">                 $where_args = false;
</span><span class="lines">@@ -314,6 +202,12 @@
</span><span class="cx">                 if ( !empty( $secondary_item_id ) )
</span><span class="cx">                         $where_args[] = $wpdb-&gt;prepare( &quot;secondary_item_id = %s&quot;, $secondary_item_id );
</span><span class="cx"> 
</span><ins>+                if ( !empty( $action ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;action = %s&quot;, bp_activity_add_timesince_placeholder( $action ) );
+
+                if ( !empty( $content ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;content = %s&quot;, $content );
+
</ins><span class="cx">                 if ( !empty( $where_args ) )
</span><span class="cx">                         $where_sql = 'WHERE ' . join( ' AND ', $where_args );
</span><span class="cx">                 else
</span><span class="lines">@@ -322,6 +216,103 @@
</span><span class="cx">                 return $wpdb-&gt;get_var( &quot;SELECT id FROM {$bp-&gt;activity-&gt;table_name} {$where_sql}&quot; );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function delete( $args ) {
+                global $wpdb, $bp;
+
+                extract( $args );
+
+                $defaults = array(
+                        'id' =&gt; false,
+                        'action' =&gt; false,
+                        'content' =&gt; false,
+                        'component' =&gt; false,
+                        'type' =&gt; false,
+                        'primary_link' =&gt; false,
+                        'user_id' =&gt; false,
+                        'item_id' =&gt; false,
+                        'secondary_item_id' =&gt; false,
+                        'recorded_time' =&gt; false,
+                        'hide_sitewide' =&gt; false
+                );
+
+                $where_args = false;
+
+                if ( !empty( $id ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;id = %d&quot;, $id );
+
+                if ( !empty( $user_id ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;user_id = %d&quot;, $user_id );
+
+                if ( !empty( $action ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;action = %s&quot;, bp_activity_add_timesince_placeholder( $action ) );
+
+                if ( !empty( $content ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;content = %s&quot;, $content );
+
+                if ( !empty( $component ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;component = %s&quot;, $component );
+
+                if ( !empty( $type ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;type = %s&quot;, $type );
+
+                if ( !empty( $primary_link ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;primary_link = %s&quot;, $primary_link );
+
+                if ( !empty( $item_id ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;item_id = %s&quot;, $item_id );
+
+                if ( !empty( $secondary_item_id ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;secondary_item_id = %s&quot;, $secondary_item_id );
+
+                if ( !empty( $recorded_time ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;recorded_time = %s&quot;, $recorded_time );
+
+                if ( !empty( $hide_sitewide ) )
+                        $where_args[] = $wpdb-&gt;prepare( &quot;recorded_time = %d&quot;, $hide_sitewide );
+
+                if ( !empty( $where_args ) )
+                        $where_sql = 'WHERE ' . join( ' AND ', $where_args );
+                else
+                        return false;
+
+                /* Fetch the activity IDs so we can delete any comments for this activity item */
+                $activity_ids = $wpdb-&gt;get_col( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;activity-&gt;table_name} {$where_sql}&quot; ) );
+
+                if ( !$wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} {$where_sql}&quot; ) ) )
+                        return false;
+
+                if ( $activity_ids ) {
+                        BP_Activity_Activity::delete_activity_item_comments( $activity_ids );
+                        BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );
+
+                        return $activity_ids;
+                }
+
+                return $activity_ids;
+        }
+
+        function delete_activity_item_comments( $activity_ids ) {
+                global $bp, $wpdb;
+
+                if ( is_array($activity_ids) )
+                        $activity_ids = implode( ',', $activity_ids );
+
+                $activity_ids = $wpdb-&gt;escape( $activity_ids );
+
+                return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name} WHERE type = 'activity_comment' AND item_id IN ({$activity_ids})&quot; ) );
+        }
+
+        function delete_activity_meta_entries( $activity_ids ) {
+                global $bp, $wpdb;
+
+                if ( is_array($activity_ids) )
+                        $activity_ids = implode( ',', $activity_ids );
+
+                $activity_ids = $wpdb-&gt;escape( $activity_ids );
+
+                return $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;activity-&gt;table_name_meta} WHERE activity_id IN ({$activity_ids})&quot; ) );
+        }
+
</ins><span class="cx">         function append_comments( $activities ) {
</span><span class="cx">                 global $bp, $wpdb;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpactivitybpactivitytemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-templatetags.php (2470 => 2471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-templatetags.php        2010-01-27 14:11:11 UTC (rev 2470)
+++ trunk/bp-activity/bp-activity-templatetags.php        2010-01-28 18:01:42 UTC (rev 2471)
</span><span class="lines">@@ -297,7 +297,13 @@
</span><span class="cx"> }
</span><span class="cx">         function bp_get_activity_user_link() {
</span><span class="cx">                 global $activities_template;
</span><del>-                return apply_filters( 'bp_get_activity_user_link', bp_core_get_user_domain( $activities_template-&gt;activity-&gt;user_id, $activities_template-&gt;activity-&gt;user_nicename, $activities_template-&gt;activity-&gt;user_login ) );
</del><ins>+
+                if ( empty( $activities_template-&gt;activity-&gt;user_id ) )
+                        $link = $activities_template-&gt;activity-&gt;primary_link;
+                else
+                        $link = bp_core_get_user_domain( $activities_template-&gt;activity-&gt;user_id, $activities_template-&gt;activity-&gt;user_nicename, $activities_template-&gt;activity-&gt;user_login );
+
+                return apply_filters( 'bp_get_activity_user_link', $link );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_avatar( $args = '' ) {
</span><span class="lines">@@ -445,13 +451,18 @@
</span><span class="cx">                 if ( !$parent_activity )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><ins>+                if ( empty( $parent_activity-&gt;content ) )
+                        $content = $parent_activity-&gt;action;
+                else
+                        $content = $parent_activity-&gt;action . $parent_activity-&gt;content;
+
</ins><span class="cx">                 /* Remove the time since content */
</span><del>-                $parent_activity-&gt;content = str_replace( '&lt;span class=&quot;time-since&quot;&gt;%s&lt;/span&gt;', '', $parent_activity-&gt;content );
</del><ins>+                $content = str_replace( '&lt;span class=&quot;time-since&quot;&gt;%s&lt;/span&gt;', '', $content );
</ins><span class="cx"> 
</span><span class="cx">                 /* Remove images */
</span><del>-                $parent_activity-&gt;content = preg_replace( '/&lt;img[^&gt;]*&gt;/Ui', '', $parent_activity-&gt;content );
</del><ins>+                $content = preg_replace( '/&lt;img[^&gt;]*&gt;/Ui', '', $content );
</ins><span class="cx"> 
</span><del>-                return apply_filters( 'bp_get_activity_parent_content', $parent_activity-&gt;content );
</del><ins>+                return apply_filters( 'bp_get_activity_parent_content', $content );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_is_favorite() {
</span></span></pre></div>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (2470 => 2471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2010-01-27 14:11:11 UTC (rev 2470)
+++ trunk/bp-activity.php        2010-01-28 18:01:42 UTC (rev 2471)
</span><span class="lines">@@ -610,21 +610,20 @@
</span><span class="cx">                 'component' =&gt; false,
</span><span class="cx">                 'type' =&gt; false,
</span><span class="cx">                 'item_id' =&gt; false,
</span><del>-                'secondary_item_id' =&gt; false
</del><ins>+                'secondary_item_id' =&gt; false,
+                'action' =&gt; false,
+                'content' =&gt; false
</ins><span class="cx">         );
</span><span class="cx"> 
</span><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx"> 
</span><del>-         return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id ) );
</del><ins>+         return apply_filters( 'bp_activity_get_activity_id', BP_Activity_Activity::get_id( $user_id, $component, $type, $item_id, $secondary_item_id, $action, $content ) );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /***
</span><span class="cx">  * Deleting Activity
</span><span class="cx">  *
</span><del>- * There are multiple ways to delete activity items, depending on
- * the information you have at the time.
- *
</del><span class="cx">  * If you're looking to hook into one action that provides the ID(s) of
</span><span class="cx">  * the activity/activities deleted, then use:
</span><span class="cx">  *
</span><span class="lines">@@ -634,62 +633,58 @@
</span><span class="cx">  * array of activity IDs depending on the number deleted.
</span><span class="cx"> */
</span><span class="cx"> 
</span><del>-function bp_activity_delete_by_item_id( $args = '' ) {
</del><ins>+function bp_activity_delete( $args = '' ) {
</ins><span class="cx">         global $bp;
</span><span class="cx"> 
</span><ins>+        /* Pass one or more the of following variables to delete by those variables */
</ins><span class="cx">         $defaults = array(
</span><del>-                'item_id' =&gt; false,
</del><ins>+                'id' =&gt; false,
+                'action' =&gt; false,
+                'content' =&gt; false,
</ins><span class="cx">                 'component' =&gt; false,
</span><del>-                'type' =&gt; false, // optional
-                'user_id' =&gt; false, // optional
-                'secondary_item_id' =&gt; false // optional
</del><ins>+                'type' =&gt; false,
+                'primary_link' =&gt; false,
+                'user_id' =&gt; false,
+                'item_id' =&gt; false,
+                'secondary_item_id' =&gt; false,
+                'recorded_time' =&gt; false,
+                'hide_sitewide' =&gt; false
</ins><span class="cx">         );
</span><span class="cx"> 
</span><del>-        $r = wp_parse_args( $args, $defaults );
-        extract( $r, EXTR_SKIP );
</del><ins>+        $args = wp_parse_args( $args, $defaults );
</ins><span class="cx"> 
</span><del>-        if ( !$activity_ids_deleted = BP_Activity_Activity::delete_by_item_id( $item_id, $component, $type, $user_id, $secondary_item_id ) )
</del><ins>+        if ( !$activity_ids_deleted = BP_Activity_Activity::delete( $args ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        do_action( 'bp_activity_delete_by_item_id', $item_id, $component, $type, $user_id, $secondary_item_id );
</del><ins>+        do_action( 'bp_activity_delete', $args );
</ins><span class="cx">         do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
</span><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><ins>+        /* The following functions have been deprecated in place of bp_activity_delete() */
+        function bp_activity_delete_by_item_id( $args = '' ) {
+                global $bp;
</ins><span class="cx"> 
</span><del>-function bp_activity_delete_by_activity_id( $activity_id ) {
-        if ( !BP_Activity_Activity::delete_by_activity_id( $activity_id ) )
-                return false;
</del><ins>+                $defaults = array( 'item_id' =&gt; false, 'component' =&gt; false, 'type' =&gt; false, 'user_id' =&gt; false, 'secondary_item_id' =&gt; false );
+                $r = wp_parse_args( $args, $defaults );
+                extract( $r, EXTR_SKIP );
</ins><span class="cx"> 
</span><del>-        do_action( 'bp_activity_delete_by_activity_id', $activity_id );
-        do_action( 'bp_activity_deleted_activities', $activity_id );
</del><ins>+                return bp_activity_delete( array( 'item_id' =&gt; $item_id, 'component' =&gt; $component, 'type' =&gt; $type, 'user_id' =&gt; $user_id, 'secondary_item_id' =&gt; $secondary_item_id ) );
+        }
</ins><span class="cx"> 
</span><del>-        return true;
-}
</del><ins>+        function bp_activity_delete_by_activity_id( $activity_id ) {
+                return bp_activity_delete( array( 'id' =&gt; $activity_id ) );
+        }
</ins><span class="cx"> 
</span><del>-function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
-        /* Insert the &quot;time-since&quot; placeholder to match the existing content in the DB */
-        $content = bp_activity_add_timesince_placeholder( $content );
</del><ins>+        function bp_activity_delete_by_content( $user_id, $content, $component, $type ) {
+                return bp_activity_delete( array( 'user_id' =&gt; $user_id, 'content' =&gt; $content, 'component' =&gt; $component, 'type' =&gt; $type ) );
+        }
</ins><span class="cx"> 
</span><del>-        if ( !$activity_ids_deleted = BP_Activity_Activity::delete_by_content( $user_id, $content, $component, $type ) )
-                return false;
</del><ins>+        function bp_activity_delete_for_user_by_component( $user_id, $component ) {
+                return bp_activity_delete( array( 'user_id' =&gt; $user_id, 'component' =&gt; $component ) );
+        }
+        /* End deprecation */
</ins><span class="cx"> 
</span><del>-        do_action( 'bp_activity_delete_by_content', $user_id, $content, $component, $type );
-        do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
-
-        return true;
-}
-
-function bp_activity_delete_for_user_by_component( $user_id, $component ) {
-        if ( !$activity_ids_deleted = BP_Activity_Activity::delete_for_user_by_component( $user_id, $component ) )
-                return false;
-
-        do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component );
-        do_action( 'bp_activity_deleted_activities', $activity_ids_deleted );
-
-        return true;
-}
-
</del><span class="cx"> function bp_activity_get_permalink( $activity_id, $activity_obj = false ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -996,7 +991,7 @@
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_remove_data( $user_id ) {
</span><span class="cx">         // Clear the user's activity from the sitewide stream and clear their activity tables
</span><del>-        BP_Activity_Activity::delete_for_user( $user_id );
</del><ins>+        bp_activity_delete( array( 'user_id' =&gt; $user_id ) );
</ins><span class="cx"> 
</span><span class="cx">         // Remove any usermeta
</span><span class="cx">         delete_usermeta( $user_id, 'bp_latest_update' );
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-templatetags.php (2470 => 2471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-templatetags.php        2010-01-27 14:11:11 UTC (rev 2470)
+++ trunk/bp-groups/bp-groups-templatetags.php        2010-01-28 18:01:42 UTC (rev 2471)
</span><span class="lines">@@ -1499,6 +1499,7 @@
</span><span class="cx">                 $bp-&gt;groups-&gt;current_create_step = array_shift( array_keys( $bp-&gt;groups-&gt;group_creation_steps ) );
</span><span class="cx"> 
</span><span class="cx">         $counter = 1;
</span><ins>+
</ins><span class="cx">         foreach ( $bp-&gt;groups-&gt;group_creation_steps as $slug =&gt; $step ) {
</span><span class="cx">                 $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (2470 => 2471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2010-01-27 14:11:11 UTC (rev 2470)
+++ trunk/bp-groups.php        2010-01-28 18:01:42 UTC (rev 2471)
</span><span class="lines">@@ -106,8 +106,6 @@
</span><span class="cx"> add_action( 'plugins_loaded', 'groups_setup_root_component', 2 );
</span><span class="cx"> 
</span><span class="cx"> function groups_check_installed() {
</span><del>-        global $wpdb, $bp;
-
</del><span class="cx">         /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
</span><span class="cx">         if ( get_site_option('bp-groups-db-version') &lt; BP_GROUPS_DB_VERSION )
</span><span class="cx">                 groups_install();
</span><span class="lines">@@ -115,7 +113,7 @@
</span><span class="cx"> add_action( 'admin_menu', 'groups_check_installed' );
</span><span class="cx"> 
</span><span class="cx"> function groups_setup_nav() {
</span><del>-        global $bp, $current_blog, $group_obj;
</del><ins>+        global $bp;
</ins><span class="cx"> 
</span><span class="cx">         if ( $group_id = BP_Groups_Group::group_exists($bp-&gt;current_action) ) {
</span><span class="cx"> 
</span><span class="lines">@@ -138,9 +136,6 @@
</span><span class="cx"> 
</span><span class="cx">                 /* Should this group be visible to the logged in user? */
</span><span class="cx">                 $bp-&gt;groups-&gt;current_group-&gt;is_group_visible_to_member = ( 'public' == $bp-&gt;groups-&gt;current_group-&gt;status || $is_member ) ? true : false;
</span><del>-
-                /* Pre 1.1 backwards compatibility - use $bp-&gt;groups-&gt;current_group instead */
-                $group_obj = &amp;$bp-&gt;groups-&gt;current_group;
</del><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /* Add 'Groups' to the main navigation */
</span><span class="lines">@@ -666,9 +661,11 @@
</span><span class="cx"> function groups_screen_group_activity_permalink() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !$bp-&gt;is_single_item || $bp-&gt;current_component != $bp-&gt;groups-&gt;slug || $bp-&gt;current_action != $bp-&gt;activity-&gt;slug )
</del><ins>+        if ( $bp-&gt;current_component != $bp-&gt;groups-&gt;slug || $bp-&gt;current_action != $bp-&gt;activity-&gt;slug || empty( $bp-&gt;action_variables[0] ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><ins>+        $bp-&gt;is_single_item = true;
+
</ins><span class="cx">         bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp', 'groups_screen_group_activity_permalink', 3 );
</span><span class="lines">@@ -1243,8 +1240,12 @@
</span><span class="cx">         if ( !is_array( $bp-&gt;groups-&gt;group_creation_steps ) )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        foreach ( $bp-&gt;groups-&gt;group_creation_steps as $slug =&gt; $step )
</del><ins>+        foreach ( $bp-&gt;groups-&gt;group_creation_steps as $slug =&gt; $step ) {
+                while ( !empty( $temp[$step['position']] ) )
+                        $step['position']++;
+
</ins><span class="cx">                 $temp[$step['position']] = array( 'name' =&gt; $step['name'], 'slug' =&gt; $slug );
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         /* Sort the steps by their position key */
</span><span class="cx">         ksort($temp);
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_incajaxphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/ajax.php (2470 => 2471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-27 14:11:11 UTC (rev 2470)
+++ trunk/bp-themes/bp-default/_inc/ajax.php        2010-01-28 18:01:42 UTC (rev 2471)
</span><span class="lines">@@ -155,8 +155,8 @@
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( empty( $_POST['id'] ) || !is_numeric( $_POST['id'] ) || !bp_activity_delete_by_activity_id( $_POST['id'] ) ) {
-                echo '-1&lt;div class=&quot;error&quot;&gt;&lt;p&gt;' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '&lt;/p&gt;&lt;/div&gt;';
</del><ins>+        if ( empty( $_POST['id'] ) || !is_numeric( $_POST['id'] ) || !bp_activity_delete( array( 'id' =&gt; $_POST['id'] ) ) ) {
+                echo '-1&lt;div id=&quot;message&quot; class=&quot;error&quot;&gt;&lt;p&gt;' . __( 'There was a problem when deleting. Please try again.', 'buddypress' ) . '&lt;/p&gt;&lt;/div&gt;';
</ins><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultactivitypostformphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/activity/post-form.php (2470 => 2471)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/activity/post-form.php        2010-01-27 14:11:11 UTC (rev 2470)
+++ trunk/bp-themes/bp-default/activity/post-form.php        2010-01-28 18:01:42 UTC (rev 2471)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;h5&gt;
</span><del>-                &lt;?php if ( bp_is_group_home() ) : ?&gt;
</del><ins>+                &lt;?php if ( bp_is_group() ) : ?&gt;
</ins><span class="cx">                         &lt;?php printf( __( &quot;What's new in %s, %s?&quot;, 'buddypress' ), bp_get_group_name(), bp_dtheme_firstname() ) ?&gt;
</span><span class="cx">                 &lt;?php else : ?&gt;
</span><span class="cx">                         &lt;?php printf( __( &quot;What's new %s?&quot;, 'buddypress' ), bp_dtheme_firstname() ) ?&gt;
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx">                                 &lt;input type=&quot;submit&quot; name=&quot;aw-whats-new-submit&quot; id=&quot;aw-whats-new-submit&quot; value=&quot;&lt;?php _e( 'Post Update', 'buddypress' ) ?&gt;&quot; /&gt;
</span><span class="cx">                         &lt;/div&gt;
</span><span class="cx"> 
</span><del>-                        &lt;?php if ( !bp_is_my_profile() &amp;&amp; !bp_is_group_home() ) : ?&gt;
</del><ins>+                        &lt;?php if ( !bp_is_my_profile() &amp;&amp; !bp_is_group() ) : ?&gt;
</ins><span class="cx">                                 &lt;div id=&quot;whats-new-post-in-box&quot;&gt;
</span><span class="cx">                                         &lt;?php _e( 'Post in', 'buddypress' ) ?&gt;:
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>