function bbpvotes_buddypress_voted_activity($post_id, $user_id, $vote)
{
    //check vote value
    if (is_bool($vote) === false) {
        return new WP_Error('vote_is_not_bool', __('Vote is not a boolean', 'bbpvotes'));
    }
    $voteplus = $vote === true;
    $voteminus = $vote === false;
    $post = get_post($post_id);
    $user_link = bbp_get_user_profile_link($user_id);
    //build item link
    if ($post->post_type == bbp_get_topic_post_type()) {
        $topic_id = $post->ID;
        $post_permalink = get_permalink($post->ID);
    } elseif ($post->post_type == bbp_get_reply_post_type()) {
        $topic_id = bbp_get_reply_topic_id($post->ID);
        $post_permalink = bbp_get_reply_url($post->ID);
    }
    //topic infos
    $topic = get_post($topic_id);
    $topic_author_link = bbp_get_user_profile_link($topic->post_author);
    $topic_title = $topic->post_title;
    $post_link = '<a href="' . $post_permalink . '">' . $topic_title . '</a>';
    if ($voteplus) {
        $type = 'bbpvotes_voted_up';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    } else {
        $type = 'bbpvotes_voted_down';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    }
    $args = array('action' => $action, 'component' => 'bbpress', 'type' => $type, 'item_id' => $topic->ID);
    if ($post->post_type == bbp_get_reply_post_type()) {
        $args['secondary_item_id'] = $post->ID;
    }
    /*
        if ($is_update){
       $previous_activity_id = 
       $args['id'] = $previous_activity_id;
        }
    */
    bp_activity_add($args);
}
 /**
  * @covers ::bbp_forum_last_reply_author_link
  * @covers ::bbp_get_forum_last_reply_author_link
  */
 public function test_bbp_get_forum_last_reply_author_link()
 {
     if (is_multisite()) {
         $this->markTestSkipped('Skipping URL tests in multisite for now.');
     }
     $u = $this->factory->user->create();
     $c = $this->factory->forum->create(array('forum_meta' => array('forum_type' => 'category', 'status' => 'open')));
     $f = $this->factory->forum->create(array('post_author' => $u, 'post_parent' => $c, 'forum_meta' => array('forum_id' => $c, 'forum_type' => 'forum', 'status' => 'open')));
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_author' => $u, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_parent' => $t, 'post_author' => $u, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the forums last reply author link.
     $last_reply_author_link = bbp_get_forum_last_reply_author_link($f);
     $this->assertSame(bbp_get_user_profile_link($u), $last_reply_author_link);
     // Get the categories last reply author link.
     $last_reply_author_link = bbp_get_forum_last_reply_author_link($c);
     $this->assertSame(bbp_get_user_profile_link($u), $last_reply_author_link);
 }
Esempio n. 3
0
 /**
  * Record an activity stream entry when a reply is created
  *
  * @since bbPress (r3395)
  * @param int $topic_id
  * @param int $forum_id
  * @param array $anonymous_data
  * @param int $topic_author_id
  * @uses bbp_get_reply_id()
  * @uses bbp_get_topic_id()
  * @uses bbp_get_forum_id()
  * @uses bbp_get_user_profile_link()
  * @uses bbp_get_reply_url()
  * @uses bbp_get_reply_content()
  * @uses bbp_get_topic_permalink()
  * @uses bbp_get_topic_title()
  * @uses bbp_get_forum_permalink()
  * @uses bbp_get_forum_title()
  * @uses bp_create_excerpt()
  * @uses apply_filters()
  * @return Bail early if topic is by anonywous user
  */
 public function reply_create($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author_id)
 {
     // Do not log activity of anonymous users
     if (!empty($anonymous_data)) {
         return;
     }
     // Bail if site is private
     if (!bbp_is_site_public()) {
         return;
     }
     // Validate activity data
     $user_id = $reply_author_id;
     $reply_id = bbp_get_reply_id($reply_id);
     $topic_id = bbp_get_topic_id($topic_id);
     $forum_id = bbp_get_forum_id($forum_id);
     // Bail if user is not active
     if (bbp_is_user_inactive($user_id)) {
         return;
     }
     // Bail if reply is not published
     if (!bbp_is_reply_published($reply_id)) {
         return;
     }
     // Setup links for activity stream
     $user_link = bbp_get_user_profile_link($user_id);
     // Reply
     $reply_url = bbp_get_reply_url($reply_id);
     $reply_content = get_post_field('post_content', $reply_id, 'raw');
     // Topic
     $topic_permalink = bbp_get_topic_permalink($topic_id);
     $topic_title = get_post_field('post_title', $topic_id, 'raw');
     $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
     // Forum
     $forum_permalink = bbp_get_forum_permalink($forum_id);
     $forum_title = get_post_field('post_title', $forum_id, 'raw');
     $forum_link = '<a href="' . $forum_permalink . '" title="' . $forum_title . '">' . $forum_title . '</a>';
     // Activity action & text
     $activity_text = sprintf(__('%1$s replied to the topic %2$s in the forum %3$s', 'bbpress'), $user_link, $topic_link, $forum_link);
     $activity_action = apply_filters('bbp_activity_reply_create', $activity_text, $user_id, $reply_id, $topic_id);
     $activity_content = apply_filters('bbp_activity_reply_create_excerpt', bp_create_excerpt($reply_content), $reply_content);
     // Compile the activity stream results
     $activity = array('id' => $this->get_activity_id($reply_id), 'user_id' => $user_id, 'action' => $activity_action, 'content' => $activity_content, 'primary_link' => $reply_url, 'type' => $this->reply_create, 'item_id' => $reply_id, 'secondary_item_id' => $topic_id, 'recorded_time' => get_post_time('Y-m-d H:i:s', true, $reply_id), 'hide_sitewide' => !bbp_is_forum_public($forum_id, false));
     // Record the activity
     $activity_id = $this->record_activity($activity);
     // Add the activity entry ID as a meta value to the reply
     if (!empty($activity_id)) {
         update_post_meta($reply_id, '_bbp_activity_id', $activity_id);
     }
 }
Esempio n. 4
0
/**
 * Return link to author of last reply of forum
 *
 * @since bbPress (r2625)
 *
 * @param int $forum_id Optional. Forum id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum_last_reply_author_id() To get the forum's last
 *                                             reply's author id
 * @uses bbp_get_user_profile_link() To get the reply's author's profile
 *                                    link
 * @uses apply_filters() Calls 'bbp_get_forum_last_reply_author_link'
 *                        with the author link and forum id
 * @return string Link to author of last reply of forum
 */
function bbp_get_forum_last_reply_author_link($forum_id = 0)
{
    $forum_id = bbp_get_forum_id($forum_id);
    $author_id = bbp_get_forum_last_reply_author_id($forum_id);
    $author_link = bbp_get_user_profile_link($author_id);
    return apply_filters('bbp_get_forum_last_reply_author_link', $author_link, $forum_id);
}
Esempio n. 5
0
/**
 * Return the moderators for an object
 *
 * @since 2.6.0 bbPress
 *
 * @param int   $object_id Optional. Object id
 * @param array $args     This function supports these arguments:
 *  - before: Before the tag list
 *  - sep: Tag separator
 *  - after: After the tag list
 *
 * @return string Moderator list of the object
 */
function bbp_get_moderator_list($object_id = 0, $args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('before' => '<div class="bbp-moderators"><p>' . esc_html__('Moderators:', 'bbpress') . '&nbsp;', 'sep' => ', ', 'after' => '</p></div>', 'none' => ''), 'get_moderator_list');
    // Get forum moderators
    $user_ids = bbp_get_moderator_ids($object_id);
    if (!empty($user_ids)) {
        // In admin, use nicenames
        if (is_admin()) {
            $users = bbp_get_user_nicenames_from_ids($user_ids);
            // In theme, use display names & profile links
        } else {
            foreach ($user_ids as $user_id) {
                $users[] = bbp_get_user_profile_link($user_id);
            }
        }
        $retval = $r['before'] . implode($r['sep'], $users) . $r['after'];
        // No forum moderators
    } else {
        $retval = $r['none'];
    }
    return apply_filters('bbp_get_moderator_list', $retval);
}
Esempio n. 6
0
		<div class="last-posted-topic-title">
			<a href="<?php 
echo bbp_get_forum_last_topic_permalink();
?>
"><?php 
echo bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id());
?>
</a>
		</div>
		<div class="last-posted-topic-user">av 
		<span class="bbp-author-avatar"><?php 
echo get_avatar(bbp_get_forum_last_reply_author_id(), '14');
?>
 </span>
			<?php 
echo bbp_get_user_profile_link(bbp_get_forum_last_reply_author_id());
?>
		</div>
		<div class="last-posted-topic-time">
			<?php 
echo bbp_get_forum_last_active_time();
?>
		</div>
	</li>
    
    </div>
    
		<?php 
do_action('bbp_theme_before_forum_sub_forums');
?>
Esempio n. 7
0
 /**
  * @covers ::bbp_user_profile_link
  * @covers ::bbp_get_user_profile_link
  */
 public function test_bbp_get_user_profile_link()
 {
     $display_name = $this->keymaster_userdata->display_name;
     // Pretty permalinks
     $this->set_permalink_structure('/%postname%/');
     $profile_link = '<a href="http://' . WP_TESTS_DOMAIN . '/forums/users/' . $this->keymaster_userdata->user_nicename . '/" rel="nofollow">' . $display_name . '</a>';
     $user_profile_link = bbp_get_user_profile_link($this->keymaster_id);
     // String.
     $this->assertSame($profile_link, $user_profile_link);
     // Output.
     $this->expectOutputString($profile_link);
     bbp_user_profile_link($this->keymaster_id);
     ob_clean();
     // Ugly permalinks
     $this->set_permalink_structure();
     $profile_link = '<a href="http://' . WP_TESTS_DOMAIN . '/?bbp_user='******'" rel="nofollow">' . $display_name . '</a>';
     $user_profile_link = bbp_get_user_profile_link($this->keymaster_id);
     // String.
     $this->assertSame($profile_link, $user_profile_link);
     // Output.
     $this->expectOutputString($profile_link);
     bbp_user_profile_link($this->keymaster_id);
 }
Esempio n. 8
0
/**
 * Output link to the profile page of a user
 *
 * @since bbPress (r2688)
 *
 * @param int $user_id Optional. User id
 * @uses bbp_get_user_profile_link() To get user profile link
 */
function bbp_user_profile_link($user_id = 0)
{
    echo bbp_get_user_profile_link($user_id);
}
Esempio n. 9
0
/**
 * Return the moderators of a forum
 *
 * @since 2.6.0 bbPress (r5834)
 *
 * @param int   $forum_id Optional. Forum id
 * @param array $args     This function supports these arguments:
 *  - before: Before the tag list
 *  - sep: Tag separator
 *  - after: After the tag list
 * @uses bbp_get_forum_id()  To get the forum id
 * @uses get_the_term_list() To get the moderator list
 *
 * @return string Moderator list of the forum
 */
function bbp_get_forum_mod_list($forum_id = 0, $args = array())
{
    // Bail if forum-mods are off
    if (!bbp_allow_forum_mods()) {
        return '';
    }
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('before' => '<div class="bbp-forum-mods"><p>' . esc_html__('Moderators:', 'bbpress') . '&nbsp;', 'sep' => ', ', 'after' => '</p></div>', 'none' => ''), 'get_forum_mod_list');
    // Bail if forum ID is invalid
    $forum_id = bbp_get_forum_id($forum_id);
    if (empty($forum_id)) {
        return '';
    }
    // Get forum moderators
    $moderators = bbp_get_forum_mods($forum_id);
    if (!empty($moderators)) {
        // In admin, use nicenames
        if (is_admin()) {
            // @todo link to filtering forums by moderator
            $users = wp_list_pluck($moderators, 'name');
            // In theme, use display names & profile links
        } else {
            $users = array();
            $term_ids = wp_list_pluck($moderators, 'term_id');
            foreach ($term_ids as $term_id) {
                $user_id = bbp_get_term_taxonomy_user_id($term_id);
                $users[] = bbp_get_user_profile_link($user_id);
            }
        }
        $retval = $r['before'] . implode($r['sep'], $users) . $r['after'];
        // No forum moderators
    } else {
        $retval = $r['none'];
    }
    return $retval;
}
Esempio n. 10
0
 public function epicwebs_get_last_poster_block($subforum_id = "")
 {
     if (!empty($subforum_id)) {
         // Main forum display with sub forums
         $output = "<div class='last-posted-topic-title'>";
         $output .= "<a href='" . bbp_get_forum_last_topic_permalink($subforum_id) . "'>" . bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id($subforum_id)) . "</a>";
         $output .= "</div>";
         $output .= "<div class='last-posted-topic-user'>av ";
         $author_id = bbp_get_forum_last_reply_author_id($subforum_id);
         $output .= "<span class=\"bbp-author-avatar\">" . get_avatar($author_id, '14') . "&nbsp;</span>";
         $output .= bbp_get_user_profile_link($author_id);
         $output .= "</div>";
         $output .= "<div class='last-posted-topic-time'>";
         $output .= bbp_get_forum_last_active_time($subforum_id);
         $output .= "</div>";
     } else {
         // forum category display (no sub forums list)
         $output = "<div class='last-posted-topic-title'>";
         $output .= "<a href='" . bbp_get_forum_last_topic_permalink() . "'>" . bbp_get_topic_last_reply_title(bbp_get_forum_last_active_id()) . "</a>";
         $output .= "</div>";
         $output .= "<div class='last-posted-topic-user'>av ";
         $output .= "<span class=\"bbp-author-avatar\">" . get_avatar(bbp_get_forum_last_reply_author_id(), '14') . "&nbsp;</span>";
         $output .= bbp_get_user_profile_link(bbp_get_forum_last_reply_author_id());
         $output .= "</div>";
         $output .= "<div class='last-posted-topic-time'>";
         $output .= bbp_get_forum_last_active_time();
         $output .= "</div>";
     }
     return $output;
 }
Esempio n. 11
0
function bbp_filter_forum_mod_term_link($termlink = '', $term = '', $taxonomy = '')
{
    // Bail if taxonomy is not forum mod
    if (bbp_get_forum_mod_tax_id() !== $taxonomy) {
        return $termlink;
    }
    // Bail if forum mods is not allowed
    if (!bbp_allow_forum_mods()) {
        return $termlink;
    }
    // Get user ID from taxonomy term
    $user_id = bbp_get_term_taxonomy_user_id($term->term_id, bbp_get_forum_mod_tax_id());
    if (is_admin()) {
        // Get the moderator's display name
        $display_name = get_userdata($user_id)->display_name;
        $user_link = get_edit_user_link($user_id);
        // Link or name only
        if (!empty($user_link)) {
            $retval = '<a href="' . esc_url($user_link) . '">' . esc_html($display_name) . '</a>';
            // Can't edit
        } else {
            $retval = $display_name;
        }
        // Theme side term link
    } else {
        $retval = bbp_get_user_profile_link($user_id);
    }
    return $retval;
}