public function getPostData()
 {
     $fooName = 'bbp_get_' . $this->postType . '_content';
     $content = $fooName($this->postId);
     $return = array('autor' => array('isCurrentUser' => $this->autorId == get_current_user_id(), 'url' => bp_core_get_user_domain($this->autorId), 'avatar' => bp_core_fetch_avatar(array('item_id' => $autorId, 'height' => $imgSize, 'width' => $imgSize)), 'name' => bbp_get_reply_author_display_name($this->postId)), 'type' => $this->postType, 'attachmentList' => $this->_getAttachmentList(), 'sContent' => bbp_get_reply_content($this->postId), 'id' => $this->postId, 'likes' => 0, 'sDate' => get_post_time('j F ', false, $this->postId, true) . __('at', 'qode') . get_post_time(' H:i', false, $this->postId, true), 'sContentShort' => mb_substr($content, 0, 500), 'sContent' => $content, 'like' => get_post_meta($this->postId, 'likes', true), 'isLiked' => get_post_meta($this->postId, 'like_' . $autorId, true));
     return $return;
 }
示例#2
0
/**
 * Returns a trimmed reply content string.
 * Works for replies as well as topics.
 * Must be used while inside the loop
 */
function buddyboss_global_search_reply_intro($character_limit = 50)
{
    $content = '';
    switch (get_post_type(get_the_ID())) {
        case 'topic':
            $reply_content = bbp_get_topic_content(get_the_ID());
            break;
        case 'reply':
            $reply_content = bbp_get_reply_content(get_the_ID());
            break;
        default:
            $reply_content = get_the_content();
            break;
    }
    if ($reply_content) {
        $content = wp_strip_all_tags($reply_content, true);
        $search_term = buddyboss_global_search()->search->get_search_term();
        $search_term_position = strpos($content, $search_term);
        if ($search_term_position !== false) {
            $shortened_content = '...' . substr($content, $search_term_position, $character_limit);
            //highlight search keyword
            $shortened_content = str_replace($search_term, "<strong>" . $search_term . "</strong>", $shortened_content);
        } else {
            $shortened_content = substr($content, 0, $character_limit);
        }
        if (strlen($content) > $character_limit) {
            $shortened_content .= '...';
        }
        $content = $shortened_content;
    }
    return apply_filters('buddyboss_global_search_reply_intro', $content);
}
 public static function reply_message($message, $reply_id, $topic_id, $user_id)
 {
     $reply_content = strip_tags(bbp_get_reply_content($reply_id));
     $reply_url = bbp_get_reply_url($reply_id);
     $reply_author = bbp_get_reply_author_display_name($reply_id);
     $custom_message = get_option('_bbp_reply_notice_body');
     $message = $custom_message ? $custom_message : $message;
     $message = str_replace('{author}', $reply_author, $message);
     $message = str_replace('{content}', $reply_content, $message);
     $message = str_replace('{url}', $reply_url, $message);
     return $message;
 }
示例#4
0
 /**
  * @group canonical
  * @covers ::bbp_insert_reply
  */
 public function test_bbp_insert_reply()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_title' => 'Reply To: Topic 1', 'post_content' => 'Content of reply to Topic 1', 'post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the reply.
     $reply = bbp_get_reply($r);
     remove_all_filters('bbp_get_reply_content');
     // Reply post.
     $this->assertSame('Reply To: Topic 1', bbp_get_reply_title($r));
     $this->assertSame('Content of reply to Topic 1', bbp_get_reply_content($r));
     $this->assertSame('publish', bbp_get_reply_status($r));
     $this->assertSame($t, wp_get_post_parent_id($r));
     $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?reply=' . $reply->post_name, $reply->guid);
     // Reply meta.
     $this->assertSame($f, bbp_get_reply_forum_id($r));
     $this->assertSame($t, bbp_get_reply_topic_id($r));
 }
示例#5
0
/**
 * Sends notification emails for new replies to subscribed topics
 *
 * Gets new post's ID and check if there are subscribed users to that topic, and
 * if there are, send notifications
 *
 * Note: in bbPress 2.6, we've moved away from 1 email per subscriber to 1 email
 * with everyone BCC'd. This may have negative repercussions for email services
 * that limit the number of addresses in a BCC field (often to around 500.) In
 * those cases, we recommend unhooking this function and creating your own
 * custom emailer script.
 *
 * @since 2.6.0 bbPress (r5413)
 *
 * @param int $reply_id ID of the newly made reply
 * @param int $topic_id ID of the topic of the reply
 * @param int $forum_id ID of the forum of the reply
 * @param mixed $anonymous_data Array of anonymous user data
 * @param int $reply_author ID of the topic author ID
 *
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_reply_id() To validate the reply ID
 * @uses bbp_get_topic_id() To validate the topic ID
 * @uses bbp_get_forum_id() To validate the forum ID
 * @uses bbp_get_reply() To get the reply
 * @uses bbp_is_reply_published() To make sure the reply is published
 * @uses bbp_get_topic_id() To validate the topic ID
 * @uses bbp_get_topic() To get the reply's topic
 * @uses bbp_is_topic_published() To make sure the topic is published
 * @uses bbp_get_reply_author_display_name() To get the reply author's display name
 * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id,
 *                    topic id and user id
 * @uses bbp_get_topic_subscribers() To get the topic subscribers
 * @uses apply_filters() Calls 'bbp_subscription_mail_message' with the
 *                    message, reply id, topic id and user id
 * @uses apply_filters() Calls 'bbp_subscription_mail_title' with the
 *                    topic title, reply id, topic id and user id
 * @uses apply_filters() Calls 'bbp_subscription_mail_headers'
 * @uses get_userdata() To get the user data
 * @uses wp_mail() To send the mail
 * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id,
 *                    topic id and user id
 * @return bool True on success, false on failure
 */
function bbp_notify_topic_subscribers($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0)
{
    // Bail if subscriptions are turned off
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    /** Validation ************************************************************/
    $reply_id = bbp_get_reply_id($reply_id);
    $topic_id = bbp_get_topic_id($topic_id);
    $forum_id = bbp_get_forum_id($forum_id);
    /** Topic *****************************************************************/
    // Bail if topic is not published
    if (!bbp_is_topic_published($topic_id)) {
        return false;
    }
    /** Reply *****************************************************************/
    // Bail if reply is not published
    if (!bbp_is_reply_published($reply_id)) {
        return false;
    }
    // Poster name
    $reply_author_name = bbp_get_reply_author_display_name($reply_id);
    /** Mail ******************************************************************/
    // Remove filters from reply content and topic title to prevent content
    // from being encoded with HTML entities, wrapped in paragraph tags, etc...
    remove_all_filters('bbp_get_reply_content');
    remove_all_filters('bbp_get_topic_title');
    // Strip tags from text and setup mail data
    $topic_title = strip_tags(bbp_get_topic_title($topic_id));
    $reply_content = strip_tags(bbp_get_reply_content($reply_id));
    $reply_url = bbp_get_reply_url($reply_id);
    $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    // For plugins to filter messages per reply/topic/user
    $message = sprintf(__('%1$s wrote:

%2$s

Post Link: %3$s

-----------

You are receiving this email because you subscribed to a forum topic.

Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $reply_author_name, $reply_content, $reply_url);
    $message = apply_filters('bbp_subscription_mail_message', $message, $reply_id, $topic_id);
    if (empty($message)) {
        return;
    }
    // For plugins to filter titles per reply/topic/user
    $subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id);
    if (empty($subject)) {
        return;
    }
    /** Users *****************************************************************/
    // Get the noreply@ address
    $no_reply = bbp_get_do_not_reply_address();
    // Setup "From" email address
    $from_email = apply_filters('bbp_subscription_from_email', $no_reply);
    // Setup the From header
    $headers = array('From: ' . get_bloginfo('name') . ' <' . $from_email . '>');
    // Get topic subscribers and bail if empty
    $user_ids = bbp_get_topic_subscribers($topic_id, true);
    // Dedicated filter to manipulate user ID's to send emails to
    $user_ids = apply_filters('bbp_topic_subscription_user_ids', $user_ids);
    if (empty($user_ids)) {
        return false;
    }
    // Loop through users
    foreach ((array) $user_ids as $user_id) {
        // Don't send notifications to the person who made the post
        if (!empty($reply_author) && (int) $user_id === (int) $reply_author) {
            continue;
        }
        // Get email address of subscribed user
        $headers[] = 'Bcc: ' . get_userdata($user_id)->user_email;
    }
    /** Send it ***************************************************************/
    // Custom headers
    $headers = apply_filters('bbp_subscription_mail_headers', $headers);
    $to_email = apply_filters('bbp_subscription_to_email', $no_reply);
    do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids);
    // Send notification email
    wp_mail($to_email, $subject, $message, $headers);
    do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids);
    return true;
}
示例#6
0
文件: bbPress.php 项目: rmccue/Falcon
 /**
  * Send a notification to subscribers
  *
  * @wp-filter bbp_new_reply 1
  */
 public function notify_on_reply($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0)
 {
     if ($this->handler === null) {
         return false;
     }
     global $wpdb;
     if (!bbp_is_subscriptions_active()) {
         return false;
     }
     $reply_id = bbp_get_reply_id($reply_id);
     $topic_id = bbp_get_topic_id($topic_id);
     $forum_id = bbp_get_forum_id($forum_id);
     if (!bbp_is_reply_published($reply_id)) {
         return false;
     }
     if (!bbp_is_topic_published($topic_id)) {
         return false;
     }
     $user_ids = bbp_get_topic_subscribers($topic_id, true);
     if (empty($user_ids)) {
         return false;
     }
     // Poster name
     $reply_author_name = apply_filters('bbsub_reply_author_name', bbp_get_reply_author_display_name($reply_id));
     do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids);
     // Don't send notifications to the person who made the post
     $send_to_author = Falcon::get_option('bbsub_send_to_author', false);
     if (!$send_to_author && !empty($reply_author)) {
         $user_ids = array_filter($user_ids, function ($id) use($reply_author) {
             return (int) $id !== (int) $reply_author;
         });
     }
     // Get userdata for all users
     $user_ids = array_map(function ($id) {
         return get_userdata($id);
     }, $user_ids);
     // Sanitize the HTML into text
     $content = apply_filters('bbsub_html_to_text', bbp_get_reply_content($reply_id));
     // Build email
     $text = "%1\$s\n\n";
     $text .= "---\nReply to this email directly or view it online:\n%2\$s\n\n";
     $text .= "You are receiving this email because you subscribed to it. Login and visit the topic to unsubscribe from these emails.";
     $text = sprintf($text, $content, bbp_get_reply_url($reply_id));
     $text = apply_filters('bbsub_email_message', $text, $reply_id, $topic_id, $content);
     $subject = apply_filters('bbsub_email_subject', 'Re: [' . get_option('blogname') . '] ' . bbp_get_topic_title($topic_id), $reply_id, $topic_id);
     $options = array('id' => $topic_id, 'author' => $reply_author_name);
     $this->handler->send_mail($user_ids, $subject, $text, $options);
     do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids);
     return true;
 }
 /**
  * Sends the new reply notification email to moderators on private replies
  *
  * @since 1.2
  *
  * @param $message string The email message
  * @param $reply_id int The ID of the reply
  * @param $topic_id int The ID of the reply's topic
  *
  * @return void
  */
 public function subscription_email($message, $reply_id, $topic_id)
 {
     if (!$this->is_private($reply_id)) {
         return false;
         // reply isn't private so do nothing
     }
     $topic_author = bbp_get_topic_author_id($topic_id);
     $reply_author = bbp_get_reply_author_id($reply_id);
     $reply_author_name = bbp_get_reply_author_display_name($reply_id);
     // Strip tags from text and setup mail data
     $topic_title = strip_tags(bbp_get_topic_title($topic_id));
     $reply_content = strip_tags(bbp_get_reply_content($reply_id));
     $reply_url = bbp_get_reply_url($reply_id);
     $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     $do_not_reply = '<noreply@' . ltrim(get_home_url(), '^(http|https)://') . '>';
     $subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id);
     // Array to hold BCC's
     $headers = array();
     // Setup the From header
     $headers[] = 'From: ' . get_bloginfo('name') . ' ' . $do_not_reply;
     // Get topic subscribers and bail if empty
     $user_ids = bbp_get_topic_subscribers($topic_id, true);
     if (empty($user_ids)) {
         return false;
     }
     // Loop through users
     foreach ((array) $user_ids as $user_id) {
         // Don't send notifications to the person who made the post
         if (!empty($reply_author) && (int) $user_id === (int) $reply_author) {
             continue;
         }
         if (user_can($user_id, 'moderate') || (int) $topic_author === (int) $user_id) {
             // Get email address of subscribed user
             $headers[] = 'Bcc: ' . get_userdata($user_id)->user_email;
         }
     }
     wp_mail($do_not_reply, $subject, $message, $headers);
 }
示例#8
0
 /**
  * @group canonical
  * @covers ::bbp_create_initial_content
  */
 public function test_bbp_create_initial_content()
 {
     $category_id = $this->factory->forum->create(array('forum_meta' => array('_bbp_forum_type' => 'category', '_bbp_status' => 'open')));
     bbp_create_initial_content(array('forum_parent' => $category_id));
     $forum_id = bbp_forum_query_subforum_ids($category_id);
     $forum_id = (int) $forum_id[0];
     $topic_id = bbp_get_forum_last_topic_id($forum_id);
     $reply_id = bbp_get_forum_last_reply_id($forum_id);
     // Forum post
     $this->assertSame('General', bbp_get_forum_title($forum_id));
     $this->assertSame('General chit-chat', bbp_get_forum_content($forum_id));
     $this->assertSame('open', bbp_get_forum_status($forum_id));
     $this->assertTrue(bbp_is_forum_public($forum_id));
     $this->assertSame($category_id, bbp_get_forum_parent_id($forum_id));
     // Topic post
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame('Hello World!', bbp_get_topic_title($topic_id));
     remove_all_filters('bbp_get_topic_content');
     $topic_content = "I am the first topic in your new forums.";
     $this->assertSame($topic_content, bbp_get_topic_content($topic_id));
     $this->assertSame('publish', bbp_get_topic_status($topic_id));
     $this->assertTrue(bbp_is_topic_published($topic_id));
     // Reply post
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_reply_title($reply_id));
     $this->assertSame($reply_id, bbp_get_reply_title_fallback($reply_id));
     remove_all_filters('bbp_get_reply_content');
     $reply_content = "Oh, and this is what a reply looks like.";
     $this->assertSame($reply_content, bbp_get_reply_content($reply_id));
     $this->assertSame('publish', bbp_get_reply_status($reply_id));
     $this->assertTrue(bbp_is_reply_published($reply_id));
     // Category meta
     $this->assertSame(1, bbp_get_forum_subforum_count($category_id, true));
     $this->assertSame(0, bbp_get_forum_topic_count($category_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($category_id, true));
     $this->assertSame(0, bbp_get_forum_reply_count($category_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($category_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($category_id, true, true));
     $this->assertSame(0, bbp_get_forum_post_count($category_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($category_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($category_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($category_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($category_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($category_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($category_id));
     // Forum meta
     $this->assertSame(0, bbp_get_forum_subforum_count($forum_id, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, false, true));
     $this->assertSame(0, bbp_get_forum_topic_count_hidden($forum_id, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, false, true));
     $this->assertSame(1, bbp_get_forum_topic_count($forum_id, true, true));
     $this->assertSame(1, bbp_get_forum_reply_count($forum_id, true, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, false, true));
     $this->assertSame(2, bbp_get_forum_post_count($forum_id, true, true));
     $this->assertSame($topic_id, bbp_get_forum_last_topic_id($forum_id));
     $this->assertSame('Hello World!', bbp_get_forum_last_topic_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_reply_id($forum_id));
     $this->assertSame('Reply To: Hello World!', bbp_get_forum_last_reply_title($forum_id));
     $this->assertSame($reply_id, bbp_get_forum_last_active_id($forum_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_forum_last_active_time($forum_id));
     // Topic meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($topic_id));
     $this->assertSame($forum_id, bbp_get_topic_forum_id($topic_id));
     $this->assertSame(1, bbp_get_topic_voice_count($topic_id, true));
     $this->assertSame(1, bbp_get_topic_reply_count($topic_id, true));
     $this->assertSame(0, bbp_get_topic_reply_count_hidden($topic_id, true));
     $this->assertSame($reply_id, bbp_get_topic_last_reply_id($topic_id));
     $this->assertSame($reply_id, bbp_get_topic_last_active_id($topic_id));
     $this->assertSame('1 day, 16 hours ago', bbp_get_topic_last_active_time($topic_id));
     // Reply Meta
     $this->assertSame('127.0.0.1', bbp_current_author_ip($reply_id));
     $this->assertSame($forum_id, bbp_get_reply_forum_id($reply_id));
     $this->assertSame($topic_id, bbp_get_reply_topic_id($reply_id));
 }
示例#9
0
文件: reply.php 项目: ntwb/bbPress
 /**
  * @covers ::bbp_reply_content
  * @covers ::bbp_get_reply_content
  */
 public function test_bbp_get_reply_content()
 {
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_content' => 'Content of Reply 1', 'post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     remove_all_filters('bbp_get_reply_content');
     $reply_content = bbp_get_reply_content($r);
     $this->assertSame('Content of Reply 1', $reply_content);
 }
示例#10
0
/**
 * Sends notification emails for new posts
 *
 * Gets new post's ID and check if there are subscribed users to that topic, and
 * if there are, send notifications
 *
 * @since bbPress (r2668)
 *
 * @param int $reply_id ID of the newly made reply
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_reply_id() To validate the reply ID
 * @uses bbp_get_reply() To get the reply
 * @uses bbp_get_reply_topic_id() To get the topic ID of the reply
 * @uses bbp_is_reply_published() To make sure the reply is published
 * @uses bbp_get_topic_id() To validate the topic ID
 * @uses bbp_get_topic() To get the reply's topic
 * @uses bbp_is_topic_published() To make sure the topic is published
 * @uses get_the_author_meta() To get the author's display name
 * @uses do_action() Calls 'bbp_pre_notify_subscribers' with the reply id and
 *                    topic id
 * @uses bbp_get_topic_subscribers() To get the topic subscribers
 * @uses apply_filters() Calls 'bbp_subscription_mail_message' with the
 *                        message, reply id, topic id and user id
 * @uses get_userdata() To get the user data
 * @uses wp_mail() To send the mail
 * @uses do_action() Calls 'bbp_post_notify_subscribers' with the reply id
 *                    and topic id
 * @return bool True on success, false on failure
 */
function bbp_notify_subscribers($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0)
{
    // Bail if subscriptions are turned off
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    /** Validation ************************************************************/
    $reply_id = bbp_get_reply_id($reply_id);
    $topic_id = bbp_get_topic_id($topic_id);
    $forum_id = bbp_get_forum_id($forum_id);
    /** Reply *****************************************************************/
    // Bail if reply is not published
    if (!bbp_is_reply_published($reply_id)) {
        return false;
    }
    /** Topic *****************************************************************/
    // Bail if topic is not published
    if (!bbp_is_topic_published($topic_id)) {
        return false;
    }
    /** User ******************************************************************/
    // Get subscribers and bail if empty
    $user_ids = bbp_get_topic_subscribers($topic_id, true);
    if (empty($user_ids)) {
        return false;
    }
    // Poster name
    $reply_author_name = bbp_get_reply_author_display_name($reply_id);
    /** Mail ******************************************************************/
    do_action('bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids);
    // Remove filters from reply content and topic title to prevent content
    // from being encoded with HTML entities, wrapped in paragraph tags, etc...
    remove_all_filters('bbp_get_reply_content');
    remove_all_filters('bbp_get_topic_title');
    // Strip tags from text
    $topic_title = strip_tags(bbp_get_topic_title($topic_id));
    $reply_content = strip_tags(bbp_get_reply_content($reply_id));
    $reply_url = bbp_get_reply_url($reply_id);
    $blog_name = get_option('blogname');
    // Loop through users
    foreach ((array) $user_ids as $user_id) {
        // Don't send notifications to the person who made the post
        if (!empty($reply_author) && (int) $user_id == (int) $reply_author) {
            continue;
        }
        // For plugins to filter messages per reply/topic/user
        $message = sprintf(__('%1$s wrote:

%2$s
			
Post Link: %3$s

-----------

You are receiving this email because you subscribed to a forum topic.

Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $reply_author_name, $reply_content, $reply_url);
        $message = apply_filters('bbp_subscription_mail_message', $message, $reply_id, $topic_id, $user_id);
        if (empty($message)) {
            continue;
        }
        // For plugins to filter titles per reply/topic/user
        $subject = apply_filters('bbp_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $reply_id, $topic_id, $user_id);
        if (empty($subject)) {
            continue;
        }
        // Custom headers
        $headers = apply_filters('bbp_subscription_mail_headers', array());
        // Get user data of this user
        $user = get_userdata($user_id);
        // Send notification email
        wp_mail($user->user_email, $subject, $message, $headers);
    }
    do_action('bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids);
    return true;
}
										                                            href="<?php 
                    echo bp_core_get_user_domain($reply->post_author);
                    ?>
"><?php 
                    echo bbp_get_reply_author_display_name($reply->ID);
                    ?>
</a>
                                                                                    <?php 
                    if ($postUser->has_cap('bbp_keymaster')) {
                        echo "<small>(Администратор форума)</small>";
                    } elseif ($postUser->has_cap('bbp_moderator')) {
                        echo "<small>(Преподаватель)</small>";
                    }
                    ?>
                                                                                    <?php 
                    echo bbp_get_reply_content($reply->ID);
                    ?>
										                                    </div>
										                                    <div class="single_reply_attaches">
										                                        <?php 
                    $attaches = get_comment_meta($reply->ID, 'attaches', true);
                    foreach (explode(',', $attaches) as $attach) {
                        if (empty($attach)) {
                            continue;
                        }
                        $r = wp_get_attachment_image_src($attach, 'full');
                        ?>
										                                            <div
										                                                class="single_reply_single_attachment">
										                                                <div class="attachment-image"><a
										                                                        target="_blank"
示例#12
0
/**
 * Return the excerpt of the reply
 *
 * @since bbPress (r2751)
 *
 * @param int $reply_id Optional. Reply id
 * @param int $length Optional. Length of the excerpt. Defaults to 100
 *                     letters
 * @uses bbp_get_reply_id() To get the reply id
 * @uses get_post_field() To get the excerpt
 * @uses bbp_get_reply_content() To get the reply content
 * @uses apply_filters() Calls 'bbp_get_reply_excerpt' with the excerpt,
 *                        reply id and length
 * @return string Reply Excerpt
 */
function bbp_get_reply_excerpt($reply_id = 0, $length = 100)
{
    $reply_id = bbp_get_reply_id($reply_id);
    $length = (int) $length;
    $excerpt = get_post_field($reply_id, 'post_excerpt');
    if (empty($excerpt)) {
        $excerpt = bbp_get_reply_content($reply_id);
    }
    $excerpt = trim(strip_tags($excerpt));
    if (!empty($length) && strlen($excerpt) > $length) {
        $excerpt = substr($excerpt, 0, $length - 1);
        $excerpt .= '&hellip;';
    }
    return apply_filters('bbp_get_reply_excerpt', $excerpt, $reply_id, $length);
}
    /**
     * Notify admins on new reply on the forum
     * 
     * A modified/inspired version of  bbp_notify_topic_subscribers()
     * @param type $reply_id
     * @param type $topic_id
     * @param type $forum_id
     * @param type $anonymous_data
     * @param type $reply_author
     * @param type $unknown_boolean
     * @param type $reply_to
     * @return boolean
     */
    public function notify_reply($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author, $unknown_boolean, $reply_to)
    {
        $reply_id = bbp_get_reply_id($reply_id);
        $topic_id = bbp_get_topic_id($topic_id);
        $forum_id = bbp_get_forum_id($forum_id);
        // Poster name
        $reply_author_name = bbp_get_reply_author_display_name($reply_id);
        remove_all_filters('bbp_get_reply_content');
        remove_all_filters('bbp_get_topic_title');
        // Strip tags from text and setup mail data
        $topic_title = strip_tags(bbp_get_topic_title($topic_id));
        $reply_content = strip_tags(bbp_get_reply_content($reply_id));
        $reply_url = bbp_get_reply_url($reply_id);
        $message = sprintf(__('%1$s wrote:

%2$s

Post Link: %3$s

-----------

You are receiving this email because you askd for it.

Login and visit the settings to disable these emails.', 'bbp-notify-admin'), $reply_author_name, $reply_content, $reply_url);
        $message = apply_filters('bbp_notify_admin_reply_mail_message', $message, $reply_id, $topic_id);
        if (empty($message)) {
            return;
        }
        $subject = apply_filters('bbp_notify_admin_reply_mail_title', $this->get_subject(__('New Reply: ', 'bbp-notify-admin') . $topic_title), $reply_id, $topic_id);
        if (empty($subject)) {
            return;
        }
        $headers = $this->get_headers();
        //get all admin users
        $users = $this->get_users_to_notify('reply');
        $users = apply_filters('bbp_notify_admin_reply_notifiable_users', $users);
        if (empty($users)) {
            return false;
        }
        //get all users emails
        $emails = $this->get_emails($users, 'reply');
        if (empty($emails)) {
            return false;
            //no one to send to
        }
        $to_email = array_shift($emails);
        // Loop through users
        foreach ($emails as $email) {
            //add all other users as bcc(only applies in case we have more than 1 admin )
            $headers[] = 'Bcc:' . $email;
        }
        $this->notify(array('subject' => $subject, 'message' => $message, 'to' => $to_email, 'headers' => $headers));
    }
示例#14
0
function load_more_topics()
{
    $content = '';
    ob_start();
    $forum_id = $_POST['forum'];
    if ($topics = bbp_has_topics(array('post_parent' => $forum_id, 'posts_per_page' => 11, 'paged' => $_POST['list']))) {
        $counter = 0;
        while (bbp_topics()) {
            bbp_the_topic();
            if (++$counter == 12) {
                break;
            }
            ?>
<div class="topics_list_single_topic  <?php 
            $postUser = new WP_User(bbp_get_topic_author_id());
            echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : "";
            ?>
"
	id="topic-<?php 
            echo bbp_get_topic_id();
            ?>
"
	data-bbp_forum_id="<?php 
            echo $forum_id;
            ?>
"
	data-id="<?php 
            echo bbp_get_topic_id();
            ?>
">
	<div class="single_topic_header">
		<div class="photo">
			<a
				href="<?php 
            echo bp_core_get_user_domain(bbp_get_topic_author_id());
            ?>
"><?php 
            echo bp_core_fetch_avatar(array('item_id' => bbp_get_topic_author_id(), 'height' => 40, 'width' => 40));
            ?>
</a>
		</div>
		<div class="info">
			<div class="name">
				<a
					href="<?php 
            echo bp_core_get_user_domain(bbp_get_topic_author_id());
            ?>
"><?php 
            echo bbp_get_topic_author_display_name(bbp_get_topic_id());
            ?>
</a>
                <?php 
            if ($postUser->has_cap('bbp_keymaster')) {
                echo "<small>(Администратор форума)</small>";
            } elseif ($postUser->has_cap('bbp_moderator')) {
                echo "<small>(Преподаватель)</small>";
            }
            ?>
			</div>
			<div class="date"><?php 
            echo get_post_time('j F ', false, bbp_get_topic_id(), true) . __('at', 'qode') . get_post_time(' H:i', false, bbp_get_topic_id(), true);
            ?>
</div>
		</div>
                    <?php 
            if (bbp_get_topic_author_id() == get_current_user_id()) {
                ?>
                        <a href="#" class="addi_actions_open"></a>
		<div class="addi_actions" style="display: none">
			<ul>
				<li><a class="edit_action" href="#">Редактировать</a></li>
				<li><a class="remove_action" href="#">Удалить</a></li>
			</ul>
		</div>
                    <?php 
            }
            ?>
                </div>
	<div class="single_topic_content">
                    <?php 
            $content = bbp_get_topic_content();
            if (mb_strlen($content) > 500) {
                echo '<div class="show">' . mb_substr($content, 0, 500) . '... <a href="#" class="show_all">' . __('More', 'qode') . '</a></div>';
                ?>
                        <div class="hide"><?php 
                echo $content;
                ?>
</div>
                    <?php 
            } else {
                echo $content;
            }
            ?>
                </div>
	<div style="display: none" class="single_topic_content_edit">
		<textarea class="edit_content"><?php 
            echo get_post_field('post_content', bbp_get_topic_id());
            ?>
</textarea>

		<div class="edit_actions">
			<button class="cancel"><?php 
            _e('Cancel', 'qode');
            ?>
</button>
			<button class="save"><?php 
            _e('Save', 'qode');
            ?>
</button>
		</div>
	</div>
	<div class="single_topic_replies_container">
		<div class="single_topic_replies">
                        <?php 
            $replies = get_posts($default = array('post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true));
            // Stickies not supported
            $i = count($replies);
            if ($i == 5) {
                $count = new WP_Query($default = array('numberposts' => -1, 'post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true));
                // Stickies not supported
                $count = $count->found_posts - 4;
                ?>
<a href="#" class="load_all_replies"><i class="comments_img"></i>Просмотреть
                            еще <?php 
                echo $count . ' ' . custom_plural_form($count, 'комментарий', 'комментария', 'комментариев');
                ?>
                            </a>
                        <?php 
            }
            $replies = array_reverse($replies);
            //array_shift ( $replies );
            foreach ($replies as $reply) {
                ?>
				<div class="single_topic_reply <?php 
                $postUser = new WP_User($reply->post_author);
                echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : "";
                ?>
"
				data-id="<?php 
                echo $reply->ID;
                ?>
">
				<div class="photo">
					<a
						href="<?php 
                echo bp_core_get_user_domain($reply->post_author);
                ?>
"><?php 
                echo bp_core_fetch_avatar(array('item_id' => $reply->post_author, 'height' => 32, 'width' => 32));
                ?>
</a>
				</div>
				<div class="content_wrapper">
					<div class="reply_content">
						<a class="author-link"
							href="<?php 
                echo bp_core_get_user_domain($reply->post_author);
                ?>
"><?php 
                echo bbp_get_reply_author_display_name($reply->ID);
                ?>
</a>
                            
                        <?php 
                if ($postUser->has_cap('bbp_keymaster')) {
                    echo "<small>(Администратор форума)</small>";
                } elseif ($postUser->has_cap('bbp_moderator')) {
                    echo "<small>(Преподаватель)</small>";
                }
                ?>
							<?php 
                echo bbp_get_reply_content($reply->ID);
                ?>
                    </div>
					<div style="display: none" class="reply_content_edit">
						<textarea class="reply_content_edit_textarea"><?php 
                echo get_post_field('post_content', $reply->ID);
                ?>
</textarea>
						
						<div class="edit_actions">
							<a class="cancel" href="#">Отменить</a>
						</div>
					</div>
					<div class="date">
						<?php 
                echo get_post_time('j F ', false, $reply->ID, true) . __('at', 'qode') . get_post_time(' H:i', false, $reply->ID, true);
                ?>
</span><?php 
                $like = get_post_meta($reply->ID, 'like_' . get_current_user_id(), true);
                ?>
					</div>
				</div>
				<?php 
                if ($reply->post_author == get_current_user_id()) {
                    ?>
				<a class="addi_actions_open" href="#"></a>
				<div class="addi_actions" style="display: none">
					<ul>
						<li><a class="edit_action" href="#">Редактировать</a></li>
						<li><a class="remove_action" href="#">Удалить</a></li>
					</ul>
				</div>
                                <?php 
                }
                ?>
                            </div>
                        <?php 
            }
            $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
            ?>
                    </div>
		<div class="single_topic_reply_form">
			<form
				action="<?php 
            echo $url;
            ?>
#topic-<?php 
            echo bbp_get_topic_id();
            ?>
"
				data-bbp_forum_id="<?php 
            echo $forum_id;
            ?>
"
				data-bbp_topic_id="<?php 
            echo bbp_get_topic_id();
            ?>
" method="post">
				<div class="photo">
					<a
						href="<?php 
            echo bp_core_get_user_domain(get_current_user_id());
            ?>
"><?php 
            echo bp_core_fetch_avatar(array('item_id' => get_current_user_id(), 'height' => 32, 'width' => 32));
            ?>
</a>
				</div>
				<div class="reply-form">
					<textarea
						placeholder="<?php 
            _e('Введите текст сообщения...', 'qode');
            ?>
"
						name="content"></textarea>
				</div>

				<input type="hidden" name="bbp_forum_id"
					value="<?php 
            echo $forum_id;
            ?>
"> <input type="hidden"
					name="bbp_topic_id" value="<?php 
            echo bbp_get_topic_id();
            ?>
"> <input
					type="hidden" name="action" value="custom-bbp-reply-create"> <input
					type="hidden" name="security"
					value="<?php 
            echo wp_create_nonce('custom-bbp-reply-create');
            ?>
">
			</form>
		</div>
	</div>
</div>
<?php 
        }
        if ($counter == 11) {
            ?>
<a class="load_more_topics" href="#"><?php 
            _e('Load more discussions', 'qode');
            ?>
</a>
<?php 
        }
    }
    $content = ob_get_contents();
    ob_end_clean();
    die(json_encode(array('result' => 'OK', 'content' => $content)));
}
 /**
  * @since 1.4
  */
 private function _build_email($type, $post_id)
 {
     $email_subject = get_option("bbpress_notify_new{$type}_email_subject");
     $email_body = get_option("bbpress_notify_new{$type}_email_body");
     $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     $excerpt_size = apply_filters('bpnns_excerpt_size', 100);
     // Replace shortcodes
     if ('topic' === $type) {
         $content = bbp_get_topic_content($post_id);
         $title = html_entity_decode(strip_tags(bbp_get_topic_title($post_id)), ENT_NOQUOTES, 'UTF-8');
         $excerpt = html_entity_decode(strip_tags(bbp_get_topic_excerpt($post_id, $excerpt_size)), ENT_NOQUOTES, 'UTF-8');
         $author = bbp_get_topic_author($post_id);
         $url = apply_filters('bbpnns_topic_url', bbp_get_topic_permalink($post_id), $post_id, $title);
         $forum = html_entity_decode(strip_tags(get_the_title(bbp_get_topic_forum_id($post_id))), ENT_NOQUOTES, 'UTF-8');
     } elseif ('reply' === $type) {
         $content = bbp_get_reply_content($post_id);
         $title = html_entity_decode(strip_tags(bbp_get_reply_title($post_id)), ENT_NOQUOTES, 'UTF-8');
         $excerpt = html_entity_decode(strip_tags(bbp_get_reply_excerpt($post_id, $excerpt_size)), ENT_NOQUOTES, 'UTF-8');
         $author = bbp_get_reply_author($post_id);
         $url = apply_filters('bbpnns_reply_url', bbp_get_reply_permalink($post_id), $post_id, $title);
         $forum = html_entity_decode(strip_tags(get_the_title(bbp_get_reply_forum_id($post_id))), ENT_NOQUOTES, 'UTF-8');
     } else {
         wp_die('Invalid type!');
     }
     $content = preg_replace('/<br\\s*\\/?>/is', PHP_EOL, $content);
     $content = preg_replace('/(?:<\\/p>\\s*<p>)/ism', PHP_EOL . PHP_EOL, $content);
     $content = html_entity_decode(strip_tags($content), ENT_NOQUOTES, 'UTF-8');
     $topic_reply = apply_filters('bbpnns_topic_reply', bbp_get_reply_url($post_id), $post_id, $title);
     $email_subject = str_replace('[blogname]', $blogname, $email_subject);
     $email_subject = str_replace("[{$type}-title]", $title, $email_subject);
     $email_subject = str_replace("[{$type}-content]", $content, $email_subject);
     $email_subject = str_replace("[{$type}-excerpt]", $excerpt, $email_subject);
     $email_subject = str_replace("[{$type}-author]", $author, $email_subject);
     $email_subject = str_replace("[{$type}-url]", $url, $email_subject);
     $email_subject = str_replace("[{$type}-replyurl]", $topic_reply, $email_subject);
     $email_subject = str_replace("[{$type}-forum]", $forum, $email_subject);
     $email_body = str_replace('[blogname]', $blogname, $email_body);
     $email_body = str_replace("[{$type}-title]", $title, $email_body);
     $email_body = str_replace("[{$type}-content]", $content, $email_body);
     $email_body = str_replace("[{$type}-excerpt]", $excerpt, $email_body);
     $email_body = str_replace("[{$type}-author]", $author, $email_body);
     $email_body = str_replace("[{$type}-url]", $url, $email_body);
     $email_body = str_replace("[{$type}-replyurl]", $topic_reply, $email_body);
     $email_body = str_replace("[{$type}-forum]", $forum, $email_body);
     /**
      * Allow subject and body modifications
      * @since 1.6.6
      */
     $email_subject = apply_filters('bbpnns_filter_email_subject_in_build', $email_subject, $type, $post_id);
     $email_body = apply_filters('bbpnns_filter_email_body_in_build', $email_body, $type, $post_id);
     return array($email_subject, $email_body);
 }
示例#16
0
/**
 * Return the excerpt of the reply
 *
 * @since bbPress (r2751)
 *
 * @param int $reply_id Optional. Reply id
 * @param int $length Optional. Length of the excerpt. Defaults to 100
 *                     letters
 * @uses bbp_get_reply_id() To get the reply id
 * @uses get_post_field() To get the excerpt
 * @uses bbp_get_reply_content() To get the reply content
 * @uses apply_filters() Calls 'bbp_get_reply_excerpt' with the excerpt,
 *                        reply id and length
 * @return string Reply Excerpt
 */
function bbp_get_reply_excerpt($reply_id = 0, $length = 100)
{
    $reply_id = bbp_get_reply_id($reply_id);
    $length = (int) $length;
    $excerpt = get_post_field('post_excerpt', $reply_id);
    if (empty($excerpt)) {
        $excerpt = bbp_get_reply_content($reply_id);
    }
    $excerpt = trim(strip_tags($excerpt));
    // Multibyte support
    if (function_exists('mb_strlen')) {
        $excerpt_length = mb_strlen($excerpt);
    } else {
        $excerpt_length = strlen($excerpt);
    }
    if (!empty($length) && $excerpt_length > $length) {
        $excerpt = substr($excerpt, 0, $length - 1);
        $excerpt .= '&hellip;';
    }
    return apply_filters('bbp_get_reply_excerpt', $excerpt, $reply_id, $length);
}
示例#17
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 forum is not public
     if (!bbp_is_forum_public($forum_id, false)) {
         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 = bbp_get_reply_content($reply_id);
     // Topic
     $topic_permalink = bbp_get_topic_permalink($topic_id);
     $topic_title = bbp_get_topic_title($topic_id);
     $topic_link = '<a href="' . $topic_permalink . '" title="' . $topic_title . '">' . $topic_title . '</a>';
     // Forum
     $forum_permalink = bbp_get_forum_permalink($forum_id);
     $forum_title = bbp_get_forum_title($forum_id);
     $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('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);
     // 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);
     }
 }