Skip to:
Content

BuddyPress.org

Changeset 2287


Ignore:
Timestamp:
01/10/2010 08:42:42 PM (15 years ago)
Author:
apeatling
Message:

Shifted the filter select from the main activity page tab row onto a second row to accommodate the missing feed link (links will be altered on an upcoming commit). Added a mentions tab. Tweaked a couple of css styles and ID's for better re-use.

Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2285 r2287  
    194194
    195195function bp_activity_screen_notification_settings() {
    196     global $current_user; ?>
     196    global $bp; ?>
    197197    <table class="notification-settings" id="activity-notification-settings">
    198198        <tr>
     
    205205        <tr>
    206206            <td></td>
    207             <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), $current_user->user_login ) ?></td>
    208             <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $current_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
    209             <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
     207            <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ?></td>
     208            <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
     209            <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
    210210        </tr>
    211211        <tr>
    212212            <td></td>
    213213            <td><?php printf( __( "A member replies to an update you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
    214             <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $current_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
    215             <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
     214            <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
     215            <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_usermeta( $bp->loggedin_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
    216216        </tr>
    217217
     
    444444}
    445445
     446function bp_activity_post_update( $args = '' ) {
     447    global $bp;
     448
     449    $defaults = array(
     450        'content' => false,
     451        'user_id' => $bp->loggedin_user->id
     452    );
     453
     454    $r = wp_parse_args( $args, $defaults );
     455    extract( $r, EXTR_SKIP );
     456
     457    if ( empty($content) || empty($content) )
     458        return false;
     459
     460    /* Record this on the user's profile */
     461    $from_user_link = bp_core_get_userlink( $user_id );
     462    $activity_content = sprintf( __('%s posted an update:', 'buddypress'), $from_user_link );
     463    $activity_content .= '<div class="activity-inner">' . $content . '</div>';
     464
     465    $primary_link = bp_core_get_userlink( $user_id, false, true );
     466
     467    /* Now write the values */
     468    $activity_id = bp_activity_add( array(
     469        'user_id' => $user_id,
     470        'content' => apply_filters( 'bp_activity_new_update_content', $activity_content ),
     471        'primary_link' => apply_filters( 'bp_activity_new_update_primary_link', $primary_link ),
     472        'component_name' => $bp->activity->id,
     473        'component_action' => 'new_wire_post'
     474    ) );
     475
     476    /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
     477    update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
     478
     479    do_action( 'bp_activity_posted_update', $content, $user_id, $activity_id );
     480
     481    return $activity_id;
     482}
     483
    446484function bp_activity_new_comment( $args = '' ) {
    447485    global $bp;
  • trunk/bp-activity/bp-activity-filters.php

    r2270 r2287  
    7474
    7575    foreach( (array)$usernames as $username ) {
    76         if ( !username_exists( $username ) )
     76        if ( !$user_id = username_exists( $username ) )
    7777            continue;
     78
     79        /* Increase the number of new @ mentions for the user */
     80        $new_mention_count = (int)get_usermeta( $user_id, 'bp_new_mention_count' );
     81        update_usermeta( $user_id, 'bp_new_mention_count', $new_mention_count + 1 );
    7882
    7983        $content = str_replace( "@$username", "<a href='" . bp_core_get_user_domain( bp_core_get_userid( $username ) ) . "' rel='nofollow'>@$username</a>", $content );
     
    8286    return $content;
    8387}
    84 add_filter( 'xprofile_activity_new_update_content', 'bp_activity_at_name_filter' );
     88add_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' );
    8589add_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
    8690add_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' );
  • trunk/bp-activity/bp-activity-notifications.php

    r2277 r2287  
    11<?php
     2
     3function bp_activity_at_message_notification( $content, $poster_user_id, $activity_id ) {
     4    global $bp;
     5
     6    /* Scan for @username strings in an activity update. Notify each user. */
     7    $pattern = '/[@]+([A-Za-z0-9-_]+)/';
     8    preg_match_all( $pattern, $content, $usernames );
     9
     10    /* Make sure there's only one instance of each username */
     11    if ( !$usernames = array_unique( $usernames[1] ) )
     12        return false;
     13
     14    foreach( (array)$usernames as $username ) {
     15        if ( !$receiver_user_id = bp_core_get_userid($username) )
     16            continue;
     17
     18        // Add a screen notification of an @message
     19        bp_core_add_notification( $activity_id, $receiver_user_id, $bp->activity->id, 'new_at_mention', $poster_user_id );
     20
     21        // Now email the user with the contents of the message (if they have enabled email notifications)
     22        if ( !get_usermeta( $user_id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $user_id, 'notification_activity_new_mention' ) ) {
     23            $poster_name = bp_core_get_user_displayname( $poster_user_id );
     24
     25            $message_link = bp_activity_get_permalink( $activity_id );
     26            $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications/';
     27
     28            // Set up and send the message
     29            $ud = get_userdata( $receiver_user_id );
     30            $to = $ud->user_email;
     31            $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), stripslashes($poster_name) );
     32
     33$message = sprintf( __(
     34'%s mentioned you in an update:
     35
     36"%s"
     37
     38To view and respond to the message, log in and visit: %s
     39
     40---------------------
     41', 'buddypress' ), $poster_name, wp_filter_kses( stripslashes($content) ), $message_link );
     42
     43            $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     44
     45            // Send it
     46            wp_mail( $to, $subject, $message );
     47        }
     48    }
     49}
     50add_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 );
    251
    352function bp_activity_new_comment_notification( $comment_id, $params ) {
  • trunk/bp-activity/bp-activity-templatetags.php

    r2277 r2287  
    666666    }
    667667
     668function bp_total_mention_count_for_user( $user_id = false ) {
     669    echo bp_get_total_favorite_count_for_user( $user_id );
     670}
     671    function bp_get_total_mention_count_for_user( $user_id = false ) {
     672        return apply_filters( 'bp_get_total_mention_count_for_user', get_usermeta( $user_id, 'bp_new_mention_count' ) );
     673    }
     674
    668675function bp_send_public_message_link() {
    669676    echo bp_get_send_public_message_link();
     
    672679        global $bp;
    673680
    674         return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . $bp->displayed_user->userdata->user_login );
    675     }
     681        return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
     682    }
     683
    676684
    677685/* RSS Feed Template Tags ***************************/
  • trunk/bp-messages/bp-messages-templatetags.php

    r2276 r2287  
    442442        global $bp;
    443443
    444         return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $bp->displayed_user->userdata->user_login );
     444        return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
    445445    }
    446446
     
    454454            return false;
    455455
    456         return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $bp->displayed_user->userdata->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
     456        return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
    457457    }
    458458
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r2268 r2287  
    7171        ));
    7272    } else {
    73         $activity_id = xprofile_post_update( array(
     73        $activity_id = bp_activity_post_update( array(
    7474            'content' => $_POST['content']
    7575        ));
     
    169169            $query_string = 'user_id=' . $bp->displayed_user->id;
    170170        } else {
    171             /* Set a valid type */
    172             if ( !$type || ( 'all' != $type && 'friends' != $type && 'groups' != $type && 'favorites' != $type ) )
    173                 $type = 'all';
    174 
    175             if ( ( 'friends' == $type || 'groups' == $type || 'favorites' == $type ) && !is_user_logged_in() )
     171            /* Make sure a type is set. */
     172            if ( empty($type) )
    176173                $type = 'all';
    177174
     
    195192                    $query_string = 'include=' . $favorite_ids;
    196193                    break;
     194                case 'atme':
     195                    $query_string = 'search_terms=@' . bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login );
     196
     197                    /* Reset the number of new @ mentions for the user */
     198                    delete_usermeta( $bp->loggedin_user->id, 'bp_new_mention_count' );
     199                    break;
    197200            }
    198201        }
  • trunk/bp-themes/bp-default/_inc/css/default.css

    r2279 r2287  
    493493                }
    494494
    495     div.item-list-tabs#user-subnav,
    496     div.item-list-tabs#group-subnav {
     495    div.item-list-tabs#subnav {
    497496        background: #fff;
    498497        margin: 0 -15px 15px -15px;
  • trunk/bp-themes/bp-default/_inc/global.js

    r2284 r2287  
    9797
    9898    /* List tabs event delegation */
    99     j('div.item-list-tabs').click( function(event) {
     99    j('div.activity-type-tabs').click( function(event) {
    100100        var target = j(event.target).parent();
    101101
    102102        /* Activity Stream Tabs */
    103         if ( target.attr('id') == 'activity-all' ||
    104              target.attr('id') == 'activity-friends' ||
    105              target.attr('id') == 'activity-groups' ||
    106              target.attr('id') == 'activity-favorites' ) {
    107 
    108             var type = target.attr('id').substr( 9, target.attr('id').length );
    109             var filter = j("#activity-filter-select select").val();
    110 
    111             bp_activity_request(type, filter, target);
    112 
    113             return false;
    114         }
     103        var type = target.attr('id').substr( 9, target.attr('id').length );
     104        var filter = j("#activity-filter-select select").val();
     105
     106        if ( type == 'atme' )
     107            j( 'li#' + target.attr('id') + ' a strong' ).remove();
     108
     109        bp_activity_request(type, filter, target);
     110
     111        return false;
    115112    });
    116113
    117114    /* Activity filter select */
    118115    j('#activity-filter-select select').change( function() {
    119         var selected_tab = j( '.' + j(this).parent().parent().parent().attr('class') + ' li.selected');
     116        var selected_tab = j( 'div.activity-type-tabs li.selected' );
    120117
    121118        if ( !selected_tab.length )
     
    158155                if ( 'fav' == type ) {
    159156                    if ( !j('div.item-list-tabs li#activity-favorites').length )
    160                         j('div.item-list-tabs ul').append( '<li id="activity-favorites"><a href="">My Favorites (<span>0</span>)</a></li>');
     157                        j('div.item-list-tabs ul li#activity-atme').before( '<li id="activity-favorites"><a href="">My Favorites (<span>0</span>)</a></li>');
    161158
    162159                    target.removeClass('fav');
  • trunk/bp-themes/bp-default/activity/activity-loop.php

    r2284 r2287  
    2525<?php else : ?>
    2626    <div id="message" class="info">
    27         <p><?php _e( 'No activity found.', 'buddypress' ) ?></p>
     27        <p><?php _e( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ) ?></p>
    2828    </div>
    2929<?php endif; ?>
  • trunk/bp-themes/bp-default/activity/index.php

    r2284 r2287  
    1616            <?php do_action( 'template_notices' ) ?>
    1717
    18             <div class="item-list-tabs">
     18            <div class="item-list-tabs activity-type-tabs">
    1919                <ul>
    20                     <li class="selected" id="activity-all"><a href="<?php bp_root_domain() ?>"><?php printf( __( 'All Members (%s)', 'buddypress' ), bp_get_total_site_member_count() ) ?></a></li>
     20                    <li class="selected" id="activity-all"><a href="<?php bp_root_domain() ?>" title="<?php _e( 'The public activity for everyone on this site.', 'buddypress' ) ?>"><?php printf( __( 'All Members (%s)', 'buddypress' ), bp_get_total_site_member_count() ) ?></a></li>
    2121
    2222                    <?php if ( is_user_logged_in() ) : ?>
    2323
    2424                        <?php if ( bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
    25                             <li id="activity-friends"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/my-friends/' ?>"><?php printf( __( 'My Friends (%s)', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ) ?></a></li>
     25                            <li id="activity-friends"><a href="<?php echo site_url( BP_ACTIVITY_SLUG . '/#my-friends/' ) ?>" title="<?php _e( 'The activity of my friends only.', 'buddypress' ) ?>"><?php printf( __( 'My Friends (%s)', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ) ?></a></li>
    2626                        <?php endif; ?>
    2727
    2828                        <?php if ( bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) : ?>
    29                             <li id="activity-groups"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/my-groups/' ?>"><?php printf( __( 'My Groups (%s)', 'buddypress' ), bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) ?></a></li>
     29                            <li id="activity-groups"><a href="<?php echo site_url( BP_ACTIVITY_SLUG . '/#my-groups/' ) ?>" title="<?php _e( 'The activity of groups I am a member of.', 'buddypress' ) ?>"><?php printf( __( 'My Groups (%s)', 'buddypress' ), bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) ?></a></li>
    3030                        <?php endif; ?>
    3131
    3232                        <?php if ( bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) : ?>
    33                             <li id="activity-favorites"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/my-favorites/' ?>"><?php printf( __( 'My Favorites (<span>%s</span>)', 'buddypress' ), bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) ?></a></li>
     33                            <li id="activity-favorites"><a href="<?php echo site_url( BP_ACTIVITY_SLUG . '/#my-favorites/' ) ?>" title="<?php _e( "The activity I've marked as a favorite.", 'buddypress' ) ?>"><?php printf( __( 'My Favorites (<span>%s</span>)', 'buddypress' ), bp_get_total_favorite_count_for_user( bp_loggedin_user_id() ) ) ?></a></li>
    3434                        <?php endif; ?>
     35
     36                        <li id="activity-atme"><a href="<?php echo site_url( BP_ACTIVITY_SLUG . '/#atme/' ) ?>" title="<?php _e( 'Activity that I have been mentioned in.', 'buddypress' ) ?>"><?php printf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() ) ?><?php if ( bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) : ?> <strong><?php printf( __( '(%s new)', 'buddypress' ), bp_get_total_mention_count_for_user( bp_loggedin_user_id() ) ) ?></strong><?php endif; ?></a></li>
    3537
    3638                    <?php endif; ?>
    3739
    3840                    <?php do_action( 'bp_activity_type_tabs' ) ?>
     41                </ul>
     42            </div><!-- .item-list-tabs -->
     43
     44            <div class="item-list-tabs no-ajax" id="subnav">
     45                <ul>
     46                    <li class="feed"><a href="<?php bp_sitewide_activity_feed_link() ?>" title="RSS Feed"><?php _e( 'RSS', 'buddypress' ) ?></a></li>
     47
     48                    <?php do_action( 'bp_activity_syndication_options' ) ?>
    3949
    4050                    <li id="activity-filter-select" class="last">
  • trunk/bp-themes/bp-default/functions.php

    r2284 r2287  
    6565
    6666    if ( $comment->user_id )
    67         $userlink = bp_core_get_userurl( $comment->user_id );
     67        $userlink = bp_core_get_user_domain( $comment->user_id );
    6868
    6969    if ( $comment_type == 'comment' ) { ?>
  • trunk/bp-themes/bp-default/groups/single/activity.php

    r2284 r2287  
    1 <div class="item-list-tabs no-ajax" id="user-subnav">
     1<div class="item-list-tabs no-ajax" id="subnav">
    22    <ul>
    33        <li class="feed"><a href="<?php bp_group_activity_feed_link() ?>" title="RSS Feed"><?php _e( 'RSS', 'buddypress' ) ?></a></li>
  • trunk/bp-themes/bp-default/groups/single/admin.php

    r2284 r2287  
    1 <div class="item-list-tabs no-ajax" id="group-subnav">
     1<div class="item-list-tabs no-ajax" id="subnav">
    22    <ul>
    33        <?php bp_group_admin_tabs(); ?>
  • trunk/bp-themes/bp-default/groups/single/home.php

    r2284 r2287  
    1212
    1313            <div id="item-nav">
    14                 <div class="item-list-tabs no-ajax" id="group-nav">
     14                <div class="item-list-tabs no-ajax" id="sub-nav">
    1515                    <ul>
    1616                        <?php bp_get_options_nav() ?>
  • trunk/bp-themes/bp-default/groups/single/plugins.php

    r2284 r2287  
    1212
    1313            <div id="item-nav">
    14                 <div class="item-list-tabs no-ajax" id="group-nav">
     14                <div class="item-list-tabs no-ajax" id="sub-nav">
    1515                    <ul>
    1616                        <?php bp_get_options_nav() ?>
     
    2323            <div id="item-body">
    2424
    25                 <div class="item-list-tabs no-ajax" id="group-subnav">
     25                <div class="item-list-tabs no-ajax" id="subnav">
    2626                    <ul>
    2727                        <?php bp_get_options_nav() ?>
  • trunk/bp-themes/bp-default/members/single/activity.php

    r2284 r2287  
    1 <div class="item-list-tabs no-ajax" id="user-subnav">
     1<div class="item-list-tabs no-ajax" id="subnav">
    22    <ul>
    33        <li class="feed"><a href="<?php bp_activities_member_rss_link() ?>" title="RSS Feed"><?php _e( 'RSS', 'buddypress' ) ?></a></li>
  • trunk/bp-themes/bp-default/members/single/blogs.php

    r2284 r2287  
    1 <div class="item-list-tabs" id="user-subnav">
     1<div class="item-list-tabs" id="subnav">
    22    <ul>
    33        <li id="blogs-filter-select" class="last filter">
  • trunk/bp-themes/bp-default/members/single/friends.php

    r2284 r2287  
    1 <div class="item-list-tabs no-ajax" id="user-subnav">
     1<div class="item-list-tabs no-ajax" id="subnav">
    22    <ul>
    33        <?php if ( bp_is_my_profile() ) : ?>
  • trunk/bp-themes/bp-default/members/single/groups.php

    r2284 r2287  
    1 <div class="item-list-tabs no-ajax" id="user-subnav">
     1<div class="item-list-tabs no-ajax" id="subnav">
    22    <ul>
    33        <?php if ( bp_is_my_profile() ) : ?>
  • trunk/bp-themes/bp-default/members/single/messages.php

    r2284 r2287  
    1 <div class="item-list-tabs no-ajax" id="user-subnav">
     1<div class="item-list-tabs no-ajax" id="subnav">
    22    <ul>
    33        <?php bp_get_options_nav() ?>
  • trunk/bp-themes/bp-default/members/single/plugins.php

    r2284 r2287  
    1111
    1212            <div id="item-nav">
    13                 <div class="item-list-tabs no-ajax" id="user-nav">
     13                <div class="item-list-tabs no-ajax" id="sub-nav">
    1414                    <ul>
    1515                        <?php bp_get_user_nav() ?>
     
    2222            <div id="item-body">
    2323
    24                 <div class="item-list-tabs no-ajax" id="user-subnav">
     24                <div class="item-list-tabs no-ajax" id="subnav">
    2525                    <ul>
    2626                        <?php bp_get_options_nav() ?>
  • trunk/bp-themes/bp-default/members/single/profile.php

    r2284 r2287  
    11<?php if ( bp_is_my_profile() ) : ?>
    2     <div class="item-list-tabs no-ajax" id="user-subnav">
     2    <div class="item-list-tabs no-ajax" id="subnav">
    33        <ul>
    44            <?php bp_get_options_nav() ?>
  • trunk/bp-xprofile.php

    r2284 r2287  
    753753 */
    754754
    755 function xprofile_post_update( $args = '' ) {
    756     global $bp;
    757 
    758     $defaults = array(
    759         'content' => false,
    760         'user_id' => $bp->loggedin_user->id
    761     );
    762 
    763     $r = wp_parse_args( $args, $defaults );
    764     extract( $r, EXTR_SKIP );
    765 
    766     if ( empty($content) || empty($content) )
    767         return false;
    768 
    769     /* Record this on the user's profile */
    770     $from_user_link = bp_core_get_userlink( $user_id );
    771     $activity_content = sprintf( __('%s posted an update:', 'buddypress'), $from_user_link );
    772     $activity_content .= '<div class="activity-inner">' . $content . '</div>';
    773 
    774     $primary_link = bp_core_get_userlink( $user_id, false, true );
    775 
    776     /* Now write the values */
    777     $activity_id = xprofile_record_activity( array(
    778         'user_id' => $user_id,
    779         'content' => apply_filters( 'xprofile_activity_new_update_content', $activity_content ),
    780         'primary_link' => apply_filters( 'xprofile_activity_new_update_primary_link', $primary_link ),
    781         'component_action' => 'new_wire_post'
    782     ) );
    783 
    784     /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
    785     update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
    786 
    787     do_action( 'xprofile_posted_update', $content, $user_id, $activity_id );
    788 
    789     return $activity_id;
    790 }
    791 
    792755/*** Field Group Management **************************************************/
    793756
  • trunk/bp-xprofile/bp-xprofile-notifications.php

    r2218 r2287  
    11<?php
    2 
    3 function xprofile_at_message_notification( $content, $poster_user_id, $activity_id ) {
    4     global $bp;
    5 
    6     /* Scan for @username strings in an activity update. Notify each user. */
    7     $pattern = '/[@]+([A-Za-z0-9-_]+)/';
    8     preg_match_all( $pattern, $content, $usernames );
    9 
    10     /* Make sure there's only one instance of each username */
    11     if ( !$usernames = array_unique( $usernames[1] ) )
    12         return false;
    13 
    14     foreach( (array)$usernames as $username ) {
    15         if ( !$receiver_user_id = bp_core_get_userid($username) )
    16             continue;
    17 
    18         // Add a screen notification of an @message
    19         bp_core_add_notification( $activity_id, $receiver_user_id, $bp->profile->id, 'new_at_mention', $poster_user_id );
    20 
    21         // Now email the user with the contents of the message (if they have enabled email notifications)
    22         if ( !get_usermeta( $user_id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $user_id, 'notification_activity_new_mention' ) ) {
    23             $poster_name = bp_core_get_user_displayname( $poster_user_id );
    24 
    25             $message_link = bp_activity_get_permalink( $activity_id );
    26             $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications/';
    27 
    28             // Set up and send the message
    29             $ud = get_userdata( $receiver_user_id );
    30             $to = $ud->user_email;
    31             $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), stripslashes($poster_name) );
    32 
    33 $message = sprintf( __(
    34 '%s mentioned you in an update:
    35 
    36 "%s"
    37 
    38 To view and respond to the message, log in and visit: %s
    39 
    40 ---------------------
    41 ', 'buddypress' ), $poster_name, wp_filter_kses( stripslashes($content) ), $message_link );
    42 
    43             $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    44 
    45             // Send it
    46             wp_mail( $to, $subject, $message );
    47         }
    48     }
    49 }
    50 add_action( 'xprofile_posted_update', 'xprofile_at_message_notification', 10, 3 );
    512
    523/**
Note: See TracChangeset for help on using the changeset viewer.