function messages_notification_new_message($args = array())
{
    // These should be extracted below
    $recipients = array();
    $email_subject = $email_content = '';
    extract($args);
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Bail if no recipients
    if (!empty($recipients)) {
        foreach ($recipients as $recipient) {
            if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
                continue;
            }
            // User data and links
            $ud = get_userdata($recipient->user_id);
            // Bail if user cannot be found
            if (empty($ud)) {
                continue;
            }
            $message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
            // Sender info
            $sender_name = stripslashes($sender_name);
            $subject = stripslashes(wp_filter_kses($subject));
            $content = stripslashes(wp_filter_kses($content));
            // Set up and send the message
            $email_to = $ud->user_email;
            $email_subject = bp_get_email_subject(array('text' => sprintf(__('New message from %s', 'buddypress'), $sender_name)));
            $email_content = sprintf(__('%1$s sent you a new message:

Subject: %2$s

"%3$s"

To view and read your messages please log in and visit: %4$s

---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
            // Only show the disable notifications line if the settings component is enabled
            if (bp_is_active('settings')) {
                $email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            }
            // Send the message
            $email_to = apply_filters('messages_notification_new_message_to', $email_to);
            $email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
            $email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
            wp_mail($email_to, $email_subject, $email_content);
        }
    }
    do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
function messages_notification_new_message($args = array())
{
    // These should be extracted below
    $recipients = array();
    $email_subject = $email_content = '';
    extract($args);
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Bail if no recipients
    if (!empty($recipients)) {
        foreach ($recipients as $recipient) {
            if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
                continue;
            }
            // User data and links
            $ud = get_userdata($recipient->user_id);
            $message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
            $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
            $settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
            // Sender info
            $sender_name = stripslashes($sender_name);
            $subject = stripslashes(wp_filter_kses($subject));
            $content = stripslashes(wp_filter_kses($content));
            // Set up and send the message
            $email_to = $ud->user_email;
            $sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
            $email_subject = '[' . $sitename . '] ' . sprintf(__('New message from %s', 'buddypress'), $sender_name);
            $email_content = sprintf(__('%1$s sent you a new message:

Subject: %2$s

"%3$s"

To view and read your messages please log in and visit: %4$s

---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
            $email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
            // Send the message
            $email_to = apply_filters('messages_notification_new_message_to', $email_to);
            $email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
            $email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
            wp_mail($email_to, $email_subject, $email_content);
        }
    }
    do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
function messages_action_bulk_delete()
{
    if (!bp_is_messages_component() || !bp_is_action_variable('bulk-delete', 0)) {
        return false;
    }
    $thread_ids = $_POST['thread_ids'];
    if (!$thread_ids || !messages_check_thread_access($thread_ids)) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action()));
    } else {
        if (!check_admin_referer('messages_delete_thread')) {
            return false;
        }
        if (!messages_delete_thread($thread_ids)) {
            bp_core_add_message(__('There was an error deleting messages.', 'buddypress'), 'error');
        } else {
            bp_core_add_message(__('Messages deleted.', 'buddypress'));
        }
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action()));
    }
}
Пример #4
0
<div class="cb-login-modal clearfix <?php 
echo $cb_menu_color;
?>
">
    <div class="lwa cb-logged-in clearfix">

<?php 
if (class_exists('buddypress')) {
    global $bp;
    $cb_buddypress_current_user_id = $bp->loggedin_user->id;
    if (function_exists('bp_get_groups_root_slug')) {
        $cb_buddypress_user_group_link = bp_loggedin_user_domain() . bp_get_groups_root_slug();
    }
    if (function_exists('bp_get_messages_slug')) {
        $cb_buddypress_user_message_link = bp_loggedin_user_domain() . bp_get_messages_slug();
    }
    if (function_exists('bp_get_activity_slug')) {
        $cb_buddypress_user_activity_link = bp_loggedin_user_domain() . bp_get_activity_slug();
    }
    $cb_buddypress_user_avatar = bp_core_fetch_avatar(array('item_id' => $cb_buddypress_current_user_id, 'type' => 'full', 'width' => 120, 'height' => 120));
    $cb_buddypress_mystery_man = 'mystery-man.jpg';
    $cb_buddypress_avatar_check = strpos($cb_buddypress_user_avatar, $cb_buddypress_mystery_man);
    if ($cb_buddypress_avatar_check === false) {
        $cb_buddypress_final_avatar = $cb_buddypress_user_avatar;
    } else {
        $cb_buddypress_final_avatar = get_avatar($cb_author_id, $size = '150');
    }
    ?>
        
        <div class="cb-header">
Пример #5
0
/**
 * Format notifications for the Messages component.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param string $action The kind of notification being rendered.
 * @param int $item_id The primary item id.
 * @param int $secondary_item_id The secondary item id.
 * @param int $total_items The total number of messaging-related notifications
 *        waiting for the user
 * @param string $format Return value format. 'string' for BuddyBar-compatible
 *        notifications; 'array' for WP Toolbar. Default: 'string'.
 * @return string|array Formatted notifications.
 */
function messages_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    $total_items = (int) $total_items;
    $link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox');
    $title = __('Inbox', 'buddypress');
    if ('new_message' === $action) {
        if ($total_items > 1) {
            $text = sprintf(__('You have %d new messages', 'buddypress'), $total_items);
            $filter = 'bp_messages_multiple_new_message_notification';
        } else {
            // get message thread ID
            $message = new BP_Messages_Message($item_id);
            $thread_id = $message->thread_id;
            $link = !empty($thread_id) ? bp_get_message_thread_view_link($thread_id) : false;
            if (!empty($secondary_item_id)) {
                $text = sprintf(__('%s sent you a new private message', 'buddypress'), bp_core_get_user_displayname($secondary_item_id));
            } else {
                $text = sprintf(_n('You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress'), bp_core_number_format($total_items));
            }
            $filter = 'bp_messages_single_new_message_notification';
        }
    }
    if ('string' === $format) {
        if (!empty($link)) {
            $retval = '<a href="' . esc_url($link) . '" title="' . esc_attr($title) . '">' . esc_html($text) . '</a>';
        } else {
            $retval = esc_html($text);
        }
        $return = apply_filters($filter, $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
    } else {
        $return = apply_filters($filter, array('text' => $text, 'link' => $link), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
    }
    do_action('messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
Пример #6
0
										</span>
									</a>
									</li>
									<?php 
        if ($count == 5) {
            break;
        }
        ?>
									<?php 
    }
    ?>
									<?php 
}
?>
									<li class="new"><a href="<?php 
echo bp_loggedin_user_domain() . bp_get_messages_slug();
?>
">Read All Messages</a></li>
								</ul>
							</div>
						</div>
					</li>
					<li>
						<div class="btn-group">
							<button class="btn btn-default dropdown-toggle tp-icon"
								data-toggle="dropdown">
								<i class="glyphicon glyphicon-globe"></i> <span class="badge"><?php 
echo bp_notifications_get_unread_notification_count();
?>
</span>
							</button>
Пример #7
0
 function test_member_messages_notices()
 {
     $this->go_to(bp_core_get_user_domain(bp_loggedin_user_id()) . bp_get_messages_slug() . '/notices');
     $this->assertTrue(bp_is_notices());
 }
function messages_screen_notices()
{
    global $notice_id;
    if (!is_super_admin()) {
        return false;
    }
    $notice_id = (int) bp_action_variable(1);
    if (!empty($notice_id) && is_numeric($notice_id)) {
        $notice = new BP_Messages_Notice($notice_id);
        if (bp_is_action_variable('deactivate', 0)) {
            if (!$notice->deactivate()) {
                bp_core_add_message(__('There was a problem deactivating that notice.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Notice deactivated.', 'buddypress'));
            }
        } else {
            if (bp_is_action_variable('activate', 0)) {
                if (!$notice->activate()) {
                    bp_core_add_message(__('There was a problem activating that notice.', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Notice activated.', 'buddypress'));
                }
            } else {
                if (bp_is_action_variable('delete')) {
                    if (!$notice->delete()) {
                        bp_core_add_message(__('There was a problem deleting that notice.', 'buddypress'), 'buddypress');
                    } else {
                        bp_core_add_message(__('Notice deleted.', 'buddypress'));
                    }
                }
            }
        }
        bp_core_redirect(bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices');
    }
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    do_action('messages_screen_notices');
    bp_core_load_template(apply_filters('messages_template_notices', 'members/single/home'));
}
Пример #9
0
 /**
  * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
  * Create your own kleo_entry_meta() to override in a child theme.
  * @since 1.0
  */
 function kleo_entry_meta($echo = true, $att = array())
 {
     global $kleo_config;
     $meta_list = array();
     $author_links = '';
     $meta_elements = sq_option('blog_meta_elements', $kleo_config['blog_meta_defaults']);
     // Translators: used between list items, there is a space after the comma.
     if (in_array('categories', $meta_elements)) {
         $categories_list = get_the_category_list(__(', ', 'kleo_framework'));
     }
     // Translators: used between list items, there is a space after the comma.
     if (in_array('tags', $meta_elements)) {
         $tag_list = get_the_tag_list('', __(', ', 'kleo_framework'));
     }
     $date = sprintf('<a href="%1$s" rel="bookmark" class="post-time">' . '<time class="entry-date" datetime="%2$s">%3$s</time>' . '<time class="modify-date hide hidden updated" datetime="%4$s">%5$s</time>' . '</a>', esc_url(get_permalink()), esc_attr(get_the_date('c')), esc_html(get_the_date()), esc_html(get_the_modified_date('c')), esc_html(get_the_modified_date()));
     if (is_array($meta_elements) && !empty($meta_elements)) {
         if (in_array('author_link', $meta_elements) || in_array('avatar', $meta_elements)) {
             /* If buddypress is active then create a link to Buddypress profile instead */
             if (function_exists('bp_is_active')) {
                 $author_link = esc_url(bp_core_get_userlink(get_the_author_meta('ID'), $no_anchor = false, $just_link = true));
                 $author_title = esc_attr(sprintf(__('View %s\'s profile', 'kleo_framework'), get_the_author()));
             } else {
                 $author_link = esc_url(get_author_posts_url(get_the_author_meta('ID')));
                 $author_title = esc_attr(sprintf(__('View all POSTS by %s', 'kleo_framework'), get_the_author()));
             }
             $author = sprintf('<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s %4$s</a>', $author_link, $author_title, in_array('avatar', $meta_elements) ? get_avatar(get_the_author_meta('ID'), 50) : '', in_array('author_link', $meta_elements) ? '<span class="author-name">' . get_the_author() . '</span>' : '');
             $meta_list[] = '<small class="meta-author author vcard">' . $author . '</small>';
         }
         if (function_exists('bp_is_active')) {
             if (in_array('profile', $meta_elements)) {
                 $author_links .= '<a href="' . bp_core_get_userlink(get_the_author_meta('ID'), $no_anchor = false, $just_link = true) . '">' . '<i class="icon-user-1 hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View profile', 'kleo_framework'), get_the_author())) . '"' . 'data-toggle="tooltip"' . 'data-placement="top"></i>' . '</a>';
             }
             if (bp_is_active('messages')) {
                 if (in_array('message', $meta_elements)) {
                     $author_links .= '<a href="' . wp_nonce_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username(get_the_author_meta('ID'))) . '">' . '<i class="icon-mail hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('Contact %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>';
                 }
             }
         }
         if (in_array('archive', $meta_elements)) {
             $author_links .= '<a href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . '<i class="icon-docs hover-tip" ' . 'data-original-title="' . esc_attr(sprintf(__('View all posts by %s', 'kleo_framework'), get_the_author())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a>';
         }
     }
     if ($author_links != '') {
         $meta_list[] = '<small class="meta-links">' . $author_links . '</small>';
     }
     if (in_array('date', $meta_elements)) {
         $meta_list[] = '<small>' . $date . '</small>';
     }
     $cat_tag = array();
     if (isset($categories_list) && $categories_list) {
         $cat_tag[] = $categories_list;
     }
     if (isset($tag_list) && $tag_list) {
         $cat_tag[] = $tag_list;
     }
     if (!empty($cat_tag)) {
         $meta_list[] = '<small class="meta-category">' . implode(", ", $cat_tag) . '</small>';
     }
     //comments
     if ((!isset($att['comments']) || isset($att['comments']) && $att['comments'] !== false) && in_array('comments', $meta_elements)) {
         $meta_list[] = '<small class="meta-comment-count"><a href="' . get_permalink() . '#comments">' . get_comments_number() . ' <i class="icon-chat-1 hover-tip" ' . 'data-original-title="' . sprintf(_n('This article has one comment', 'This article has %1$s comments', get_comments_number(), 'kleo_framework'), number_format_i18n(get_comments_number())) . '" ' . 'data-toggle="tooltip" ' . 'data-placement="top"></i>' . '</a></small>';
     }
     $meta_separator = isset($att['separator']) ? $att['separator'] : sq_option('blog_meta_sep', ', ');
     if ($echo) {
         echo implode($meta_separator, $meta_list);
     } else {
         return implode($meta_separator, $meta_list);
     }
 }
/**
 * AJAX handler for autocomplete.
 *
 * Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
 *
 * @since BuddyPress (1.2.0)
 *
 * @return string HTML.
 */
function bp_legacy_theme_ajax_messages_autocomplete_results()
{
    // Include everyone in the autocomplete, or just friends?
    if (bp_is_current_component(bp_get_messages_slug())) {
        $autocomplete_all = buddypress()->messages->autocomplete_all;
    }
    $pag_page = 1;
    $limit = (int) $_GET['limit'] ? $_GET['limit'] : apply_filters('bp_autocomplete_max_results', 10);
    $search_terms = isset($_GET['q']) ? $_GET['q'] : '';
    $user_query_args = array('search_terms' => $search_terms, 'page' => intval($pag_page), 'per_page' => intval($limit));
    // If only matching against friends, get an $include param for
    // BP_User_Query
    if (!$autocomplete_all && bp_is_active('friends')) {
        $include = BP_Friends_Friendship::get_friend_user_ids(bp_loggedin_user_id());
        // Ensure zero matches if no friends are found
        if (empty($include)) {
            $include = array(0);
        }
        $user_query_args['include'] = $include;
    }
    $user_query = new BP_User_Query($user_query_args);
    // Backward compatibility - if a plugin is expecting a legacy
    // filter, pass the IDs through the filter and requery (groan)
    if (has_filter('bp_core_autocomplete_ids') || has_filter('bp_friends_autocomplete_ids')) {
        $found_user_ids = wp_list_pluck($user_query->results, 'ID');
        if ($autocomplete_all) {
            $found_user_ids = apply_filters('bp_core_autocomplete_ids', $found_user_ids);
        } else {
            $found_user_ids = apply_filters('bp_friends_autocomplete_ids', $found_user_ids);
        }
        if (empty($found_user_ids)) {
            $found_user_ids = array(0);
        }
        // Repopulate the $user_query variable
        $user_query = new BP_User_Query(array('include' => $found_user_ids));
    }
    if (!empty($user_query->results)) {
        foreach ($user_query->results as $user) {
            if (bp_is_username_compatibility_mode()) {
                // Sanitize for spaces. Use urlencode() rather
                // than rawurlencode() because %20 breaks JS
                $username = urlencode($user->user_login);
            } else {
                $username = $user->user_nicename;
            }
            // Note that the final line break acts as a delimiter for the
            // autocomplete javascript and thus should not be removed
            echo '<span id="link-' . esc_attr($username) . '" href="' . bp_core_get_user_domain($user->ID) . '"></span>' . bp_core_fetch_avatar(array('item_id' => $user->ID, 'type' => 'thumb', 'width' => 15, 'height' => 15, 'alt' => $user->display_name)) . ' &nbsp;' . bp_core_get_user_displayname($user->ID) . ' (' . esc_html($username) . ')' . "\n";
        }
    }
    exit;
}
/**
 * Format notifications for the Messages component.
 *
 * @since 1.0.0
 *
 * @param string $action            The kind of notification being rendered.
 * @param int    $item_id           The primary item id.
 * @param int    $secondary_item_id The secondary item id.
 * @param int    $total_items       The total number of messaging-related notifications
 *                                  waiting for the user.
 * @param string $format            Return value format. 'string' for BuddyBar-compatible
 *                                  notifications; 'array' for WP Toolbar. Default: 'string'.
 * @return string|array Formatted notifications.
 */
function messages_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    $total_items = (int) $total_items;
    $text = '';
    $link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox');
    $title = __('Inbox', 'buddypress');
    $amount = 'single';
    if ('new_message' === $action) {
        if ($total_items > 1) {
            $amount = 'multiple';
            $text = sprintf(__('You have %d new messages', 'buddypress'), $total_items);
        } else {
            // Get message thread ID.
            $message = new BP_Messages_Message($item_id);
            $thread_id = $message->thread_id;
            $link = !empty($thread_id) ? bp_get_message_thread_view_link($thread_id) : false;
            if (!empty($secondary_item_id)) {
                $text = sprintf(__('%s sent you a new private message', 'buddypress'), bp_core_get_user_displayname($secondary_item_id));
            } else {
                $text = sprintf(_n('You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress'), bp_core_number_format($total_items));
            }
        }
        if ('string' === $format) {
            if (!empty($link)) {
                $return = '<a href="' . esc_url($link) . '" title="' . esc_attr($title) . '">' . esc_html($text) . '</a>';
            } else {
                $return = esc_html($text);
            }
            /**
             * Filters the new message notification text before the notification is created.
             *
             * This is a dynamic filter. Possible filter names are:
             *   - 'bp_messages_multiple_new_message_notification'.
             *   - 'bp_messages_single_new_message_notification'.
             *
             * @param string $return            Notification text.
             * @param int    $total_items       Number of messages referred to by the notification.
             * @param string $text              The raw notification test (ie, not wrapped in a link).
             * @param int    $item_id           ID of the associated item.
             * @param int    $secondary_item_id ID of the secondary associated item.
             */
            $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
        } else {
            /** This filter is documented in bp-messages/bp-messages-notifications.php */
            $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', array('text' => $text, 'link' => $link), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
        }
        // Custom notification action for the Messages component
    } else {
        if ('string' === $format) {
            $return = $text;
        } else {
            $return = array('text' => $text, 'link' => $link);
        }
        /**
         * Backcompat for plugins that used to filter bp_messages_single_new_message_notification
         * for their custom actions. These plugins should now use 'bp_messages_' . $action . '_notification'
         */
        if (has_filter('bp_messages_single_new_message_notification')) {
            if ('string' === $format) {
                /** This filter is documented in bp-messages/bp-messages-notifications.php */
                $return = apply_filters('bp_messages_single_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
                // Notice that there are seven parameters instead of six? Ugh...
            } else {
                /** This filter is documented in bp-messages/bp-messages-notifications.php */
                $return = apply_filters('bp_messages_single_new_message_notification', $return, $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
            }
        }
        /**
         * Filters the custom action notification before the notification is created.
         *
         * This is a dynamic filter based on the message notification action.
         *
         * @since 2.6.0
         *
         * @param array  $value             An associative array containing the text and the link of the notification
         * @param int    $item_id           ID of the associated item.
         * @param int    $secondary_item_id ID of the secondary associated item.
         * @param int    $total_items       Number of messages referred to by the notification.
         * @param string $format            Return value format. 'string' for BuddyBar-compatible
         *                                  notifications; 'array' for WP Toolbar. Default: 'string'.
         */
        $return = apply_filters("bp_messages_{$action}_notification", $return, $item_id, $secondary_item_id, $total_items, $format);
    }
    /**
     * Fires right before returning the formatted message notifications.
     *
     * @since 1.0.0
     *
     * @param string $action            The type of message notification.
     * @param int    $item_id           The primary item ID.
     * @param int    $secondary_item_id The secondary item ID.
     * @param int    $total_items       Total amount of items to format.
     */
    do_action('messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
Пример #12
0
function bp_get_send_private_message_link()
{
    if (bp_is_my_profile() || !is_user_logged_in()) {
        return false;
    }
    return apply_filters('bp_get_send_private_message_link', wp_nonce_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username(bp_displayed_user_id())));
}
 function private_message_super_admin_override()
 {
     if (!isset($_GET['bpmSuperAdminOverridePrivateMessage']) || !is_super_admin()) {
         return;
     }
     check_admin_referer('bpmSuperAdminOverridePrivateMessage');
     $thread_id = (int) bp_action_variable(0);
     bp_core_new_subnav_item(array('name' => sprintf(__('Review message by %s', 'bp-moderation'), bp_get_displayed_user_username()), 'slug' => 'view', 'parent_url' => trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()), 'parent_slug' => bp_get_messages_slug(), 'screen_function' => true, 'position' => 40, 'user_has_access' => is_super_admin(), 'link' => bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . (int) $thread_id));
     bp_core_load_template(apply_filters('messages_template_view_message', 'members/single/home'));
     die;
 }
Пример #14
0
/**
 * Output the messages component slug
 *
 * @package BuddyPress
 * @subpackage Messages Template
 * @since 1.5
 *
 * @uses bp_get_messages_slug()
 */
function bp_messages_slug()
{
    echo bp_get_messages_slug();
}
/**
 * Email message recipients to alert them of a new unread private message.
 *
 * @since 1.0.0
 *
 * @param array|BP_Messages_Message $raw_args {
 *     Array of arguments. Also accepts a BP_Messages_Message object.
 *     @type array  $recipients    User IDs of recipients.
 *     @type string $email_subject Subject line of message.
 *     @type string $email_content Content of message.
 *     @type int    $sender_id     User ID of sender.
 * }
 */
function messages_notification_new_message($raw_args = array())
{
    if (is_object($raw_args)) {
        $args = (array) $raw_args;
    } else {
        $args = $raw_args;
    }
    // These should be extracted below.
    $recipients = array();
    $email_subject = $email_content = '';
    $sender_id = 0;
    // Barf.
    extract($args);
    if (empty($recipients)) {
        return;
    }
    $sender_name = bp_core_get_user_displayname($sender_id);
    // Send an email to each recipient.
    foreach ($recipients as $recipient) {
        if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
            continue;
        }
        // User data and links.
        $ud = get_userdata($recipient->user_id);
        if (empty($ud)) {
            continue;
        }
        $unsubscribe_args = array('user_id' => $recipient->user_id, 'notification_type' => 'messages-unread');
        $args = array('tokens' => array('usermessage' => wp_strip_all_tags(stripslashes($message)), 'message.url' => esc_url(bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/view/' . $thread_id . '/'), 'sender.name' => $sender_name, 'usersubject' => sanitize_text_field(stripslashes($subject)), 'unsubscribe' => esc_url(bp_email_get_unsubscribe_link($unsubscribe_args))));
        bp_send_email('messages-unread', $ud, $args);
    }
    /**
     * Fires after the sending of a new message email notification.
     *
     * @since 1.5.0
     * @deprecated 2.5.0 Use the filters in BP_Email.
     *                   $email_subject and $email_content arguments unset and deprecated.
     *
     * @param array  $recipients    User IDs of recipients.
     * @param string $email_subject Deprecated in 2.5; now an empty string.
     * @param string $email_content Deprecated in 2.5; now an empty string.
     * @param array  $args          Array of originally provided arguments.
     */
    do_action('bp_messages_sent_notification_email', $recipients, '', '', $args);
}
Пример #16
0
/**
 * Load the Messages > Notices screen.
 *
 * @return false|null False on failure.
 */
function messages_screen_notices()
{
    global $notice_id;
    if (!bp_current_user_can('bp_moderate')) {
        return false;
    }
    $notice_id = (int) bp_action_variable(1);
    if (!empty($notice_id) && is_numeric($notice_id)) {
        $notice = new BP_Messages_Notice($notice_id);
        if (bp_is_action_variable('deactivate', 0)) {
            if (!$notice->deactivate()) {
                bp_core_add_message(__('There was a problem deactivating that notice.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Notice deactivated.', 'buddypress'));
            }
        } elseif (bp_is_action_variable('activate', 0)) {
            if (!$notice->activate()) {
                bp_core_add_message(__('There was a problem activating that notice.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Notice activated.', 'buddypress'));
            }
        } elseif (bp_is_action_variable('delete')) {
            if (!$notice->delete()) {
                bp_core_add_message(__('There was a problem deleting that notice.', 'buddypress'), 'buddypress');
            } else {
                bp_core_add_message(__('Notice deleted.', 'buddypress'));
            }
        }
        bp_core_redirect(trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices'));
    }
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    /**
     * Fires right before the loading of the Messages notices screen template file.
     *
     * @since BuddyPress (1.0.0)
     */
    do_action('messages_screen_notices');
    /**
     * Filters the template to load for the Messages notices screen.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $template Path to the messages template to load.
     */
    bp_core_load_template(apply_filters('messages_template_notices', 'members/single/home'));
}
/**
 * Bulk manage handler to set the star status for multiple messages.
 *
 * @since 2.3.0
 */
function bp_messages_star_bulk_manage_handler()
{
    if (empty($_POST['messages_bulk_nonce'])) {
        return;
    }
    // Check the nonce.
    if (!wp_verify_nonce($_POST['messages_bulk_nonce'], 'messages_bulk_nonce')) {
        return;
    }
    // Check capability.
    if (!is_user_logged_in() || !bp_core_can_edit_settings()) {
        return;
    }
    $action = !empty($_POST['messages_bulk_action']) ? $_POST['messages_bulk_action'] : '';
    $threads = !empty($_POST['message_ids']) ? $_POST['message_ids'] : '';
    $threads = wp_parse_id_list($threads);
    // Bail if action doesn't match our star actions or no IDs.
    if (false === in_array($action, array('star', 'unstar'), true) || empty($threads)) {
        return;
    }
    // It's star time!
    switch ($action) {
        case 'star':
            $count = count($threads);
            // If we're starring a thread, we only star the first message in the thread.
            foreach ($threads as $thread) {
                $thread = new BP_Messages_thread($thread);
                $mids = wp_list_pluck($thread->messages, 'id');
                bp_messages_star_set_action(array('action' => 'star', 'message_id' => $mids[0]));
            }
            bp_core_add_message(sprintf(_n('%s message was successfully starred', '%s messages were successfully starred', $count, 'buddypress'), $count));
            break;
        case 'unstar':
            $count = count($threads);
            foreach ($threads as $thread) {
                bp_messages_star_set_action(array('action' => 'unstar', 'thread_id' => $thread, 'bulk' => true));
            }
            bp_core_add_message(sprintf(_n('%s message was successfully unstarred', '%s messages were successfully unstarred', $count, 'buddypress'), $count));
            break;
    }
    // Redirect back to message box.
    bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/');
    die;
}
/**
 * Format the BuddyBar/Toolbar notifications for the Messages component
 *
 * @package BuddyPress
 *
 * @param string $action The kind of notification being rendered
 * @param int $item_id The primary item id
 * @param int $secondary_item_id The secondary item id
 * @param int $total_items The total number of messaging-related notifications waiting for the user
 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' for WP Toolbar
 */
function messages_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    if ('new_message' == $action) {
        $link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox');
        $title = __('Inbox', 'buddypress');
        if ((int) $total_items > 1) {
            $text = sprintf(__('You have %d new messages', 'buddypress'), (int) $total_items);
            $filter = 'bp_messages_multiple_new_message_notification';
        } else {
            $text = sprintf(__('You have %d new message', 'buddypress'), (int) $total_items);
            $filter = 'bp_messages_single_new_message_notification';
        }
    }
    if ('string' == $format) {
        $return = apply_filters($filter, '<a href="' . $link . '" title="' . $title . '">' . $text . '</a>', (int) $total_items, $text, $link);
    } else {
        $return = apply_filters($filter, array('text' => $text, 'link' => $link), $link, (int) $total_items, $text, $link);
    }
    do_action('messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
Пример #19
0
function filter_message_button_link($link)
{
    $link = wp_nonce_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username(bp_get_member_user_id()));
    return $link;
}
Пример #20
0
/**
 * Load an individual conversation screen.
 *
 * @since BuddyPress (1.0.0)
 *
 * @return bool|null False on failure.
 */
function messages_screen_conversation()
{
    // Bail if not viewing a single message
    if (!bp_is_messages_component() || !bp_is_current_action('view')) {
        return false;
    }
    $thread_id = (int) bp_action_variable(0);
    if (empty($thread_id) || !messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !bp_current_user_can('bp_moderate')) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()));
    }
    // Load up BuddyPress one time
    $bp = buddypress();
    // Decrease the unread count in the nav before it's rendered
    $bp->bp_nav[$bp->messages->slug]['name'] = sprintf(__('Messages <span>%s</span>', 'buddypress'), bp_get_total_unread_messages_count());
    /**
     * Fires right before the loading of the Messages view screen template file.
     *
     * @since BuddyPress (1.7.0)
     */
    do_action('messages_screen_conversation');
    /**
     * Filters the template to load for the Messages view screen.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $template Path to the messages template to load.
     */
    bp_core_load_template(apply_filters('messages_template_view_message', 'members/single/home'));
}
Пример #21
0
<?php 
if (class_exists('buddypress')) {
    global $bp;
    $cb_buddypress_user_profile_link = $cb_buddypress_user_profile_link = NULL;
    $cb_buddypress_current_user_id = $bp->loggedin_user->id;
    if (function_exists('bp_loggedin_user_domain')) {
        $cb_buddypress_user_profile_link = bp_loggedin_user_domain();
    }
    if (isset($bp->profile->slug)) {
        $cb_buddypress_user_profile_slug = $cb_buddypress_user_profile_link . $bp->profile->slug;
    }
    if (function_exists('bp_get_groups_root_slug')) {
        $cb_buddypress_user_group_link = $cb_buddypress_user_profile_link . bp_get_groups_root_slug();
    }
    if (function_exists('bp_get_messages_slug')) {
        $cb_buddypress_user_message_link = $cb_buddypress_user_profile_link . bp_get_messages_slug();
    }
    if (function_exists('bp_get_activity_slug')) {
        $cb_buddypress_user_activity_link = $cb_buddypress_user_profile_link . bp_get_activity_slug();
    }
    $cb_buddypress_user_avatar = bp_core_fetch_avatar(array('item_id' => $cb_buddypress_current_user_id, 'type' => 'full', 'width' => 120, 'height' => 120));
    $cb_buddypress_mystery_man = 'mystery-man.jpg';
    $cb_buddypress_avatar_check = strpos($cb_buddypress_user_avatar, $cb_buddypress_mystery_man);
    if ($cb_buddypress_avatar_check === false) {
        $cb_buddypress_final_avatar = $cb_buddypress_user_avatar;
    } else {
        $cb_buddypress_final_avatar = get_avatar($cb_author_id, $size = '150');
    }
    ?>

        <div class="cb-header">
Пример #22
0
/**
 * Builds the row actions
 *
 * @global object $buddydrive_template
 * @uses buddydrive_get_item_id() to get item id
 * @uses buddydrive_is_buddyfile() to check for a file
 * @uses buddydrive_get_item_description() to get item's description
 * @uses buddydrive_get_item_privacy() to get item's privacy options
 * @uses buddydrive_current_user_can_link()
 * @uses buddydrive_get_action_link()
 * @uses buddydrive_current_user_can_share()
 * @uses bp_is_active() to check for the messages, activity and group components.
 * @uses bp_loggedin_user_domain() to get user's home url
 * @uses bp_get_messages_slug() to get the messages component slug
 * @uses buddydrive_current_user_can_share()
 * @return [type] [description]
 */
function buddydrive_get_row_actions()
{
    global $buddydrive_template;
    $row_actions = $inside_top = $inside_bottom = false;
    $buddyfile_id = buddydrive_get_item_id();
    if (buddydrive_is_buddyfile()) {
        $description = buddydrive_get_item_description();
        if (!empty($description)) {
            $inside_top[] = '<a class="buddydrive-show-desc" href="#">' . __('Description', 'buddydrive') . '</a>';
            $inside_bottom .= '<div class="buddydrive-ra-desc hide ba">' . $description . '</div>';
        }
    }
    $privacy = buddydrive_get_item_privacy();
    switch ($privacy['privacy']) {
        case 'public':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_url(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('activity')) {
                $inside_top[] = '<a class="buddydrive-profile-activity" href="#">' . __('Share', 'buddydrive') . '</a>';
            }
            break;
        case 'password':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_url(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('messages')) {
                $inside_top[] = '<a class="buddydrive-private-message" href="' . esc_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?buddyitem=' . $buddyfile_id) . '">' . esc_html__('Share', 'buddydrive') . '</a>';
            }
            break;
        case 'friends':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_attr(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('messages')) {
                $inside_top[] = '<a class="buddydrive-private-message" href="' . esc_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?buddyitem=' . $buddyfile_id) . '&friends=1">' . esc_html__('Share', 'buddydrive') . '</a>';
            }
            break;
        case 'groups':
            if (buddydrive_current_user_can_link($privacy)) {
                $inside_top[] = '<a class="buddydrive-show-link" href="#">' . __('Link', 'buddydrive') . '</a>';
                $inside_bottom .= '<div class="buddydrive-ra-link hide ba"><input type="text" class="buddydrive-file-input" id="buddydrive-link-' . esc_attr($buddyfile_id) . '" value="' . esc_url(buddydrive_get_action_link()) . '"></div>';
            }
            if (buddydrive_current_user_can_share() && bp_is_active('activity') && bp_is_active('groups')) {
                $inside_top[] = '<a class="buddydrive-group-activity" href="#">' . __('Share', 'buddydrive') . '</a>';
            }
            if (buddydrive_current_user_can_remove($privacy['group']) && bp_is_active('groups')) {
                $inside_top[] = '<a class="buddydrive-remove-group" href="#" data-group="' . esc_attr($privacy['group']) . '">' . esc_html__('Remove', 'buddydrive') . '</a>';
            }
            break;
    }
    if (!empty($inside_top)) {
        $inside_top = '<div class="buddydrive-action-btn">' . implode(' | ', $inside_top) . '</div>';
    }
    if (!empty($inside_top)) {
        $row_actions .= '<div class="buddydrive-row-actions">' . $inside_top . $inside_bottom . '</div>';
    }
    return apply_filters('buddydrive_get_row_actions', $row_actions);
}
Пример #23
0
 function show_message_icon($meta, $instructor_id)
 {
     if (is_numeric($instructor_id) && is_singular('course') && is_user_logged_in()) {
         $meta .= '<ul class="instructor_meta">';
         if (is_user_logged_in()) {
             $user_id = get_current_user_id();
             if ($user_id != $instructor_id && function_exists('bp_get_messages_slug')) {
                 $link = wp_nonce_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username($instructor_id));
                 $meta .= '<li><a href="' . $link . '" class="button tip" title="' . __('Send Message', 'vibe-customtypes') . '"><i class="icon-email"></i></a></li>';
             }
         }
         $user_info = get_userdata($instructor_id);
         $meta .= '<li><a href="mailto:' . $user_info->user_email . '" class="button tip" title="' . __('Send Email', 'vibe-customtypes') . '"><i class="icon-at-email"></i></a></li>';
         $meta .= '</ul>';
     }
     return $meta;
 }
     * @since 1.2.0
     */
    do_action('bp_after_member_messages_pagination');
    ?>

	<?php 
    /**
     * Fires before the members messages threads.
     *
     * @since 1.2.0
     */
    do_action('bp_before_member_messages_threads');
    ?>

	<form action="<?php 
    echo bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action();
    ?>
/bulk-manage/" method="post" id="messages-bulk-management">

		<table id="message-threads" class="messages-notices">

			<thead>
				<tr>
					<th scope="col" class="thread-checkbox bulk-select-all"><input id="select-all-messages" type="checkbox"><label class="bp-screen-reader-text" for="select-all-messages"><?php 
    _e('Select all', 'buddypress');
    ?>
</label></th>
					<th scope="col" class="thread-from"><?php 
    _e('From', 'buddypress');
    ?>
</th>
Пример #25
0
/**
 * Get the URL for deleting the current thread.
 *
 * @return string URL
 */
function bp_get_the_thread_delete_link()
{
    return apply_filters('bp_get_message_thread_delete_link', wp_nonce_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread'));
}
/**
 * Format notifications for the Messages component.
 *
 * @since BuddyPress (1.0.0)
 *
 * @param string $action            The kind of notification being rendered.
 * @param int    $item_id           The primary item id.
 * @param int    $secondary_item_id The secondary item id.
 * @param int    $total_items       The total number of messaging-related notifications
 *                                  waiting for the user.
 * @param string $format            Return value format. 'string' for BuddyBar-compatible
 *                                  notifications; 'array' for WP Toolbar. Default: 'string'.
 *
 * @return string|array Formatted notifications.
 */
function messages_format_notifications($action, $item_id, $secondary_item_id, $total_items, $format = 'string')
{
    $total_items = (int) $total_items;
    $link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox');
    $title = __('Inbox', 'buddypress');
    $amount = 'single';
    if ('new_message' === $action) {
        if ($total_items > 1) {
            $amount = 'multiple';
            $text = sprintf(__('You have %d new messages', 'buddypress'), $total_items);
        } else {
            $amount = 'single';
            // get message thread ID
            $message = new BP_Messages_Message($item_id);
            $thread_id = $message->thread_id;
            $link = !empty($thread_id) ? bp_get_message_thread_view_link($thread_id) : false;
            if (!empty($secondary_item_id)) {
                $text = sprintf(__('%s sent you a new private message', 'buddypress'), bp_core_get_user_displayname($secondary_item_id));
            } else {
                $text = sprintf(_n('You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress'), bp_core_number_format($total_items));
            }
        }
    }
    if ('string' === $format) {
        if (!empty($link)) {
            $retval = '<a href="' . esc_url($link) . '" title="' . esc_attr($title) . '">' . esc_html($text) . '</a>';
        } else {
            $retval = esc_html($text);
        }
        /**
         * Filters the new message notification text before the notification is created.
         *
         * This is a dynamic filter. Possible filter names are:
         *   - 'bp_messages_multiple_new_message_notification'.
         *   - 'bp_messages_single_new_message_notification'.
         *
         * @param string $retval            Notification text.
         * @param int    $total_items       Number of messages referred to by the notification.
         * @param string $text              The raw notification test (ie, not wrapped in a link).
         * @param int    $item_id           ID of the associated item.
         * @param int    $secondary_item_id ID of the secondary associated item.
         */
        $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
    } else {
        /** This filter is documented in bp-messages/bp-messages-notifications.php */
        $return = apply_filters('bp_messages_' . $amount . '_new_message_notification', array('text' => $text, 'link' => $link), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id);
    }
    /**
     * Fires right before returning the formatted message notifications.
     *
     * @since BuddyPress (1.0.0)
     *
     * @param string $action            The type of message notification.
     * @param int    $item_id           The primary item ID.
     * @param int    $secondary_item_id The secondary item ID.
     * @param int    $total_items       Total amount of items to format.
     */
    do_action('messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items);
    return $return;
}
Пример #27
0
/**
 * AJAX handler for autocomplete.
 *
 * Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
 *
 * @since BuddyPress (1.2.0)
 *
 * @return string HTML.
 */
function bp_legacy_theme_ajax_messages_autocomplete_results()
{
    /**
     * Filters the max results default value for ajax messages autocomplete results.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param int $value Max results for autocomplete. Default 10.
     */
    $limit = isset($_GET['limit']) ? absint($_GET['limit']) : (int) apply_filters('bp_autocomplete_max_results', 10);
    $term = isset($_GET['q']) ? sanitize_text_field($_GET['q']) : '';
    // Include everyone in the autocomplete, or just friends?
    if (bp_is_current_component(bp_get_messages_slug())) {
        $only_friends = buddypress()->messages->autocomplete_all === false;
    } else {
        $only_friends = true;
    }
    $suggestions = bp_core_get_suggestions(array('limit' => $limit, 'only_friends' => $only_friends, 'term' => $term, 'type' => 'members'));
    if ($suggestions && !is_wp_error($suggestions)) {
        foreach ($suggestions as $user) {
            // Note that the final line break acts as a delimiter for the
            // autocomplete JavaScript and thus should not be removed
            printf('<span id="%s" href="#"></span><img src="%s" style="width: 15px"> &nbsp; %s (%s)' . "\n", esc_attr('link-' . $user->ID), esc_url($user->image), esc_html($user->name), esc_html($user->ID));
        }
    }
    exit;
}
Пример #28
0
/**
 * AJAX handler for autocomplete. Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
 *
 * @global BuddyPress $bp The one true BuddyPress instance
 * @return string HTML
 * @since BuddyPress (1.2)
 */
function bp_dtheme_ajax_messages_autocomplete_results()
{
    global $bp;
    // Include everyone in the autocomplete, or just friends?
    if (bp_is_current_component(bp_get_messages_slug())) {
        $autocomplete_all = $bp->messages->autocomplete_all;
    }
    $pag_page = 1;
    $limit = $_GET['limit'] ? $_GET['limit'] : apply_filters('bp_autocomplete_max_results', 10);
    // Get the user ids based on the search terms
    if (!empty($autocomplete_all)) {
        $users = BP_Core_User::search_users($_GET['q'], $limit, $pag_page);
        if (!empty($users['users'])) {
            // Build an array with the correct format
            $user_ids = array();
            foreach ($users['users'] as $user) {
                if ($user->id != bp_loggedin_user_id()) {
                    $user_ids[] = $user->id;
                }
            }
            $user_ids = apply_filters('bp_core_autocomplete_ids', $user_ids, $_GET['q'], $limit);
        }
    } else {
        if (bp_is_active('friends')) {
            $users = friends_search_friends($_GET['q'], bp_loggedin_user_id(), $limit, 1);
            // Keeping the bp_friends_autocomplete_list filter for backward compatibility
            $users = apply_filters('bp_friends_autocomplete_list', $users, $_GET['q'], $limit);
            if (!empty($users['friends'])) {
                $user_ids = apply_filters('bp_friends_autocomplete_ids', $users['friends'], $_GET['q'], $limit);
            }
        }
    }
    if (!empty($user_ids)) {
        foreach ($user_ids as $user_id) {
            $ud = get_userdata($user_id);
            if (!$ud) {
                continue;
            }
            if (bp_is_username_compatibility_mode()) {
                $username = $ud->user_login;
            } else {
                $username = $ud->user_nicename;
            }
            // Note that the final line break acts as a delimiter for the
            // autocomplete javascript and thus should not be removed
            echo '<span id="link-' . $username . '" href="' . bp_core_get_user_domain($user_id) . '"></span>' . bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15, 'alt' => $ud->display_name)) . ' &nbsp;' . bp_core_get_user_displayname($user_id) . ' (' . $username . ')' . "\n";
        }
    }
    exit;
}
/**
 * Get the URL for deleting the current thread.
 *
 * @since 1.5.0
 *
 * @return string URL
 */
function bp_get_the_thread_delete_link()
{
    /**
     * Filters the URL for deleting the current thread.
     *
     * @since 1.0.0
     *
     * @param string $value URL for deleting the current thread.
     * @param string $value Text indicating action being executed.
     */
    return apply_filters('bp_get_message_thread_delete_link', wp_nonce_url(bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox/delete/' . bp_get_the_thread_id(), 'messages_delete_thread'));
}
Пример #30
-1
 /**
  * Set up the Toolbar.
  *
  * @param array $wp_admin_nav See {BP_Component::setup_admin_bar()}
  *                            for details.
  */
 public function setup_admin_bar($wp_admin_nav = array())
 {
     // Menus for logged in user
     if (is_user_logged_in()) {
         // Setup the logged in user variables
         $messages_link = trailingslashit(bp_loggedin_user_domain() . bp_get_messages_slug());
         // Unread message count
         $count = messages_get_unread_count();
         if (!empty($count)) {
             $title = sprintf(__('Messages <span class="count">%s</span>', 'buddypress'), bp_core_number_format($count));
             $inbox = sprintf(__('Inbox <span class="count">%s</span>', 'buddypress'), bp_core_number_format($count));
         } else {
             $title = __('Messages', 'buddypress');
             $inbox = __('Inbox', 'buddypress');
         }
         // Add main Messages menu
         $wp_admin_nav[] = array('parent' => buddypress()->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => $title, 'href' => $messages_link);
         // Inbox
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-inbox', 'title' => $inbox, 'href' => $messages_link);
         // Starred
         if (bp_is_active($this->id, 'star')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-starred', 'title' => __('Starred', 'buddypress'), 'href' => trailingslashit($messages_link . bp_get_messages_starred_slug()));
         }
         // Sent Messages
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-sentbox', 'title' => __('Sent', 'buddypress'), 'href' => trailingslashit($messages_link . 'sentbox'));
         // Compose Message
         $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-compose', 'title' => __('Compose', 'buddypress'), 'href' => trailingslashit($messages_link . 'compose'));
         // Site Wide Notices
         if (bp_current_user_can('bp_moderate')) {
             $wp_admin_nav[] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-notices', 'title' => __('All Member Notices', 'buddypress'), 'href' => trailingslashit($messages_link . 'notices'));
         }
     }
     parent::setup_admin_bar($wp_admin_nav);
 }