<!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][8460] trunk/src/bp-groups/bp-groups-forums.php: Groups - deprecated forums file clean-up:</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 { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { 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/8460">8460</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2014-05-28 21:06:07 +0000 (Wed, 28 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Groups - deprecated forums file clean-up:
* Reduce indentation.
* Code formatting clean-up.
* Update phpdoc blocks where necessary.
* Whitespace clean-up.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpgroupsbpgroupsforumsphp">trunk/src/bp-groups/bp-groups-forums.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpgroupsbpgroupsforumsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/bp-groups/bp-groups-forums.php (8459 => 8460)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/bp-groups/bp-groups-forums.php 2014-05-28 21:00:39 UTC (rev 8459)
+++ trunk/src/bp-groups/bp-groups-forums.php 2014-05-28 21:06:07 UTC (rev 8460)
</span><span class="lines">@@ -24,23 +24,28 @@
</span><span class="cx"> *
</span><span class="cx"> * @param int $group_id The group ID that the new forum should be attached to
</span><span class="cx"> * @param string $group_name The group name
</span><del>- * @param string $group_description The group description
</del><ins>+ * @param string $group_desc The group description
</ins><span class="cx"> *
</span><span class="cx"> * @since BuddyPress (1.0)
</span><span class="cx"> */
</span><span class="cx"> function groups_new_group_forum( $group_id = 0, $group_name = '', $group_desc = '' ) {
</span><del>- global $bp;
</del><span class="cx">
</span><del>- if ( empty( $group_id ) )
</del><ins>+ if ( empty( $group_id ) ) {
</ins><span class="cx"> $group_id = bp_get_current_group_id();
</span><ins>+ }
</ins><span class="cx">
</span><del>- if ( empty( $group_name ) )
</del><ins>+ if ( empty( $group_name ) ) {
</ins><span class="cx"> $group_name = bp_get_current_group_name();
</span><ins>+ }
</ins><span class="cx">
</span><del>- if ( empty( $group_desc ) )
- $group_desc = $bp->groups->current_group->description;
</del><ins>+ if ( empty( $group_desc ) ) {
+ $group_desc = bp_get_current_group_description();
+ }
</ins><span class="cx">
</span><del>- $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc' => $group_desc ) );
</del><ins>+ $forum_id = bp_forums_new_forum( array(
+ 'forum_name' => $group_name,
+ 'forum_desc' => $group_desc
+ ) );
</ins><span class="cx">
</span><span class="cx"> groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
</span><span class="cx">
</span><span class="lines">@@ -68,17 +73,16 @@
</span><span class="cx"> * 3. The built-in bbPress forums are not correctly installed (usually means they've been
</span><span class="cx"> * uninstalled)
</span><span class="cx"> */
</span><del>- if ( empty( $group->enable_forum ) || !bp_is_active( 'forums' ) || ( function_exists( 'bp_forums_is_installed_correctly' ) && !bp_forums_is_installed_correctly() ) )
</del><ins>+ if ( empty( $group->enable_forum ) || !bp_is_active( 'forums' ) || ( function_exists( 'bp_forums_is_installed_correctly' ) && !bp_forums_is_installed_correctly() ) ) {
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><del>- $args = array(
- 'forum_id' => groups_get_groupmeta( $group_id, 'forum_id' ),
- 'forum_name' => $group->name,
- 'forum_desc' => $group->description,
- 'forum_slug' => $group->slug
- );
-
- bp_forums_update_forum( apply_filters( 'groups_update_group_forum', $args ) );
</del><ins>+ bp_forums_update_forum( apply_filters( 'groups_update_group_forum', array(
+ 'forum_id' => groups_get_groupmeta( $group_id, 'forum_id' ),
+ 'forum_name' => $group->name,
+ 'forum_desc' => $group->description,
+ 'forum_slug' => $group->slug
+ ) ) );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'groups_details_updated', 'groups_update_group_forum' );
</span><span class="cx">
</span><span class="lines">@@ -95,38 +99,43 @@
</span><span class="cx"> * @since BuddyPress (1.0)
</span><span class="cx"> */
</span><span class="cx"> function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
</span><del>- if ( empty( $post_text ) )
</del><ins>+ if ( empty( $post_text ) ) {
</ins><span class="cx"> return false;
</span><ins>+ }
</ins><span class="cx">
</span><del>- $post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
- $topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
</del><ins>+ $post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
+ $topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
+ $post_id = bp_forums_insert_post( array(
+ 'post_text' => $post_text,
+ 'topic_id' => $topic_id
+ ) );
</ins><span class="cx">
</span><del>- if ( $post_id = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
- $topic = bp_forums_get_topic_details( $topic_id );
</del><ins>+ if ( empty( $post_id ) ) {
+ return false;
+ }
</ins><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() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
- $activity_content = bp_create_excerpt( $post_text );
- $primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
</del><ins>+ $topic = bp_forums_get_topic_details( $topic_id );
+ $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() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
+ $activity_content = bp_create_excerpt( $post_text );
+ $primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
</ins><span class="cx">
</span><del>- if ( $page )
- $primary_link .= "?topic_page=" . $page;
</del><ins>+ if ( !empty( $page ) ) {
+ $primary_link .= "?topic_page=" . $page;
+ }
</ins><span class="cx">
</span><del>- // Record this in activity streams
- groups_record_activity( array(
- 'action' => apply_filters_ref_array( 'groups_activity_new_forum_post_action', array( $activity_action, $post_id, $post_text, &$topic ) ),
- 'content' => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &$topic ) ),
- 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
- 'type' => 'new_forum_post',
- 'item_id' => bp_get_current_group_id(),
- 'secondary_item_id' => $post_id
- ) );
</del><ins>+ // Record this in activity streams
+ groups_record_activity( array(
+ 'action' => apply_filters_ref_array( 'groups_activity_new_forum_post_action', array( $activity_action, $post_id, $post_text, &$topic ) ),
+ 'content' => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_id, $post_text, &$topic ) ),
+ 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', "{$primary_link}#post-{$post_id}" ),
+ 'type' => 'new_forum_post',
+ 'item_id' => bp_get_current_group_id(),
+ 'secondary_item_id' => $post_id
+ ) );
</ins><span class="cx">
</span><del>- do_action( 'groups_new_forum_topic_post', bp_get_current_group_id(), $post_id );
</del><ins>+ do_action( 'groups_new_forum_topic_post', bp_get_current_group_id(), $post_id );
</ins><span class="cx">
</span><del>- return $post_id;
- }
-
- return false;
</del><ins>+ return $post_id;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -146,33 +155,38 @@
</span><span class="cx"> if ( empty( $topic_title ) || empty( $topic_text ) )
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- $topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
- $topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
- $topic_tags = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
- $forum_id = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
</del><ins>+ $topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
+ $topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
+ $topic_tags = apply_filters( 'group_forum_topic_tags_before_save', $topic_tags );
+ $forum_id = apply_filters( 'group_forum_topic_forum_id_before_save', $forum_id );
+ $topic_id = bp_forums_new_topic( array(
+ 'topic_title' => $topic_title,
+ 'topic_text' => $topic_text,
+ 'topic_tags' => $topic_tags,
+ 'forum_id' => $forum_id
+ ) );
</ins><span class="cx">
</span><del>- if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
- $topic = bp_forums_get_topic_details( $topic_id );
</del><ins>+ if ( empty( $topic_id ) ) {
+ return false;
+ }
</ins><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() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
- $activity_content = bp_create_excerpt( $topic_text );
</del><ins>+ $topic = bp_forums_get_topic_details( $topic_id );
+ $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() ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
+ $activity_content = bp_create_excerpt( $topic_text );
</ins><span class="cx">
</span><del>- // Record this in activity streams
- groups_record_activity( array(
- 'action' => apply_filters_ref_array( 'groups_activity_new_forum_topic_action', array( $activity_action, $topic_text, &$topic ) ),
- 'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
- 'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
- 'type' => 'new_forum_topic',
- 'item_id' => bp_get_current_group_id(),
- 'secondary_item_id' => $topic->topic_id
- ) );
</del><ins>+ // Record this in activity streams
+ groups_record_activity( array(
+ 'action' => apply_filters_ref_array( 'groups_activity_new_forum_topic_action', array( $activity_action, $topic_text, &$topic ) ),
+ 'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
+ 'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
+ 'type' => 'new_forum_topic',
+ 'item_id' => bp_get_current_group_id(),
+ 'secondary_item_id' => $topic->topic_id
+ ) );
</ins><span class="cx">
</span><del>- do_action_ref_array( 'groups_new_forum_topic', array( bp_get_current_group_id(), &$topic ) );
</del><ins>+ do_action_ref_array( 'groups_new_forum_topic', array( bp_get_current_group_id(), &$topic ) );
</ins><span class="cx">
</span><del>- return $topic;
- }
-
- return false;
</del><ins>+ return $topic;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -189,45 +203,50 @@
</span><span class="cx"> * @since BuddyPress (1.1)
</span><span class="cx"> */
</span><span class="cx"> function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text, $topic_tags = false ) {
</span><del>- global $bp;
</del><ins>+ $bp = buddypress();
</ins><span class="cx">
</span><span class="cx"> $topic_title = apply_filters( 'group_forum_topic_title_before_save', $topic_title );
</span><span class="cx"> $topic_text = apply_filters( 'group_forum_topic_text_before_save', $topic_text );
</span><ins>+ $topic = bp_forums_update_topic( array(
+ 'topic_title' => $topic_title,
+ 'topic_text' => $topic_text,
+ 'topic_id' => $topic_id,
+ 'topic_tags' => $topic_tags
+ ) );
</ins><span class="cx">
</span><del>- if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id, 'topic_tags' => $topic_tags ) ) ) {
</del><ins>+ if ( empty( $topic ) ) {
+ return false;
+ }
</ins><span class="cx">
</span><del>- // Get the corresponding activity item
- if ( bp_is_active( 'activity' ) ) {
- $id = bp_activity_get_activity_id( array(
- 'item_id' => bp_get_current_group_id(),
- 'secondary_item_id' => $topic_id,
- 'component' => $bp->groups->id,
- 'type' => 'new_forum_topic'
- ) );
- }
</del><ins>+ // Get the corresponding activity item
+ if ( bp_is_active( 'activity' ) ) {
+ $id = bp_activity_get_activity_id( array(
+ 'item_id' => bp_get_current_group_id(),
+ 'secondary_item_id' => $topic_id,
+ 'component' => $bp->groups->id,
+ 'type' => 'new_forum_topic'
+ ) );
+ }
</ins><span class="cx">
</span><del>- $activity_action = sprintf( __( '%1$s edited the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
- $activity_content = bp_create_excerpt( $topic_text );
</del><ins>+ $activity_action = sprintf( __( '%1$s edited the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
+ $activity_content = bp_create_excerpt( $topic_text );
</ins><span class="cx">
</span><del>- // Record this in activity streams
- groups_record_activity( array(
- 'id' => $id,
- 'action' => apply_filters_ref_array( 'groups_activity_new_forum_topic_action', array( $activity_action, $topic_text, &$topic ) ),
- 'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
- 'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
- 'type' => 'new_forum_topic',
- 'item_id' => (int) bp_get_current_group_id(),
- 'user_id' => (int) $topic->topic_poster,
- 'secondary_item_id' => $topic->topic_id,
- 'recorded_time ' => $topic->topic_time
- ) );
</del><ins>+ // Record this in activity streams
+ groups_record_activity( array(
+ 'id' => $id,
+ 'action' => apply_filters_ref_array( 'groups_activity_new_forum_topic_action', array( $activity_action, $topic_text, &$topic ) ),
+ 'content' => apply_filters_ref_array( 'groups_activity_new_forum_topic_content', array( $activity_content, $topic_text, &$topic ) ),
+ 'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/' ),
+ 'type' => 'new_forum_topic',
+ 'item_id' => (int) bp_get_current_group_id(),
+ 'user_id' => (int) $topic->topic_poster,
+ 'secondary_item_id' => $topic->topic_id,
+ 'recorded_time ' => $topic->topic_time
+ ) );
</ins><span class="cx">
</span><del>- do_action_ref_array( 'groups_update_group_forum_topic', array( &$topic ) );
</del><ins>+ do_action_ref_array( 'groups_update_group_forum_topic', array( &$topic ) );
</ins><span class="cx">
</span><del>- return $topic;
- }
-
- return false;
</del><ins>+ return $topic;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -244,52 +263,59 @@
</span><span class="cx"> * @since BuddyPress (1.1)
</span><span class="cx"> */
</span><span class="cx"> function groups_update_group_forum_post( $post_id, $post_text, $topic_id, $page = false ) {
</span><del>- global $bp;
</del><ins>+ $bp = buddypress();
</ins><span class="cx">
</span><span class="cx"> $post_text = apply_filters( 'group_forum_post_text_before_save', $post_text );
</span><span class="cx"> $topic_id = apply_filters( 'group_forum_post_topic_id_before_save', $topic_id );
</span><span class="cx"> $post = bp_forums_get_post( $post_id );
</span><ins>+ $post_id = bp_forums_insert_post( array(
+ 'post_id' => $post_id,
+ 'post_text' => $post_text,
+ 'post_time' => $post->post_time,
+ 'topic_id' => $topic_id,
+ 'poster_id' => $post->poster_id
+ ) );
</ins><span class="cx">
</span><del>- if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
- $topic = bp_forums_get_topic_details( $topic_id );
</del><ins>+ if ( empty( $post_id ) ) {
+ return false;
+ }
</ins><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->poster_id ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
- $activity_content = bp_create_excerpt( $post_text );
- $primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
</del><ins>+ $topic = bp_forums_get_topic_details( $topic_id );
+ $activity_action = sprintf( __( '%1$s replied to the forum topic %2$s in the group %3$s', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( groups_get_current_group() ) . '">' . esc_attr( bp_get_current_group_name() ) . '</a>' );
+ $activity_content = bp_create_excerpt( $post_text );
+ $primary_link = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic->topic_slug . '/';
</ins><span class="cx">
</span><del>- if ( $page )
- $primary_link .= "?topic_page=" . $page;
</del><ins>+ if ( !empty( $page ) ) {
+ $primary_link .= "?topic_page=" . $page;
+ }
</ins><span class="cx">
</span><del>- // Get the corresponding activity item
- if ( bp_is_active( 'activity' ) ) {
- $id = bp_activity_get_activity_id( array(
- 'user_id' => $post->poster_id,
- 'component' => $bp->groups->id,
- 'type' => 'new_forum_post',
- 'item_id' => bp_get_current_group_id(),
- 'secondary_item_id' => $post_id
- ) );
- }
-
- // Update the entry in activity streams
- groups_record_activity( array(
- 'id' => $id,
- 'action' => apply_filters_ref_array( 'groups_activity_new_forum_post_action', array( $activity_action, $post_text, &$topic, &$topic ) ),
- 'content' => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &$topic, &$topic ) ),
- 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
</del><ins>+ // Get the corresponding activity item
+ if ( bp_is_active( 'activity' ) ) {
+ $id = bp_activity_get_activity_id( array(
+ 'user_id' => $post->poster_id,
+ 'component' => $bp->groups->id,
</ins><span class="cx"> 'type' => 'new_forum_post',
</span><del>- 'item_id' => (int) bp_get_current_group_id(),
- 'user_id' => (int) $post->poster_id,
- 'secondary_item_id' => $post_id,
- 'recorded_time' => $post->post_time
- ) );
</del><ins>+ 'item_id' => bp_get_current_group_id(),
+ 'secondary_item_id' => $post_id
+ ) );
+ }
</ins><span class="cx">
</span><del>- do_action_ref_array( 'groups_update_group_forum_post', array( $post, &$topic ) );
</del><ins>+ // Update the entry in activity streams
+ groups_record_activity( array(
+ 'id' => $id,
+ 'action' => apply_filters_ref_array( 'groups_activity_new_forum_post_action', array( $activity_action, $post_text, &$topic, &$topic ) ),
+ 'content' => apply_filters_ref_array( 'groups_activity_new_forum_post_content', array( $activity_content, $post_text, &$topic, &$topic ) ),
+ 'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', $primary_link . "#post-" . $post_id ),
+ 'type' => 'new_forum_post',
+ 'item_id' => (int) bp_get_current_group_id(),
+ 'user_id' => (int) $post->poster_id,
+ 'secondary_item_id' => $post_id,
+ 'recorded_time' => $post->post_time
+ ) );
</ins><span class="cx">
</span><del>- return $post_id;
- }
</del><ins>+ do_action_ref_array( 'groups_update_group_forum_post', array( $post, &$topic ) );
</ins><span class="cx">
</span><del>- return false;
</del><ins>+ return $post_id;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -308,16 +334,18 @@
</span><span class="cx"> * @since BuddyPress (1.1)
</span><span class="cx"> */
</span><span class="cx"> function groups_delete_group_forum_topic( $topic_id ) {
</span><del>- global $bp;
</del><ins>+ $bp = buddypress();
</ins><span class="cx">
</span><span class="cx"> // Before deleting the thread, get the post ids so that their activity items can be deleted
</span><del>- $posts = bp_forums_get_topic_posts( array( 'topic_id' => $topic_id, 'per_page' => -1 ) );
</del><ins>+ $posts = bp_forums_get_topic_posts( array( 'topic_id' => $topic_id, 'per_page' => -1 ) );
+ $action = bp_forums_delete_topic( array( 'topic_id' => $topic_id ) );
</ins><span class="cx">
</span><del>- if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {
</del><ins>+ if ( !empty( $action ) ) {
</ins><span class="cx"> do_action( 'groups_before_delete_group_forum_topic', $topic_id );
</span><span class="cx">
</span><span class="cx"> // Delete the corresponding activity stream items
</span><span class="cx"> if ( bp_is_active( 'activity' ) ) {
</span><ins>+
</ins><span class="cx"> // The activity item for the initial topic
</span><span class="cx"> bp_activity_delete( array(
</span><span class="cx"> 'item_id' => bp_get_current_group_id(),
</span><span class="lines">@@ -338,11 +366,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> do_action( 'groups_delete_group_forum_topic', $topic_id );
</span><del>-
- return true;
</del><span class="cx"> }
</span><span class="cx">
</span><del>- return false;
</del><ins>+ return (bool) $action;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -353,33 +379,34 @@
</span><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><del>- * @param int $topic_id Optional. The topic to which the post belongs. This value isn't used in the
- * function but is passed along to do_action() hooks.
</del><ins>+ * @param int $topic_id Optional. The topic to which the post belongs. This
+ * value isn't used in the function but is passed along to
+ * do_action() hooks.
</ins><span class="cx"> * @return bool True on success.
</span><span class="cx"> *
</span><span class="cx"> * @since BuddyPress (1.1)
</span><span class="cx"> */
</span><span class="cx"> function groups_delete_group_forum_post( $post_id, $topic_id = false ) {
</span><del>- global $bp;
</del><span class="cx">
</span><del>- if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) {
</del><ins>+ $action = bp_forums_delete_post( array( 'post_id' => $post_id ) );
+
+ if ( !empty( $action ) ) {
</ins><span class="cx"> do_action( 'groups_before_delete_group_forum_post', $post_id, $topic_id );
</span><span class="cx">
</span><span class="cx"> // Delete the corresponding activity stream item
</span><del>- if ( bp_is_active( 'activity' ) )
</del><ins>+ if ( bp_is_active( 'activity' ) ) {
</ins><span class="cx"> bp_activity_delete( array(
</span><span class="cx"> 'item_id' => bp_get_current_group_id(),
</span><span class="cx"> 'secondary_item_id' => $post_id,
</span><del>- 'component' => $bp->groups->id,
</del><ins>+ 'component' => buddypress()->groups->id,
</ins><span class="cx"> 'type' => 'new_forum_post'
</span><span class="cx"> ) );
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
</span><del>-
- return true;
</del><span class="cx"> }
</span><span class="cx">
</span><del>- return false;
</del><ins>+ return (bool) $action;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>
</body>
</html>