Beispiel #1
0
 /**
  * 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 notification emails for new topics to subscribed forums
 *
 * Gets new post's ID and check if there are subscribed users to that forum, 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.5.0 bbPress (r5156)
 *
 * @param int $topic_id ID of the newly made reply
 * @param int $forum_id ID of the forum for the topic
 * @param mixed $anonymous_data Array of anonymous user data
 * @param int $topic_author ID of the topic author ID
 *
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_topic_id() To validate the topic ID
 * @uses bbp_get_forum_id() To validate the forum ID
 * @uses bbp_is_topic_published() To make sure the topic is published
 * @uses bbp_get_forum_subscribers() To get the forum subscribers
 * @uses bbp_get_topic_author_display_name() To get the topic author's display name
 * @uses do_action() Calls 'bbp_pre_notify_forum_subscribers' with the topic id,
 *                    forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_message' with the
 *                    message, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_title' with the
 *                    topic title, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_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_forum_subscribers' with the topic,
 *                    id, forum id and user id
 * @return bool True on success, false on failure
 */
function bbp_notify_forum_subscribers($topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0)
{
    // Bail if subscriptions are turned off
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    /** Validation ************************************************************/
    $topic_id = bbp_get_topic_id($topic_id);
    $forum_id = bbp_get_forum_id($forum_id);
    /**
     * Necessary for backwards compatibility
     *
     * @see https://bbpress.trac.wordpress.org/ticket/2620
     */
    $user_id = 0;
    /** Topic *****************************************************************/
    // Bail if topic is not published
    if (!bbp_is_topic_published($topic_id)) {
        return false;
    }
    // Poster name
    $topic_author_name = bbp_get_topic_author_display_name($topic_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_topic_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));
    $topic_content = strip_tags(bbp_get_topic_content($topic_id));
    $topic_url = get_permalink($topic_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

Topic Link: %3$s

-----------

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

Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $topic_author_name, $topic_content, $topic_url);
    $message = apply_filters('bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id);
    if (empty($message)) {
        return;
    }
    // For plugins to filter titles per reply/topic/user
    $subject = apply_filters('bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id);
    if (empty($subject)) {
        return;
    }
    /** User ******************************************************************/
    // 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_forum_subscribers($forum_id, true);
    // Dedicated filter to manipulate user ID's to send emails to
    $user_ids = apply_filters('bbp_forum_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($topic_author) && (int) $user_id === (int) $topic_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_forum_subscribers', $topic_id, $forum_id, $user_ids);
    // Send notification email
    wp_mail($to_email, $subject, $message, $headers);
    do_action('bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids);
    return true;
}
 /**
  * AJAX handler to Subscribe/Unsubscribe a user from a topic
  *
  * @since bbPress (r3732)
  *
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_is_user_logged_in() To check if user is logged in
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses current_user_can() To check if the current user can edit the user
  * @uses bbp_get_topic() To get the topic
  * @uses wp_verify_nonce() To verify the nonce
  * @uses bbp_is_user_subscribed() To check if the topic is in user's subscriptions
  * @uses bbp_remove_user_subscriptions() To remove the topic from user's subscriptions
  * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions
  * @uses bbp_ajax_response() To return JSON
  */
 public function ajax_subscription()
 {
     // Bail if subscriptions are not active
     if (!bbp_is_subscriptions_active()) {
         bbp_ajax_response(false, __('Subscriptions are no longer active.', 'bbpress'), 300);
     }
     // Bail if user is not logged in
     if (!is_user_logged_in()) {
         bbp_ajax_response(false, __('Please login to subscribe to this topic.', 'bbpress'), 301);
     }
     // Get user and topic data
     $user_id = bbp_get_current_user_id();
     $id = intval($_POST['id']);
     // Bail if user cannot add favorites for this user
     if (!current_user_can('edit_user', $user_id)) {
         bbp_ajax_response(false, __('You do not have permission to do this.', 'bbpress'), 302);
     }
     // Get the topic
     $topic = bbp_get_topic($id);
     // Bail if topic cannot be found
     if (empty($topic)) {
         bbp_ajax_response(false, __('The topic could not be found.', 'bbpress'), 303);
     }
     // Bail if user did not take this action
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'toggle-subscription_' . $topic->ID)) {
         bbp_ajax_response(false, __('Are you sure you meant to do that?', 'bbpress'), 304);
     }
     // Take action
     $status = bbp_is_user_subscribed($user_id, $topic->ID) ? bbp_remove_user_subscription($user_id, $topic->ID) : bbp_add_user_subscription($user_id, $topic->ID);
     // Bail if action failed
     if (empty($status)) {
         bbp_ajax_response(false, __('The request was unsuccessful. Please try again.', 'bbpress'), 305);
     }
     // Put subscription attributes in convenient array
     $attrs = array('topic_id' => $topic->ID, 'user_id' => $user_id);
     // Action succeeded
     bbp_ajax_response(true, bbp_get_user_subscribe_link($attrs, $user_id, false), 200);
 }
Beispiel #4
0
 /**
  * Set favorites and subscriptions query variables if viewing member profile
  * pages.
  *
  * @since bbPress (r4615)
  *
  * @global WP_Query $wp_query
  * @return If not viewing your own profile
  */
 public function set_member_forum_query_vars()
 {
     // Special handling for forum component
     if (!bp_is_my_profile()) {
         return;
     }
     global $wp_query;
     // 'favorites' action
     if (bbp_is_favorites_active() && bp_is_current_action(bbp_get_user_favorites_slug())) {
         $wp_query->bbp_is_single_user_favs = true;
         // 'subscriptions' action
     } elseif (bbp_is_subscriptions_active() && bp_is_current_action(bbp_get_user_subscriptions_slug())) {
         $wp_query->bbp_is_single_user_subs = true;
     }
 }
Beispiel #5
0
/**
 * Return the link to subscribe/unsubscribe from a topic
 *
 * @since bbPress (r2668)
 *
 * @param mixed $args This function supports these arguments:
 *  - subscribe: Subscribe text
 *  - unsubscribe: Unsubscribe text
 *  - user_id: User id
 *  - topic_id: Topic id
 *  - before: Before the link
 *  - after: After the link
 * @param int $user_id Optional. User id
 * @param bool $wrap Optional. If you want to wrap the link in <span id="subscription-toggle">.
 * @uses bbp_get_user_id() To get the user id
 * @uses current_user_can() To check if the current user can edit user
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_user_subscribed() To check if the user is subscribed
 * @uses bbp_is_subscriptions() To check if it's the subscriptions page
 * @uses bbp_get_subscriptions_permalink() To get subscriptions link
 * @uses bbp_get_topic_permalink() To get topic link
 * @uses apply_filters() Calls 'bbp_get_user_subscribe_link' with the
 *                        link, args, user id & topic id
 * @return string Permanent link to topic
 */
function stachestack_bbp_get_user_subscribe_link($args = '', $user_id = 0, $wrap = true)
{
    if (!bbp_is_subscriptions_active()) {
        return;
    }
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('subscribe' => __('Subscribe', 'bbpress'), 'unsubscribe' => __('Unsubscribe', 'bbpress'), 'user_id' => 0, 'topic_id' => 0, 'before' => '&nbsp;|&nbsp;', 'after' => ''), 'get_user_subscribe_link');
    // Validate user and topic ID's
    $user_id = bbp_get_user_id($r['user_id'], true, true);
    $topic_id = bbp_get_topic_id($r['topic_id']);
    if (empty($user_id) || empty($topic_id)) {
        return false;
    }
    // No link if you can't edit yourself
    if (!current_user_can('edit_user', (int) $user_id)) {
        return false;
    }
    // Decide which link to show
    $is_subscribed = bbp_is_user_subscribed($user_id, $topic_id);
    if (!empty($is_subscribed)) {
        $text = $r['unsubscribe'];
        $query_args = array('action' => 'bbp_unsubscribe', 'topic_id' => $topic_id);
    } else {
        $text = $r['subscribe'];
        $query_args = array('action' => 'bbp_subscribe', 'topic_id' => $topic_id);
    }
    // Create the link based where the user is and if the user is
    // subscribed already
    if (bbp_is_subscriptions()) {
        $permalink = bbp_get_subscriptions_permalink($user_id);
    } elseif (bbp_is_single_topic() || bbp_is_single_reply()) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } else {
        $permalink = get_permalink();
    }
    $url = esc_url(wp_nonce_url(add_query_arg($query_args, $permalink), 'toggle-subscription_' . $topic_id));
    $sub = $is_subscribed ? ' class="is-subscribed"' : '';
    $html = sprintf('%s<span id="subscribe-%d"  %s><a href="%s" class="btn btn-warning btn-xs subscription-toggle" data-topic="%d">%s</a></span>%s', $r['before'], $topic_id, $sub, $url, $topic_id, $text, $r['after']);
    // Initial output is wrapped in a span, ajax output is hooked to this
    if (!empty($wrap)) {
        $html = '<span id="subscription-toggle">' . $html . '</span>';
    }
    // Return the link
    return apply_filters('bbp_get_user_subscribe_link', $html, $r, $user_id, $topic_id);
}
Beispiel #6
0
<?php

/**
 * User Subscriptions
 *
 * @package bbPress
 * @subpackage Theme
 */
?>

	<?php 
do_action('bbp_template_before_user_subscriptions');
?>

	<?php 
if (bbp_is_subscriptions_active()) {
    ?>

		<?php 
    if (bbp_is_user_home() || current_user_can('edit_users')) {
        ?>

			<div id="bbp-user-subscriptions" class="bbp-user-subscriptions">
				<h2 class="entry-title"><?php 
        _e('Subscribed Forums', 'wpdance');
        ?>
</h2>
				<div class="bbp-user-section">

					<?php 
        if (bbp_get_user_forum_subscriptions()) {
Beispiel #7
0
/**
 * Allow subscriptions setting field
 *
 * @since 2.0.0 bbPress (r2737)
 *
 * @uses checked() To display the checked attribute
 */
function bbp_admin_setting_callback_subscriptions()
{
    ?>

	<input name="_bbp_enable_subscriptions" id="_bbp_enable_subscriptions" type="checkbox" value="1" <?php 
    checked(bbp_is_subscriptions_active(true));
    bbp_maybe_admin_setting_disabled('_bbp_enable_subscriptions');
    ?>
 />
	<label for="_bbp_enable_subscriptions"><?php 
    esc_html_e('Allow users to subscribe to forums and topics', 'bbpress');
    ?>
</label>

<?php 
}
Beispiel #8
0
/**
 * Handles the front end subscribing and unsubscribing topics
 *
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_user_id() To get the user id
 * @uses bbp_verify_nonce_request() To verify the nonce and check the request
 * @uses current_user_can() To check if the current user can edit the user
 * @uses bbPress:errors:add() To log the error messages
 * @uses bbp_is_user_subscribed() To check if the topic is in user's
 *                                 subscriptions
 * @uses bbp_remove_user_subscription() To remove the user subscription
 * @uses bbp_add_user_subscription() To add the user subscription
 * @uses do_action() Calls 'bbp_subscriptions_handler' with success, user id,
 *                    topic id and action
 * @uses bbp_is_subscription() To check if it's the subscription page
 * @uses bbp_get_subscription_link() To get the subscription page link
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses wp_safe_redirect() To redirect to the url
 */
function bbp_subscriptions_handler()
{
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    // Bail if not a GET action
    if ('GET' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if required GET actions aren't passed
    if (empty($_GET['topic_id']) || empty($_GET['action'])) {
        return;
    }
    // Setup possible get actions
    $possible_actions = array('bbp_subscribe', 'bbp_unsubscribe');
    // Bail if actions aren't meant for this function
    if (!in_array($_GET['action'], $possible_actions)) {
        return;
    }
    // Get required data
    $action = $_GET['action'];
    $user_id = bbp_get_user_id(0, true, true);
    $topic_id = intval($_GET['topic_id']);
    // Check for empty topic
    if (empty($topic_id)) {
        bbp_add_error('bbp_subscription_topic_id', __('<strong>ERROR</strong>: No topic was found! Which topic are you subscribing/unsubscribing to?', 'bbpress'));
        // Check nonce
    } elseif (!bbp_verify_nonce_request('toggle-subscription_' . $topic_id)) {
        bbp_add_error('bbp_subscription_topic_id', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
        // Check current user's ability to edit the user
    } elseif (!current_user_can('edit_user', $user_id)) {
        bbp_add_error('bbp_subscription_permissions', __('<strong>ERROR</strong>: You don\'t have the permission to edit favorites of that user!', 'bbpress'));
    }
    // Bail if we have errors
    if (bbp_has_errors()) {
        return;
    }
    /** No errors *************************************************************/
    $is_subscription = bbp_is_user_subscribed($user_id, $topic_id);
    $success = false;
    if (true == $is_subscription && 'bbp_unsubscribe' == $action) {
        $success = bbp_remove_user_subscription($user_id, $topic_id);
    } elseif (false == $is_subscription && 'bbp_subscribe' == $action) {
        $success = bbp_add_user_subscription($user_id, $topic_id);
    }
    // Do additional subscriptions actions
    do_action('bbp_subscriptions_handler', $success, $user_id, $topic_id, $action);
    // Success!
    if (true == $success) {
        // Redirect back from whence we came
        if (bbp_is_subscriptions()) {
            $redirect = bbp_get_subscriptions_permalink($user_id);
        } elseif (bbp_is_single_user()) {
            $redirect = bbp_get_user_profile_url();
        } elseif (is_singular(bbp_get_topic_post_type())) {
            $redirect = bbp_get_topic_permalink($topic_id);
        } elseif (is_single() || is_page()) {
            $redirect = get_permalink();
        }
        wp_safe_redirect($redirect);
        // For good measure
        exit;
        // Fail! Handle errors
    } elseif (true == $is_subscription && 'bbp_unsubscribe' == $action) {
        bbp_add_error('bbp_unsubscribe', __('<strong>ERROR</strong>: There was a problem unsubscribing from that topic!', 'bbpress'));
    } elseif (false == $is_subscription && 'bbp_subscribe' == $action) {
        bbp_add_error('bbp_subscribe', __('<strong>ERROR</strong>: There was a problem subscribing to that topic!', 'bbpress'));
    }
}
 /**
  * AJAX handler to gettting the Subscribe/Unsubscribe state for a user from a forum
  *
  * @since bbPress (r5155)
  *
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_is_user_logged_in() To check if user is logged in
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses current_user_can() To check if the current user can edit the user
  * @uses bbp_get_forum() To get the forum
  * @uses wp_verify_nonce() To verify the nonce
  * @uses bbp_is_user_subscribed() To check if the forum is in user's subscriptions
  * @uses bbp_remove_user_subscriptions() To remove the forum from user's subscriptions
  * @uses bbp_add_user_subscriptions() To add the forum from user's subscriptions
  * @uses bbp_ajax_response() To return JSON
  */
 public function ajax_get_forum_subscription()
 {
     // Bail if subscriptions are not active
     if (!bbp_is_subscriptions_active()) {
         bbp_ajax_response(false, __('Subscriptions are no longer active.', 'bbpress'), 300);
     }
     // Bail if user is not logged in
     if (!is_user_logged_in()) {
         bbp_ajax_response(false, __('Please login to subscribe to this forum.', 'bbpress'), 301);
     }
     // Get user and forum data
     $user_id = bbp_get_current_user_id();
     $id = intval($_POST['id']);
     // Bail if user cannot add favorites for this user
     if (!current_user_can('edit_user', $user_id)) {
         bbp_ajax_response(false, __('You do not have permission to do this.', 'bbpress'), 302);
     }
     // Get the forum
     $forum = bbp_get_forum($id);
     // Bail if forum cannot be found
     if (empty($forum)) {
         bbp_ajax_response(false, __('The forum could not be found.', 'bbpress'), 303);
     }
     // Bail if user did not take this action
     //if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'toggle-subscription_' . $forum->ID ) ) {
     //        bbp_ajax_response( false, __( 'Are you sure you meant to do that?', 'bbpress' ), 304 );
     //}
     // Put subscription attributes in convenient array
     $attrs = array('forum_id' => $forum->ID, 'user_id' => $user_id);
     // Action succeeded
     bbp_ajax_response(true, bbp_get_forum_subscription_link($attrs, $user_id, false), 200);
 }
Beispiel #10
0
/**
 * Allow subscriptions setting field
 *
 * @since bbPress (r2737)
 *
 * @uses checked() To display the checked attribute
 */
function bbp_admin_setting_callback_subscriptions()
{
    ?>

	<input id="_bbp_enable_subscriptions" name="_bbp_enable_subscriptions" type="checkbox" id="_bbp_enable_subscriptions" value="1" <?php 
    checked(bbp_is_subscriptions_active(true));
    ?>
 />
	<label for="_bbp_enable_subscriptions"><?php 
    _e('Allow users to subscribe to topics', 'bbpress');
    ?>
</label>

<?php 
}
Beispiel #11
0
 function cb_bbp_author_details($cb_author_id, $cb_desc = true)
 {
     $cb_author_email = get_the_author_meta('publicemail', $cb_author_id);
     $cb_author_name = get_the_author_meta('display_name', $cb_author_id);
     $cb_author_position = get_the_author_meta('position', $cb_author_id);
     $cb_author_tw = get_the_author_meta('twitter', $cb_author_id);
     $cb_author_go = get_the_author_meta('googleplus', $cb_author_id);
     $cb_author_www = get_the_author_meta('url', $cb_author_id);
     $cb_author_desc = get_the_author_meta('description', $cb_author_id);
     $cb_author_posts = count_user_posts($cb_author_id);
     $cb_author_output = NULL;
     $cb_author_output .= '<div class="cb-author-details cb-bbp clearfix"><div class="cb-mask"><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '" rel="me">' . get_avatar(bbp_get_displayed_user_field('user_email', 'raw'), apply_filters('bbp_single_user_details_avatar_size', 150)) . '</a></div><div class="cb-meta"><h3><a href="' . bbp_get_user_profile_url() . '" title="' . bbp_get_displayed_user_field('display_name') . '">' . $cb_author_name . '</a></h3>';
     if ($cb_author_position != NULL) {
         $cb_author_output .= '<div class="cb-author-position">' . $cb_author_position . '</div>';
     }
     if ($cb_author_desc != NULL && $cb_desc == true) {
         $cb_author_output .= '<p class="cb-author-bio">' . $cb_author_desc . '</p>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_tw != NULL || $cb_author_go != NULL) {
         $cb_author_output .= '<div class="cb-author-page-contact">';
     }
     if ($cb_author_email != NULL) {
         $cb_author_output .= '<a href="mailto:' . $cb_author_email . '"><i class="icon-envelope-alt cb-tip-bot" title="' . __('Email', 'cubell') . '"></i></a>';
     }
     if ($cb_author_www != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_www . '" target="_blank"><i class="icon-link cb-tip-bot" title="' . __('Website', 'cubell') . '"></i></a> ';
     }
     if ($cb_author_tw != NULL) {
         $cb_author_output .= ' <a href="//www.twitter.com/' . $cb_author_tw . '" target="_blank" ><i class="icon-twitter cb-tip-bot" title="Twitter"></i></a>';
     }
     if ($cb_author_go != NULL) {
         $cb_author_output .= ' <a href="' . $cb_author_go . '" rel="publisher" target="_top" title="Google+" class="cb-googleplus cb-tip-bot" ><img src="//ssl.gstatic.com/images/icons/gplus-32.png"  data-src-retina="//ssl.gstatic.com/images/icons/gplus-64.png" alt="Google+" ></a>';
     }
     if ($cb_author_email != NULL || $cb_author_www != NULL || $cb_author_go != NULL || $cb_author_tw != NULL) {
         $cb_author_output .= '</div>';
     }
     $cb_author_output .= '<div id="cb-user-nav"><ul>';
     if (bbp_is_single_user_replies()) {
         $cb_user_current = 'current';
     }
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_topics()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-topics-created-link"><a href="' . bbp_get_user_topics_created_url() . '">' . __('Topics Started', 'bbpress') . '</a></span></li>';
     $cb_author_output .= '<li class="';
     if (bbp_is_single_user_replies()) {
         $cb_author_output .= 'current';
     }
     $cb_author_output .= '"><span class="bbp-user-replies-created-link"><a href="' . bbp_get_user_replies_created_url() . '">' . __('Replies Created', 'bbpress') . '</a></span></li>';
     if (bbp_is_favorites_active()) {
         $cb_author_output .= '<li class="';
         if (bbp_is_favorites()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-favorites-link"><a href="' . bbp_get_favorites_permalink() . '">' . __('Favorites', 'bbpress') . '</a></span></li>';
     }
     if (bbp_is_user_home() || current_user_can('edit_users')) {
         if (bbp_is_subscriptions_active()) {
             $cb_author_output .= '<li class="';
             if (bbp_is_subscriptions()) {
                 $cb_author_output .= 'current';
             }
             $cb_author_output .= '"><span class="bbp-user-subscriptions-link"><a href="' . bbp_get_subscriptions_permalink() . '">' . __('Subscriptions', 'bbpress') . '</a></span></li>';
         }
         $cb_author_output .= '<li class="';
         if (bbp_is_single_user_edit()) {
             $cb_author_output .= 'current';
         }
         $cb_author_output .= '"><span class="bbp-user-edit-link"><a href="' . bbp_get_user_profile_edit_url() . '">' . __('Edit', 'bbpress') . '</a></span></li>';
     }
     $cb_author_output .= '</ul></div><!-- #cb-user-nav -->';
     $cb_author_output .= '</div></div>';
     return $cb_author_output;
 }
Beispiel #12
0
 /**
  * Setup BuddyBar navigation
  *
  * @since 2.1.0 bbPress (r3552)
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     // Stop if there is no user displayed or logged in
     if (!is_user_logged_in() && !bp_displayed_user_id()) {
         return;
     }
     // Define local variable(s)
     $user_domain = '';
     // Add 'Forums' to the main navigation
     $main_nav = array('name' => __('Forums', 'bbpress'), 'slug' => $this->slug, 'position' => 80, 'screen_function' => 'bbp_member_forums_screen_topics', 'default_subnav_slug' => bbp_get_topic_archive_slug(), 'item_css_id' => $this->id);
     // Determine user to use
     if (bp_displayed_user_id()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     // User link
     $forums_link = trailingslashit($user_domain . $this->slug);
     // Topics started
     $sub_nav[] = array('name' => __('Topics Started', 'bbpress'), 'slug' => bbp_get_topic_archive_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_topics', 'position' => 20, 'item_css_id' => 'topics');
     // Replies to topics
     $sub_nav[] = array('name' => __('Replies Created', 'bbpress'), 'slug' => bbp_get_reply_archive_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_replies', 'position' => 40, 'item_css_id' => 'replies');
     // Favorite topics
     if (bbp_is_favorites_active()) {
         $sub_nav[] = array('name' => __('Favorites', 'bbpress'), 'slug' => bbp_get_user_favorites_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_favorites', 'position' => 60, 'item_css_id' => 'favorites');
     }
     // Subscribed topics (my profile only)
     if (bp_is_my_profile() && bbp_is_subscriptions_active()) {
         $sub_nav[] = array('name' => __('Subscriptions', 'bbpress'), 'slug' => bbp_get_user_subscriptions_slug(), 'parent_url' => $forums_link, 'parent_slug' => $this->slug, 'screen_function' => 'bbp_member_forums_screen_subscriptions', 'position' => 60, 'item_css_id' => 'subscriptions');
     }
     parent::setup_nav($main_nav, $sub_nav);
 }
    public static function roost_bbp_forum_subscription( $post ) {
        global $post;
        $post_id = $post->ID;

        $url = bbp_get_forum_permalink( $post_id );

        $roost_bbp_subscriptions = get_post_meta( $post_id, '_roost_bbp_subscription', true );

        echo( sprintf( "<span id='roost-subscribe-%d' style='display:none;'><a href='%s' data-post='%d' class='roost-forum-subscribe-link' class='subscription-toggle'></a></span>", $post_id, $url, $post_id ) );
        ?>
        <script>
            jQuery(document).ready(function($) {
                var subscribeLink = $('.roost-forum-subscribe-link');
                var subscribeWrap = $('#roost-subscribe-<?php echo( $post_id ); ?>');
                <?php
                    if ( ! empty( $roost_bbp_subscriptions ) ) {
                        $reply_bbp_subscriptions = json_encode( $roost_bbp_subscriptions );
                ?>
                        var registrations = <?php echo( $reply_bbp_subscriptions ); ?>;
                <?php
                    } else {
                ?>
                        var registrations = [];
                <?php
                    }
                ?>

                setTimeout(function(){
                    if ( window.roostEnabled ){
                        if ( 'undefined' !== typeof registrations[window.roostToken] ) {
                            if ( true === registrations[window.roostToken] ) {
                                subscribeLink.text( 'Unsubscribe from Push Notifications' );
                                subscribeLink.data( 'action', 'roost_bbp_unsubscribe' );
                            }
                        } else {
                            subscribeLink.text( 'Subscribe with Push Notifications' );
                            subscribeLink.data( 'action', 'roost_bbp_subscribe' );
                        }
                        <?php
                            if ( true === bbp_is_subscriptions_active() && true === is_user_logged_in() ) {
                        ?>
                            subscribeWrap.detach().appendTo( '#subscription-toggle' ).show();
                            subscribeWrap.prepend( ' | ' );
                        <?php
                            } else {
                        ?>
                            subscribeWrap.wrap( "<div id='subscription-toggle'></div>" ).show();
                        <?php
                            }
                        ?>
                    }
                }, 1500);

                subscribeLink.on( 'click', function( e ){
                    e.preventDefault();
                    var data = {
                        link: subscribeLink.attr( 'href' ),
                        action: subscribeLink.data( 'action' ),
                        roostToken: window.roostToken,
                        postID: subscribeLink.data( 'post' ),
                    };
                    if ( 'roost_bbp_subscribe' === subscribeLink.data( 'action' ) ){
                        subscribeLink.text( 'Unsubscribe from Push Notifications' );
                        subscribeLink.data( 'action', 'roost_bbp_unsubscribe' );
                    } else {
                        subscribeLink.text( 'Subscribe with Push Notifications' );
                        subscribeLink.data( 'action', 'roost_bbp_subscribe' );
                    }

                    $.post( ajaxurl, data, function( response ) {

                    });
                });
            });
        </script>
        <?php
    }
Beispiel #14
0
 /**
  * Subscribe/Unsubscribe a user from a topic
  *
  * @since bbPress (r2668)
  *
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses current_user_can() To check if the current user can edit the user
  * @uses bbp_get_topic() To get the topic
  * @uses check_ajax_referer() To verify the nonce & check the referer
  * @uses bbp_is_user_subscribed() To check if the topic is in user's
  *                                 subscriptions
  * @uses bbp_remove_user_subscriptions() To remove the topic from user's
  *                                        subscriptions
  * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions
  */
 function bbp_skeleton_dim_subscription()
 {
     if (!bbp_is_subscriptions_active()) {
         return;
     }
     $user_id = bbp_get_current_user_id();
     $id = intval($_POST['id']);
     if (!current_user_can('edit_user', $user_id)) {
         die('-1');
     }
     if (!($topic = bbp_get_topic($id))) {
         die('0');
     }
     check_ajax_referer("toggle-subscription_{$topic->ID}");
     if (bbp_is_user_subscribed($user_id, $topic->ID)) {
         if (bbp_remove_user_subscription($user_id, $topic->ID)) {
             die('1');
         }
     } else {
         if (bbp_add_user_subscription($user_id, $topic->ID)) {
             die('1');
         }
     }
     die('0');
 }
Beispiel #15
0
/**
 * Sends notification emails for new topics to subscribed forums
 *
 * Gets new post's ID and check if there are subscribed users to that topic, and
 * if there are, send notifications
 *
 * @since bbPress (r5156)
 *
 * @param int $topic_id ID of the newly made reply
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_topic_id() To validate the topic ID
 * @uses bbp_get_forum_id() To validate the forum ID
 * @uses bbp_is_topic_published() To make sure the topic is published
 * @uses bbp_get_forum_subscribers() To get the forum subscribers
 * @uses bbp_get_topic_author_display_name() To get the topic author's display name
 * @uses do_action() Calls 'bbp_pre_notify_forum_subscribers' with the topic id,
 *                    forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_message' with the
 *                    message, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_subscription_mail_title' with the
 *                    topic title, topic id, forum id and user id
 * @uses apply_filters() Calls 'bbp_forum_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_forum_subscribers' with the topic,
 *                    id, forum id and user id
 * @return bool True on success, false on failure
 */
function bbp_notify_forum_subscribers($topic_id = 0, $forum_id = 0, $anonymous_data = false, $topic_author = 0)
{
    // Bail if subscriptions are turned off
    if (!bbp_is_subscriptions_active()) {
        return false;
    }
    /** Validation ************************************************************/
    $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;
    }
    /** User ******************************************************************/
    // Get forum subscribers and bail if empty
    $user_ids = bbp_get_forum_subscribers($forum_id, true);
    if (empty($user_ids)) {
        return false;
    }
    // Poster name
    $topic_author_name = bbp_get_topic_author_display_name($topic_id);
    /** Mail ******************************************************************/
    do_action('bbp_pre_notify_forum_subscribers', $topic_id, $forum_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_topic_content');
    remove_all_filters('bbp_get_topic_title');
    // Strip tags from text
    $topic_title = strip_tags(bbp_get_topic_title($topic_id));
    $topic_content = strip_tags(bbp_get_topic_content($topic_id));
    $topic_url = get_permalink($topic_id);
    $blog_name = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    // Loop through users
    foreach ((array) $user_ids as $user_id) {
        // Don't send notifications to the person who made the post
        if (!empty($topic_author) && (int) $user_id === (int) $topic_author) {
            continue;
        }
        // For plugins to filter messages per reply/topic/user
        $message = sprintf(__('%1$s wrote:

%2$s

Topic Link: %3$s

-----------

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

Login and visit the topic to unsubscribe from these emails.', 'bbpress'), $topic_author_name, $topic_content, $topic_url);
        $message = apply_filters('bbp_forum_subscription_mail_message', $message, $topic_id, $forum_id, $user_id);
        if (empty($message)) {
            continue;
        }
        // For plugins to filter titles per reply/topic/user
        $subject = apply_filters('bbp_forum_subscription_mail_title', '[' . $blog_name . '] ' . $topic_title, $topic_id, $forum_id, $user_id);
        if (empty($subject)) {
            continue;
        }
        // Custom headers
        $headers = apply_filters('bbp_forum_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_forum_subscribers', $topic_id, $forum_id, $user_ids);
    return true;
}
/**
 * Handle all the extra meta stuff from posting a new reply or editing a reply
 *
 * @param int $reply_id Optional. Reply id
 * @param int $topic_id Optional. Topic id
 * @param int $forum_id Optional. Forum id
 * @param bool|array $anonymous_data Optional logged-out user data.
 * @param int $author_id Author id
 * @param bool $is_edit Optional. Is the post being edited? Defaults to false.
 * @param int $reply_to Optional. Reply to id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_current_user_id() To get the current user id
 * @uses bbp_get_reply_topic_id() To get the reply topic id
 * @uses bbp_get_topic_forum_id() To get the topic forum id
 * @uses update_post_meta() To update the reply metas
 * @uses set_transient() To update the flood check transient for the ip
 * @uses bbp_update_user_last_posted() To update the users last posted time
 * @uses bbp_is_subscriptions_active() To check if the subscriptions feature is
 *                                      activated or not
 * @uses bbp_is_user_subscribed() To check if the user is subscribed
 * @uses bbp_remove_user_subscription() To remove the user's subscription
 * @uses bbp_add_user_subscription() To add the user's subscription
 * @uses bbp_update_reply_forum_id() To update the reply forum id
 * @uses bbp_update_reply_topic_id() To update the reply topic id
 * @uses bbp_update_reply_to() To update the reply to id
 * @uses bbp_update_reply_walker() To update the reply's ancestors' counts
 */
function bbp_update_reply($reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false, $reply_to = 0)
{
    // Validate the ID's passed from 'bbp_new_reply' action
    $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_to = bbp_validate_reply_to($reply_to);
    // Bail if there is no reply
    if (empty($reply_id)) {
        return;
    }
    // Check author_id
    if (empty($author_id)) {
        $author_id = bbp_get_current_user_id();
    }
    // Check topic_id
    if (empty($topic_id)) {
        $topic_id = bbp_get_reply_topic_id($reply_id);
    }
    // Check forum_id
    if (!empty($topic_id) && empty($forum_id)) {
        $forum_id = bbp_get_topic_forum_id($topic_id);
    }
    // If anonymous post, store name, email, website and ip in post_meta.
    // It expects anonymous_data to be sanitized.
    // Check bbp_filter_anonymous_post_data() for sanitization.
    if (!empty($anonymous_data) && is_array($anonymous_data)) {
        // Parse arguments against default values
        $r = bbp_parse_args($anonymous_data, array('bbp_anonymous_name' => '', 'bbp_anonymous_email' => '', 'bbp_anonymous_website' => ''), 'update_reply');
        // Update all anonymous metas
        foreach ($r as $anon_key => $anon_value) {
            update_post_meta($reply_id, '_' . $anon_key, (string) $anon_value, false);
        }
        // Set transient for throttle check (only on new, not edit)
        if (empty($is_edit)) {
            set_transient('_bbp_' . bbp_current_author_ip() . '_last_posted', time());
        }
    } else {
        if (empty($is_edit) && !current_user_can('throttle')) {
            bbp_update_user_last_posted($author_id);
        }
    }
    // Handle Subscription Checkbox
    if (bbp_is_subscriptions_active() && !empty($author_id) && !empty($topic_id)) {
        $subscribed = bbp_is_user_subscribed($author_id, $topic_id);
        $subscheck = !empty($_POST['bbp_topic_subscription']) && 'bbp_subscribe' === $_POST['bbp_topic_subscription'] ? true : false;
        // Subscribed and unsubscribing
        if (true === $subscribed && false === $subscheck) {
            bbp_remove_user_subscription($author_id, $topic_id);
            // Subscribing
        } elseif (false === $subscribed && true === $subscheck) {
            bbp_add_user_subscription($author_id, $topic_id);
        }
    }
    // Reply meta relating to reply position in tree
    bbp_update_reply_forum_id($reply_id, $forum_id);
    bbp_update_reply_topic_id($reply_id, $topic_id);
    bbp_update_reply_to($reply_id, $reply_to);
    // Update associated topic values if this is a new reply
    if (empty($is_edit)) {
        // Update poster IP if not editing
        update_post_meta($reply_id, '_bbp_author_ip', bbp_current_author_ip(), false);
        // Last active time
        $last_active_time = current_time('mysql');
        // Walk up ancestors and do the dirty work
        bbp_update_reply_walker($reply_id, $last_active_time, $forum_id, $topic_id, false);
    }
}
Beispiel #17
0
/**
 * Return the link to subscribe/unsubscribe from a topic
 *
 * @since bbPress (r2668)
 *
 * @param mixed $args This function supports these arguments:
 *  - subscribe: Subscribe text
 *  - unsubscribe: Unsubscribe text
 *  - user_id: User id
 *  - topic_id: Topic id
 *  - before: Before the link
 *  - after: After the link
 * @param int $user_id Optional. User id
 * @uses bbp_get_user_id() To get the user id
 * @uses current_user_can() To check if the current user can edit user
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_user_subscribed() To check if the user is subscribed
 * @uses bbp_is_subscriptions() To check if it's the subscriptions page
 * @uses bbp_get_subscriptions_permalink() To get subscriptions link
 * @uses bbp_get_topic_permalink() To get topic link
 * @uses apply_filters() Calls 'bbp_get_user_subscribe_link' with the
 *                        link, args, user id & topic id
 * @return string Permanent link to topic
 */
function bbp_get_user_subscribe_link($args = '', $user_id = 0)
{
    if (!bbp_is_subscriptions_active()) {
        return;
    }
    $defaults = array('subscribe' => __('Subscribe', 'bbpress'), 'unsubscribe' => __('Unsubscribe', 'bbpress'), 'user_id' => 0, 'topic_id' => 0, 'before' => '&nbsp;|&nbsp;', 'after' => '');
    $args = bbp_parse_args($args, $defaults, 'get_user_subscribe_link');
    extract($args);
    // Validate user and topic ID's
    $user_id = bbp_get_user_id($user_id, true, true);
    $topic_id = bbp_get_topic_id($topic_id);
    if (empty($user_id) || empty($topic_id)) {
        return false;
    }
    // No link if you can't edit yourself
    if (!current_user_can('edit_user', (int) $user_id)) {
        return false;
    }
    // Decine which link to show
    $is_subscribed = bbp_is_user_subscribed($user_id, $topic_id);
    if (!empty($is_subscribed)) {
        $text = $unsubscribe;
        $query_args = array('action' => 'bbp_unsubscribe', 'topic_id' => $topic_id);
    } else {
        $text = $subscribe;
        $query_args = array('action' => 'bbp_subscribe', 'topic_id' => $topic_id);
    }
    // Create the link based where the user is and if the user is
    // subscribed already
    if (bbp_is_subscriptions()) {
        $permalink = bbp_get_subscriptions_permalink($user_id);
    } elseif (is_singular(bbp_get_topic_post_type())) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } elseif (is_singular(bbp_get_reply_post_type())) {
        $permalink = bbp_get_topic_permalink($topic_id);
    } elseif (bbp_is_query_name('bbp_single_topic')) {
        $permalink = get_permalink();
    }
    $url = esc_url(wp_nonce_url(add_query_arg($query_args, $permalink), 'toggle-subscription_' . $topic_id));
    $is_subscribed = $is_subscribed ? 'is-subscribed' : '';
    $html = '<span id="subscription-toggle">' . $before . '<span id="subscribe-' . $topic_id . '" class="' . $is_subscribed . '"><a href="' . $url . '" class="dim:subscription-toggle:subscribe-' . $topic_id . ':is-subscribed">' . $text . '</a></span>' . $after . '</span>';
    // Return the link
    return apply_filters('bbp_get_user_subscribe_link', $html, $args, $user_id, $topic_id);
}
/**
 * Remove a deleted topic from all users' subscriptions
 *
 * @since bbPress (r2652)
 *
 * @param int $topic_id Get the topic id to remove
 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
 * @uses bbp_get_topic_id To get the topic id
 * @uses bbp_get_topic_subscribers() To get the topic subscribers
 * @uses bbp_remove_user_subscription() To remove the user subscription
 */
function bbp_remove_topic_from_all_subscriptions($topic_id = 0)
{
    // Subscriptions are not active
    if (!bbp_is_subscriptions_active()) {
        return;
    }
    $topic_id = bbp_get_topic_id($topic_id);
    // Bail if no topic
    if (empty($topic_id)) {
        return;
    }
    // Get users
    $users = (array) bbp_get_topic_subscribers($topic_id);
    // Users exist
    if (!empty($users)) {
        // Loop through users
        foreach ($users as $user) {
            // Remove each user
            bbp_remove_user_subscription($user, $topic_id);
        }
    }
}
 /**
  * Subscribe/Unsubscribe a user from a topic
  *
  * @since bbPress (r3732)
  *
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses current_user_can() To check if the current user can edit the user
  * @uses bbp_get_topic() To get the topic
  * @uses check_ajax_referer() To verify the nonce & check the referer
  * @uses bbp_is_user_subscribed() To check if the topic is in user's
  *                                 subscriptions
  * @uses bbp_remove_user_subscriptions() To remove the topic from user's
  *                                        subscriptions
  * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions
  */
 public function ajax_subscription()
 {
     if (!bbp_is_subscriptions_active()) {
         return;
     }
     $user_id = bbp_get_current_user_id();
     $id = intval($_POST['id']);
     if (!current_user_can('edit_user', $user_id)) {
         die('-1');
     }
     $topic = bbp_get_topic($id);
     if (empty($topic)) {
         die('0');
     }
     check_ajax_referer('toggle-subscription_' . $topic->ID);
     if (bbp_is_user_subscribed($user_id, $topic->ID)) {
         if (bbp_remove_user_subscription($user_id, $topic->ID)) {
             die('1');
         }
     } else {
         if (bbp_add_user_subscription($user_id, $topic->ID)) {
             die('1');
         }
     }
     die('0');
 }
Beispiel #20
0
							<?php 
        bbp_form_topic_status_dropdown();
        ?>

						</p>

						<?php 
        do_action('bbp_theme_after_topic_form_status');
        ?>

					<?php 
    }
    ?>

					<?php 
    if (bbp_is_subscriptions_active() && !bbp_is_anonymous() && (!bbp_is_topic_edit() || bbp_is_topic_edit() && !bbp_is_topic_anonymous())) {
        ?>

						<?php 
        do_action('bbp_theme_before_topic_form_subscriptions');
        ?>

						<p>
							<input name="bbp_topic_subscription" id="bbp_topic_subscription" type="checkbox" value="bbp_subscribe" <?php 
        bbp_form_topic_subscribed();
        ?>
 tabindex="<?php 
        bbp_tab_index();
        ?>
" />
    /**
     * Displays the output, the login form
     *
     * @since bbPress (r2827)
     *
     * @param mixed $args Arguments
     * @param array $instance Instance
     * @uses apply_filters() Calls 'bbp_login_widget_title' with the title
     * @uses get_template_part() To get the login/logged in form
     */
    public function widget($args = array(), $instance = array())
    {
        // Get widget settings
        $settings = $this->parse_settings($instance);
        // Typical WordPress filter
        $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
        // bbPress filters
        $settings['title'] = apply_filters('bbp_login_widget_title', $settings['title'], $instance, $this->id_base);
        $settings['register'] = apply_filters('bbp_login_widget_register', $settings['register'], $instance, $this->id_base);
        $settings['lostpass'] = apply_filters('bbp_login_widget_lostpass', $settings['lostpass'], $instance, $this->id_base);
        echo $args['before_widget'];
        if (!empty($settings['title'])) {
            echo $args['before_title'] . $settings['title'] . $args['after_title'];
        }
        if (!is_user_logged_in()) {
            ?>
			<form method="post" action="<?php 
            bbp_wp_login_action(array('context' => 'login_post'));
            ?>
" class="bbp-login-form">
				<fieldset>
					<legend><?php 
            _e('Log In', 'bbpress');
            ?>
</legend>

					<div class="bbp-username form-group">
						<label for="user_login" class="sr-only"><?php 
            _e('Username', 'bbpress');
            ?>
: </label>
						<div class="input-group">
							<span class="input-group-addon">
								<span class="glyphicon ipt-icomoon-user"></span>
							</span>
							<input placeholder="<?php 
            _e('Username', 'bbpress');
            ?>
" class="form-control" type="text" name="log" value="<?php 
            bbp_sanitize_val('user_login', 'text');
            ?>
" size="20" id="user_login" tabindex="<?php 
            bbp_tab_index();
            ?>
" />
						</div>
					</div>

					<div class="bbp-password form-group">
						<label for="user_pass" class="sr-only"><?php 
            _e('Password', 'bbpress');
            ?>
: </label>
						<div class="input-group">
							<span class="input-group-addon">
								<span class="glyphicon ipt-icomoon-console"></span>
							</span>
							<input placeholder="<?php 
            _e('Password', 'bbpress');
            ?>
" class="form-control" type="password" name="pwd" value="<?php 
            bbp_sanitize_val('user_pass', 'password');
            ?>
" size="20" id="user_pass" tabindex="<?php 
            bbp_tab_index();
            ?>
" />
						</div>
					</div>

					<?php 
            do_action('login_form');
            ?>

					<div class="bbp-remember-me checkbox">
						<input type="checkbox" name="rememberme" value="forever" <?php 
            checked(bbp_get_sanitize_val('rememberme', 'checkbox'), true, true);
            ?>
 id="rememberme" tabindex="<?php 
            bbp_tab_index();
            ?>
" />
						<label for="rememberme"><?php 
            _e('Remember Me', 'bbpress');
            ?>
</label>
					</div>

					<div class="bbp-submit-wrapper btn-group">
						<?php 
            if (!empty($settings['lostpass'])) {
                ?>
							<a href="<?php 
                echo esc_url($settings['lostpass']);
                ?>
" title="<?php 
                esc_attr_e('Lost Password', 'bbpress');
                ?>
" class="bbp-lostpass-link btn btn-default"><span class="glyphicon ipt-icomoon-info"></span></a>
						<?php 
            }
            ?>
						<?php 
            if (!empty($settings['register'])) {
                ?>
							<a href="<?php 
                echo esc_url($settings['register']);
                ?>
" title="<?php 
                esc_attr_e('Register', 'bbpress');
                ?>
" class="bbp-register-link btn btn-default"><span class="glyphicon ipt-icomoon-signup"></span> <?php 
                _e('Register', 'bbpress');
                ?>
</a>
						<?php 
            }
            ?>
						<button class="btn btn-primary" type="submit" name="user-submit" id="user-submit" tabindex="<?php 
            bbp_tab_index();
            ?>
" class="button submit user-submit"><span class="glyphicon ipt-icomoon-switch"></span> <?php 
            _e('Log In', 'bbpress');
            ?>
</button>
					</div>
					<?php 
            bbp_user_login_fields();
            ?>
				</fieldset>
			</form>

		<?php 
        } else {
            ?>

			<div class="bbp-logged-in">
				<a href="<?php 
            bbp_user_profile_url(bbp_get_current_user_id());
            ?>
" class="submit user-submit thumbnail pull-left"><?php 
            echo get_avatar(bbp_get_current_user_id(), '64');
            ?>
</a>
				<h4><?php 
            bbp_user_profile_link(bbp_get_current_user_id());
            ?>
</h4>
				<div class="btn-group">
					<a class="btn btn-default btn-sm" href="<?php 
            bbp_user_profile_edit_url(bbp_get_current_user_id());
            ?>
" title="<?php 
            printf(esc_attr__("Edit Your Profile", 'ipt_kb'));
            ?>
"><span class="glyphicon glyphicon-edit"></span> <?php 
            _e('Edit', 'bbpress');
            ?>
</a>
					<?php 
            bbp_logout_link();
            ?>
				</div>

				<div class="clearfix"></div>

				<div class="list-group">
					<a href="<?php 
            bbp_user_profile_url(bbp_get_current_user_id());
            ?>
" class="list-group-item bbp-user-forum-role <?php 
            if (bbp_is_user_home() && bbp_is_single_user_profile()) {
                echo 'active';
            }
            ?>
">
						<span class="glyphicon ipt-icomoon-user4"></span> <?php 
            printf(__('%s Forum Role', 'ipt_kb'), '<span class="badge">' . bbp_get_user_display_role(bbp_get_current_user_id()) . '</span>');
            ?>
					</a>
					<a href="<?php 
            bbp_user_topics_created_url(bbp_get_current_user_id());
            ?>
" class="list-group-item bbp-user-topic-count <?php 
            if (bbp_is_user_home() && bbp_is_single_user_topics()) {
                echo 'active';
            }
            ?>
">
						<span class="glyphicon ipt-icomoon-bubbles4"></span> <?php 
            printf(__('%s Topics Started', 'ipt_kb'), '<span class="badge">' . bbp_get_user_topic_count_raw(bbp_get_current_user_id()) . '</span>');
            ?>
					</a>
					<a href="<?php 
            bbp_user_replies_created_url(bbp_get_current_user_id());
            ?>
" class="list-group-item bbp-user-reply-count <?php 
            if (bbp_is_user_home() && bbp_is_single_user_replies()) {
                echo 'active';
            }
            ?>
">
						<span class="glyphicon ipt-icomoon-reply"></span> <?php 
            printf(__('%s Replies Created', 'ipt_kb'), '<span class="badge">' . bbp_get_user_reply_count_raw(bbp_get_current_user_id()) . '</span>');
            ?>
					</a>
					<?php 
            if (bbp_is_favorites_active()) {
                ?>
					<a href="<?php 
                bbp_favorites_permalink(bbp_get_current_user_id());
                ?>
" class="list-group-item bbp-user-favorite-count <?php 
                if (bbp_is_user_home() && bbp_is_favorites()) {
                    echo 'active';
                }
                ?>
" title="<?php 
                printf(esc_attr__("Your Favorites", 'ipt_kb'));
                ?>
">
						<span class="glyphicon ipt-icomoon-heart"></span> <?php 
                printf(__('%s Favorites', 'ipt_kb'), '<span class="badge">' . count(bbp_get_user_favorites_topic_ids(bbp_get_current_user_id())) . '</span>');
                ?>
					</a>
					<?php 
            }
            ?>
					<?php 
            if (bbp_is_subscriptions_active()) {
                ?>
					<a href="<?php 
                bbp_subscriptions_permalink(bbp_get_current_user_id());
                ?>
" class="list-group-item bbp-user-subscribe-count <?php 
                if (bbp_is_user_home() && bbp_is_subscriptions()) {
                    echo 'active';
                }
                ?>
" title="<?php 
                printf(esc_attr__("Your Subscriptions", 'ipt_kb'));
                ?>
">
						<span class="glyphicon ipt-icomoon-bookmarks"></span> <?php 
                printf(__('%s Subscriptions', 'ipt_kb'), '<span class="badge">' . count(bbp_get_user_subscribed_topic_ids(bbp_get_current_user_id())) . '</span>');
                ?>
					</a>
					<?php 
            }
            ?>
				</div>
			</div>

		<?php 
        }
        echo $args['after_widget'];
    }
" size="40" name="bbp_topic_tags" id="bbp_topic_tags" <?php 
        disabled(bbp_is_topic_spam());
        ?>
 />
						</p>

						<?php 
        do_action('bbp_theme_after_reply_form_tags');
        ?>

					<?php 
    }
    ?>

					<?php 
    if (bbp_is_subscriptions_active() && !bbp_is_anonymous() && (!bbp_is_reply_edit() || bbp_is_reply_edit() && !bbp_is_reply_anonymous())) {
        ?>

						<?php 
        do_action('bbp_theme_before_reply_form_subscription');
        ?>

						<p>

							<input name="bbp_topic_subscription" id="bbp_topic_subscription" type="checkbox" value="bbp_subscribe"<?php 
        bbp_form_topic_subscribed();
        ?>
 tabindex="<?php 
        bbp_tab_index();
        ?>
" />
 /**
  * Override bbPress profile URL with BuddyPress profile URL
  *
  * @since bbPress (r3401)
  * @param string $url
  * @param int $user_id
  * @param string $user_nicename
  * @return string
  */
 public function user_profile_url($user_id)
 {
     // Define local variable(s)
     $profile_url = '';
     // Special handling for forum component
     if (bp_is_current_component('forums')) {
         // Empty action or 'topics' action
         if (!bp_current_action() || bp_is_current_action('topics')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/topics';
             // Empty action or 'topics' action
         } elseif (bp_is_current_action('replies')) {
             $profile_url = bp_core_get_user_domain($user_id) . 'forums/replies';
             // 'favorites' action
         } elseif (bbp_is_favorites_active() && bp_is_current_action('favorites')) {
             $profile_url = $this->get_favorites_permalink('', $user_id);
             // 'subscriptions' action
         } elseif (bbp_is_subscriptions_active() && bp_is_current_action('subscriptions')) {
             $profile_url = $this->get_subscriptions_permalink('', $user_id);
         }
         // Not in users' forums area
     } else {
         $profile_url = bp_core_get_user_domain($user_id);
     }
     return trailingslashit($profile_url);
 }