Example #1
0
/**
 * Is it groups gallery component?
 * @return boolean
 */
function mpp_is_group_gallery_component()
{
    if (function_exists('bp_is_group') && bp_is_group() && bp_is_current_action(MPP_GALLERY_SLUG)) {
        return true;
    }
    return false;
}
Example #2
0
/**
 * Forces the BP Profile Pages to be 1 Column
 * 
 * @package lsx
 * @subpackage jetpack
 * @category infinite scroll
 */
function lsx_buddypress_page_columns($layout)
{
    if (bp_is_profile_component() || bp_is_settings_component() || bp_is_activity_component() || bp_is_group() || bp_is_messages_component() || bp_is_members_directory() || bp_is_groups_directory() || bp_is_groups_component() || bp_is_members_component()) {
        $layout = '1c';
    }
    return $layout;
}
 /**
  * Gets the item id of the item (eg group, user) associated with the page you're on.
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  *
  * @return str $view The current item type
  */
 function setup_item()
 {
     global $bp;
     if (empty($this->item_type)) {
         return false;
     }
     $id = '';
     $name = '';
     $slug = '';
     switch ($this->item_type) {
         case 'group':
             if (bp_is_group()) {
                 $group = groups_get_current_group();
                 $id = $group->id;
                 $name = $group->name;
                 $slug = $group->slug;
             }
             break;
         case 'user':
             if (bp_is_user()) {
                 $id = bp_displayed_user_id();
                 $name = bp_get_displayed_user_fullname();
                 $slug = bp_get_displayed_user_username();
             }
             break;
     }
     // Todo: abstract into groups. Will be a pain
     $this->item_id = apply_filters('bp_docs_get_item_id', $id);
     $this->item_name = apply_filters('bp_docs_get_item_name', $name);
     $this->item_slug = apply_filters('bp_docs_get_item_slug', $slug);
     // Put some stuff in $bp
     $bp->bp_docs->current_item = $this->item_id;
 }
/**
 * Sends an email notification and a BP notification when someone mentions you in an update
 *
 * @since BuddyPress (1.2)
 *
 * @param int $activity_id The id of the activity update
 * @param int $receiver_user_id The unique user_id of the user who is receiving the update
 *
 * @uses bp_core_add_notification()
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses wp_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_is_active()
 * @uses bp_is_group()
 * @uses bp_get_current_group_name()
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_mention_email' hook
 */
function bp_activity_at_message_notification($activity_id, $receiver_user_id)
{
    // Don't leave multiple notifications for the same activity item
    $notifications = BP_Core_Notification::get_all_for_user($receiver_user_id, 'all');
    foreach ($notifications as $notification) {
        if ($activity_id == $notification->item_id) {
            return;
        }
    }
    $activity = new BP_Activity_Activity($activity_id);
    $subject = '';
    $message = '';
    $content = '';
    // Add the BP notification
    bp_core_add_notification($activity_id, $receiver_user_id, 'activity', 'new_at_mention', $activity->user_id);
    // Now email the user with the contents of the message (if they have enabled email notifications)
    if ('no' != bp_get_user_meta($receiver_user_id, 'notification_activity_new_mention', true)) {
        $poster_name = bp_core_get_user_displayname($activity->user_id);
        $message_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($receiver_user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(strip_tags(stripslashes($activity->content)));
        // Set up and send the message
        $ud = bp_core_get_core_userdata($receiver_user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s mentioned you in an update', 'buddypress'), $poster_name)));
        if (bp_is_active('groups') && bp_is_group()) {
            $message = sprintf(__('%1$s mentioned you in the group "%2$s":

"%3$s"

To view and respond to the message, log in and visit: %4$s

---------------------
', 'buddypress'), $poster_name, bp_get_current_group_name(), $content, $message_link);
        } else {
            $message = sprintf(__('%1$s mentioned you in an update:

"%2$s"

To view and respond to the message, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $message_link);
        }
        // Only show the disable notifications line if the settings component is enabled
        if (bp_is_active('settings')) {
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        }
        /* Send the message */
        $to = apply_filters('bp_activity_at_message_notification_to', $to);
        $subject = apply_filters('bp_activity_at_message_notification_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link);
        wp_mail($to, $subject, $message);
    }
    do_action('bp_activity_sent_mention_email', $activity, $subject, $message, $content);
}
Example #5
0
/**
 * Protect access to single groups.
 *
 * @since BuddyPress (2.1.0)
 */
function bp_groups_group_access_protection()
{
    if (!bp_is_group()) {
        return;
    }
    $current_group = groups_get_current_group();
    $user_has_access = $current_group->user_has_access;
    $no_access_args = array();
    if (!$user_has_access && 'hidden' !== $current_group->status) {
        // Always allow access to home and request-membership
        if (bp_is_current_action('home') || bp_is_current_action('request-membership')) {
            $user_has_access = true;
            // User doesn't have access, so set up redirect args
        } else {
            if (is_user_logged_in()) {
                $no_access_args = array('message' => __('You do not have access to this group.', 'buddypress'), 'root' => bp_get_group_permalink($current_group) . 'home/', 'redirect' => false);
            }
        }
    }
    // Protect the admin tab from non-admins
    if (bp_is_current_action('admin') && !bp_is_item_admin()) {
        $user_has_access = false;
        $no_access_args = array('message' => __('You are not an admin of this group.', 'buddypress'), 'root' => bp_get_group_permalink($current_group), 'redirect' => false);
    }
    /**
     * Allow plugins to filter whether the current user has access to this group content.
     *
     * Note that if a plugin sets $user_has_access to false, it may also
     * want to change the $no_access_args, to avoid problems such as
     * logged-in users being redirected to wp-login.php.
     *
     * @since BuddyPress (2.1.0)
     *
     * @param bool $user_has_access True if the user has access to the
     *        content, otherwise false.
     * @param array $no_access_args Arguments to be passed to
     *        bp_core_no_access() in case of no access. Note that this
     *        value is passed by reference, so it can be modified by the
     *        filter callback.
     */
    $user_has_access = apply_filters_ref_array('bp_group_user_has_access', array($user_has_access, &$no_access_args));
    // If user has access, we return rather than redirect
    if ($user_has_access) {
        return;
    }
    // Hidden groups should return a 404 for non-members.
    // Unset the current group so that you're not redirected
    // to the default group tab
    if ('hidden' == $current_group->status) {
        buddypress()->groups->current_group = 0;
        buddypress()->is_single_item = false;
        bp_do_404();
        return;
    } else {
        bp_core_no_access($no_access_args);
    }
}
function mpp_group_filter_status($statuses)
{
    if (bp_is_group()) {
        unset($statuses['friends']);
        unset($statuses['private']);
    } else {
        unset($statuses['groupsonly']);
    }
    return $statuses;
}
/**
 *
 * @global type $bp
 * @return type 
 */
function bcg_is_disabled_for_group()
{
    $bp = buddypress();
    $group_id = false;
    if (bp_is_group_create()) {
        $group_id = $_COOKIE['bp_new_group_id'];
    } elseif (bp_is_group()) {
        $group_id = $bp->groups->current_group->id;
    }
    return apply_filters('bcg_is_disabled_for_group', bcg_is_disabled($group_id));
}
Example #8
0
 function training_wpo_buddypress_init()
 {
     if (bp_is_user_activity()) {
         remove_action('wpo_layout_breadcrumbs_buddy_render', 'training_wpo_layout_breadcrumbs_buddypress');
         add_action('wpo_layout_breadcrumbs_buddy_render', 'training_wpo_buddypress_user_header');
     }
     if (bp_is_group()) {
         remove_action('wpo_layout_breadcrumbs_buddy_render', 'training_wpo_layout_breadcrumbs_buddypress');
         add_action('wpo_layout_breadcrumbs_buddy_render', 'training_wpo_buddypress_group_header');
     }
 }
function mp_group_nav()
{
    if (!bp_is_group()) {
        return;
    }
    $component = 'groups';
    $component_id = groups_get_current_group()->id;
    if (mpp_user_can_create_gallery($component, $component_id)) {
        echo sprintf("<li><a href='%s'>%s</a></li>", mpp_get_gallery_base_url($component, $component_id), __('All Galleries', 'mediapress'));
        echo sprintf("<li><a href='%s'>%s</a></li>", mpp_get_gallery_create_url($component, $component_id), __('Create Gallery', 'mediapress'));
    }
}
/**
 * Load the js only when needed
 *
 * @return bool
 */
function cfbgr_is_restriction_js()
{
    // Group create
    if (bp_is_group_create() && bp_is_group_creation_step('group-settings')) {
        return true;
    }
    // Group manage
    if (bp_is_group() && bp_is_group_admin_screen('group-settings')) {
        return true;
    }
    return false;
}
Example #11
0
/**
 * Populate the $groups_template global for use outside the loop
 *
 * We build the group navigation outside the groups loop. In order to use BP's
 * group template functions while building the nav, we must have the template
 * global populated. In this function, we fill in any missing data, based on
 * the current group.
 *
 * This issue should be fixed more elegantly upstream in BuddyPress, ideally
 * by making the template functions fall back on the current group when the
 * loop global is not populated.
 */
function wff_populate_group_global()
{
    global $groups_template;
    if (bp_is_group() && isset($groups_template->groups[0]->group_id) && empty($groups_template->groups[0]->name)) {
        $current_group = groups_get_current_group();
        // Fill in all missing properties
        foreach ($current_group as $cur_key => $cur_value) {
            if (!isset($groups_template->groups[0]->{$cur_key})) {
                $groups_template->groups[0]->{$cur_key} = $cur_value;
            }
        }
    }
}
/**
 * Sends an email notification and a BP notification when someone mentions you in an update
 *
 * @since 1.2.0
 *
 * @param int $activity_id The id of the activity update
 * @param int $receiver_user_id The unique user_id of the user who is receiving the update
 *
 * @global object $bp BuddyPress global settings
 * @uses bp_core_add_notification()
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses nxt_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_is_active()
 * @uses bp_is_group()
 * @uses bp_get_current_group_name()
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook
 * @uses nxt_mail()
 * @uses do_action() To call the 'bp_activity_sent_mention_email' hook
 */
function bp_activity_at_message_notification($activity_id, $receiver_user_id)
{
    global $bp;
    $activity = new BP_Activity_Activity($activity_id);
    $subject = '';
    $message = '';
    // Add the BP notification
    bp_core_add_notification($activity_id, $receiver_user_id, 'activity', 'new_at_mention', $activity->user_id);
    // Now email the user with the contents of the message (if they have enabled email notifications)
    if ('no' != bp_get_user_meta($receiver_user_id, 'notification_activity_new_mention', true)) {
        $poster_name = bp_core_get_user_displayname($activity->user_id);
        $message_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($receiver_user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(strip_tags(stripslashes($activity->content)));
        // Set up and send the message
        $ud = bp_core_get_core_userdata($receiver_user_id);
        $to = $ud->user_email;
        $sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
        $subject = '[' . $sitename . '] ' . sprintf(__('%s mentioned you in an update', 'buddypress'), $poster_name);
        if (bp_is_active('groups') && bp_is_group()) {
            $message = sprintf(__('%1$s mentioned you in the group "%2$s":

"%3$s"

To view and respond to the message, log in and visit: %4$s

---------------------
', 'buddypress'), $poster_name, bp_get_current_group_name(), $content, $message_link);
        } else {
            $message = sprintf(__('%1$s mentioned you in an update:

"%2$s"

To view and respond to the message, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $message_link);
        }
        $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        /* Send the message */
        $to = apply_filters('bp_activity_at_message_notification_to', $to);
        $subject = apply_filters('bp_activity_at_message_notification_subject', $subject, $poster_name);
        $message = apply_filters('bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link);
        nxt_mail($to, $subject, $message);
    }
    do_action('bp_activity_sent_mention_email', $activity, $subject, $message, $content);
}
Example #13
0
/**
 * Returns the cover photo url
 * @return string the cover photo url
 */
function klein_get_cover_photo_src()
{
    if (!function_exists('bcp_get_cover_photo')) {
        return;
    }
    $item_id = bp_displayed_user_id();
    $item_type = 'user';
    if (bp_is_group()) {
        $item_id = bp_get_group_id();
        $item_type = 'group';
    }
    $args = array('type' => $item_type, 'object_id' => $item_id);
    $cover_photo_url = esc_url(bcp_get_cover_photo($args));
    return $cover_photo_url;
}
Example #14
0
 /**
  *
  */
 function set_bp_component_context()
 {
     if (bp_displayed_user_id() && !bp_is_group()) {
         $this->type = 'profile';
     } else {
         if (!bp_displayed_user_id() && bp_is_group()) {
             $this->type = 'group';
         } else {
             $this->type = 'profile';
         }
     }
     $this->id = $this->get_current_bp_component_id();
     if ($this->id == null) {
         global $bp;
         $this->id = $bp->loggedin_user->id;
     }
 }
/**
 * Adds the Group Admin top-level menu to group pages
 *
 * @package BuddyPress
 * @since 1.5
 *
 * @todo Add dynamic menu items for group extensions
 */
function bp_groups_group_admin_menu()
{
    global $nxt_admin_bar, $bp;
    // Only show if viewing a group
    if (!bp_is_group()) {
        return false;
    }
    // Only show this menu to group admins and super admins
    if (!is_super_admin() && !bp_group_is_admin()) {
        return false;
    }
    if ('3.2' == bp_get_major_nxt_version()) {
        // Group avatar
        $avatar = bp_core_fetch_avatar(array('object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'width' => 16, 'height' => 16));
        // Unique ID for the 'My Account' menu
        $bp->group_admin_menu_id = !empty($avatar) ? 'group-admin-with-avatar' : 'group-admin';
        // Add the top-level Group Admin button
        $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => $avatar . bp_get_current_group_name(), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    } elseif ('3.3' == bp_get_major_nxt_version()) {
        // Unique ID for the 'My Account' menu
        $bp->group_admin_menu_id = 'group-admin';
        // Add the top-level Group Admin button
        $nxt_admin_bar->add_menu(array('id' => $bp->group_admin_menu_id, 'title' => __('Edit Group', 'buddypress'), 'href' => bp_get_group_permalink($bp->groups->current_group)));
    }
    // Group Admin > Edit details
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'edit-details', 'title' => __('Edit Details', 'buddypress'), 'href' => bp_get_groups_action_link('admin/edit-details')));
    // Group Admin > Group settings
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-settings', 'title' => __('Edit Settings', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-settings')));
    // Group Admin > Group avatar
    if (!(int) bp_get_option('bp-disable-avatar-uploads')) {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'group-avatar', 'title' => __('Edit Avatar', 'buddypress'), 'href' => bp_get_groups_action_link('admin/group-avatar')));
    }
    // Group Admin > Manage invitations
    if (bp_is_active('friends')) {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-invitations', 'title' => __('Manage Invitations', 'buddypress'), 'href' => bp_get_groups_action_link('send-invites')));
    }
    // Group Admin > Manage members
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'manage-members', 'title' => __('Manage Members', 'buddypress'), 'href' => bp_get_groups_action_link('admin/manage-members')));
    // Group Admin > Membership Requests
    if (bp_get_group_status($bp->groups->current_group) == 'private') {
        $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'membership-requests', 'title' => __('Membership Requests', 'buddypress'), 'href' => bp_get_groups_action_link('admin/membership-requests')));
    }
    // Delete Group
    $nxt_admin_bar->add_menu(array('parent' => $bp->group_admin_menu_id, 'id' => 'delete-group', 'title' => __('Delete Group', 'buddypress'), 'href' => bp_get_groups_action_link('admin/delete-group')));
}
/**
 * Send email and BP notifications when a user is mentioned in an update.
 *
 * @since 1.2.0
 *
 * @uses bp_notifications_add_notification()
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses wp_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_is_active()
 * @uses bp_is_group()
 * @uses bp_get_current_group_name()
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook.
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_mention_email' hook.
 *
 * @param int $activity_id      The ID of the activity update.
 * @param int $receiver_user_id The ID of the user who is receiving the update.
 */
function bp_activity_at_message_notification($activity_id, $receiver_user_id)
{
    $notifications = BP_Core_Notification::get_all_for_user($receiver_user_id, 'all');
    // Don't leave multiple notifications for the same activity item.
    foreach ($notifications as $notification) {
        if ($activity_id == $notification->item_id) {
            return;
        }
    }
    $activity = new BP_Activity_Activity($activity_id);
    $email_type = 'activity-at-message';
    $group_name = '';
    $message_link = bp_activity_get_permalink($activity_id);
    $poster_name = bp_core_get_user_displayname($activity->user_id);
    remove_filter('bp_get_activity_content_body', 'convert_smilies');
    remove_filter('bp_get_activity_content_body', 'wpautop');
    remove_filter('bp_get_activity_content_body', 'bp_activity_truncate_entry', 5);
    /** This filter is documented in bp-activity/bp-activity-template.php */
    $content = apply_filters('bp_get_activity_content_body', $activity->content);
    add_filter('bp_get_activity_content_body', 'convert_smilies');
    add_filter('bp_get_activity_content_body', 'wpautop');
    add_filter('bp_get_activity_content_body', 'bp_activity_truncate_entry', 5);
    // Now email the user with the contents of the message (if they have enabled email notifications).
    if ('no' != bp_get_user_meta($receiver_user_id, 'notification_activity_new_mention', true)) {
        if (bp_is_active('groups') && bp_is_group()) {
            $email_type = 'groups-at-message';
            $group_name = bp_get_current_group_name();
        }
        $args = array('tokens' => array('activity' => $activity, 'usermessage' => wp_strip_all_tags($content), 'group.name' => $group_name, 'mentioned.url' => $message_link, 'poster.name' => $poster_name, 'receiver-user.id' => $receiver_user_id));
        bp_send_email($email_type, $receiver_user_id, $args);
    }
    /**
     * Fires after the sending of an @mention email notification.
     *
     * @since 1.5.0
     * @since 2.5.0 $subject, $message, $content arguments unset and deprecated.
     *
     * @param BP_Activity_Activity $activity         Activity Item object.
     * @param string               $deprecated       Removed in 2.5; now an empty string.
     * @param string               $deprecated       Removed in 2.5; now an empty string.
     * @param string               $deprecated       Removed in 2.5; now an empty string.
     * @param int                  $receiver_user_id The ID of the user who is receiving the update.
     */
    do_action('bp_activity_sent_mention_email', $activity, '', '', '', $receiver_user_id);
}
Example #17
0
/**
 * Return solr results when called from an ajax call.
 */
function humcore_ajax_return_solr_results()
{
    ob_start();
    if (bp_is_user()) {
        locate_template(array('deposits/user-deposits-loop.php'), true);
    } else {
        if (bp_is_group()) {
            locate_template(array('deposits/group-deposits-loop.php'), true);
        } else {
            locate_template(array('deposits/deposits-loop.php'), true);
        }
    }
    $results = ob_get_contents();
    ob_end_clean();
    echo $results;
    // XSS OK.
    exit;
}
 function group_activity_subscription()
 {
     $this->name = __('Email Options', 'bp-ass');
     $this->slug = 'notifications';
     // Only enable the notifications nav item if the user is a member of the group
     if (bp_is_group() && groups_is_user_member(bp_loggedin_user_id(), bp_get_current_group_id())) {
         $this->enable_nav_item = true;
     } else {
         $this->enable_nav_item = false;
     }
     $this->nav_item_position = 91;
     $this->enable_create_step = false;
     if (get_option('ass-admin-can-send-email') == 'no') {
         $this->enable_edit_item = false;
     }
     // hook in the css and js
     add_action('wp_print_styles', array(&$this, 'add_settings_stylesheet'));
     add_action('wp_enqueue_scripts', array(&$this, 'ass_add_javascript'), 1);
 }
 public function view_single()
 {
     $bp = buddypress();
     if (function_exists('bp_is_group') && !bp_is_group()) {
         return;
     }
     //do not catch the request for creating new post
     if (bp_is_action_variable('create', 0)) {
         return;
     }
     $current_group = groups_get_current_group();
     if (bcg_is_disabled($current_group->id)) {
         return;
     }
     //if the group is private/hidden and user is not member, return
     if (($current_group->status == 'private' || $current_group->status == 'hidden') && (!is_user_logged_in() || !groups_is_user_member(bp_loggedin_user_id(), $current_group->id))) {
         return;
         //avoid prioivacy troubles
     }
     if (bcg_is_component() && !empty($bp->action_variables[0])) {
         //should we check for the existence of the post?
         add_action('bp_template_content', array($this, 'get_single_post_contents'));
     }
 }
/**
 * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
 * Each component adds to its sub navigation array within its own setup_nav() function.
 *
 * This sub navigation array is the secondary level navigation, so for profile it contains:
 *      [Public, Edit Profile, Change Avatar]
 *
 * The function will also analyze the current action for the current component to determine whether
 * or not to highlight a particular sub nav item.
 *
 * @package BuddyPress Core
 * @global object $bp Global BuddyPress settings object
 * @uses bp_get_user_nav() Renders the navigation for a profile of a currently viewed user.
 */
function bp_get_options_nav()
{
    global $bp;
    // If we are looking at a member profile, then the we can use the current component as an
    // index. Otherwise we need to use the component's root_slug
    $component_index = !empty($bp->displayed_user) ? $bp->current_component : bp_get_root_slug($bp->current_component);
    if (!bp_is_single_item()) {
        if (!isset($bp->bp_options_nav[$component_index]) || count($bp->bp_options_nav[$component_index]) < 1) {
            return false;
        } else {
            $the_index = $component_index;
        }
    } else {
        if (!isset($bp->bp_options_nav[$bp->current_item]) || count($bp->bp_options_nav[$bp->current_item]) < 1) {
            return false;
        } else {
            $the_index = $bp->current_item;
        }
    }
    // Loop through each navigation item
    foreach ((array) $bp->bp_options_nav[$the_index] as $subnav_item) {
        if (!$subnav_item['user_has_access']) {
            continue;
        }
        // If the current action or an action variable matches the nav item id, then add a highlight CSS class.
        if ($subnav_item['slug'] == $bp->current_action) {
            $selected = ' class="current selected"';
        } else {
            $selected = '';
        }
        // List type depends on our current component
        $list_type = bp_is_group() ? 'groups' : 'personal';
        // echo out the final list item
        echo apply_filters('bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-' . $list_type . '-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item);
    }
}
Example #21
0
 /**
  *
  */
 function miss_document_title()
 {
     global $page, $paged, $wp_query;
     /* Set up some default variables. */
     $domain = MISS_TEXTDOMAIN;
     $doctitle = get_bloginfo('name');
     $separator = ' | ';
     $description = get_bloginfo('description', 'display');
     //$doctitle = get_bloginfo( 'name' );
     /* If viewing the front page and posts page of the site. */
     if (is_front_page() && is_home() && !is_singular()) {
         if ($description != "") {
             $doctitle = $description;
         } else {
             $separator = '';
         }
     }
     /* If viewing the posts page or a singular post. */
     if (is_home() || is_singular()) {
         $post_id = $wp_query->get_queried_object_id();
         $prefix = get_post_meta($post_id, 'Title', true);
         if (empty($prefix) && is_front_page()) {
             $prefix = get_bloginfo('name');
         } elseif (empty($prefix)) {
             $prefix = get_post_field('post_title', $post_id);
         }
     } elseif (is_archive()) {
         /* If viewing a taxonomy term archive. */
         if (is_category() || is_tag() || is_tax()) {
             $term = $wp_query->get_queried_object();
             $prefix = $term->name;
         } elseif (function_exists('is_post_type_archive') && is_post_type_archive()) {
             $post_type = get_post_type_object(get_query_var('post_type'));
             $prefix = miss_get_setting(get_post_type() . '_page_caption') ? miss_get_setting(get_post_type() . '_page_caption') : $post_type->labels->name;
         } elseif (is_author()) {
             $prefix = get_the_author_meta('display_name', get_query_var('author'));
         } elseif (is_date()) {
             if (get_query_var('minute') && get_query_var('hour')) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('g:i a', MISS_TEXTDOMAIN)));
             } elseif (get_query_var('minute')) {
                 $prefix = sprintf(__('Archive for minute %1$s', MISS_TEXTDOMAIN), get_the_time(__('i', MISS_TEXTDOMAIN)));
             } elseif (get_query_var('hour')) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('g a', MISS_TEXTDOMAIN)));
             } elseif (is_day()) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('F jS, Y', MISS_TEXTDOMAIN)));
             } elseif (get_query_var('w')) {
                 $prefix = sprintf(__('Archive for week %1$s of %2$s', MISS_TEXTDOMAIN), get_the_time(__('W', MISS_TEXTDOMAIN)), get_the_time(__('Y', MISS_TEXTDOMAIN)));
             } elseif (is_month()) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), single_month_title(' ', false));
             } elseif (is_year()) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('Y', MISS_TEXTDOMAIN)));
             }
         }
     } elseif (is_search()) {
         $prefix = sprintf(__('Search results for &quot;%1$s&quot;', MISS_TEXTDOMAIN), esc_attr(get_search_query()));
     } elseif (is_404()) {
         $prefix = __('404 Not Found', MISS_TEXTDOMAIN);
     } elseif (function_exists('bp_is_activity_component') && bp_is_activity_component()) {
         $prefix = __('Activity', MISS_TEXTDOMAIN);
     } elseif (function_exists('bp_is_group') && bp_is_group()) {
         $prefix = __('Group', MISS_TEXTDOMAIN);
     }
     /**
      * Events Calendar PRO Support
      * 
      * @since 1.8
      */
     if (class_exists('TribeEventsPro')) {
         if (function_exists('tribe_is_month') && tribe_is_month()) {
             $prefix = __('Events for', MISS_TEXTDOMAIN);
             $prefix .= Date("F Y", strtotime($wp_query->get('start_date')));
         }
         if (function_exists('tribe_is_day') && tribe_is_day()) {
             $prefix = __('Events for', MISS_TEXTDOMAIN);
             $prefix .= Date("l, F jS Y", strtotime($wp_query->get('start_date')));
         }
         if (function_exists('tribe_is_week') && tribe_is_week()) {
             if (function_exists('tribe_get_first_week_day')) {
                 $prefix = sprintf(__('Events for week of %s', MISS_TEXTDOMAIN), Date("l, F jS Y", strtotime(tribe_get_first_week_day($wp_query->get('start_date')))));
             }
             //$page_tagline = Date("l, F jS Y", strtotime($wp_query->get('start_date') ) );
         }
         if (function_exists('tribe_is_map') && tribe_is_map() || function_exists('tribe_is_photo') && tribe_is_photo()) {
             if (tribe_is_past()) {
                 $prefix = __('Past Events', MISS_TEXTDOMAIN);
             } else {
                 $prefix = __('Upcoming Events', MISS_TEXTDOMAIN);
             }
         }
         if (function_exists('tribe_is_showing_all') && tribe_is_showing_all()) {
             $prefix = sprintf('%s %s', __('All events for', MISS_TEXTDOMAIN), get_the_title());
         }
     }
     /* If the current page is a paged page. */
     if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
         $prefix = sprintf(__('%1$sPage %2$s', MISS_TEXTDOMAIN), $prefix . $separator, number_format_i18n($page));
     }
     if (is_front_page()) {
         $doctitle = $doctitle . $separator . $description;
     } else {
         $doctitle = $prefix . $separator . $doctitle;
     }
     /* Apply the wp_title filters so we're compatible with plugins. */
     $doctitle = apply_filters('wp_title', $doctitle, '', '');
     /* Return the title to the screen. */
     return apply_atomic('document_title', esc_attr($doctitle));
 }
Example #22
0
 <?php 
}
?>
</textarea>
		</div>

		<div id="whats-new-options">
			<div id="whats-new-submit">
				<input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="<?php 
_e('Post Update', 'buddypress');
?>
" />
			</div>

			<?php 
if (bp_is_active('groups') && !bp_is_my_profile() && !bp_is_group()) {
    ?>

				<div id="whats-new-post-in-box">

					<?php 
    _e('Post in', 'buddypress');
    ?>
:

					<select id="whats-new-post-in" name="whats-new-post-in">
						<option selected="selected" value="0"><?php 
    _e('My Profile', 'buddypress');
    ?>
</option>
 function _register()
 {
     global $bp;
     // If admin/create names and slugs are not provided, they fall back on the main
     // name and slug for the extension
     if (!$this->admin_name) {
         $this->admin_name = $this->name;
     }
     if (!$this->admin_slug) {
         $this->admin_slug = $this->slug;
     }
     if (!$this->create_name) {
         $this->create_name = $this->name;
     }
     if (!$this->create_slug) {
         $this->create_slug = $this->slug;
     }
     if (!empty($this->enable_create_step)) {
         // Insert the group creation step for the new group extension
         $bp->groups->group_creation_steps[$this->create_slug] = array('name' => $this->create_name, 'slug' => $this->create_slug, 'position' => $this->create_step_position);
         // Attach the group creation step display content action
         add_action('groups_custom_create_steps', array(&$this, 'create_screen'));
         // Attach the group creation step save content action
         add_action('groups_create_group_step_save_' . $this->create_slug, array(&$this, 'create_screen_save'));
     }
     // When we are viewing a single group, add the group extension nav item
     if (bp_is_group()) {
         if ($this->visibility == 'public' || $this->visibility != 'public' && $bp->groups->current_group->user_has_access) {
             if ($this->enable_nav_item) {
                 bp_core_new_subnav_item(array('name' => !$this->nav_item_name ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => $bp->groups->current_group->slug, 'parent_url' => bp_get_group_permalink($bp->groups->current_group), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array(&$this, '_display_hook'), 'user_has_access' => $this->enable_nav_item));
                 // When we are viewing the extension display page, set the title and options title
                 if (bp_is_current_action($this->slug)) {
                     add_action('bp_template_content_header', create_function('', 'echo "' . esc_attr($this->name) . '";'));
                     add_action('bp_template_title', create_function('', 'echo "' . esc_attr($this->name) . '";'));
                 }
             }
             // Hook the group home widget
             if (!bp_current_action() && bp_is_current_action('home')) {
                 add_action($this->display_hook, array(&$this, 'widget_display'));
             }
         }
     }
     // Construct the admin edit tab for the new group extension
     if (!empty($this->enable_edit_item) && bp_is_item_admin()) {
         add_action('groups_admin_tabs', create_function('$current, $group_slug', '$selected = ""; if ( "' . esc_attr($this->admin_slug) . '" == $current ) $selected = " class=\\"current\\""; echo "<li{$selected}><a href=\\"' . trailingslashit(bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/{$group_slug}/admin/' . esc_attr($this->admin_slug)) . '\\">' . esc_attr($this->admin_name) . '</a></li>";'), 10, 2);
         // Catch the edit screen and forward it to the plugin template
         if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable($this->admin_slug, 0)) {
             // Check whether the user is saving changes
             $this->edit_screen_save();
             add_action('groups_custom_edit_steps', array(&$this, 'edit_screen'));
             if ('' != locate_template(array('groups/single/home.php'), false)) {
                 bp_core_load_template(apply_filters('groups_template_group_home', 'groups/single/home'));
             } else {
                 add_action('bp_template_content_header', create_function('', 'echo "<ul class=\\"content-header-nav\\">"; bp_group_admin_tabs(); echo "</ul>";'));
                 add_action('bp_template_content', array(&$this, 'edit_screen'));
                 bp_core_load_template(apply_filters('bp_core_template_plugin', '/groups/single/plugins'));
             }
         }
     }
 }
/**
 * Add inline css to display the component's single item cover image
 *
 * @since 2.4.0
 *
 * @param  bool $return True to get the inline css.
 * @return string|array the inline css or an associative array containing
 *                      the css rules and the style handle
 */
function bp_add_cover_image_inline_css($return = false)
{
    $bp = buddypress();
    // Find the component of the current item.
    if (bp_is_user()) {
        // User is not allowed to upload cover images
        // no need to carry on.
        if (bp_disable_cover_image_uploads()) {
            return;
        }
        $cover_image_object = array('component' => 'xprofile', 'object' => $bp->displayed_user);
    } elseif (bp_is_group()) {
        // Users are not allowed to upload cover images for their groups
        // no need to carry on.
        if (bp_disable_group_cover_image_uploads()) {
            return;
        }
        $cover_image_object = array('component' => 'groups', 'object' => $bp->groups->current_group);
    } else {
        $cover_image_object = apply_filters('bp_current_cover_image_object_inline_css', array());
    }
    // Bail if no component were found.
    if (empty($cover_image_object['component']) || empty($cover_image_object['object']) || !bp_is_active($cover_image_object['component'], 'cover_image')) {
        return;
    }
    // Get the settings of the cover image feature for the current component.
    $params = bp_attachments_get_cover_image_settings($cover_image_object['component']);
    // Bail if no params.
    if (empty($params)) {
        return;
    }
    // Try to call the callback.
    if (is_callable($params['callback'])) {
        $object_dir = $cover_image_object['component'];
        if ('xprofile' === $object_dir) {
            $object_dir = 'members';
        }
        $cover_image = bp_attachments_get_attachment('url', array('object_dir' => $object_dir, 'item_id' => $cover_image_object['object']->id));
        if (empty($cover_image)) {
            if (!empty($params['default_cover'])) {
                $cover_image = $params['default_cover'];
            }
        }
        $inline_css = call_user_func_array($params['callback'], array(array('cover_image' => esc_url_raw($cover_image), 'component' => sanitize_key($cover_image_object['component']), 'object_id' => (int) $cover_image_object['object']->id, 'width' => (int) $params['width'], 'height' => (int) $params['height'])));
        // Finally add the inline css to the handle.
        if (!empty($inline_css)) {
            // Used to get the css when Ajax setting the cover image.
            if (true === $return) {
                return array('css_rules' => '<style type="text/css">' . "\n" . $inline_css . "\n" . '</style>', 'handle' => $params['theme_handle']);
            }
            wp_add_inline_style($params['theme_handle'], $inline_css);
        } else {
            return false;
        }
    }
}
/**
 * Hook group activity feed to <head>
 *
 * @since BuddyPress (1.5)
 */
function bp_groups_activity_feed()
{
    if (!bp_is_active('groups') || !bp_is_active('activity') || !bp_is_group()) {
        return;
    }
    ?>

	<link rel="alternate" type="application/rss+xml" title="<?php 
    bloginfo('name');
    ?>
 | <?php 
    bp_current_group_name();
    ?>
 | <?php 
    _e('Group Activity RSS Feed', 'buddypress');
    ?>
" href="<?php 
    bp_group_activity_feed_link();
    ?>
" />

<?php 
}
Example #26
0
/**
 *  widget for the community navigation
 *
 * @package Custom Community
 * @since 1.8.3
 */
function widget_community_nav($sidebar_id = false)
{
    ?>
		<?php 
    global $cap;
    if ($sidebar_id == 'leftsidebar' && $cap->bg_leftsidebar_default_nav && $cap->bg_leftsidebar_default_nav == 'no') {
        return;
    }
    ?>
  		<div id="community-nav" class="widget widget-title" >
        	<h3 class="widgettitle"><?php 
    _e('Community', 'cc');
    ?>
</h3>
  				<ul class="item-list">
					
			  		<?php 
    if ('activity' != bp_dtheme_page_on_front() && bp_is_active('activity')) {
        ?>
                                        <li<?php 
        if (bp_is_activity_component()) {
            ?>
 class="selected"<?php 
        }
        ?>
>
							<a href="<?php 
        echo site_url();
        ?>
/<?php 
        echo BP_ACTIVITY_SLUG;
        ?>
/" title="<?php 
        _e('Activity', 'cc');
        ?>
"><?php 
        _e('Activity', 'cc');
        ?>
</a>
						</li>
					<?php 
    }
    ?>

                                        <li<?php 
    if (bp_is_members_component() || bp_is_user()) {
        ?>
 class="selected"<?php 
    }
    ?>
>
                                                <a href="<?php 
    echo site_url();
    ?>
/<?php 
    echo BP_MEMBERS_SLUG;
    ?>
/" title="<?php 
    _e('Members', 'cc');
    ?>
"><?php 
    _e('Members', 'cc');
    ?>
</a>
                                        </li>
			
                                    <?php 
    if (bp_is_active('groups')) {
        ?>
                                            <li<?php 
        if (bp_is_groups_component() || bp_is_group()) {
            ?>
 class="selected"<?php 
        }
        ?>
>
                                                    <a href="<?php 
        echo site_url();
        ?>
/<?php 
        echo BP_GROUPS_SLUG;
        ?>
/" title="<?php 
        _e('Groups', 'cc');
        ?>
"><?php 
        _e('Groups', 'cc');
        ?>
</a>
                                            </li>
			
                                        <?php 
        if (bp_is_active('forums') && (function_exists('bp_forums_is_installed_correctly') && !(int) bp_get_option('bp-disable-forum-directory')) && bp_forums_is_installed_correctly()) {
            ?>
                                                <li<?php 
            if (bp_is_forums_component()) {
                ?>
 class="selected"<?php 
            }
            ?>
>
                                                        <a href="<?php 
            echo site_url();
            ?>
/<?php 
            echo BP_FORUMS_SLUG;
            ?>
/" title="<?php 
            _e('Forums', 'cc');
            ?>
"><?php 
            _e('Forums', 'cc');
            ?>
</a>
                                                </li>
                                        <?php 
        }
        ?>
					<?php 
    }
    ?>
					<?php 
    if (bp_is_active('blogs') && is_multisite()) {
        ?>
                                                        <li<?php 
        if (bp_is_blogs_component()) {
            ?>
 class="selected"<?php 
        }
        ?>
>
							<a href="<?php 
        echo site_url();
        ?>
/<?php 
        echo BP_BLOGS_SLUG;
        ?>
/" title="<?php 
        _e('Blogs', 'cc');
        ?>
"><?php 
        _e('Blogs', 'cc');
        ?>
</a>
						</li>
					<?php 
    }
    ?>
  				</ul>
				
   <?php 
    if (bp_is_single_item() || bp_is_user()) {
        ?>
	   	<?php 
        if (bp_is_group()) {
            ?>
		<div id="community-single-nav" class="widget-title" >
		  <ul class="item-list">
		  <h3 class="widgettitle"><?php 
            _e('@ Group', 'cc');
            ?>
</h3>
				<?php 
            bp_get_options_nav();
            ?>
				<?php 
            do_action('bp_group_options_nav');
            ?>
			</ul>
		
		</div>	
		<?php 
        }
        ?>

		<?php 
        if (bp_is_user()) {
            ?>
		<div id="community-single-nav" class="widget-title" >
		  <ul class="item-list">
		  <h3 class="widgettitle"><?php 
            _e('@ Member', 'cc');
            ?>
</h3>
		  <?php 
            bp_get_displayed_user_nav();
            ?>
				<?php 
            do_action('bp_group_options_nav');
            ?>
			</ul>
		
		</div>	
		<?php 
        }
        ?>
  	<?php 
    }
    ?>
  	</div>
<?php 
}
 /**
  * Get the group id to set its avatar.
  *
  * @since 2.3.0
  *
  * @return integer The group ID.
  */
 private function get_group_id()
 {
     $group_id = 0;
     if (bp_is_group()) {
         $group_id = bp_get_current_group_id();
     }
     return $group_id;
 }
Example #28
0
if (member_is_in_single_group()) {
    //get the group slug
    ?>
							<li class="trans-nav-link"><a class="trans-nav-courses <?php 
    echo $group_active_class;
    ?>
" href="<?php 
    echo $user_courses_link;
    ?>
">Your Courses</a></li>
							<?php 
} else {
    ?>
							<li class="trans-nav-link"><a class="trans-nav-courses <?php 
    echo $group_active_class;
    ?>
" href="<?php 
    echo $user_courses_link;
    ?>
">Your Courses</a></li>
							<?php 
}
?>
						</ul>
					</div>		
 	<?php 
if (bp_is_group() || bp_is_user()) {
    ?>
 		 	</div>
 	<?php 
}
/**
 * Determine access setting for a group/user pair.
 *
 * @param int $group_id Group ID. Default: current group ID.
 * @param int $user_id User ID. Default: current user ID.
 */
function invite_anyone_group_invite_access_test($group_id = 0, $user_id = 0)
{
    global $current_user, $bp;
    if (empty($group_id)) {
        $group_id = bp_is_group() ? bp_get_current_group_id() : 0;
    }
    if (empty($group_id) && !bp_is_group_create()) {
        return 'noone';
    }
    if (empty($user_id)) {
        $user_id = bp_loggedin_user_id();
    }
    if (empty($user_id)) {
        return 'noone';
    }
    $iaoptions = invite_anyone_options();
    if (bp_is_group_create()) {
        if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) {
            return 'anyone';
        }
        if ($iaoptions['group_invites_can_group_admin'] == 'friends') {
            return 'friends';
        }
        if ($iaoptions['group_invites_can_group_admin'] == 'noone') {
            return 'noone';
        }
    }
    if (!groups_is_user_member($user_id, $group_id)) {
        return 'noone';
    }
    if (user_can($user_id, 'bp_moderate')) {
        if (empty($iaoptions['group_invites_can_admin']) || $iaoptions['group_invites_can_admin'] == 'anyone' || !$iaoptions['group_invites_can_admin']) {
            return 'anyone';
        }
        if ($iaoptions['group_invites_can_admin'] == 'friends') {
            return 'friends';
        }
        if ($iaoptions['group_invites_can_admin'] == 'noone') {
            return 'noone';
        }
    } else {
        if (groups_is_user_admin($user_id, $group_id)) {
            if (empty($iaoptions['group_invites_can_group_admin']) || $iaoptions['group_invites_can_group_admin'] == 'anyone' || !$iaoptions['group_invites_can_group_admin']) {
                return 'anyone';
            }
            if ($iaoptions['group_invites_can_group_admin'] == 'friends') {
                return 'friends';
            }
            if ($iaoptions['group_invites_can_group_admin'] == 'noone') {
                return 'noone';
            }
        } else {
            if (groups_is_user_mod($user_id, $group_id)) {
                if (empty($iaoptions['group_invites_can_group_mod']) || $iaoptions['group_invites_can_group_mod'] == 'anyone' || !$iaoptions['group_invites_can_group_mod']) {
                    return 'anyone';
                }
                if ($iaoptions['group_invites_can_group_mod'] == 'friends') {
                    return 'friends';
                }
                if ($iaoptions['group_invites_can_group_mod'] == 'noone') {
                    return 'noone';
                }
            } else {
                if (empty($iaoptions['group_invites_can_group_member']) || $iaoptions['group_invites_can_group_member'] == 'anyone' || !$iaoptions['group_invites_can_group_member']) {
                    return 'anyone';
                }
                if ($iaoptions['group_invites_can_group_member'] == 'friends') {
                    return 'friends';
                }
                if ($iaoptions['group_invites_can_group_member'] == 'noone') {
                    return 'noone';
                }
            }
        }
    }
    return 'noone';
}
/**
 * Send email and BP notifications when a user is mentioned in an update.
 *
 * @since 1.2.0
 *
 * @uses bp_notifications_add_notification()
 * @uses bp_get_user_meta()
 * @uses bp_core_get_user_displayname()
 * @uses bp_activity_get_permalink()
 * @uses bp_core_get_user_domain()
 * @uses bp_get_settings_slug()
 * @uses bp_activity_filter_kses()
 * @uses bp_core_get_core_userdata()
 * @uses wp_specialchars_decode()
 * @uses get_blog_option()
 * @uses bp_is_active()
 * @uses bp_is_group()
 * @uses bp_get_current_group_name()
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_to' hook.
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_subject' hook.
 * @uses apply_filters() To call the 'bp_activity_at_message_notification_message' hook.
 * @uses wp_mail()
 * @uses do_action() To call the 'bp_activity_sent_mention_email' hook.
 *
 * @param int $activity_id      The ID of the activity update.
 * @param int $receiver_user_id The ID of the user who is receiving the update.
 */
function bp_activity_at_message_notification($activity_id, $receiver_user_id)
{
    // Don't leave multiple notifications for the same activity item.
    $notifications = BP_Core_Notification::get_all_for_user($receiver_user_id, 'all');
    foreach ($notifications as $notification) {
        if ($activity_id == $notification->item_id) {
            return;
        }
    }
    $activity = new BP_Activity_Activity($activity_id);
    $subject = '';
    $message = '';
    $content = '';
    // Now email the user with the contents of the message (if they have enabled email notifications).
    if ('no' != bp_get_user_meta($receiver_user_id, 'notification_activity_new_mention', true)) {
        $poster_name = bp_core_get_user_displayname($activity->user_id);
        $message_link = bp_activity_get_permalink($activity_id);
        $settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
        $settings_link = bp_core_get_user_domain($receiver_user_id) . $settings_slug . '/notifications/';
        $poster_name = stripslashes($poster_name);
        $content = bp_activity_filter_kses(strip_tags(stripslashes($activity->content)));
        // Set up and send the message.
        $ud = bp_core_get_core_userdata($receiver_user_id);
        $to = $ud->user_email;
        $subject = bp_get_email_subject(array('text' => sprintf(__('%s mentioned you in an update', 'buddypress'), $poster_name)));
        if (bp_is_active('groups') && bp_is_group()) {
            $message = sprintf(__('%1$s mentioned you in the group "%2$s":

"%3$s"

To view and respond to the message, log in and visit: %4$s

---------------------
', 'buddypress'), $poster_name, bp_get_current_group_name(), $content, $message_link);
        } else {
            $message = sprintf(__('%1$s mentioned you in an update:

"%2$s"

To view and respond to the message, log in and visit: %3$s

---------------------
', 'buddypress'), $poster_name, $content, $message_link);
        }
        // Only show the disable notifications line if the settings component is enabled.
        if (bp_is_active('settings')) {
            $message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
        }
        /**
         * Filters the user email that the @mention notification will be sent to.
         *
         * @since 1.2.0
         *
         * @param string $to User email the notification is being sent to.
         */
        $to = apply_filters('bp_activity_at_message_notification_to', $to);
        /**
         * Filters the @mention notification subject that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $subject     Email notification subject text.
         * @param string $poster_name Name of the person who made the @mention.
         */
        $subject = apply_filters('bp_activity_at_message_notification_subject', $subject, $poster_name);
        /**
         * Filters the @mention notification message that will be sent to user.
         *
         * @since 1.2.0
         *
         * @param string $message       Email notification message text.
         * @param string $poster_name   Name of the person who made the @mention.
         * @param string $content       Content of the @mention.
         * @param string $message_link  URL permalink for the activity message.
         * @param string $settings_link URL permalink for the user's notification settings area.
         */
        $message = apply_filters('bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link);
        wp_mail($to, $subject, $message);
    }
    /**
     * Fires after the sending of an @mention email notification.
     *
     * @since 1.5.0
     *
     * @param BP_Activity_Activity $activity         Activity Item object.
     * @param string               $subject          Email notification subject text.
     * @param string               $message          Email notification message text.
     * @param string               $content          Content of the @mention.
     * @param int                  $receiver_user_id The ID of the user who is receiving the update.
     */
    do_action('bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id);
}