<!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" />
<title>[BuddyPress][6064] trunk/bp-groups/bp-groups-forums.php: Removes global $bp references for native BP functions in bp-group-forums.php.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/6064">6064</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2012-06-08 21:27:01 +0000 (Fri, 08 Jun 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Removes global $bp references for native BP functions in bp-group-forums.php. Adds PHPDoc throughout bp-group-forums.php. Fixes <a href="http://buddypress.trac.wordpress.org/ticket/4239">#4239</a>, props r-a-y</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpgroupsbpgroupsforumsphp">trunk/bp-groups/bp-groups-forums.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpgroupsbpgroupsforumsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-forums.php (6063 => 6064)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-forums.php        2012-06-08 20:36:15 UTC (rev 6063)
+++ trunk/bp-groups/bp-groups-forums.php        2012-06-08 21:27:01 UTC (rev 6064)
</span><span class="lines">@@ -14,14 +14,25 @@
</span><span class="cx"> // Exit if accessed directly
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><ins>+/**
+ * Creates a new forum inside a specific BuddyPress group.
+ *
+ * Uses the bundled version of bbPress packaged with BuddyPress.
+ *
+ * @param int $group_id The group ID that the new forum should be attached to
+ * @param string $group_name The group name
+ * @param string $group_description The group description
+ *
+ * @since 1.0
+ */
</ins><span class="cx"> function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="cx">         if ( empty( $group_id ) )
</span><del>-                $group_id = $bp-&gt;groups-&gt;current_group-&gt;id;
</del><ins>+                $group_id = bp_get_current_group_id();
</ins><span class="cx"> 
</span><span class="cx">         if ( empty( $group_name ) )
</span><del>-                $group_name = $bp-&gt;groups-&gt;current_group-&gt;name;
</del><ins>+                $group_name = bp_get_current_group_name();
</ins><span class="cx"> 
</span><span class="cx">         if ( empty( $group_desc ) )
</span><span class="cx">                 $group_desc = $bp-&gt;groups-&gt;current_group-&gt;description;
</span><span class="lines">@@ -40,6 +51,8 @@
</span><span class="cx">  * @subpackage Groups
</span><span class="cx">  *
</span><span class="cx">  * @param int $group_id Group id, passed from groups_details_updated
</span><ins>+ *
+ * @since 1.1
</ins><span class="cx">  */
</span><span class="cx"> function groups_update_group_forum( $group_id ) {
</span><span class="cx"> 
</span><span class="lines">@@ -66,9 +79,19 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'groups_details_updated', 'groups_update_group_forum' );
</span><span class="cx"> 
</span><ins>+/**
+ * Creates a new group forum post.
+ *
+ * Uses the bundled version of bbPress packaged with BuddyPress.
+ *
+ * @param string $post_text The text for the forum post
+ * @param int $topic_id The topic ID used so we can identify where the new forum post should reside
+ * @param mixed $page The page number where the new forum post should reside. Defaults to boolean false.
+ * @return mixed The new forum post ID on success. Boolean false on failure.
+ *
+ * @since 1.0
+ */
</ins><span class="cx"> function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
</span><del>-        global $bp;
-
</del><span class="cx">         if ( empty( $post_text ) )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="lines">@@ -78,24 +101,24 @@
</span><span class="cx">         if ( $post_id = bp_forums_insert_post( array( 'post_text' =&gt; $post_text, 'topic_id' =&gt; $topic_id ) ) ) {
</span><span class="cx">                 $topic = bp_forums_get_topic_details( $topic_id );
</span><span class="cx"> 
</span><del>-                $activity_action = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . 'forum/topic/' . $topic-&gt;topic_slug .'/&quot;&gt;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '&quot;&gt;' . esc_attr( $bp-&gt;groups-&gt;current_group-&gt;name ) . '&lt;/a&gt;' );
</del><ins>+                $activity_action = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug .'/&quot;&gt;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . '&quot;&gt;' . esc_attr( bp_get_current_group_name() ) . '&lt;/a&gt;' );
</ins><span class="cx">                 $activity_content = bp_create_excerpt( $post_text );
</span><del>-                $primary_link = bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . 'forum/topic/' . $topic-&gt;topic_slug . '/';
</del><ins>+                $primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug . '/';
</ins><span class="cx"> 
</span><span class="cx">                 if ( $page )
</span><span class="cx">                         $primary_link .= &quot;?topic_page=&quot; . $page;
</span><span class="cx"> 
</span><span class="cx">                 // Record this in activity streams
</span><span class="cx">                 groups_record_activity( array(
</span><del>-                        'action'            =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_action',       array( $activity_action,  $post_id, $post_text, &amp;$topic ) ),
-                        'content'           =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_content',      array( $activity_content, $post_id, $post_text, &amp;$topic ) ),
</del><ins>+                        'action'            =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_id, $post_text, &amp;$topic ) ),
+                        'content'           =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &amp;$topic ) ),
</ins><span class="cx">                         'primary_link'      =&gt; apply_filters( 'groups_activity_new_forum_post_primary_link', &quot;{$primary_link}#post-{$post_id}&quot; ),
</span><span class="cx">                         'type'              =&gt; 'new_forum_post',
</span><del>-                        'item_id'           =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
</del><ins>+                        'item_id'           =&gt; bp_get_current_group_id(),
</ins><span class="cx">                         'secondary_item_id' =&gt; $post_id
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><del>-                do_action( 'groups_new_forum_topic_post', $bp-&gt;groups-&gt;current_group-&gt;id, $post_id );
</del><ins>+                do_action( 'groups_new_forum_topic_post', bp_get_current_group_id(), $post_id );
</ins><span class="cx"> 
</span><span class="cx">                 return $post_id;
</span><span class="cx">         }
</span><span class="lines">@@ -103,9 +126,20 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Creates a new group forum topic.
+ *
+ * Uses the bundled version of bbPress packaged with BuddyPress.
+ *
+ * @param string $topic_title The title for the forum topic
+ * @param string $topic_text The text for the forum topic
+ * @param string $topic_tags A comma-delimited string of topic tags
+ * @param int $forum_id The forum ID this forum topic resides in
+ * @return mixed The new topic object on success. Boolean false on failure.
+ *
+ * @since 1.0
+ */
</ins><span class="cx"> function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) {
</span><del>-        global $bp;
-
</del><span class="cx">         if ( empty( $topic_title ) || empty( $topic_text ) )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="lines">@@ -117,20 +151,20 @@
</span><span class="cx">         if ( $topic_id = bp_forums_new_topic( array( 'topic_title' =&gt; $topic_title, 'topic_text' =&gt; $topic_text, 'topic_tags' =&gt; $topic_tags, 'forum_id' =&gt; $forum_id ) ) ) {
</span><span class="cx">                 $topic = bp_forums_get_topic_details( $topic_id );
</span><span class="cx"> 
</span><del>-                $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . 'forum/topic/' . $topic-&gt;topic_slug .'/&quot;&gt;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '&quot;&gt;' . esc_attr( $bp-&gt;groups-&gt;current_group-&gt;name ) . '&lt;/a&gt;' );
</del><ins>+                $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( bp_loggedin_user_id() ), '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug .'/&quot;&gt;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . '&quot;&gt;' . esc_attr( bp_get_current_group_name() ) . '&lt;/a&gt;' );
</ins><span class="cx">                 $activity_content = bp_create_excerpt( $topic_text );
</span><span class="cx"> 
</span><span class="cx">                 // Record this in activity streams
</span><span class="cx">                 groups_record_activity( array(
</span><span class="cx">                         'action'            =&gt; apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &amp;$topic ) ),
</span><span class="cx">                         'content'           =&gt; apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &amp;$topic ) ),
</span><del>-                        'primary_link'      =&gt; apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . 'forum/topic/' . $topic-&gt;topic_slug . '/' ),
</del><ins>+                        'primary_link'      =&gt; apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug . '/' ),
</ins><span class="cx">                         'type'              =&gt; 'new_forum_topic',
</span><del>-                        'item_id'           =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
</del><ins>+                        'item_id'           =&gt; bp_get_current_group_id(),
</ins><span class="cx">                         'secondary_item_id' =&gt; $topic-&gt;topic_id
</span><span class="cx">                 ) );
</span><span class="cx"> 
</span><del>-          do_action_ref_array( 'groups_new_forum_topic', array( $bp-&gt;groups-&gt;current_group-&gt;id, &amp;$topic ) );
</del><ins>+                do_action_ref_array( 'groups_new_forum_topic', array( bp_get_current_group_id(), &amp;$topic ) );
</ins><span class="cx"> 
</span><span class="cx">                 return $topic;
</span><span class="cx">         }
</span><span class="lines">@@ -138,6 +172,19 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Updates an existing group forum topic.
+ *
+ * Uses the bundled version of bbPress packaged with BuddyPress.
+ *
+ * @param int $topic_id The topic ID of the existing forum topic
+ * @param string $topic_title The title for the forum topic
+ * @param string $topic_text The text for the forum topic
+ * @param mixed $topic_tags A comma-delimited string of topic tags. Defaults to boolean false.
+ * @return mixed The topic object on success. Boolean false on failure.
+ *
+ * @since 1.1
+ */
</ins><span class="cx"> function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text, $topic_tags = false ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -149,14 +196,14 @@
</span><span class="cx">                 // Get the corresponding activity item
</span><span class="cx">                 if ( bp_is_active( 'activity' ) ) {
</span><span class="cx">                         $id = bp_activity_get_activity_id( array(
</span><del>-                                        'item_id'           =&gt; $bp-&gt;groups-&gt;current_group-&gt;id,
</del><ins>+                                        'item_id'           =&gt; bp_get_current_group_id(),
</ins><span class="cx">                                         'secondary_item_id' =&gt; $topic_id,
</span><span class="cx">                                         'component'         =&gt; $bp-&gt;groups-&gt;id,
</span><span class="cx">                                         'type'              =&gt; 'new_forum_topic'
</span><span class="cx">                         ) );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $topic-&gt;topic_poster ), '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . 'forum/topic/' . $topic-&gt;topic_slug .'/&quot;&gt;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '&quot;&gt;' . esc_attr( $bp-&gt;groups-&gt;current_group-&gt;name ) . '&lt;/a&gt;' );
</del><ins>+                $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $topic-&gt;topic_poster ), '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug .'/&quot;&gt;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . '&quot;&gt;' . esc_attr( bp_get_current_group_name() ) . '&lt;/a&gt;' );
</ins><span class="cx">                 $activity_content = bp_create_excerpt( $topic_text );
</span><span class="cx"> 
</span><span class="cx">                 // Record this in activity streams
</span><span class="lines">@@ -164,9 +211,9 @@
</span><span class="cx">                         'id'                =&gt; $id,
</span><span class="cx">                         'action'            =&gt; apply_filters_ref_array( 'groups_activity_new_forum_topic_action',  array( $activity_action,  $topic_text, &amp;$topic ) ),
</span><span class="cx">                         'content'           =&gt; apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &amp;$topic ) ),
</span><del>-                        'primary_link'      =&gt; apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . 'forum/topic/' . $topic-&gt;topic_slug . '/' ),
</del><ins>+                        'primary_link'      =&gt; apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug . '/' ),
</ins><span class="cx">                         'type'              =&gt; 'new_forum_topic',
</span><del>-                        'item_id'           =&gt; (int) $bp-&gt;groups-&gt;current_group-&gt;id,
</del><ins>+                        'item_id'           =&gt; (int) bp_get_current_group_id(),
</ins><span class="cx">                         'user_id'           =&gt; (int) $topic-&gt;topic_poster,
</span><span class="cx">                         'secondary_item_id' =&gt; $topic-&gt;topic_id,
</span><span class="cx">                         'recorded_time '    =&gt; $topic-&gt;topic_time
</span><span class="lines">@@ -180,6 +227,19 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Updates an existing group forum post.
+ *
+ * Uses the bundled version of bbPress packaged with BuddyPress.
+ *
+ * @param int $post_id The post ID of the existing forum post
+ * @param string $post_text The text for the forum post
+ * @param int $topic_id The topic ID of the existing forum topic
+ * @param mixed $page The page number where the new forum post should reside. Defaults to boolean false.
+ * @return mixed The forum post ID on success. Boolean false on failure.
+ *
+ * @since 1.1
+ */
</ins><span class="cx"> function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -190,25 +250,32 @@
</span><span class="cx">         if ( $post_id = bp_forums_insert_post( array( 'post_id' =&gt; $post_id, 'post_text' =&gt; $post_text, 'post_time' =&gt; $post-&gt;post_time, 'topic_id' =&gt; $topic_id, 'poster_id' =&gt; $post-&gt;poster_id ) ) ) {
</span><span class="cx">                 $topic = bp_forums_get_topic_details( $topic_id );
</span><span class="cx"> 
</span><del>-                $activity_action = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$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;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '&quot;&gt;' . esc_attr( $bp-&gt;groups-&gt;current_group-&gt;name ) . '&lt;/a&gt;' );
</del><ins>+                $activity_action = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $post-&gt;poster_id ), '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug .'&quot;&gt;' . esc_attr( $topic-&gt;topic_title ) . '&lt;/a&gt;', '&lt;a href=&quot;' . bp_get_group_permalink( groups_get_current_group() ) . '&quot;&gt;' . esc_attr( bp_get_current_group_name() ) . '&lt;/a&gt;' );
</ins><span class="cx">                 $activity_content = bp_create_excerpt( $post_text );
</span><del>-                $primary_link = bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . 'forum/topic/' . $topic-&gt;topic_slug . '/';
</del><ins>+                $primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic-&gt;topic_slug . '/';
</ins><span class="cx"> 
</span><span class="cx">                 if ( $page )
</span><span class="cx">                         $primary_link .= &quot;?topic_page=&quot; . $page;
</span><span class="cx"> 
</span><del>-                // Fetch an existing entry and update if one exists.
-                if ( bp_is_active( 'activity' ) )
-                        $id = bp_activity_get_activity_id( array( 'user_id' =&gt; $post-&gt;poster_id, 'component' =&gt; $bp-&gt;groups-&gt;id, 'type' =&gt; 'new_forum_post', 'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id, 'secondary_item_id' =&gt; $post_id ) );
</del><ins>+                // Get the corresponding activity item
+                if ( bp_is_active( 'activity' ) ) {
+                        $id = bp_activity_get_activity_id( array(
+                                'user_id'           =&gt; $post-&gt;poster_id,
+                                'component'         =&gt; $bp-&gt;groups-&gt;id,
+                                'type'              =&gt; 'new_forum_post',
+                                'item_id'           =&gt; bp_get_current_group_id(),
+                                'secondary_item_id' =&gt; $post_id
+                         ) );
+                }
</ins><span class="cx"> 
</span><span class="cx">                 // Update the entry in activity streams
</span><span class="cx">                 groups_record_activity( array(
</span><span class="cx">                         'id'                =&gt; $id,
</span><del>-                        'action'            =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_text, &amp;$topic, &amp;$forum_post ) ),
-                        'content'           =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &amp;$topic, &amp;$forum_post ) ),
</del><ins>+                        'action'            =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_action',  array( $activity_action,  $post_text, &amp;$topic, &amp;$topic ) ),
+                        'content'           =&gt; apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &amp;$topic, &amp;$topic ) ),
</ins><span class="cx">                         'primary_link'      =&gt; apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . &quot;#post-&quot; . $post_id ),
</span><span class="cx">                         'type'              =&gt; 'new_forum_post',
</span><del>-                        'item_id'           =&gt; (int) $bp-&gt;groups-&gt;current_group-&gt;id,
</del><ins>+                        'item_id'           =&gt; (int) bp_get_current_group_id(),
</ins><span class="cx">                         'user_id'           =&gt; (int) $post-&gt;poster_id,
</span><span class="cx">                         'secondary_item_id' =&gt; $post_id,
</span><span class="cx">                         'recorded_time'     =&gt; $post-&gt;post_time
</span><span class="lines">@@ -223,8 +290,10 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Handles the forum topic deletion routine
</del><ins>+ * Deletes a group forum topic and also any corresponding activity items.
</ins><span class="cx">  *
</span><ins>+ * Uses the bundled version of bbPress packaged with BuddyPress.
+ *
</ins><span class="cx">  * @package BuddyPress
</span><span class="cx">  *
</span><span class="cx">  * @uses bp_activity_delete() to delete corresponding activity items
</span><span class="lines">@@ -232,6 +301,8 @@
</span><span class="cx">  * @uses bp_forums_delete_topic() to do the deletion itself
</span><span class="cx">  * @param int $topic_id The id of the topic to be deleted
</span><span class="cx">  * @return bool True if the delete routine went through properly
</span><ins>+ *
+ * @since 1.1
</ins><span class="cx">  */
</span><span class="cx"> function groups_delete_group_forum_topic( $topic_id ) {
</span><span class="cx">         global $bp;
</span><span class="lines">@@ -242,14 +313,24 @@
</span><span class="cx">         if ( bp_forums_delete_topic( array( 'topic_id' =&gt; $topic_id ) ) ) {
</span><span class="cx">                 do_action( 'groups_before_delete_group_forum_topic', $topic_id );
</span><span class="cx"> 
</span><del>-                // Delete the activity stream items
</del><ins>+                // Delete the corresponding activity stream items
</ins><span class="cx">                 if ( bp_is_active( 'activity' ) ) {
</span><span class="cx">                         // The activity item for the initial topic
</span><del>-                        bp_activity_delete( array( 'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id, 'secondary_item_id' =&gt; $topic_id, 'component' =&gt; $bp-&gt;groups-&gt;id, 'type' =&gt; 'new_forum_topic' ) );
</del><ins>+                        bp_activity_delete( array(
+                                'item_id'           =&gt; bp_get_current_group_id(),
+                                'secondary_item_id' =&gt; $topic_id,
+                                'component'         =&gt; $bp-&gt;groups-&gt;id,
+                                'type'              =&gt; 'new_forum_topic'
+                        ) );
</ins><span class="cx"> 
</span><span class="cx">                         // The activity item for each post
</span><span class="cx">                         foreach ( (array) $posts as $post ) {
</span><del>-                                bp_activity_delete( array( 'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id, 'secondary_item_id' =&gt; $post-&gt;post_id, 'component' =&gt; $bp-&gt;groups-&gt;id, 'type' =&gt; 'new_forum_post' ) );
</del><ins>+                                bp_activity_delete( array(
+                                        'item_id'           =&gt; bp_get_current_group_id(),
+                                        'secondary_item_id' =&gt; $post-&gt;post_id,
+                                        'component'         =&gt; $bp-&gt;groups-&gt;id,
+                                        'type'              =&gt; 'new_forum_post'
+                                ) );
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -262,14 +343,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * Delete a forum post
</del><ins>+ * Deletes a group forum post and its corresponding activity item.
</ins><span class="cx">  *
</span><ins>+ * Uses the bundled version of bbPress packaged with BuddyPress.
+ *
</ins><span class="cx">  * @package BuddyPress
</span><span class="cx">  *
</span><span class="cx">  * @param int $post_id The id of the post you want to delete
</span><span class="cx">  * @param int $topic_id Optional. The topic to which the post belongs. This value isn't used in the
</span><span class="cx">  *   function but is passed along to do_action() hooks.
</span><span class="cx">  * @return bool True on success.
</span><ins>+ *
+ * @since 1.1
</ins><span class="cx">  */
</span><span class="cx"> function groups_delete_group_forum_post( $post_id, $topic_id = false ) {
</span><span class="cx">         global $bp;
</span><span class="lines">@@ -277,9 +362,14 @@
</span><span class="cx">         if ( bp_forums_delete_post( array( 'post_id' =&gt; $post_id ) ) ) {
</span><span class="cx">                 do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
</span><span class="cx"> 
</span><del>-                // Delete the activity stream item
</del><ins>+                // Delete the corresponding activity stream item
</ins><span class="cx">                 if ( bp_is_active( 'activity' ) )
</span><del>-                        bp_activity_delete( array( 'item_id' =&gt; $bp-&gt;groups-&gt;current_group-&gt;id, 'secondary_item_id' =&gt; $post_id, 'component' =&gt; $bp-&gt;groups-&gt;id, 'type' =&gt; 'new_forum_post' ) );
</del><ins>+                        bp_activity_delete( array(
+                                'item_id'           =&gt; bp_get_current_group_id(),
+                                'secondary_item_id' =&gt; $post_id,
+                                'component'         =&gt; $bp-&gt;groups-&gt;id,
+                                'type'              =&gt; 'new_forum_post'
+                        ) );
</ins><span class="cx"> 
</span><span class="cx">                 do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
</span><span class="cx"> 
</span><span class="lines">@@ -289,6 +379,15 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Get a total count of all public topics of a given type, across groups/forums
+ *
+ * @package BuddyPress
+ * @since 1.5
+ *
+ * @param string $type Either 'newest', 'popular', 'unreplied', 'tags'.  Defaults to 'newest'.
+ * @return int The topic count
+ */
</ins><span class="cx"> function groups_total_public_forum_topic_count( $type = 'newest' ) {
</span><span class="cx">         return apply_filters( 'groups_total_public_forum_topic_count', BP_Groups_Group::get_global_forum_topic_count( $type ) );
</span><span class="cx"> }
</span><span class="lines">@@ -297,7 +396,7 @@
</span><span class="cx">  * Get a total count of all topics of a given status, across groups/forums
</span><span class="cx">  *
</span><span class="cx">  * @package BuddyPress
</span><del>- * @since BuddyPress (1.5)
</del><ins>+ * @since 1.5
</ins><span class="cx">  *
</span><span class="cx">  * @param str $status 'public', 'private', 'hidden', 'all' Which group types to count
</span><span class="cx">  * @return int The topic count
</span></span></pre>
</div>
</div>

</body>
</html>