Skip to:
Content

BuddyPress.org

Changeset 3300


Ignore:
Timestamp:
10/24/2010 09:22:29 PM (14 years ago)
Author:
djpaul
Message:

Fixed #2676

Location:
trunk
Files:
1 added
99 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2863 r3300  
    55
    66function bp_activity_setup_globals() {
    7     global $bp, $wpdb, $current_blog;
     7    global $bp, $current_blog;
    88
    99    if ( !defined( 'BP_ACTIVITY_SLUG' ) )
    1010        define ( 'BP_ACTIVITY_SLUG', $bp->pages->activity->slug );
    1111
    12     /* For internal identification */
     12    // For internal identification
    1313    $bp->activity->id = 'activity';
    1414    $bp->activity->name = $bp->pages->activity->name;
    1515    $bp->activity->slug = BP_ACTIVITY_SLUG;
    1616
    17     $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity';
    18     $bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta';
     17    $bp->activity->table_name      = $bp->table_prefix . 'bp_activity';
     18    $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
     19
    1920    $bp->activity->format_notification_function = 'bp_activity_format_notifications';
    2021
    21     /* Register this in the active components array */
     22    // Register this in the active components array
    2223    $bp->active_components[$bp->activity->slug] = $bp->activity->id;
    2324
     
    4344
    4445    if ( bp_is_active( 'groups' ) )
    45         bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => $bp->groups->name, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
     46        bp_core_new_subnav_item( array( 'name' => __( 'Groups', 'buddypress' ), 'slug' => BP_GROUPS_SLUG, 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_groups', 'position' => 30, 'item_css_id' => 'activity-groups' ) );
    4647
    4748    bp_core_new_subnav_item( array( 'name' => __( 'Favorites', 'buddypress' ), 'slug' => 'favorites', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->name, 'screen_function' => 'bp_activity_screen_favorites', 'position' => 40, 'item_css_id' => 'activity-favs' ) );
     
    9394        return false;
    9495
    95     if ( !is_site_admin() )
     96    if ( !is_super_admin() )
    9697        $bp->is_item_admin = false;
    9798
     
    106107        return false;
    107108
    108     if ( !is_site_admin() )
     109    if ( !is_super_admin() )
    109110        $bp->is_item_admin = false;
    110111
     
    116117    global $bp;
    117118
    118     if ( !is_site_admin() )
     119    if ( !is_super_admin() )
    119120        $bp->is_item_admin = false;
    120121
     
    126127    global $bp;
    127128
    128     if ( !is_site_admin() )
     129    if ( !is_super_admin() )
    129130        $bp->is_item_admin = false;
    130131
     
    173174            bp_core_redirect( $bp->loggedin_user->domain );
    174175        else
    175             bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . clean_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) );
     176            bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) );
    176177    }
    177178
     
    183184function bp_activity_screen_notification_settings() {
    184185    global $bp; ?>
    185     <table class="notification-settings" id="activity-notification-settings">
    186         <tr>
    187             <th class="icon"></th>
    188             <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
    189             <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    190             <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    191         </tr>
    192 
    193         <tr>
    194             <td></td>
    195             <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) ) ?></td>
    196             <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>
    197             <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>
    198         </tr>
    199         <tr>
    200             <td></td>
    201             <td><?php printf( __( "A member replies to an update or comment you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
    202             <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>
    203             <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>
    204         </tr>
    205 
    206         <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
     186    <table class="notification-settings zebra" id="activity-notification-settings">
     187        <thead>
     188            <tr>
     189                <th class="icon"></th>
     190                <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
     191                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     192                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     193            </tr>
     194        </thead>
     195
     196        <tbody>
     197            <tr>
     198                <td></td>
     199                <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->loggedin_user->id, $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login ) ) ?></td>
     200                <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_mention', true ) || 'yes' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_mention', true ) ) { ?>checked="checked" <?php } ?>/></td>
     201                <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_mention', true ) ) { ?>checked="checked" <?php } ?>/></td>
     202            </tr>
     203            <tr>
     204                <td></td>
     205                <td><?php printf( __( "A member replies to an update or comment you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
     206                <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_reply', true ) || 'yes' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_reply', true ) ) { ?>checked="checked" <?php } ?>/></td>
     207                <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_reply', true ) ) { ?>checked="checked" <?php } ?>/></td>
     208            </tr>
     209
     210            <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
     211        </tbody>
    207212    </table>
    208213<?php
     
    271276
    272277    /* Check access */
    273     if ( !is_site_admin() && $activity->user_id != $bp->loggedin_user->id )
     278    if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id )
    274279        return false;
    275280
     
    541546
    542547function bp_activity_add( $args = '' ) {
    543     global $bp, $wpdb;
     548    global $bp;
    544549
    545550    $defaults = array(
    546         'id' => false, // Pass an existing activity ID to update an existing entry.
    547 
    548         'action' => '', // The activity action - e.g. "Jon Doe posted an update"
    549         'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
    550 
    551         'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
    552         'type' => false, // The activity type e.g. activity_update, profile_updated
    553         'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
    554 
    555         'user_id' => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
    556         'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
     551        'id'                => false, // Pass an existing activity ID to update an existing entry.
     552
     553        'action'            => '', // The activity action - e.g. "Jon Doe posted an update"
     554        'content'           => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
     555
     556        'component'         => false, // The name/ID of the component e.g. groups, profile, mycomponent
     557        'type'              => false, // The activity type e.g. activity_update, profile_updated
     558        'primary_link'      => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
     559
     560        'user_id'           => $bp->loggedin_user->id, // Optional: The user to record the activity for, can be false if this activity is not for a user.
     561        'item_id'           => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
    557562        'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
    558         'recorded_time' => gmdate( "Y-m-d H:i:s" ), // The GMT time that this activity was recorded
    559         'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
     563        'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
     564        'hide_sitewide'     => false // Should this be hidden on the sitewide activity stream?
    560565    );
    561566
     
    628633
    629634    /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
    630     update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
     635    update_user_meta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
    631636
    632637    /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
     
    755760        $user_id = $args['user_id'];
    756761
    757     $latest_update = get_usermeta( $user_id, 'bp_latest_update' );
     762    $latest_update = get_user_meta( $user_id, 'bp_latest_update', true );
    758763    if ( !empty( $latest_update ) ) {
    759764        if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
    760             delete_usermeta( $user_id, 'bp_latest_update' );
     765            delete_user_meta( $user_id, 'bp_latest_update' );
    761766    }
    762767
     
    909914
    910915function bp_activity_get_user_favorites( $user_id ) {
    911     $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
     916    $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
    912917    $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) );
    913918
     
    916921
    917922    $new_favs = array_unique( (array)$new_favs );
    918     update_usermeta( $user_id, 'bp_favorite_activities', $new_favs );
     923    update_user_meta( $user_id, 'bp_favorite_activities', $new_favs );
    919924
    920925    return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
     
    928933
    929934    /* Update the user's personal favorites */
    930     $my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
     935    $my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) );
    931936    $my_favs[] = $activity_id;
    932937
     
    939944        $fav_count = 1;
    940945
    941     update_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
     946    update_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
    942947    bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count );
    943948
     
    954959
    955960    /* Remove the fav from the user's favs */
    956     $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
     961    $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
    957962    $my_favs = array_flip( (array) $my_favs );
    958963    unset( $my_favs[$activity_id] );
     
    967972    }
    968973
    969     update_usermeta( $user_id, 'bp_favorite_activities', $my_favs );
     974    update_user_meta( $user_id, 'bp_favorite_activities', $my_favs );
    970975
    971976    do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
     
    10891094
    10901095    // Remove any usermeta
    1091     delete_usermeta( $user_id, 'bp_latest_update' );
    1092     delete_usermeta( $user_id, 'bp_favorite_activities' );
     1096    delete_user_meta( $user_id, 'bp_latest_update' );
     1097    delete_user_meta( $user_id, 'bp_favorite_activities' );
    10931098
    10941099    do_action( 'bp_activity_remove_data', $user_id );
     
    10981103add_action( 'make_spam_user', 'bp_activity_remove_data' );
    10991104
     1105/**
     1106 * updates_register_activity_actions()
     1107 *
     1108 * Register the activity stream actions for updates
     1109 *
     1110 * @global array $bp
     1111 */
     1112function updates_register_activity_actions() {
     1113    global $bp;
     1114
     1115    bp_activity_set_action( $bp->activity->id, 'activity_update', __( 'Posted an update', 'buddypress' ) );
     1116
     1117    do_action( 'updates_register_activity_actions' );
     1118}
     1119add_action( 'bp_register_activity_actions', 'updates_register_activity_actions' );
    11001120
    11011121/********************************************************************************
     
    11101130    do_action( 'bp_register_activity_actions' );
    11111131}
    1112 add_action( 'plugins_loaded', 'bp_register_activity_actions' );
     1132add_action( 'bp_loaded', 'bp_register_activity_actions', 8 );
    11131133
    11141134
  • trunk/bp-activity/bp-activity-classes.php

    r3236 r3300  
    9898        $where_conditions = array();
    9999
     100        /* Searching */
     101        if ( $search_terms ) {
     102            $search_terms = $wpdb->escape( $search_terms );
     103            $where_conditions['search_sql'] = "a.content LIKE '%%" . like_escape( $search_terms ) . "%%'";
     104        }
     105
    100106        /* Filtering */
    101107        if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) )
     
    117123        $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
    118124
    119         /* Searching */
    120         if ( $search_terms ) {
    121             $search_terms = $wpdb->escape( $search_terms );
    122 
    123             if ( !empty( $filter['user_id'] ) )
    124                 $where_sql .= ' OR ';
    125             else if ( !empty( $where_conditions ) )
    126                 $where_sql .= ' AND ';
    127 
    128             $where_sql .= "a.content LIKE '%%" . like_escape( $search_terms ) . "%%'";
    129         }
    130 
    131125        if ( $per_page && $page ) {
    132126            $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page ), intval( $per_page ) );
    133127            $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) ) );
    134         } else
     128        } else {
    135129            $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', $wpdb->prepare( "{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}", $select_sql, $from_sql, $where_sql, $sort ) ) );
     130        }
    136131
    137132        $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(a.id) FROM {$bp->activity->table_name} a {$where_sql} ORDER BY a.date_recorded {$sort}" ) );
     
    532527        global $bp, $wpdb;
    533528
    534         return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) );
     529        return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded DESC LIMIT 1" ) );
    535530    }
    536531
     
    538533        global $bp;
    539534
    540         if ( !$favorite_activity_entries = get_usermeta( $user_id, 'bp_favorite_activities' ) )
     535        if ( !$favorite_activity_entries = get_user_meta( $user_id, 'bp_favorite_activities', true ) )
    541536            return 0;
    542537
  • trunk/bp-activity/bp-activity-notifications.php

    r3232 r3300  
    55
    66    /* Scan for @username strings in an activity update. Notify each user. */
    7     $pattern = '/[@]+([A-Za-z0-9-_]+)/';
     7    $pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
    88    preg_match_all( $pattern, $content, $usernames );
    99
     
    1313
    1414    foreach( (array)$usernames as $username ) {
    15         if ( !$receiver_user_id = bp_core_get_userid($username) )
     15        if ( !$receiver_user_id = bp_core_get_userid( $username ) )
    1616            continue;
    1717
    1818        // Now email the user with the contents of the message (if they have enabled email notifications)
    19         if ( 'no' != get_usermeta( $receiver_user_id, 'notification_activity_new_mention' ) ) {
     19        if ( 'no' != get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
    2020            $poster_name = bp_core_get_user_displayname( $poster_user_id );
    2121
     
    2727
    2828            // Set up and send the message
    29             $ud = bp_core_get_core_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' ), $poster_name );
     29            $ud       = bp_core_get_core_userdata( $receiver_user_id );
     30            $to       = $ud->user_email;
     31            $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     32            $subject  = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name );
    3233
    3334$message = sprintf( __(
     
    6162    $original_activity = new BP_Activity_Activity( $activity_id );
    6263
    63     if ( $original_activity->user_id != $commenter_id && 'no' != get_usermeta( $original_activity->user_id, 'notification_activity_new_reply' ) ) {
     64    if ( $original_activity->user_id != $commenter_id && 'no' != get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) {
    6465        $poster_name = bp_core_get_user_displayname( $commenter_id );
    6566        $thread_link = bp_activity_get_permalink( $activity_id );
     
    7071
    7172        // Set up and send the message
    72         $ud = bp_core_get_core_userdata( $original_activity->user_id );
    73         $to = $ud->user_email;
    74         $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name );
     73        $ud       = bp_core_get_core_userdata( $original_activity->user_id );
     74        $to       = $ud->user_email;
     75        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     76        $subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name );
    7577
    7678$message = sprintf( __(
     
    103105    $parent_comment = new BP_Activity_Activity( $parent_id );
    104106
    105     if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != get_usermeta( $parent_comment->user_id, 'notification_activity_new_reply' ) ) {
     107    if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
    106108        $poster_name = bp_core_get_user_displayname( $commenter_id );
    107109        $thread_link = bp_activity_get_permalink( $activity_id );
     
    109111
    110112        // Set up and send the message
    111         $ud = bp_core_get_core_userdata( $parent_comment->user_id );
    112         $to = $ud->user_email;
    113         $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name );
     113        $ud       = bp_core_get_core_userdata( $parent_comment->user_id );
     114        $to       = $ud->user_email;
     115        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     116        $subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name );
    114117
    115118        $poster_name = stripslashes( $poster_name );
  • trunk/bp-activity/bp-activity-templatetags.php

    r3263 r3300  
    2626
    2727        // Get an array of the logged in user's favorite activities
    28         $this->my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
     28        $this->my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) );
    2929
    3030        // Fetch specific activity items based on ID's
    3131        if ( !empty( $include ) )
    3232            $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments ) );
     33        // Fetch all activity items
    3334        else
    3435            $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
     
    155156        $primary_id = $bp->groups->current_group->id;
    156157
    157         if ( 'public' != $bp->groups->current_group->status && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     158        if ( 'public' != $bp->groups->current_group->status && ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) || $bp->loggedin_user->is_super_admin ) )
    158159            $show_hidden = true;
    159160    }
     
    201202        // are we displaying user specific activity?
    202203        if ( is_numeric( $user_id ) ) {
    203             $show_hidden = ( $user_id == $bp->loggedin_user->id ) ? 1 : 0;
     204            $show_hidden = ( $user_id == $bp->loggedin_user->id && $scope != 'friends' ) ? 1 : 0;
    204205
    205206            switch ( $scope ) {
     
    275276        global $bp, $activities_template;
    276277
    277         $from_num = bp_core_number_format( intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1 );
    278         $to_num = bp_core_number_format( ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1 ) );
     278        $start_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
     279        $from_num = bp_core_number_format( $start_num );
     280        $to_num = bp_core_number_format( ( $start_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $start_num + ( $activities_template->pag_num - 1 ) );
    279281        $total = bp_core_number_format( $activities_template->total_activity_count );
    280282
    281         return sprintf( __( 'Viewing item %s to %s (of %s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' &nbsp; <span class="ajax-loader"></span>';
     283        return sprintf( __( 'Viewing item %1$s to %2$s (of %3$s items)', 'buddypress' ), $from_num, $to_num, $total ) . ' &nbsp; <span class="ajax-loader"></span>';
    282284    }
    283285
     
    403405    }
    404406
     407/**
     408 * bp_activity_avatar( $args )
     409 *
     410 * Output the avatar of the user that performed the action
     411 *
     412 * @param array $args
     413 */
    405414function bp_activity_avatar( $args = '' ) {
    406415    echo bp_get_activity_avatar( $args );
    407416}
     417    /**
     418     * bp_get_activity_avatar( $args )
     419     *
     420     * Return the avatar of the user that performed the action
     421     *
     422     * @global array $bp
     423     * @global object $activities_template
     424     * @param array $args optional
     425     * @return string
     426     */
    408427    function bp_get_activity_avatar( $args = '' ) {
    409428        global $bp, $activities_template;
    410429
    411430        $defaults = array(
    412             'type' => 'thumb',
    413             'width' => 20,
     431            'type'   => 'thumb',
     432            'width'  => 20,
    414433            'height' => 20,
    415             'class' => 'avatar',
    416             'alt' => __( 'Avatar', 'buddypress' ),
    417             'email' => false
     434            'class'  => 'avatar',
     435            'alt'    => __( 'Avatar', 'buddypress' ),
     436            'email'  => false
    418437        );
    419438
     
    421440        extract( $r, EXTR_SKIP );
    422441
    423         $item_id = false;
    424         if ( (int)$activities_template->activity->user_id )
    425             $item_id = $activities_template->activity->user_id;
    426         else if ( $activities_template->activity->item_id )
    427             $item_id = $activities_template->activity->item_id;
    428 
    429         $object = 'user';
    430         if ( $bp->groups->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id )
    431             $object = 'group';
    432         if ( $bp->blogs->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id )
    433             $object = 'blog';
    434 
    435         $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, $object );
    436 
    437         /* If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. */
    438         if ( 'user' == $object && empty($email) )
     442        // Primary activity avatar is always a user, but can be modified via a filter
     443        $object  = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, 'user' );
     444        $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $activities_template->activity->user_id );
     445
     446        // If this is a user object pass the users' email address for Gravatar so we don't have to refetch it.
     447        if ( 'user' == $object && empty( $email ) )
    439448            $email = $activities_template->activity->user_email;
    440449
    441450        return apply_filters( 'bp_get_activity_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) );
     451    }
     452
     453/**
     454 * bp_activity_secondary_avatar( $args )
     455 *
     456 * Output the avatar of the object that action was performed on
     457 *
     458 * @param array $args optional
     459 */
     460function bp_activity_secondary_avatar( $args = '' ) {
     461    echo bp_get_activity_secondary_avatar( $args );
     462}
     463    /**
     464     * bp_get_activity_secondary_avatar( $args )
     465     *
     466     * Return the avatar of the object that action was performed on
     467     *
     468     * @global array $bp
     469     * @global object $activities_template
     470     * @param array $args optional
     471     * @return string
     472     */
     473    function bp_get_activity_secondary_avatar( $args = '' ) {
     474        global $bp, $activities_template;
     475
     476        $defaults = array(
     477            'type'   => 'thumb',
     478            'width'  => 20,
     479            'height' => 20,
     480            'class'  => 'avatar',
     481            'alt'    => __( 'Avatar', 'buddypress' ),
     482            'email'  => false
     483        );
     484
     485        $r = wp_parse_args( $args, $defaults );
     486        extract( $r, EXTR_SKIP );
     487
     488        // Set item_id and object (default to user)
     489        switch ( $activities_template->activity->component ) {
     490            case 'groups' :
     491                $object = 'group';
     492                $item_id = $activities_template->activity->item_id;
     493                break;
     494            case 'blogs' :
     495                $object = 'blog';
     496                $item_id = $activities_template->activity->item_id;
     497                break;
     498            case 'friends' :
     499                $object  = 'user';
     500                $item_id = $activities_template->activity->secondary_item_id;
     501                break;
     502            default :
     503                $object  = 'user';
     504                $item_id = $activities_template->activity->user_id;
     505                $email = $activities_template->activity->user_email;
     506                break;
     507        }
     508
     509        // Allow object and item_id to be filtered
     510        $object  = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object );
     511        $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
     512
     513        // If we have no item_id or object, there is no avatar to display
     514        if ( empty( $item_id ) || empty( $object ) )
     515            return false;
     516
     517        return apply_filters( 'bp_get_activity_secondary_avatar', bp_core_fetch_avatar( array( 'item_id' => $item_id, 'object' => $object, 'type' => $type, 'alt' => $alt, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $email ) ) );
    442518    }
    443519
     
    449525
    450526        $action = $activities_template->activity->action;
     527
     528        $action = apply_filters( 'bp_get_activity_action_pre_meta', $action, &$activities_template->activity );
    451529
    452530        if ( !empty( $action ) )
     
    498576        global $activities_template, $bp;
    499577
    500         $meta = '<span class="activity-actions">';
     578        /* Strip any legacy time since placeholders -- TODO: Remove this in 1.3 */
     579        $content = str_replace( '<span class="time-since">%s</span>', '', $content );
    501580
    502581        /* Insert the time since. */
    503         $meta .= apply_filters( 'bp_activity_time_since', '<span class="time-since">' . sprintf( __( '&nbsp; %s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->date_recorded ) ) . '</span>', &$activities_template->activity );
     582        $content .= ' ' . apply_filters( 'bp_activity_time_since', '<span class="time-since">' . sprintf( __( '&nbsp; %s ago', 'buddypress' ), bp_core_time_since( $activities_template->activity->date_recorded ) ) . '</span>', &$activities_template->activity );
    504583
    505584        /* Insert the permalink */
    506         $meta .= apply_filters( 'bp_activity_permalink', ' &middot; <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity );
     585        $content .= apply_filters( 'bp_activity_permalink', ' &middot; <a href="' . bp_activity_get_permalink( $activities_template->activity->id, $activities_template->activity ) . '" class="view" title="' . __( 'View Thread / Permalink', 'buddypress' ) . '">' . __( 'View', 'buddypress' ) . '</a>', &$activities_template->activity );
    507586
    508587        /* Add the delete link if the user has permission on this item */
    509         if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_site_admin )
    510              $meta .= apply_filters( 'bp_activity_delete_link', ' &middot; ' . bp_get_activity_delete_link(), &$activities_template->activity );
    511 
    512         $meta .= '</span>';
    513 
    514         return apply_filters( 'bp_insert_activity_meta', $content . ' ' . $meta, $content, $meta );
     588        if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_super_admin )
     589             $content .= apply_filters( 'bp_activity_delete_link', ' &middot; ' . bp_get_activity_delete_link(), &$activities_template->activity );
     590
     591        return apply_filters( 'bp_insert_activity_meta', $content );
    515592    }
    516593
     
    585662
    586663                $content .= '<li id="acomment-' . $comment->id . '">';
    587                 $content .= '<div class="acomment-avatar"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => 25, 'height' => 25, 'email' => $comment->user_email ) ) . '</a></div>';
    588                 $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_get_member_name', $comment->user_fullname ) . '</a> &middot; ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( strtotime( $comment->date_recorded ) ) );
     664                $content .= '<div class="acomment-avatar"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'width' => 20, 'height' => 20, 'email' => $comment->user_email ) ) . '</a></div>';
     665                $content .= '<div class="acomment-meta"><a href="' . bp_core_get_user_domain( $comment->user_id, $comment->user_nicename, $comment->user_login ) . '">' . apply_filters( 'bp_acomment_name', $comment->user_fullname, $comment ) . '</a> &middot; ' . sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $comment->date_recorded ) );
    589666
    590667                /* Reply link - the span is so that threaded reply links can be hidden when JS is off. */
     
    593670
    594671                /* Delete link */
    595                 if ( $bp->loggedin_user->is_site_admin || $bp->loggedin_user->id == $comment->user_id )
     672                if ( $bp->loggedin_user->is_super_admin || $bp->loggedin_user->id == $comment->user_id )
    596673                    $content .= ' &middot; <a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/?cid=' . $comment->id, 'bp_activity_delete_link' ) . '" class="delete acomment-delete">' . __( 'Delete', 'buddypress' ) . '</a>';
    597674
     
    739816            $user_id = $bp->displayed_user->id;
    740817
    741         if ( !$update = get_usermeta( $user_id, 'bp_latest_update' ) )
     818        if ( !$update = get_user_meta( $user_id, 'bp_latest_update', true ) )
    742819            return false;
    743820
    744         $latest_update = '&quot;' . trim( strip_tags( bp_create_excerpt( $update['content'], 40 ) ) ) . '&quot;';
     821        $latest_update = '&quot;' . apply_filters( 'bp_get_activity_latest_update_excerpt', trim( strip_tags( bp_create_excerpt( $update['content'], 40 ) ) ) ) . '&quot;';
    745822        $latest_update .= ' &middot; <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $update['id'] . '/"> ' . __( 'View', 'buddypress' ) . '</a>';
    746823
     
    777854                unset($selected);
    778855
    779             $component = attribute_escape( $component );
     856            $component = esc_attr( $component );
    780857
    781858            switch ( $style ) {
     
    805882            $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
    806883
    807             $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;
     884            $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;
    808885        }
    809886
     
    811888
    812889        if ( isset( $_GET['afilter'] ) )
    813             $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
     890            $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
    814891
    815892        return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
     
    841918}
    842919    function bp_get_total_mention_count_for_user( $user_id = false ) {
    843         return apply_filters( 'bp_get_total_mention_count_for_user', get_usermeta( $user_id, 'bp_new_mention_count' ) );
     920        return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true ) );
    844921    }
    845922
  • trunk/bp-activity/feeds/bp-activity-favorites-feed.php

    r2600 r3300  
    1515    xmlns:dc="http://purl.org/dc/elements/1.1/"
    1616    xmlns:atom="http://www.w3.org/2005/Atom"
    17     <?php do_action('bp_activity_mentions_feed'); ?>
     17    <?php do_action('bp_activity_favorites_feed'); ?>
    1818>
    1919
  • trunk/bp-blogs.php

    r3232 r3300  
    1010    global $bp, $wpdb;
    1111
     12    if ( !defined( 'BP_BLOGS_SLUG' ) )
     13        define ( 'BP_BLOGS_SLUG', $bp->pages->blogs->slug );
     14
    1215    /* For internal identification */
    1316    $bp->blogs->id = 'blogs';
     
    4548
    4649    /* Add 'Blogs' to the main navigation */
    47     bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->name, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
    48 
    49     $blogs_link = $bp->loggedin_user->domain . $bp->blogs->name . '/';
     50    bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
     51
     52    $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
    5053
    5154    /* Set up the component options navigation for Blog */
     
    97100}
    98101
    99 function bp_blogs_screen_recent_posts() {
    100     do_action( 'bp_blogs_screen_recent_posts' );
    101     bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', 'members/single/home' ) );
    102 }
    103 
    104 function bp_blogs_screen_recent_comments() {
    105     do_action( 'bp_blogs_screen_recent_comments' );
    106     bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', 'members/single/home' ) );
    107 }
    108 
    109102function bp_blogs_screen_create_a_blog() {
    110103    global $bp;
     
    164157        'item_id' => false,
    165158        'secondary_item_id' => false,
    166         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     159        'recorded_time' => bp_core_current_time(),
    167160        'hide_sitewide' => false
    168161    );
     
    179172
    180173    if ( !empty( $content ) )
    181         $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ) );
     174        $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content );
    182175
    183176    /* Check for an existing entry and update if one exists. */
     
    245238}
    246239
    247 
    248240function bp_blogs_record_existing_blogs() {
    249241    global $bp, $wpdb;
     
    270262}
    271263
     264/**
     265 * Makes BuddyPress aware of a new site so that it can track its activity.
     266 *
     267 * @global object $bp BuddyPress global settings
     268 * @param int $blog_id
     269 * @param int $user_id
     270 * @param $bool $no_activity ; optional.
     271 * @since 1.0
     272 * @uses BP_Blogs_Blog
     273 */
    272274function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
    273275    global $bp;
     
    290292    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
    291293    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
    292     bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
    293 
    294     /* Only record this activity if the blog is public */
     294    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', bp_core_current_time() );
     295
     296    // Only record this activity if the blog is public
    295297    if ( (int)$_POST['blog_public'] && !$no_activity ) {
    296         /* Record this in activity streams */
     298        // Record this in activity streams
    297299        bp_blogs_record_activity( array(
    298             'user_id' => $recorded_blog->user_id,
    299             'action' => apply_filters( 'bp_blogs_activity_created_blog_action', sprintf( __( '%1$s created the blog %2$s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
    300             'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
    301             'type' => 'new_blog',
    302             'item_id' => $recorded_blog->blog_id
     300            'user_id'      => $recorded_blog->user_id,
     301            'action'       => apply_filters( 'bp_blogs_activity_created_blog_action', sprintf( __( '%s created the blog %s', 'buddypress'), bp_core_get_userlink( $recorded_blog->user_id ), '<a href="' . get_site_url( $recorded_blog->blog_id ) . '">' . esc_attr( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
     302            'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_site_url( $recorded_blog->blog_id ), $recorded_blog->blog_id ),
     303            'type'         => 'new_blog',
     304            'item_id'      => $recorded_blog->blog_id
    303305        ) );
    304306    }
     
    307309}
    308310add_action( 'wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );
     311
     312/**
     313 * bp_blogs_update_option_blogname()
     314 *
     315 * Updates blogname in BuddyPress blogmeta table
     316 *
     317 * @global object $wpdb DB Layer
     318 * @param string $oldvalue Value before save (not used)
     319 * @param string $newvalue Value to change meta to
     320 */
     321function bp_blogs_update_option_blogname( $oldvalue, $newvalue ) {
     322    global $wpdb;
     323    bp_blogs_update_blogmeta( $wpdb->blogid, 'name', $newvalue );
     324}
     325add_action( 'update_option_blogname', 'bp_blogs_update_option_blogname', 10, 2 );
     326
     327/**
     328 * bp_blogs_update_option_blogdescription()
     329 *
     330 * Updates blogdescription in BuddyPress blogmeta table
     331 *
     332 * @global object $wpdb DB Layer
     333 * @param string $oldvalue Value before save (not used)
     334 * @param string $newvalue Value to change meta to
     335 */
     336function bp_blogs_update_option_blogdescription( $oldvalue, $newvalue ) {
     337    global $wpdb;
     338    bp_blogs_update_blogmeta( $wpdb->blogid, 'description', $newvalue );
     339}
     340add_action( 'update_option_blogdescription', 'bp_blogs_update_option_blogdescription', 10, 2 );
    309341
    310342function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
     
    317349        $user_id = (int)$post->post_author;
    318350
    319     /* This is to stop infinate loops with Donncha's sitewide tags plugin */
     351    /* This is to stop infinite loops with Donncha's sitewide tags plugin */
    320352    if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id )
    321353        return false;
     
    325357        return false;
    326358
    327     if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
    328         if ( 'publish' == $post->post_status && '' == $post->post_password ) {
    329 
    330             /* If we're on a multiblog install, record this post */
    331             if ( bp_core_is_multisite() ) {
    332                 $recorded_post = new BP_Blogs_Post;
    333                 $recorded_post->user_id = $user_id;
    334                 $recorded_post->blog_id = $blog_id;
    335                 $recorded_post->post_id = $post_id;
    336                 $recorded_post->date_created = strtotime( $post->post_date );
    337 
    338                 $recorded_post_id = $recorded_post->save();
    339 
    340                 bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
    341             }
    342 
    343             if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
    344                 /* Record this in activity streams */
    345                 $post_permalink = get_permalink( $post_id );
    346 
    347                 $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
    348                 $activity_content = $post->post_content;
    349 
    350                 bp_blogs_record_activity( array(
    351                     'user_id' => (int)$post->post_author,
    352                     'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
    353                     'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
    354                     'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    355                     'type' => 'new_blog_post',
    356                     'item_id' => $blog_id,
    357                     'secondary_item_id' => $post_id,
    358                     'recorded_time' => $post->post_date_gmt
    359                 ));
    360             }
    361         }
    362     } else {
    363         $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
    364 
    365         /* Delete the recorded post if the status is not published or it is password protected */
    366         if ( 'publish' != $post->post_status || '' != $post->post_password ) {
    367             return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
    368 
    369         /* If the post author has changed, delete the post and re-add it. */
    370         } else if ( (int)$existing_post->user_id != (int)$post->post_author ) {
    371             // Delete the existing recorded post
    372             bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
    373 
    374             // Re-record the post with the new author.
    375             bp_blogs_record_post( $post_id );
    376         }
    377 
    378         bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
    379 
     359    if ( 'publish' == $post->post_status && '' == $post->post_password ) {
    380360        if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
    381             /* Now re-record the post in the activity streams */
     361            /* Record this in activity streams */
    382362            $post_permalink = get_permalink( $post_id );
    383363
    384             $activity_action = sprintf( __( '%1$s wrote a new blog post: %2$s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
     364            $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
    385365            $activity_content = $post->post_content;
    386366
     
    394374                'secondary_item_id' => $post_id,
    395375                'recorded_time' => $post->post_date_gmt
    396             ) );
     376            ));
    397377        }
    398     }
    399 
    400     bp_blogs_update_blogmeta( $blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
    401 
    402     do_action( 'bp_blogs_new_blog_post', $existing_post, $is_private, $is_recorded );
     378    } else
     379        bp_blogs_remove_post( $post_id, $blog_id );
     380
     381    bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() );
     382
     383    do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id );
    403384}
    404385add_action( 'save_post', 'bp_blogs_record_post', 10, 2 );
    405386
     387/**
     388 * bp_blogs_record_comment()
     389 *
     390 * Record blog comment activity. Checks if blog is public and post is not
     391 * password protected.
     392 *
     393 * @global object $wpdb
     394 * @global $bp $bp
     395 * @param int $comment_id
     396 * @param bool $is_approved
     397 * @return mixed
     398 */
    406399function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
    407400    global $wpdb, $bp;
     
    436429    // If blog is public allow activity to be posted
    437430    if ( get_blog_option( $blog_id, 'blog_public' ) ) {
     431
    438432        // Get activity related links
    439433        $post_permalink = get_permalink( $recorded_comment->comment_post_ID );
     
    441435
    442436        // Prepare to record in activity streams
    443         $activity_action        = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' );
    444         $activity_content       = $recorded_comment->comment_content;
     437        $activity_action    = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' );
     438        $activity_content   = $recorded_comment->comment_content;
    445439
    446440        // Record in activity streams
     
    523517add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
    524518
    525 function bp_blogs_remove_post( $post_id, $blog_id = false, $existing_post = false ) {
     519function bp_blogs_remove_post( $post_id, $blog_id = false ) {
    526520    global $current_blog, $bp;
    527521
     
    531525        $blog_id = (int)$current_blog->blog_id;
    532526
    533     if ( !$existing_post )
    534         $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
    535 
    536     // Delete post from the bp_blogs table
    537     BP_Blogs_Post::delete( $post_id, $blog_id );
    538 
    539527    // Delete activity stream item
    540528    bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) );
     
    546534function bp_blogs_remove_comment( $comment_id ) {
    547535    global $wpdb, $bp;
    548 
    549     $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
    550     BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
    551536
    552537    // Delete activity stream item
     
    585570    /* If this is regular blog, delete all data for that blog. */
    586571    BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    587     BP_Blogs_Post::delete_posts_for_blog( $blog_id );
    588     BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
    589572
    590573    // Delete activity stream item
     
    599582}
    600583
    601 /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_post' filter. */
    602 function bp_blogs_get_posts_for_user( $user_id ) {
    603     return BP_Blogs_Post::get_posts_for_user( $user_id );
    604 }
    605 
    606 /* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_comment' filter. */
    607 function bp_blogs_get_comments_for_user( $user_id ) {
    608     return BP_Blogs_Comment::get_comments_for_user( $user_id );
    609 }
    610 
    611 function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
    612     global $bp;
    613 
    614     if ( !is_numeric( $limit ) )
    615         $limit = 5;
    616 
    617     return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
    618 }
    619 
    620584function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
    621585    return BP_Blogs_Blog::get_all( $limit, $page );
     
    626590}
    627591
    628 function bp_blogs_get_all_posts( $limit = null, $page = null ) {
    629     return BP_Blogs_Post::get_all( $limit, $page );
    630 }
    631 
    632 function bp_blogs_total_post_count( $blog_id ) {
    633     return BP_Blogs_Post::total_post_count( $blog_id );
    634 }
    635 
    636 function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
    637     return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
    638 }
    639 
    640592function bp_blogs_is_blog_hidden( $blog_id ) {
    641593    return BP_Blogs_Blog::is_hidden( $blog_id );
     
    648600        $blog = bp_blogs_get_random_blogs( 1, 1 );
    649601
    650         bp_core_redirect( get_blog_option( $blog['blogs'][0]->blog_id, 'siteurl') );
     602        bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );
    651603    }
    652604}
     
    664616    global $wpdb, $bp;
    665617
    666     if ( !is_numeric( $blog_id ) )
     618    if ( !is_numeric( $blog_id ) || !bp_core_is_multisite() )
    667619        return false;
    668620
     
    692644    $blog_id = (int) $blog_id;
    693645
    694     if ( !$blog_id )
     646    if ( !$blog_id || !bp_core_is_multisite() )
    695647        return false;
    696648
     
    724676    global $wpdb, $bp;
    725677
    726     if ( !is_numeric( $blog_id ) )
     678    if ( !is_numeric( $blog_id ) || !bp_core_is_multisite() )
    727679        return false;
    728680
     
    754706
    755707function bp_blogs_remove_data( $user_id ) {
     708    if ( !bp_core_is_multisite() )
     709        return false;
     710
    756711    /* If this is regular blog, delete all data for that blog. */
    757712    BP_Blogs_Blog::delete_blogs_for_user( $user_id );
    758     BP_Blogs_Post::delete_posts_for_user( $user_id );
    759     BP_Blogs_Comment::delete_comments_for_user( $user_id );
    760713
    761714    do_action( 'bp_blogs_remove_data', $user_id );
    762715}
    763 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data', 1 );
    764 add_action( 'delete_user', 'bp_blogs_remove_data', 1 );
     716add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' );
     717add_action( 'delete_user', 'bp_blogs_remove_data' );
     718add_action( 'make_spam_user', 'bp_blogs_remove_data' );
    765719
    766720
     
    789743}
    790744
    791 function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {
    792     wp_cache_delete( 'bp_user_posts_' . $user_id, 'bp' );
    793 }
    794 
    795 function bp_blogs_format_clear_post_cache( $recorded_post_obj ) {
    796     bp_blogs_clear_post_object_cache( false, false, $recorded_post_obj->user_id );
    797 
    798     /* Clear the sitewide activity cache */
    799     wp_cache_delete( 'sitewide_activity', 'bp' );
    800 }
    801 
    802 function bp_blogs_clear_comment_object_cache( $blog_id, $comment_id, $user_id ) {
    803     wp_cache_delete( 'bp_user_comments_' . $user_id, 'bp' );
    804 }
    805 
    806 function bp_blogs_format_clear_comment_cache( $recorded_comment_obj ) {
    807     bp_blogs_clear_comment_object_cache( false, false, $recorded_comment_obj->user_id );
    808 
    809     /* Clear the sitewide activity cache */
    810     wp_cache_delete( 'sitewide_activity', 'bp' );
    811 }
    812 
    813745// List actions to clear object caches on
    814746add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
    815 add_action( 'bp_blogs_remove_post', 'bp_blogs_clear_post_object_cache', 10, 3 );
    816 add_action( 'bp_blogs_remove_comment', 'bp_blogs_clear_comment_object_cache', 10, 3 );
    817 
    818747add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
    819 add_action( 'bp_blogs_new_blog_post', 'bp_blogs_format_clear_post_cache', 10, 2 );
    820 add_action( 'bp_blogs_new_blog_comment', 'bp_blogs_format_clear_comment_cache', 10, 2 );
    821748
    822749// List actions to clear super cached pages on, if super cache is installed
  • trunk/bp-blogs/bp-blogs-classes.php

    r3232 r3300  
    7676            bp_blogs_setup_globals();
    7777
    78         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     78        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    7979            $hidden_sql = "AND wb.public = 1";
    8080
     
    162162        // Show logged in users their hidden blogs.
    163163        if ( !bp_is_my_profile() && !$show_hidden )
    164             $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id ) );
     164            $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
    165165        else
    166             $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.id", $user_id ) );
     166            $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) );
    167167
    168168        $total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );
    169169
    170170        foreach ( (array)$blogs as $blog ) {
    171             $user_blogs[$blog->id] = new stdClass;
    172             $user_blogs[$blog->id]->id = $blog->id;
    173             $user_blogs[$blog->id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
    174             $user_blogs[$blog->id]->name = $blog->name;
     171            $user_blogs[$blog->blog_id] = new stdClass;
     172            $user_blogs[$blog->blog_id]->id = $blog->id;
     173            $user_blogs[$blog->blog_id]->blog_id = $blog->blog_id;
     174            $user_blogs[$blog->blog_id]->siteurl = ( is_ssl() ) ? 'https://' . $blog->domain . $blog->path : 'http://' . $blog->domain . $blog->path;
     175            $user_blogs[$blog->blog_id]->name = $blog->name;
    175176        }
    176177
     
    209210
    210211        // If the user is logged in return the blog count including their hidden blogs.
    211         if ( ( is_user_logged_in() && $user_id == $bp->loggedin_user->id ) || is_site_admin() )
     212        if ( ( is_user_logged_in() && $user_id == $bp->loggedin_user->id ) || is_super_admin() )
    212213            return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT b.blog_id) FROM {$bp->blogs->table_name} b LEFT JOIN {$wpdb->base_prefix}blogs wb ON b.blog_id = wb.blog_id WHERE wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND user_id = %d", $user_id) );
    213214        else
     
    223224        $filter = like_escape( $wpdb->escape( $filter ) );
    224225
    225         if ( !is_site_admin() )
     226        if ( !is_super_admin() )
    226227            $hidden_sql = "AND wb.public = 1";
    227228
     
    241242            bp_blogs_setup_globals();
    242243
    243         if ( !is_site_admin() )
     244        if ( !is_super_admin() )
    244245            $hidden_sql = "AND wb.public = 1";
    245246
     
    261262        $letter = like_escape( $wpdb->escape( $letter ) );
    262263
    263         if ( !is_site_admin() )
     264        if ( !is_super_admin() )
    264265            $hidden_sql = "AND wb.public = 1";
    265266
     
    279280            return $paged_blogs;
    280281
    281         /* Fetch lastest post for each blog. */
    282         $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.blog_id IN ( {$blog_ids} ) GROUP BY p.blog_id ORDER BY p.date_created DESC" ) );
    283 
    284282        for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
    285             foreach ( (array)$post_ids as $post ) {
    286                 if ( $post->blog_id == $paged_blogs[$i]->blog_id ) {
    287                     $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $post->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY id DESC LIMIT 1" );
    288                 }
    289             }
     283            $blog_prefix = $wpdb->get_blog_prefix( $paged_blogs[$i]->blog_id );
     284            $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$blog_prefix}posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
    290285        }
    291286
     
    316311}
    317312
    318 /* DEPRECATED - Post DB recording is scheduled for removal. Please use the activity stream to fetch a user's posts. */
    319 Class BP_Blogs_Post {
    320     var $id;
    321     var $user_id;
    322     var $blog_id;
    323     var $post_id;
    324     var $date_created;
    325 
    326     function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) {
    327         global $bp, $wpdb;
    328 
    329         if ( $id || ( !$id && $blog_id && $post_id ) ) {
    330             $this->id = $id;
    331             $this->blog_id = $blog_id;
    332             $this->post_id = $post_id;
    333             $this->populate();
    334         }
    335     }
    336 
    337     function populate() {
    338         global $wpdb, $bp;
    339 
    340         if ( $this->id )
    341             $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) );
    342         else
    343             $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) );
    344 
    345         $this->id = $post->id;
    346         $this->user_id = $post->user_id;
    347         $this->blog_id = $post->blog_id;
    348         $this->post_id = $post->post_id;
    349         $this->date_created = $post->date_created;
    350     }
    351 
    352     function save() {
    353         global $wpdb, $bp;
    354 
    355         $this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );
    356         $this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );
    357         $this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );
    358         $this->date_created = apply_filters( 'bp_blogs_post_date_created_before_save', $this->date_created, $this->id );
    359 
    360         do_action( 'bp_blogs_post_before_save', $this );
    361 
    362         if ( $this->id ) {
    363             // Update
    364             $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_posts} SET post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
    365         } else {
    366             // Save
    367             $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created );
    368         }
    369 
    370         if ( !$wpdb->query($sql) )
    371             return false;
    372 
    373         do_action( 'bp_blogs_post_after_save', $this );
    374 
    375         if ( $this->id )
    376             return $this->id;
    377         else
    378             return $wpdb->insert_id;
    379     }
    380 
    381     /* Static Functions */
    382 
    383     function delete( $post_id, $blog_id ) {
    384         global $wpdb, $bp, $current_user;
    385 
    386         if ( !$bp->blogs )
    387             bp_blogs_setup_globals();
    388 
    389         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );
    390     }
    391 
    392     function delete_oldest( $user_id = null ) {
    393         global $wpdb, $bp;
    394 
    395         if ( !$bp->blogs )
    396             bp_blogs_setup_globals();
    397 
    398         if ( !$user_id )
    399             $user_id = $current_user->ID;
    400 
    401         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
    402     }
    403 
    404     function delete_posts_for_user( $user_id = null ) {
    405         global $wpdb, $bp;
    406 
    407         if ( !$bp->blogs )
    408             bp_blogs_setup_globals();
    409 
    410         if ( !$user_id )
    411             $user_id = $bp->loggedin_user->id;
    412 
    413         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
    414     }
    415 
    416     function delete_posts_for_blog( $blog_id ) {
    417         global $wpdb, $bp;
    418 
    419         if ( !$bp->blogs )
    420             bp_blogs_setup_globals();
    421 
    422         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
    423     }
    424 
    425     function get_latest_posts( $blog_id = null, $limit = 5 ) {
    426         global $wpdb, $bp;
    427 
    428         if ( !$bp->blogs )
    429             bp_blogs_setup_globals();
    430 
    431         if ( $blog_id )
    432             $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
    433 
    434         $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );
    435 
    436         for ( $i = 0; $i < count($post_ids); $i++ ) {
    437             $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
    438         }
    439 
    440         return $posts;
    441     }
    442 
    443     function get_posts_for_user( $user_id = null ) {
    444         global $bp, $wpdb;
    445 
    446         if ( !$bp->blogs )
    447             bp_blogs_setup_globals();
    448 
    449         if ( !$user_id )
    450             $user_id = $bp->displayed_user->id;
    451 
    452         // Show a logged in user their posts on private blogs, but not anyone else.
    453         if ( !bp_is_my_profile() ) {
    454             $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
    455             $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
    456         } else {
    457             $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
    458 
    459             $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
    460         }
    461 
    462         for ( $i = 0; $i < count($post_ids); $i++ ) {
    463             $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
    464         }
    465 
    466         return array( 'posts' => $posts, 'count' => $total_post_count );
    467     }
    468 
    469     function fetch_post_content( $post_object ) {
    470         // TODO: switch_to_blog() calls are expensive and this needs to be changed.
    471         switch_to_blog( $post_object->blog_id );
    472         $post = get_post($post_object->post_id);
    473         $post->blog_id = $post_object->blog_id;
    474         restore_current_blog();
    475 
    476         return $post;
    477     }
    478 
    479     function get_total_recorded_for_user( $user_id = null ) {
    480         global $bp, $wpdb;
    481 
    482         if ( !$bp->blogs )
    483             bp_blogs_setup_globals();
    484 
    485         if ( !$user_id )
    486             $user_id = $current_user->ID;
    487 
    488         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
    489     }
    490 
    491     function is_recorded( $post_id, $blog_id, $user_id = null ) {
    492         global $bp, $wpdb, $current_user;
    493 
    494         if ( !$bp->blogs )
    495             bp_blogs_setup_globals();
    496 
    497         if ( !$user_id )
    498             $user_id = $current_user->ID;
    499 
    500         return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) );
    501     }
    502 
    503     function total_post_count( $blog_id ) {
    504         global $bp, $wpdb;
    505 
    506         if ( !$bp->blogs )
    507             bp_blogs_setup_globals();
    508 
    509         if ( !$blog_id )
    510             return false;
    511 
    512         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
    513     }
    514 
    515     function get_all() {
    516         global $bp, $wpdb;
    517 
    518         if ( !$bp->blogs )
    519             bp_blogs_setup_globals();
    520 
    521         return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) );
    522     }
    523 
    524 }
    525 
    526 /* DEPRECATED - Comment DB recording is scheduled for removal. Please use the activity stream to fetch a user's comments. */
    527 Class BP_Blogs_Comment {
    528     var $id;
    529     var $user_id;
    530     var $blog_id;
    531     var $comment_id;
    532     var $comment_post_id;
    533     var $date_created;
    534 
    535     function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) {
    536         global $bp, $wpdb;
    537 
    538         if ( !$user_id )
    539             $user_id = $bp->displayed_user->id;
    540 
    541         if ( $id || ( !$id && $blog_id && $comment_id ) ) {
    542             $this->id = $id;
    543             $this->blog_id = $blog_id;
    544             $this->comment_id = $comment_id;
    545             $this->populate();
    546         }
    547     }
    548 
    549     function populate() {
    550         global $wpdb, $bp;
    551 
    552         if ( $this->id )
    553             $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) );
    554         else
    555             $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) );
    556 
    557         $this->comment_id = $comment->comment_id;
    558         $this->user_id = $comment->user_id;
    559         $this->blog_id = $comment->blog_id;
    560         $this->comment_post_id = $comment->comment_post_id;
    561         $this->date_created = $comment->date_created;
    562     }
    563 
    564     function save() {
    565         global $wpdb, $bp;
    566 
    567         $this->comment_id = apply_filters( 'bp_blogs_comment_id_before_save', $this->comment_id, $this->id );
    568         $this->comment_post_id = apply_filters( 'bp_blogs_comment_post_id_before_save', $this->comment_post_id, $this->id );
    569         $this->blog_id = apply_filters( 'bp_blogs_comment_blog_id_before_save', $this->blog_id, $this->id );
    570         $this->user_id = apply_filters( 'bp_blogs_comment_user_id_before_save', $this->user_id, $this->id );
    571         $this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );
    572 
    573         do_action( 'bp_blogs_comment_before_save', $this );
    574 
    575         if ( $this->id ) {
    576             // Update
    577             $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
    578         } else {
    579             // Save
    580             $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_comments} ( comment_id, comment_post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created );
    581         }
    582 
    583         if ( !$wpdb->query($sql) )
    584             return false;
    585 
    586         do_action( 'bp_blogs_comment_after_save', $this );
    587 
    588         if ( $this->id )
    589             return $this->id;
    590         else
    591             return $wpdb->insert_id;
    592     }
    593 
    594     /* Static Functions */
    595 
    596     function delete( $comment_id, $blog_id ) {
    597         global $wpdb, $bp, $current_user;
    598 
    599         if ( !$bp->blogs )
    600             bp_blogs_setup_globals();
    601 
    602         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) );
    603     }
    604 
    605     function delete_oldest( $user_id = null ) {
    606         global $wpdb, $bp, $current_user;
    607 
    608         if ( !$bp->blogs )
    609             bp_blogs_setup_globals();
    610 
    611         if ( !$user_id )
    612             $user_id = $current_user->ID;
    613 
    614         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
    615     }
    616 
    617     function delete_comments_for_user( $user_id = null ) {
    618         global $wpdb, $bp;
    619 
    620         if ( !$bp->blogs )
    621             bp_blogs_setup_globals();
    622 
    623         if ( !$user_id )
    624             $user_id = $bp->loggedin_user->id;
    625 
    626         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
    627     }
    628 
    629     function delete_comments_for_blog( $blog_id ) {
    630         global $wpdb, $bp;
    631 
    632         if ( !$bp->blogs )
    633             bp_blogs_setup_globals();
    634 
    635         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) );
    636     }
    637 
    638     function get_comments_for_user( $user_id = null ) {
    639         global $bp, $wpdb;
    640 
    641         if ( !$bp->blogs )
    642             bp_blogs_setup_globals();
    643 
    644         if ( !$user_id )
    645             $user_id = $bp->displayed_user->id;
    646 
    647         // Show the logged in user their comments on hidden blogs, but not to anyone else.
    648         if ( !bp_is_my_profile() ) {
    649             $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
    650             $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
    651         } else {
    652             $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
    653 
    654             $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
    655         }
    656 
    657         for ( $i = 0; $i < count($comment_ids); $i++ )
    658             $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);
    659 
    660         return array( 'comments' => $comments, 'count' => $total_comment_count );
    661     }
    662 
    663     function fetch_comment_content( $comment_object ) {
    664         switch_to_blog($comment_object->blog_id);
    665         $comment = get_comment($comment_object->comment_id);
    666         $comment->blog_id = $comment_object->blog_id;
    667         $comment->post = &get_post( $comment->comment_post_ID );
    668         restore_current_blog();
    669 
    670         return $comment;
    671     }
    672 
    673     function get_total_recorded_for_user( $user_id = null ) {
    674         global $bp, $wpdb, $current_user;
    675 
    676         if ( !$bp->blogs )
    677             bp_blogs_setup_globals();
    678 
    679         if ( !$user_id )
    680             $user_id = $current_user->ID;
    681 
    682         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
    683     }
    684 
    685     function total_comment_count( $blog_id, $post_id ) {
    686         global $bp, $wpdb;
    687 
    688         if ( !$bp->blogs )
    689             bp_blogs_setup_globals();
    690 
    691         if ( $post_id )
    692             $post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );
    693 
    694         return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );
    695     }
    696 
    697 
    698     function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) {
    699         global $bp, $wpdb, $current_user;
    700 
    701         if ( !$bp->blogs )
    702             bp_blogs_setup_globals();
    703 
    704         if ( !$user_id )
    705             $user_id = $current_user->ID;
    706 
    707         return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) );
    708     }
    709 
    710 }
    711 
    712313?>
  • trunk/bp-blogs/bp-blogs-templatetags.php

    r3263 r3300  
    2222
    2323        $this->pag_page = isset( $_REQUEST['bpage'] ) ? intval( $_REQUEST['bpage'] ) : $page;
    24         $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     24        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    2525
    2626        if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
     
    3737
    3838        if ( $max ) {
    39             if ( $max >= count( $this->blogs ) ) {
     39            if ( $max >= count($this->blogs) ) {
    4040                $this->blog_count = count( $this->blogs );
    4141            } else {
     
    148148
    149149    $blogs_template = new BP_Blogs_Template( $type, $page, $per_page, $max, $user_id, $search_terms );
    150     return $blogs_template->has_blogs();
     150    return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), &$blogs_template );
    151151}
    152152
     
    166166    global $bp, $blogs_template;
    167167
    168     $from_num = bp_core_number_format( intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1 );
    169     $to_num = bp_core_number_format( ( $from_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $from_num + ( $blogs_template->pag_num - 1 ) );
     168    $start_num = intval( ( $blogs_template->pag_page - 1 ) * $blogs_template->pag_num ) + 1;
     169    $from_num = bp_core_number_format( $start_num );
     170    $to_num = bp_core_number_format( ( $start_num + ( $blogs_template->pag_num - 1 ) > $blogs_template->total_blog_count ) ? $blogs_template->total_blog_count : $start_num + ( $blogs_template->pag_num - 1 ) );
    170171    $total = bp_core_number_format( $blogs_template->total_blog_count );
    171172
    172     echo sprintf( __( 'Viewing blog %s to %s (of %s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?> &nbsp;
     173    echo sprintf( __( 'Viewing blog %1$s to %2$s (of %3$s blogs)', 'buddypress' ), $from_num, $to_num, $total ); ?> &nbsp;
    173174    <span class="ajax-loader"></span><?php
    174175}
     
    270271function bp_blog_hidden_fields() {
    271272    if ( isset( $_REQUEST['s'] ) ) {
    272         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ). '" name="search_terms" />';
     273        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ). '" name="search_terms" />';
    273274    }
    274275
    275276    if ( isset( $_REQUEST['letter'] ) ) {
    276         echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
     277        echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    277278    }
    278279
    279280    if ( isset( $_REQUEST['blogs_search'] ) ) {
    280         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
     281        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['blogs_search'] ) . '" name="search_terms" />';
    281282    }
    282283}
     
    347348
    348349            <input type="hidden" name="stage" value="gimmeanotherblog" />
    349             <?php do_action( "signup_hidden_fields" ); ?>
     350            <?php do_action( 'signup_hidden_fields' ); ?>
    350351
    351352            <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
     
    364365
    365366    // Blog name
    366     if( 'no' == constant( "VHOST" ) )
     367    if( !is_subdomain_install() )
    367368        echo '<label for="blogname">' . __('Blog Name:', 'buddypress') . '</label>';
    368369    else
     
    373374    <?php }
    374375
    375     if( 'no' == constant( "VHOST" ) ) {
     376    if ( !is_subdomain_install() )
    376377        echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span> <input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><br />';
    377     } else {
     378    else
    378379        echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /> <span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
    379     }
     380
    380381    if ( !is_user_logged_in() ) {
    381382        print '(<strong>' . __( 'Your address will be ' , 'buddypress');
    382         if( 'no' == constant( "VHOST" ) ) {
     383
     384        if ( !is_subdomain_install() ) {
    383385            print $current_site->domain . $current_site->path . __( 'blogname' , 'buddypress');
    384386        } else {
    385387            print __( 'domain.' , 'buddypress') . $current_site->domain . $current_site->path;
    386388        }
     389
    387390        echo '.</strong> ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed so choose carefully!)' , 'buddypress') . '</p>';
    388391    }
     
    476479
    477480function bp_blogs_blog_tabs() {
    478     global $bp;
     481    global $bp, $groups_template;
    479482
    480483    // Don't show these tabs on a user's own profile
  • trunk/bp-blogs/bp-blogs-widgets.php

    r2698 r3300  
    2222        global $bp;
    2323
    24         extract( $args );
     24        extract( $args );
    2525
    2626        echo $before_widget;
    27         echo $before_title
    28            . $widget_name
    29            . $after_title; ?>
     27        echo $before_title . $widget_name . $after_title;
    3028
    31         <?php
    3229        if ( empty( $instance['max_posts'] ) || !$instance['max_posts'] )
    3330            $instance['max_posts'] = 10; ?>
     
    8178        ?>
    8279
    83         <p><label for="bp-blogs-widget-posts-max"><?php _e('Max posts to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo attribute_escape( $max_posts ); ?>" style="width: 30%" /></label></p>
     80        <p><label for="bp-blogs-widget-posts-max"><?php _e('Max posts to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="text" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
    8481    <?php
    8582    }
  • trunk/bp-core.php

    r3242 r3300  
    3030require ( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php' );
    3131require ( BP_PLUGIN_DIR . '/bp-core/bp-core-classes.php' );
     32require ( BP_PLUGIN_DIR . '/bp-core/bp-core-filters.php' );
    3233require ( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php' );
    3334require ( BP_PLUGIN_DIR . '/bp-core/bp-core-avatars.php' );
     
    6566 */
    6667function bp_core_setup_globals() {
    67     global $bp, $wpdb;
     68    global $bp;
    6869    global $current_user, $current_component, $current_action, $current_blog;
    6970    global $displayed_user_id, $bp_pages;
     
    7273    $current_user = wp_get_current_user();
    7374
     75    /* Get the base database prefix */
     76    $bp->table_prefix = bp_core_get_table_prefix();
     77
    7478    /* The domain for the root of the site where the main blog resides */
    7579    $bp->root_domain = bp_core_get_root_domain();
    76 
    77     /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
    78     $bp->active_components = array();
    7980
    8081    /* The names of the core WordPress pages used to display BuddyPress content */
     
    9596    $bp->loggedin_user->userdata = bp_core_get_core_userdata( $bp->loggedin_user->id );
    9697
    97     /* is_site_admin() hits the DB on single WP installs, so we need to get this separately so we can call it in a loop. */
    98     $bp->loggedin_user->is_site_admin = is_site_admin();
     98    /* is_super_admin() hits the DB on single WP installs, so we need to get this separately so we can call it in a loop. */
     99    $bp->loggedin_user->is_super_admin = is_super_admin();
     100    $bp->loggedin_user->is_site_admin  = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6
    99101
    100102    /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
     
    141143    $bp->bp_options_nav = array();
    142144
     145    /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
     146    $bp->active_components = array();
     147
    143148    /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
    144     $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );
     149    $bp->grav_default->user  = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );
    145150    $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
    146     $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
     151    $bp->grav_default->blog  = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
    147152
    148153    /* Fetch the full name for the logged in and current user */
    149     $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
     154    $bp->loggedin_user->fullname  = bp_core_get_user_displayname( $bp->loggedin_user->id );
    150155    $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
    151156
     
    154159       generic variable so it can be used by other components. It can also be modified, so when viewing a group
    155160       'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
    156     $bp->is_item_admin = bp_is_my_profile();
     161    $bp->is_item_admin = bp_user_has_access();
    157162
    158163    /* Used to determine if the logged in user is a moderator for the current content. */
    159164    $bp->is_item_mod = false;
    160165
    161     $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications';
     166    $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
    162167
    163168    if ( !$bp->current_component && $bp->displayed_user->id )
     
    169174
    170175/**
     176 * bp_core_get_table_prefix()
     177 *
     178 * Allow filtering of database prefix. Intended for use in multinetwork installations.
     179 *
     180 * @global object $wpdb WordPress database object
     181 * @return string Filtered database prefix
     182 */
     183function bp_core_get_table_prefix() {
     184    global $wpdb;
     185
     186    return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
     187}
     188
     189/**
    171190 * bp_core_define_slugs()
    172191 *
     
    188207    if ( !defined( 'BP_ACTIVATION_SLUG' ) )
    189208        define( 'BP_ACTIVATION_SLUG', $bp->pages->activate->slug );
     209
     210    if ( !defined( 'BP_SEARCH_SLUG' ) )
     211        define( 'BP_SEARCH_SLUG', 'search' );
    190212}
    191213add_action( 'bp_setup_globals', 'bp_core_define_slugs' );
     
    231253}
    232254
    233 
    234255/**
    235256 * bp_core_admin_menu_init()
     
    238259 *
    239260 * @package BuddyPress Core
    240  * @uses is_site_admin() returns true if the current user is a site admin, false if not
     261 * @uses is_super_admin() returns true if the current user is a site admin, false if not
    241262 */
    242263function bp_core_admin_menu_init() {
    243     if ( !is_site_admin() )
     264    if ( !is_super_admin() )
    244265        return false;
    245266
     
    255276 * @package BuddyPress Core
    256277 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    257  * @global $wpdb WordPress DB access object.
    258  * @uses is_site_admin() returns true if the current user is a site admin, false if not
     278 * @uses is_super_admin() returns true if the current user is a site admin, false if not
    259279 * @uses add_submenu_page() WP function to add a submenu item
    260280 */
    261281function bp_core_add_admin_menu() {
    262     if ( !is_site_admin() )
     282    if ( !is_super_admin() )
    263283        return false;
    264284
     
    280300add_action( 'admin_menu', 'bp_core_add_admin_menu' );
    281301
     302/**
     303 * bp_core_is_root_component()
     304 *
     305 * Checks to see if a component's URL should be in the root, not under a member page:
     306 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
     307 *
     308 * @package BuddyPress Core
     309 * @return true if root component, else false.
     310 */
     311function bp_core_is_root_component( $component_name ) {
     312    global $bp;
     313
     314    foreach ( (array) $bp->pages as $key => $page ) {
     315        if ( $key == $component_name || $page->slug == $component_name )
     316            return true;
     317    }
     318
     319    return false;
     320}
    282321
    283322/**
     
    380419 */
    381420function bp_core_action_set_spammer_status() {
    382     global $bp, $wpdb;
    383 
    384     if ( !is_site_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
     421    global $bp, $wpdb, $wp_version;
     422
     423    if ( !is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
    385424        return false;
    386425
     
    390429
    391430        /* Get the functions file */
    392         if ( file_exists( ABSPATH . 'wp-admin/includes/mu.php' ) && bp_core_is_multisite() )
    393             require( ABSPATH . 'wp-admin/includes/mu.php' );
     431        if ( bp_core_is_multisite() )
     432            require_once( ABSPATH . 'wp-admin/includes/ms.php' );
    394433
    395434        if ( 'mark-spammer' == $bp->current_action )
     
    446485    global $bp;
    447486
    448     if ( !is_site_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
     487    if ( !is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
    449488        return false;
    450489
     
    462501        }
    463502
    464         do_action( 'bp_core_action_set_spammer_status', $errors );
     503        do_action( 'bp_core_action_delete_user', $errors );
    465504
    466505        if ( $errors )
     
    472511add_action( 'wp', 'bp_core_action_delete_user', 3 );
    473512
     513
    474514/********************************************************************************
    475515 * Business Functions
     
    496536        'search_terms' => false, // Limit to users that match these search terms
    497537
     538        'include' => false, // Pass comma separated list of user_ids to limit to only these users
    498539        'per_page' => 20, // The number of results to return per page
    499540        'page' => 1, // The page to return if limiting per page
     
    504545    extract( $params, EXTR_SKIP );
    505546
    506     return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $search_terms, $populate_extras ), &$params );
     547    return apply_filters( 'bp_core_get_users', BP_Core_User::get_users( $type, $per_page, $page, $user_id, $include, $search_terms, $populate_extras ), &$params );
    507548}
    508549
     
    516557 * @global $current_user WordPress global variable containing current logged in user information
    517558 * @param user_id The ID of the user.
    518  * @uses get_usermeta() WordPress function to get the usermeta for a user.
     559 * @uses get_user_meta() WordPress function to get the usermeta for a user.
    519560 */
    520561function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) {
     
    574615
    575616    if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
    576         $domain = get_blog_option( $current_blog->blog_id, 'siteurl' );
     617        $domain = get_blog_option( $current_blog->blog_id, 'home' );
    577618    else
    578         $domain = get_blog_option( BP_ROOT_BLOG, 'siteurl' );
     619        $domain = get_blog_option( BP_ROOT_BLOG, 'home' );
    579620
    580621    return apply_filters( 'bp_core_get_root_domain', $domain );
     
    626667
    627668    /* If this is for site admins only and the user is not one, don't create the subnav item */
    628     if ( $site_admin_only && !is_site_admin() )
     669    if ( $site_admin_only && !is_super_admin() )
    629670        return false;
    630671
     
    647688     * looking at their own profile, don't create the nav item.
    648689     */
    649     if ( !$show_for_displayed_user && !bp_is_my_profile() )
     690    if ( !$show_for_displayed_user && !bp_user_has_access() )
    650691        return false;
    651692
     
    654695     * default subnav function so we can display a directory or something else.
    655696     */
    656     if ( !$bp->displayed_user->id )
     697    if ( bp_core_is_root_component( $slug ) && !$bp->displayed_user->id )
    657698        return;
    658699
     
    773814
    774815    /* If this is for site admins only and the user is not one, don't create the subnav item */
    775     if ( $site_admin_only && !is_site_admin() )
     816    if ( $site_admin_only && !is_super_admin() )
    776817        return false;
    777818
     
    868909    global $bp;
    869910
    870     if ( $function = $bp->bp_options_nav[$parent_id][$slug]['screen_function'] ) {
    871         if ( !is_object( $function[0] ) )
    872             remove_action( 'wp', $function, 3 );
     911    $screen_function = $bp->bp_options_nav[$parent_id][$slug]['screen_function'];
     912
     913    if ( $screen_function ) {
     914        if ( !is_object( $screen_function[0] ) )
     915            remove_action( 'wp', $screen_function, 3 );
    873916        else
    874             remove_action( 'wp', array( &$function[0], $function[1] ), 3 );
     917            remove_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
    875918    }
    876919
     
    898941/**
    899942 * bp_core_get_random_member()
     943 *
     944 * Returns the user_id for a user based on their username.
     945 *
     946 * @package BuddyPress Core
     947 * @param $username str Username to check.
     948 * @return false on no match
     949 * @return int the user ID of the matched user.
     950 */
     951function bp_core_get_random_member() {
     952    global $bp;
     953
     954    if ( isset( $_GET['random-member'] ) ) {
     955        $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
     956        bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
     957    }
     958}
     959add_action( 'wp', 'bp_core_get_random_member' );
     960
     961/**
     962 * bp_core_get_userid()
    900963 *
    901964 * Returns the user_id for a user based on their username.
     
    907970 * @return int the user ID of the matched user.
    908971 */
    909 function bp_core_get_random_member() {
    910     global $bp, $wpdb;
    911 
    912     if ( isset( $_GET['random-member'] ) ) {
    913         $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
    914         bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
    915     }
    916 }
    917 add_action( 'wp', 'bp_core_get_random_member' );
    918 
    919 /**
    920  * bp_core_get_userid()
    921  *
    922  * Returns the user_id for a user based on their username.
    923  *
    924  * @package BuddyPress Core
    925  * @param $username str Username to check.
    926  * @global $wpdb WordPress DB access object.
    927  * @return false on no match
    928  * @return int the user ID of the matched user.
    929  */
    930972function bp_core_get_userid( $username ) {
    931973    global $wpdb;
    932974
    933     if ( !empty( $username ) )
    934         return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
     975    if ( empty( $username ) )
     976        return false;
     977
     978    return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
    935979}
    936980
     
    11191163    }
    11201164
    1121     return apply_filters( 'bp_core_get_user_displayname', $fullname );
     1165    return apply_filters( 'bp_core_get_user_displayname', $fullname, $user_id );
    11221166}
    11231167add_filter( 'bp_core_get_user_displayname', 'strip_tags', 1 );
     
    12151259
    12161260/**
    1217  * bp_core_format_time()
    1218  */
    1219 function bp_core_format_time( $time, $just_date = false ) {
    1220     if ( !$time )
    1221         return false;
    1222 
    1223     $date = date( "F j, Y ", $time );
    1224 
    1225     if ( !$just_date ) {
    1226         $date .= __('at', 'buddypress') . date( ' g:iA', $time );
    1227     }
    1228 
    1229     return $date;
     1261 * bp_core_current_time()
     1262 *
     1263 * Get the current GMT time to save into the DB
     1264 *
     1265 * @package BuddyPress Core
     1266 * @since 1.2.6
     1267 */
     1268function bp_core_current_time( $gmt = true ) {
     1269    // Get current time in MYSQL format
     1270    $current_time = current_time( 'mysql', $gmt );
     1271
     1272    return apply_filters( 'bp_core_current_time', $current_time );
    12301273}
    12311274
     
    12831326    @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
    12841327}
    1285 add_action( 'bp_init', 'bp_core_setup_message' );
    1286 
     1328add_action( 'wp', 'bp_core_setup_message', 2 );
    12871329
    12881330/**
     
    13021344    ?>
    13031345        <div id="message" class="<?php echo $type; ?>">
    1304             <p><?php echo stripslashes( attribute_escape( $bp->template_message ) ); ?></p>
     1346            <p><?php echo stripslashes( esc_attr( $bp->template_message ) ); ?></p>
    13051347        </div>
    13061348    <?php
     
    13261368 */
    13271369function bp_core_time_since( $older_date, $newer_date = false ) {
     1370
    13281371    // array of time period chunks
    13291372    $chunks = array(
    1330     array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
    1331     array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
    1332     array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
    1333     array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
    1334     array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
    1335     array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
    1336     array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
     1373        array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
     1374        array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
     1375        array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
     1376        array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
     1377        array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
     1378        array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
     1379        array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
    13371380    );
    13381381
     
    13461389    /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
    13471390    /* $newer_date will have a value if we want to work out time elapsed between two known dates */
    1348     $newer_date = ( !$newer_date ) ? gmmktime( gmdate( 'H' ), gmdate( 'i' ), gmdate( 's' ), gmdate( 'n' ), gmdate( 'j' ), gmdate( 'Y' ) ) : $newer_date;
     1391    $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date;
    13491392
    13501393    /* Difference in seconds */
     
    13811424        if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
    13821425            /* Add to output var */
    1383             $output .= ( 1 == $count2 ) ? _c( ',|Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _c( ',|Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
     1426            $output .= ( 1 == $count2 ) ? _x( ',', 'Separator in time since', 'buddypress' ) . ' 1 '. $chunks[$i + 1][1] : _x( ',', 'Separator in time since', 'buddypress' ) . ' ' . $count2 . ' ' . $chunks[$i + 1][2];
    13841427        }
    13851428    }
     
    14011444 * @package BuddyPress Core
    14021445 * @global $userdata WordPress user data for the current logged in user.
    1403  * @uses update_usermeta() WordPress function to update user metadata in the usermeta table.
     1446 * @uses update_user_meta() WordPress function to update user metadata in the usermeta table.
    14041447 */
    14051448function bp_core_record_activity() {
     
    14091452        return false;
    14101453
    1411     $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
     1454    $activity = get_user_meta( $bp->loggedin_user->id, 'last_activity', true );
    14121455
    14131456    if ( !is_numeric( $activity ) )
    14141457        $activity = strtotime( $activity );
    14151458
    1416     if ( '' == $activity || strtotime( gmdate( "Y-m-d H:i:s" ) ) >= strtotime( '+5 minutes', $activity ) )
    1417         update_usermeta( $bp->loggedin_user->id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     1459    // Get current time
     1460    $current_time = bp_core_current_time();
     1461
     1462    if ( '' == $activity || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
     1463        update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time );
    14181464}
    14191465add_action( 'wp_head', 'bp_core_record_activity' );
     
    14461492        return $number;
    14471493
    1448     return apply_filters( 'bp_core_bp_core_number_format', number_format( $number, $decimals ), $number, $decimals );
     1494    return apply_filters( 'bp_core_number_format', number_format( $number, $decimals ), $number, $decimals );
    14491495}
    14501496
     
    14741520 *
    14751521 * @package BuddyPress Core
    1476  * @global $comment WordPress comment global for the current comment.
    1477  * @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
     1522 *
     1523 * @global $bp $bp
     1524 * @global object $current_site
     1525 * @return string
    14781526 */
    14791527function bp_core_get_site_path() {
     
    14931541            unset( $site_path[2] );
    14941542
    1495             $site_path = '/' . implode( '/', $site_path ) . '/';
     1543            if ( !count( $site_path ) )
     1544                $site_path = '/';
     1545            else
     1546                $site_path = '/' . implode( '/', $site_path ) . '/';
    14961547        }
    14971548    }
     
    15361587
    15371588    if ( bp_core_is_multisite() )
    1538         $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys})" );
     1589        $meta = $wpdb->get_results( "SELECT meta_key AS name, meta_value AS value FROM {$wpdb->sitemeta} WHERE meta_key IN ({$meta_keys}) AND site_id = {$wpdb->siteid}" );
    15391590    else
    15401591        $meta = $wpdb->get_results( "SELECT option_name AS name, option_value AS value FROM {$wpdb->options} WHERE option_name IN ({$meta_keys})" );
     
    15631614
    15641615    // Make sure we don't call status_header() in bp_core_do_catch_uri()
    1565     // as this conflicts with wp_redirect()
     1616    // as this conflicts with wp_redirect()
    15661617    $bp_no_status_set = true;
    15671618
     
    16161667
    16171668/**
    1618  * bp_core_email_from_name_filter()
    1619  *
    1620  * Sets the "From" name in emails sent to the name of the site and not "WordPress"
    1621  *
    1622  * @package BuddyPress Core
    1623  * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
    1624  * @return The blog name for the root blog
    1625  */
    1626 function bp_core_email_from_name_filter() {
    1627     return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
    1628 }
    1629 add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
    1630 
    1631 
    1632 /**
    1633  * bp_core_email_from_name_filter()
    1634  *
    1635  * Sets the "From" address in emails sent
    1636  *
    1637  * @package BuddyPress Core
    1638  * @global $current_site Object containing current site metadata
    1639  * @return noreply@sitedomain email address
    1640  */
    1641 function bp_core_email_from_address_filter() {
    1642     $domain = (array) explode( '/', site_url() );
    1643 
    1644     return apply_filters( 'bp_core_email_from_address_filter', __( 'noreply', 'buddypress' ) . '@' . $domain[2] );
    1645 }
    1646 add_filter( 'wp_mail_from', 'bp_core_email_from_address_filter' );
    1647 
    1648 /**
    16491669 * bp_core_delete_account()
    16501670 *
     
    16531673 * @package BuddyPress Core
    16541674 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    1655  * @uses is_site_admin() Checks to see if the user is a site administrator.
     1675 * @uses is_super_admin() Checks to see if the user is a site administrator.
    16561676 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs.
    16571677 * @uses wp_delete_user() Deletes a user from the system on singlesite installs.
     
    17441764function bp_core_ucfirst( $str ) {
    17451765    if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
    1746         $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
    1747         return $fc.mb_substr( $str, 1 );
     1766        $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
     1767        return $fc.mb_substr( $str, 1 );
    17481768    } else {
    17491769        return ucfirst( $str );
     
    17921812 */
    17931813function bp_core_print_generation_time() {
    1794     global $wpdb;
    1795     ?>
     1814?>
    17961815
    17971816<!-- Generated in <?php timer_stop(1); ?> seconds. (<?php echo get_num_queries(); ?> q) -->
     
    18661885    $user = get_userdatabylogin( $username );
    18671886
    1868     if ( (int)$user->spam )
     1887    if ( ( bp_core_is_multisite() && (int)$user->spam ) || 1 == (int)$user->user_status )
    18691888        bp_core_redirect( $bp->root_domain );
    18701889    else
     
    18801899 * @package BuddyPress Core
    18811900 * @param $user_id The user id for the user to delete usermeta for
    1882  * @uses delete_usermeta() deletes a row from the wp_usermeta table based on meta_key
     1901 * @uses delete_user_meta() deletes a row from the wp_usermeta table based on meta_key
    18831902 */
    18841903function bp_core_remove_data( $user_id ) {
    18851904    /* Remove usermeta */
    1886     delete_usermeta( $user_id, 'last_activity' );
     1905    delete_user_meta( $user_id, 'last_activity' );
    18871906
    18881907    /* Flush the cache to remove the user from all cached objects */
    18891908    wp_cache_flush();
    18901909}
    1891 add_action( 'wpmu_delete_user', 'bp_core_remove_data', 1 );
    1892 add_action( 'delete_user', 'bp_core_remove_data', 1 );
    1893 add_action( 'make_spam_user', 'bp_core_remove_data', 1 );
     1910add_action( 'wpmu_delete_user', 'bp_core_remove_data' );
     1911add_action( 'delete_user', 'bp_core_remove_data' );
     1912add_action( 'make_spam_user', 'bp_core_remove_data' );
    18941913
    18951914/**
     
    19071926        load_textdomain( 'buddypress', $mofile );
    19081927}
    1909 add_action ( 'plugins_loaded', 'bp_core_load_buddypress_textdomain', 5 );
     1928add_action ( 'bp_loaded', 'bp_core_load_buddypress_textdomain', 2 );
    19101929
    19111930function bp_core_add_ajax_hook() {
     
    19291948
    19301949/**
    1931  * bp_core_filter_parent_theme()
    1932  *
    1933  * Remove social network parent theme from the theme list.
    1934  *
    1935  * @package BuddyPress Core
    1936  */
    1937 function bp_core_filter_parent_theme() {
    1938     global $wp_themes, $pagenow;
    1939 
    1940     if ( is_admin() && 'themes.php' == $pagenow )
    1941         $wp_themes = get_themes();
    1942 
    1943     unset( $wp_themes['BuddyPress Classic Parent'] );
    1944 }
    1945 add_filter( 'admin_menu', 'bp_core_filter_parent_theme' );
    1946 
    1947 /**
    1948  * bp_core_allow_default_theme()
    1949  *
    1950  * On multiblog installations you must first allow themes to be activated and show
    1951  * up on the theme selection screen. This function will let the BuddyPress bundled
    1952  * themes show up on the root blog selection screen and bypass this step. It also
    1953  * means that the themes won't show for selection on other blogs.
    1954  *
    1955  * @package BuddyPress Core
    1956  */
    1957 function bp_core_allow_default_theme( $themes ) {
    1958     global $bp, $current_blog;
    1959 
    1960     if ( !is_site_admin() )
    1961         return $themes;
    1962 
    1963     if ( $current_blog->ID == $bp->root_blog ) {
    1964         $themes['bp-default'] = 1;
    1965         $themes['bp-classic'] = 1;
    1966     }
    1967 
    1968     return $themes;
    1969 }
    1970 add_filter( 'allowed_themes', 'bp_core_allow_default_theme' );
    1971 
    1972 /**
    19731950 * bp_core_activation_notice()
    19741951 *
     
    19851962        return false;
    19861963
    1987     if ( !is_site_admin() )
     1964    if ( !is_super_admin() )
    19881965        return false;
    19891966
     
    20111988add_action( 'admin_notices', 'bp_core_activation_notice' );
    20121989
    2013 
    2014 /**
    2015  * bp_core_filter_comments()
    2016  *
    2017  * Filter the blog post comments array and insert BuddyPress URLs for users.
    2018  *
    2019  * @package BuddyPress Core
    2020  */
    2021 function bp_core_filter_comments( $comments, $post_id ) {
    2022     global $wpdb;
    2023 
    2024     foreach( (array)$comments as $comment ) {
    2025         if ( $comment->user_id )
    2026             $user_ids[] = $comment->user_id;
    2027     }
    2028 
    2029     if ( empty( $user_ids ) )
    2030         return $comments;
    2031 
    2032     $user_ids = implode( ',', $user_ids );
    2033 
    2034     if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) )
    2035         return $comments;
    2036 
    2037     foreach( (array)$userdata as $user )
    2038         $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login );
    2039 
    2040     foreach( (array)$comments as $i => $comment ) {
    2041         if ( !empty( $comment->user_id ) ) {
    2042             if ( !empty( $users[$comment->user_id] ) )
    2043                 $comments[$i]->comment_author_url = $users[$comment->user_id];
     1990/**
     1991 * bp_core_activate_site_options()
     1992 *
     1993 * When switching from single to multisite we need to copy blog options to
     1994 * site options.
     1995 *
     1996 * @package BuddyPress Core
     1997 */
     1998function bp_core_activate_site_options( $keys = array() ) {
     1999    global $bp;
     2000
     2001    if ( !empty( $keys ) && is_array( $keys ) ) {
     2002        $errors = false;
     2003
     2004        foreach ( $keys as $key => $default ) {
     2005            if ( empty( $bp->site_options[ $key ] ) ) {
     2006                $bp->site_options[ $key ] = get_blog_option( BP_ROOT_BLOG, $key, $default );
     2007
     2008                if ( !update_site_option( $key, $bp->site_options[ $key ] ) )
     2009                    $errors = true;
     2010            }
    20442011        }
    2045     }
    2046 
    2047     return $comments;
    2048 }
    2049 add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
    2050 
    2051 
    2052 /**
    2053  * bp_core_login_redirect()
    2054  *
    2055  * When a user logs in, always redirect them back to the previous page. NOT the admin area.
    2056  *
    2057  * @package BuddyPress Core
    2058  */
    2059 function bp_core_login_redirect( $redirect_to ) {
    2060     global $bp, $current_blog;
    2061 
    2062     if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
    2063         return $redirect_to;
    2064 
    2065     if ( !empty( $_REQUEST['redirect_to'] ) || strpos( $_REQUEST['redirect_to'], 'wp-admin' ) )
    2066         return $redirect_to;
    2067 
    2068     if ( false === strpos( wp_get_referer(), 'wp-login.php' ) && false === strpos( wp_get_referer(), 'activate' ) && empty( $_REQUEST['nr'] ) )
    2069         return wp_get_referer();
    2070 
    2071     return $bp->root_domain;
    2072 }
    2073 add_filter( 'login_redirect', 'bp_core_login_redirect' );
    2074 
     2012
     2013        if ( empty( $errors ) )
     2014            return true;
     2015    }
     2016
     2017    return false;
     2018}
    20752019
    20762020/********************************************************************************
     
    20802024 * hook in to.
    20812025 */
    2082 
    2083 /* Allow core components and dependent plugins to set globals */
     2026 
     2027/**
     2028 * bp_include()
     2029 *
     2030 * Allow plugins to include their files ahead of core filters
     2031 */
     2032function bp_include() {
     2033    do_action( 'bp_include' );
     2034}
     2035add_action( 'bp_loaded', 'bp_include', 2 );
     2036
     2037/**
     2038 * bp_setup_root_components()
     2039 *
     2040 * Allow core components and dependent plugins to set root components
     2041 */
     2042function bp_setup_root_components() {
     2043    do_action( 'bp_setup_root_components' );
     2044}
     2045add_action( 'bp_loaded', 'bp_setup_root_components', 2 );
     2046
     2047/**
     2048 * bp_setup_globals()
     2049 *
     2050 * Allow core components and dependent plugins to set globals
     2051 */
    20842052function bp_setup_globals() {
    20852053    do_action( 'bp_setup_globals' );
    20862054}
    2087 add_action( 'plugins_loaded', 'bp_setup_globals', 5 );
    2088 
    2089 /* Allow core components and dependent plugins to set root components */
    2090 function bp_setup_root_components() {
    2091     do_action( 'bp_setup_root_components' );
    2092 }
    2093 add_action( 'plugins_loaded', 'bp_setup_root_components', 2 );
    2094 
    2095 /* Allow core components and dependent plugins to set their nav */
     2055add_action( 'bp_loaded', 'bp_setup_globals', 6 );
     2056
     2057/**
     2058 * bp_setup_nav()
     2059 *
     2060 * Allow core components and dependent plugins to set their nav
     2061 */
    20962062function bp_setup_nav() {
    20972063    do_action( 'bp_setup_nav' );
     
    20992065add_action( 'bp_loaded', 'bp_setup_nav', 8 );
    21002066
    2101 /* Allow core components and dependent plugins to register widgets */
     2067/**
     2068 * bp_setup_widgets()
     2069 *
     2070 * Allow core components and dependent plugins to register widgets
     2071 */
    21022072function bp_setup_widgets() {
    21032073    do_action( 'bp_register_widgets' );
    21042074}
    2105 add_action( 'plugins_loaded', 'bp_setup_widgets' );
     2075add_action( 'bp_loaded', 'bp_setup_widgets', 8 );
     2076
     2077/**
     2078 * bp_init()
     2079 *
     2080 * Allow components to initialize themselves cleanly
     2081 */
     2082function bp_init() {
     2083    do_action( 'bp_init' );
     2084}
     2085add_action( 'bp_loaded', 'bp_init' );
    21062086
    21072087
     
    21122092 * actions throughout BuddyPress.
    21132093 */
     2094
     2095/**
     2096 * bp_core_add_global_group()
     2097 *
     2098 * Add's 'bp' to global group of network wide cachable objects
     2099 *
     2100 * @package BuddyPress Core
     2101 */
     2102function bp_core_add_global_group() {
     2103    wp_cache_init();
     2104
     2105    if ( function_exists( 'wp_cache_add_global_groups' ) )
     2106        wp_cache_add_global_groups( array( 'bp' ) );
     2107}
     2108add_action( 'init', 'bp_core_add_global_group' );
    21142109
    21152110/**
     
    21842179    update_site_option( 'bp-pages', $page_ids );
    21852180}
    2186 
    2187 function bp_core_is_root_component( $component_name ) {
    2188     global $bp;
    2189 
    2190     foreach ( (array) $bp->pages as $key => $page ) {
    2191         if ( $key == $component_name || $page->slug == $component_name )
    2192             return true;
    2193     }
    2194 
    2195     return false;
    2196 }
    2197 
    21982181?>
  • trunk/bp-core/bp-core-adminbar.php

    r3232 r3300  
    109109    }
    110110
    111     echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
     111    echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/">';
    112112
    113113    _e( 'My Blogs', 'buddypress' );
  • trunk/bp-core/bp-core-avatars.php

    r3232 r3300  
    479479function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) {
    480480    global $pagenow;
    481 
     481   
    482482    // Do not filter if inside WordPress options page
    483483    if ( 'options-discussion.php' == $pagenow )
    484484        return $avatar;
    485 
     485   
    486486    // If passed an object, assume $user->user_id
    487487    if ( is_object( $user ) )
  • trunk/bp-core/bp-core-catchuri.php

    r3234 r3300  
    4343    }
    4444
     45    // Ajax or not?
    4546    if ( strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) )
    4647        $path = bp_core_referrer();
    4748    else
    48         $path = clean_url( $_SERVER['REQUEST_URI'] );
     49        $path = esc_url( $_SERVER['REQUEST_URI'] );
    4950
    5051    $path = apply_filters( 'bp_uri', $path );
    5152
    52     // Firstly, take GET variables off the URL to avoid problems,
    53     // they are still registered in the global $_GET variable */
     53    // Take GET variables off the URL to avoid problems,
     54    // they are still registered in the global $_GET variable
    5455    $noget = substr( $path, 0, strpos( $path, '?' ) );
    55     if ( $noget != '' ) $path = $noget;
    56 
    57     /* Fetch the current URI and explode each part separated by '/' into an array */
     56    if ( $noget != '' )
     57        $path = $noget;
     58
     59    // Fetch the current URI and explode each part separated by '/' into an array
    5860    $bp_uri = explode( "/", $path );
    5961
    60     /* Loop and remove empties */
     62    // Loop and remove empties
    6163    foreach ( (array)$bp_uri as $key => $uri_chunk )
    6264        if ( empty( $bp_uri[$key] ) ) unset( $bp_uri[$key] );
    6365
    64     if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) {
    65         /* If we are running BuddyPress on any blog, not just a root blog, we need to first
    66            shift off the blog name if we are running a subdirectory install of WPMU. */
    67         if ( $current_blog->path != '/' )
    68             array_shift( $bp_uri );
    69     }
    70 
    71     /* Set the indexes, these are incresed by one if we are not on a VHOST install */
    72     $component_index = 0;
    73     $action_index = $component_index + 1;
    74 
    75     /* Get site path items */
     66    // Running off blog other than root
     67    if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) {
     68 
     69        // Any subdirectory names must be removed from $bp_uri.
     70        // This includes two cases: (1) when WP is installed in a subdirectory,
     71        // and (2) when BP is running on secondary blog of a subdirectory
     72        // multisite installation. Phew!
     73        if ( $chunks = explode( '/', $current_blog->path ) ) {
     74            foreach( $chunks as $key => $chunk ) {
     75                $bkey = array_search( $chunk, $bp_uri );
     76 
     77                if ( $bkey !== false )
     78                    unset( $bp_uri[$bkey] );
     79 
     80                $bp_uri = array_values( $bp_uri );
     81            }
     82        }
     83    }
     84
     85    // Set the indexes, these are incresed by one if we are not on a VHOST install
     86    $component_index    = 0;
     87    $action_index       = $component_index + 1;
     88
     89    // Get site path items
    7690    $paths = explode( '/', bp_core_get_site_path() );
    7791
    78     /* Take empties off the end of path */
     92    // Take empties off the end of path
    7993    if ( empty( $paths[count($paths) - 1] ) )
    8094        array_pop( $paths );
    8195
    82     /* Take empties off the start of path */
     96    // Take empties off the start of path
    8397    if ( empty( $paths[0] ) )
    8498        array_shift( $paths );
     
    90104    }
    91105
    92     /* Reset the keys by merging with an empty array */
    93     $bp_uri = array_merge( array(), $bp_uri );
    94     $bp_unfiltered_uri = $bp_uri;
    95 
    96     /* Find a match within registered BuddyPress controlled WP pages (check members first) */
     106    // Reset the keys by merging with an empty array
     107    $bp_uri             = array_merge( array(), $bp_uri );
     108    $bp_unfiltered_uri  = $bp_uri;
     109
     110    // Find a match within registered BuddyPress controlled WP pages (check members first)
    97111    foreach ( (array)$bp_pages as $page_key => $bp_page ) {
    98112        if ( in_array( $bp_page->name, (array)$bp_uri ) ) {
    99             /* Match found, now match the slug to make sure. */
     113            // Match found, now match the slug to make sure.
    100114            $uri_chunks = explode( '/', $bp_page->slug );
    101115
     
    120134    }
    121135
    122     /* This is not a BuddyPress page, so just return. */
     136    // This is not a BuddyPress page, so just return.
    123137    if ( in_array( 0, (array) $matches ) )
    124138        return false;
    125139
    126     /* Find the offset */
     140    // Find the offset
    127141    $uri_offset = 0;
    128142    $slug = explode( '/', $match->slug );
     
    133147    }
    134148
    135     /* Global the unfiltered offset to use in bp_core_load_template() */
     149    // Global the unfiltered offset to use in bp_core_load_template()
    136150    $bp_unfiltered_uri_offset = $uri_offset;
    137151
    138     /* This is a members page so lets check if we have a displayed member */
     152    // This is a members page so lets check if we have a displayed member
    139153    if ( 'members' == $match->key ) {
    140154        if ( !empty( $bp_uri[$uri_offset + 1] ) ) {
     
    146160            $uri_offset = $uri_offset + 2;
    147161
    148             /* Remove everything from the URI up to the offset and take it from there. */
     162            // Remove everything from the URI up to the offset and take it from there.
    149163            for ( $i = 0; $i < $uri_offset; $i++ )
    150164                unset( $bp_uri[$i] );
     
    154168    }
    155169
    156     /* Reset the keys by merging with an empty array */
     170    // Reset the keys by merging with an empty array
    157171    $bp_uri = array_merge( array(), $bp_uri );
    158172
    159     /* Set the current component */
     173    // Set the current component
    160174    if ( empty( $current_component ) ) {
    161175        for ( $i = 0; $i <= $uri_offset; $i++ ) {
     
    170184        $i = 1;
    171185
    172     /* Set the current action */
     186    // Set the current action
    173187    $current_action = $bp_uri[$i];
    174188
    175     /* Unset the current_component and action from action_variables */
     189    // Unset the current_component and action from action_variables
    176190    for ( $j = 0; $j <= $i; $j++ )
    177191        unset( $bp_uri[$j] );
    178192
    179     /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
     193    // Set the entire URI as the action variables, we will unset the current_component and action in a second
    180194    $action_variables = $bp_uri;
    181195
    182     /* Remove the username from action variables if this is not a VHOST install */
     196    // Remove the username from action variables if this is not a VHOST install
    183197    if ( 'no' == VHOST && !$is_root_component )
    184198        array_shift($bp_uri);
    185199
    186     /* Reset the keys by merging with an empty array */
     200    // Reset the keys by merging with an empty array
    187201    $action_variables = array_merge( array(), $action_variables );
    188 
    189     //var_dump($current_component, $current_action, $bp_uri);
    190202}
    191 add_action( 'plugins_loaded', 'bp_core_set_uri_globals', 3 );
     203add_action( 'bp_loaded', 'bp_core_set_uri_globals', 4 );
    192204
    193205/**
  • trunk/bp-core/bp-core-classes.php

    r3267 r3300  
    5151     * @uses bp_core_get_userlink() Returns a HTML formatted link for a user with the user's full name as the link text
    5252     * @uses bp_core_get_user_email() Returns the email address for the user based on user ID
    53      * @uses get_usermeta() WordPress function returns the value of passed usermeta name from usermeta table
     53     * @uses get_user_meta() WordPress function returns the value of passed usermeta name from usermeta table
    5454     * @uses bp_core_fetch_avatar() Returns HTML formatted avatar for a user
    5555     * @uses bp_profile_last_updated_date() Returns the last updated date for a user.
     
    6161        if ( $this->profile_data ) {
    6262            $this->user_url = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
    63             $this->fullname = attribute_escape( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
     63            $this->fullname = esc_attr( $this->profile_data[BP_XPROFILE_FULLNAME_FIELD_NAME]['field_data'] );
    6464            $this->user_link = "<a href='{$this->user_url}' title='{$this->fullname}'>{$this->fullname}</a>";
    65             $this->email = attribute_escape( $this->profile_data['user_email'] );
     65            $this->email = esc_attr( $this->profile_data['user_email'] );
    6666        } else {
    6767            $this->user_url = bp_core_get_user_domain( $this->id );
    6868            $this->user_link = bp_core_get_userlink( $this->id );
    69             $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) );
    70             $this->email = attribute_escape( bp_core_get_user_email( $this->id ) );
     69            $this->fullname = esc_attr( bp_core_get_user_displayname( $this->id ) );
     70            $this->email = esc_attr( bp_core_get_user_email( $this->id ) );
    7171        }
    7272
     
    8080        $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
    8181
    82         $this->last_active = bp_core_get_last_activity( get_usermeta( $this->id, 'last_activity' ), __( 'active %s ago', 'buddypress' ) );
     82        $this->last_active = bp_core_get_last_activity( get_user_meta( $this->id, 'last_activity', true ), __( 'active %s ago', 'buddypress' ) );
    8383    }
    8484
     
    107107    /* Static Functions */
    108108
    109     function get_users( $type, $limit = null, $page = 1, $user_id = false, $search_terms = false, $populate_extras = true ) {
     109    function get_users( $type, $limit = null, $page = 1, $user_id = false, $include = false, $search_terms = false, $populate_extras = true ) {
    110110        global $wpdb, $bp;
    111111
    112112        $sql = array();
    113113
    114         $sql['select_main'] = "SELECT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
     114        $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
    115115
    116116        if ( 'active' == $type || 'online' == $type )
     
    125125        $sql['from'] = "FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN " . CUSTOM_USER_META_TABLE . " um ON um.user_id = u.ID";
    126126
     127        if ( $search_terms && function_exists( 'xprofile_install' ) || 'alphabetical' == $type )
     128            $sql['join_profiledata'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
     129
    127130        $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
    128131
     
    134137
    135138        if ( 'online' == $type )
    136             $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= NOW()";
     139            $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
    137140
    138141        if ( 'alphabetical' == $type )
    139142            $sql['where_alpha'] = "AND pd.field_id = 1";
    140143
    141         if ( $user_id && function_exists( 'friends_install' ) ) {
     144        if ( $include ) {
     145            if ( is_array( $include ) )
     146                $uids = $wpdb->escape( implode( ',', (array)$include ) );
     147            else
     148                $uids = $wpdb->escape( $include );
     149
     150            if ( !empty( $uids ) )
     151                $sql['where_users'] = "AND u.ID IN ({$uids})";
     152        }
     153
     154        else if ( $user_id && function_exists( 'friends_install' ) ) {
    142155            $friend_ids = friends_get_friend_user_ids( $user_id );
    143156            $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) );
     
    151164        }
    152165
    153         if ( $search_terms ) {
     166        if ( $search_terms && function_exists( 'xprofile_install' ) ) {
    154167            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
    155             $sql['where_searchterms'] = "AND u.display_name LIKE '%%$search_terms%%'";
     168            $sql['where_searchterms'] = "AND pd.value LIKE '%%$search_terms%%'";
    156169        }
    157170
     
    164177                break;
    165178            case 'alphabetical':
    166                 $sql[] = "ORDER BY u.display_name ASC";
     179                $sql[] = "ORDER BY pd.value ASC";
    167180                break;
    168181            case 'random':
     
    178191
    179192        /* Get paginated results */
    180         $paged_users = $wpdb->get_results( join( ' ', (array)$sql ) );
     193        $paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array)$sql ), $sql );
     194        $paged_users     = $wpdb->get_results( $paged_users_sql );
    181195
    182196        /* Re-jig the SQL so we can get the total user count */
     
    198212
    199213        /* Get total user results */
    200         $total_users = $wpdb->get_var( join( ' ', (array)$sql ) );
     214        $total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array)$sql ), $sql );
     215        $total_users     = $wpdb->get_var( $total_users_sql );
    201216
    202217        /***
     
    223238            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    224239
    225         if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
    226             return false;
     240        // Multibyte compliance
     241        if ( function_exists( 'mb_strlen' ) ) {
     242            if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
     243                return false;
     244            }
     245        } else {
     246            if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) {
     247                return false;
     248            }
     249        }
    227250
    228251        $letter = like_escape( $wpdb->escape( $letter ) );
     
    318341        /* Fetch the user's full name */
    319342        if ( bp_is_active( 'xprofile' ) && 'alphabetical' != $type ) {
     343            /* Ensure xprofile globals are set */
     344            if ( !defined( 'BP_XPROFILE_FULLNAME_FIELD_NAME' ) )
     345                xprofile_setup_globals();
     346
    320347            $names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id as id, pd.value as fullname FROM {$bp->profile->table_name_fields} pf, {$bp->profile->table_name_data} pd WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} )", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
    321348            for ( $i = 0; $i < count( $paged_users ); $i++ ) {
     
    436463        if ( $this->id ) {
    437464            // Update
    438             $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = FROM_UNIXTIME(%d), is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
     465            $sql = $wpdb->prepare( "UPDATE {$bp->core->table_name_notifications} SET item_id = %d, secondary_item_id = %d, user_id = %d, component_name = %s, component_action = %d, date_notified = %s, is_new = %d ) WHERE id = %d", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new, $this->id );
    439466        } else {
    440467            // Save
    441             $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, FROM_UNIXTIME(%d), %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
     468            $sql = $wpdb->prepare( "INSERT INTO {$bp->core->table_name_notifications} ( item_id, secondary_item_id, user_id, component_name, component_action, date_notified, is_new ) VALUES ( %d, %d, %d, %s, %s, %s, %d )", $this->item_id, $this->secondary_item_id, $this->user_id, $this->component_name, $this->component_action, $this->date_notified, $this->is_new );
    442469        }
    443470
  • trunk/bp-core/bp-core-cssjs.php

    r3280 r3300  
    3939    <style type="text/css">
    4040        ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a { background-image: url( <?php echo BP_PLUGIN_URL . '/bp-core/images/admin_menu_icon.png' ?> ) !important; background-position: -1px -32px; }
    41         ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a { background-position: -1px 0; }
     41        ul#adminmenu li.toplevel_page_bp-general-settings:hover .wp-menu-image a, ul#adminmenu li.toplevel_page_bp-general-settings.wp-has-current-submenu .wp-menu-image a { background-position: -1px 0; }
    4242        ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img { display: none; }
    4343    </style>
     
    5050    global $current_blog;
    5151
    52     if ( $current_blog->blog_id != BP_ROOT_BLOG )
     52    if ( bp_core_is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
    5353        return false;
    5454?>
     
    8383    global $bp;
    8484
    85     $image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) );
     85    $image = apply_filters( 'bp_inline_cropper_image', getimagesize( BP_AVATAR_UPLOAD_PATH . $bp->avatar_admin->image->dir ) );
    8686    $aspect_ratio = 1;
    8787
    88     /* Calculate Aspect Ratio */
     88    // Calculate Aspect Ratio
    8989    if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) )
    9090        $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
  • trunk/bp-core/bp-core-filters.php

    r2941 r3300  
    3333 */
    3434function bp_core_email_from_name_filter() {
    35     return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
     35    return apply_filters( 'bp_core_email_from_name_filter', wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ) );
    3636}
    3737add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
     
    6666    global $bp, $current_blog;
    6767
    68     if ( !is_site_admin() )
     68    if ( !is_super_admin() )
    6969        return $themes;
    7070
     
    142142 * Replace the generated password in the welcome email.
    143143 * This will not filter when the site admin registers a user.
     144 *
     145 * @uses locate_template To see if custom registration files exist
     146 * @param string $welcome_email Complete email passed through WordPress
     147 * @return string Filtered $welcome_email with 'PASSWORD' replaced by [User Set]
    144148 */
    145149function bp_core_filter_user_welcome_email( $welcome_email ) {
     
    148152        return $welcome_email;
    149153
     154    // [User Set] Replaces 'PASSWORD' in welcome email; Represents value set by user
    150155    return str_replace( 'PASSWORD', __( '[User Set]', 'buddypress' ), $welcome_email );
    151156}
     
    158163 * Replace the generated password in the welcome email.
    159164 * This will not filter when the site admin registers a user.
     165 *
     166 * @uses locate_template To see if custom registration files exist
     167 * @param string $welcome_email Complete email passed through WordPress
     168 * @param integer $blog_id ID of the blog user is joining
     169 * @param integer $user_id ID of the user joining
     170 * @param string $password Password of user
     171 * @return string Filtered $welcome_email with $password replaced by [User Set]
    160172 */
    161173function bp_core_filter_blog_welcome_email( $welcome_email, $blog_id, $user_id, $password ) {
     
    164176        return $welcome_email;
    165177
     178    // [User Set] Replaces $password in welcome email; Represents value set by user
    166179    return str_replace( $password, __( '[User Set]', 'buddypress' ), $welcome_email );
    167180}
     
    175188    // Send email with activation link.
    176189    $activate_url = bp_get_activation_page() ."?key=$key";
    177     $activate_url = clean_url($activate_url);
     190    $activate_url = esc_url($activate_url);
    178191
    179192    $admin_email = get_site_option( "admin_email" );
     
    184197    $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    185198    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    186     $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%1$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%2$s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
    187     $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
     199    $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%1$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%2$s", 'buddypress' ), $activate_url, esc_url("http://{$domain}{$path}" ) );
     200    $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), esc_url('http://' . $domain . $path));
    188201
    189202    /* Send the message */
     
    204217
    205218    $activate_url = bp_get_activation_page() ."?key=$key";
    206     $activate_url = clean_url($activate_url);
     219    $activate_url = esc_url($activate_url);
    207220    $admin_email = get_site_option( "admin_email" );
    208221
     
    216229    $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    217230    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    218     $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url . $email, clean_url("http://{$domain}{$path}" ) );
     231    $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url . $email, esc_url( "http://{$domain}{$path}" ) );
    219232    $subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
    220233
  • trunk/bp-core/bp-core-notifications.php

    r2576 r3300  
    55
    66    if ( !$date_notified )
    7         $date_notified = time();
     7        $date_notified = bp_core_current_time();
    88
    99    $notification = new BP_Core_Notification;
  • trunk/bp-core/bp-core-settings.php

    r2717 r3300  
    2222    bp_core_new_subnav_item( array( 'name' => __( 'Notifications', 'buddypress' ), 'slug' => 'notifications', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_notification_settings', 'position' => 20, 'user_has_access' => bp_is_my_profile() ) );
    2323
    24     if ( !is_site_admin() && !(int) $bp->site_options['bp-disable-account-deletion'] )
     24    if ( !is_super_admin() && !(int) $bp->site_options['bp-disable-account-deletion'] )
    2525        bp_core_new_subnav_item( array( 'name' => __( 'Delete Account', 'buddypress' ), 'slug' => 'delete-account', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_delete_account', 'position' => 90, 'user_has_access' => bp_is_my_profile() ) );
    2626}
    27 add_action( 'wp', 'bp_core_add_settings_nav', 2 );
    28 add_action( 'admin_menu', 'bp_core_add_settings_nav', 2 );
     27add_action( 'bp_setup_nav', 'bp_core_add_settings_nav' );
    2928
    3029/**** GENERAL SETTINGS ****/
     
    8887    <form action="<?php echo $bp->loggedin_user->domain . BP_SETTINGS_SLUG . '/general' ?>" method="post" class="standard-form" id="settings-form">
    8988        <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label>
    90         <input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" />
     89        <input type="text" name="email" id="email" value="<?php echo esc_attr( $current_user->user_email ); ?>" class="settings-input" />
    9190
    9291        <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label>
     
    9594
    9695        <div class="submit">
    97             <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
     96            <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto" />
    9897        </div>
    9998
     
    115114        if ( $_POST['notifications'] ) {
    116115            foreach ( (array)$_POST['notifications'] as $key => $value ) {
    117                 update_usermeta( (int)$current_user->id, $key, $value );
     116                update_user_meta( (int)$current_user->id, $key, $value );
    118117            }
    119118        }
     
    148147
    149148        <div class="submit">
    150             <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
     149            <input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto" />
    151150        </div>
    152151
     
    190189
    191190        <div class="submit">
    192             <input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> &rarr;" id="delete-account-button" name="delete-account-button" /></p>
     191            <input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> &rarr;" id="delete-account-button" name="delete-account-button" />
    193192        </div>
    194193
  • trunk/bp-core/bp-core-signup.php

    r3277 r3300  
    181181
    182182            /* Make sure we include the jQuery jCrop file for image cropping */
    183             add_action( 'wp', 'bp_core_add_jquery_cropper' );
     183            add_action( 'wp_print_scripts', 'bp_core_add_jquery_cropper' );
    184184        }
    185185    }
  • trunk/bp-core/bp-core-templatetags.php

    r3286 r3300  
    3030            $this->members = BP_Core_User::get_specific_users( $include, $this->pag_num, $this->pag_page, $populate_extras );
    3131        else
    32             $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
     32            $this->members = bp_core_get_users( array( 'type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
    3333
    3434        if ( !$max || $max >= (int)$this->members['total'] )
     
    126126    $search_terms = false;
    127127
    128     /* User filtering */
     128    // User filtering
    129129    if ( !empty( $bp->displayed_user->id ) )
    130130        $user_id = $bp->displayed_user->id;
    131131
    132     /* Pass a filter if ?s= is set. */
    133     if ( $_REQUEST['s'] )
     132    // Pass a filter if ?s= is set.
     133    if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) )
    134134        $search_terms = $_REQUEST['s'];
    135135
     
    157157    }
    158158
    159     /* Make sure we return no members if we looking at friendship requests and there are none. */
     159    // Make sure we return no members if we looking at friendship requests and there are none.
    160160    if ( empty( $include ) && $bp->friends->slug == $bp->current_component && 'requests' == $bp->current_action )
    161161        return false;
    162162
    163163    $members_template = new BP_Core_Members_Template( $type, $page, $per_page, $max, $user_id, $search_terms, $include, (bool)$populate_extras );
    164 
    165     return $members_template->has_members();
     164    return apply_filters( 'bp_has_members', $members_template->has_members(), &$members_template );
    166165}
    167166
     
    182181        global $bp, $members_template;
    183182
    184         $from_num = bp_core_number_format( intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1 );
    185         $to_num = bp_core_number_format( ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1) );
     183        $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
     184        $from_num = bp_core_number_format( $start_num );
     185        $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
    186186        $total = bp_core_number_format( $members_template->total_member_count );
    187187
     
    195195            $pag = sprintf( __( 'Viewing member %1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total );
    196196
    197         return apply_filters( 'bp_members_pagination_count', $pag );
     197        return apply_filters( 'bp_members_pagination_count', $pag . '<span class="ajax-loader"></span>' );
    198198    }
    199199
     
    207207    }
    208208
     209/**
     210 * bp_member_user_id()
     211 *
     212 * Echo id from bp_get_member_user_id()
     213 *
     214 * @uses bp_get_member_user_id()
     215 */
    209216function bp_member_user_id() {
    210217    echo bp_get_member_user_id();
    211218}
     219    /**
     220     * bp_get_member_user_id()
     221     *
     222     * Get the id of the user in a members loop
     223     *
     224     * @global object $members_template
     225     * @return string Members id
     226     */
    212227    function bp_get_member_user_id() {
    213228        global $members_template;
     
    215230        return apply_filters( 'bp_get_member_user_id', $members_template->member->id );
    216231    }
     232
     233/**
     234 * bp_member_user_nicename()
     235 *
     236 * Echo nicename from bp_get_member_user_nicename()
     237 *
     238 * @uses bp_get_member_user_nicename()
     239 */
     240function bp_member_user_nicename() {
     241    echo bp_get_member_user_nicename();
     242}
     243    /**
     244     * bp_get_member_user_nicename()
     245     *
     246     * Get the nicename of the user in a members loop
     247     *
     248     * @global object $members_template
     249     * @return string Members nicename
     250     */
     251    function bp_get_member_user_nicename() {
     252        global $members_template;
     253        return apply_filters( 'bp_get_member_user_nicename', $members_template->member->user_nicename );
     254    }
     255
     256/**
     257 * bp_member_user_login()
     258 *
     259 * Echo login from bp_get_member_user_login()
     260 *
     261 * @uses bp_get_member_user_login()
     262 */
     263function bp_member_user_login() {
     264    echo bp_get_member_user_login();
     265}
     266    /**
     267     * bp_get_member_user_login()
     268     *
     269     * Get the login of the user in a members loop
     270     *
     271     * @global object $members_template
     272     * @return string Members login
     273     */
     274    function bp_get_member_user_login() {
     275        global $members_template;
     276        return apply_filters( 'bp_get_member_user_login', $members_template->member->user_login );
     277    }
     278
     279/**
     280 * bp_member_user_email()
     281 *
     282 * Echo email address from bp_get_member_user_email()
     283 *
     284 * @uses bp_get_member_user_email()
     285 */
     286function bp_member_user_email() {
     287    echo bp_get_member_user_email();
     288}
     289    /**
     290     * bp_get_member_user_email()
     291     *
     292     * Get the email address of the user in a members loop
     293     *
     294     * @global object $members_template
     295     * @return string Members email address
     296     */
     297    function bp_get_member_user_email() {
     298        global $members_template;
     299        return apply_filters( 'bp_get_member_user_email', $members_template->member->user_email );
     300    }
     301
     302function bp_member_is_loggedin_user() {
     303    global $bp, $members_template;
     304    return apply_filters( 'bp_member_is_loggedin_user', $bp->loggedin_user->id == $members_template->member->id ? true : false );
     305}
    217306
    218307function bp_member_avatar( $args = '' ) {
     
    315404
    316405        // Populate the user if it hasn't been already.
    317         if ( empty( $members_template->member->profile_data ) )
    318             $members_template->member = new BP_Core_User( $members_template->member->id );
     406        if ( empty( $members_template->member->profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) )
     407            $members_template->member->profile_data = BP_XProfile_ProfileData::get_all_for_user( $members_template->member->id );
    319408
    320409        $data = xprofile_format_profile_field( $members_template->member->profile_data[$field]['field_type'], $members_template->member->profile_data[$field]['field_data'] );
     
    329418        global $members_template;
    330419
    331         $registered = attribute_escape( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
     420        $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
    332421
    333422        return apply_filters( 'bp_member_last_active', $registered );
     
    346435function bp_member_hidden_fields() {
    347436    if ( isset( $_REQUEST['s'] ) ) {
    348         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
     437        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ) . '" name="search_terms" />';
    349438    }
    350439
    351440    if ( isset( $_REQUEST['letter'] ) ) {
    352         echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
     441        echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    353442    }
    354443
    355444    if ( isset( $_REQUEST['members_search'] ) ) {
    356         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['members_search'] ) . '" name="search_terms" />';
     445        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['members_search'] ) . '" name="search_terms" />';
    357446    }
    358447}
     
    367456    ?>
    368457    <form action="" method="get" id="search-members-form">
    369         <label><input type="text" name="s" id="members_search" value="<?php echo attribute_escape( $search_value ) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
     458        <label><input type="text" name="s" id="members_search" value="<?php echo esc_attr( $search_value ) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
    370459        <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    371460    </form>
     
    517606        $bp->bp_options_title = __( 'Options', 'buddypress' );
    518607
    519     echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) );
     608    echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
    520609}
    521610
     
    575664
    576665        $defaults = array(
    577             'type' => 'thumb',
    578             'width' => false,
    579             'height' => false
     666            'type'      => 'thumb',
     667            'width'     => false,
     668            'height'    => false,
     669            'html'      => true
    580670        );
    581671
     
    583673        extract( $r, EXTR_SKIP );
    584674
    585         return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
     675        return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) );
    586676    }
    587677
     
    593683
    594684        $defaults = array(
    595             'type' => 'thumb',
    596             'width' => false,
    597             'height' => false
     685            'type'      => 'thumb',
     686            'width'     => false,
     687            'height'    => false,
     688            'html'      => true
    598689        );
    599690
     
    601692        extract( $r, EXTR_SKIP );
    602693
    603         return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
     694        return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) );
    604695    }
    605696
     
    641732}
    642733
    643 function bp_is_my_profile() {
    644     global $bp;
    645 
    646     if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
    647         return true;
    648 
    649     return false;
    650 }
    651 function bp_is_home() { return bp_is_my_profile(); }
    652 
    653 function bp_get_loggedin_user_link() {
    654     global $bp;
    655 
    656     return $bp->loggedin_user->domain;
    657 }
    658 
    659 function bp_get_displayed_user_link() {
    660     global $bp;
    661 
    662     return $bp->displayed_user->domain;
    663 }
    664 
    665 function bp_last_activity( $user_id = false, $echo = true ) {
    666     global $bp;
    667 
    668     if ( !$user_id )
    669         $user_id = $bp->displayed_user->id;
    670 
    671     $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') );
    672 
    673     if ( $echo )
    674         echo apply_filters( 'bp_last_activity', $last_activity );
    675     else
    676         return apply_filters( 'bp_last_activity', $last_activity );
    677 }
    678 
    679 function bp_user_firstname() {
    680     echo bp_get_user_firstname();
    681 }
    682     function bp_get_user_firstname( $name = false ) {
    683         global $bp;
    684 
    685         if ( !$name )
    686             $name = $bp->loggedin_user->fullname;
    687 
    688         $fullname = (array)explode( ' ', $name );
    689 
    690         return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
    691     }
    692 
    693 function bp_user_link() {
    694     global $bp;
    695 
    696     echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain );
    697 }
    698 
    699734function bp_core_get_wp_profile() {
    700735    global $bp;
     
    706741    <h4><?php _e( 'My Profile' ) ?></h4>
    707742
    708     <table class="wp-profile-fields">
     743    <table class="wp-profile-fields zebra">
    709744        <?php if ( $ud->display_name ) { ?>
    710745        <tr id="wp_displayname">
     
    784819
    785820function bp_format_time( $time, $just_date = false ) {
    786     $date = date( get_option('date_format'), $time );
    787 
     821    if ( !$time )
     822        return false;
     823
     824    // Get GMT offset from root blog
     825    $root_blog_offset = get_blog_option( BP_ROOT_BLOG, 'gmt_offset' );
     826
     827    // Calculate offset time
     828    $time_offset = $time + ( $root_blog_offset * 3600 );
     829
     830    // Current date (January 1, 2010)
     831    $date = date( 'F j, Y ', $time_offset );
     832
     833    // Should we show the time also?
    788834    if ( !$just_date ) {
    789         $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time );
     835        // Current time (9:50pm)
     836        $time = date( ' g:ia', $time_offset );
     837
     838        // Return string formatted with date and time
     839        $date = sprintf( __( '%1$s at %2$s', 'buddypress' ), $date, $time );
    790840    }
    791841
     
    833883}
    834884
    835 function bp_loggedinuser_link() {
    836     global $bp;
    837 
    838     if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) {
    839         echo apply_filters( 'bp_loggedinuser_link', $link );
    840     }
    841 }
    842 
    843885function bp_get_plugin_sidebar() {
    844886    locate_template( array( 'plugin-sidebar.php' ), true );
    845887}
    846888
    847 function bp_is_blog_page() {
    848     global $bp, $is_member_page, $wp_query;
    849 
    850     if ( $wp_query->is_home && !$bp->is_directory )
    851         return true;
    852 
    853     if ( !$bp->displayed_user->id && !$bp->is_single_item && !$bp->is_directory && !bp_core_is_root_component( $bp->current_component ) )
    854         return true;
    855 
    856     return false;
    857 }
    858 
    859889function bp_page_title() {
    860890    echo bp_get_page_title();
     
    864894    global $bp, $post, $wp_query, $current_blog;
    865895
    866     if ( is_front_page() || !bp_current_component() || ( is_home() && bp_is_page( 'home' ) ) ) {
     896    if ( is_front_page() || ( is_home() && bp_is_page( 'home' ) ) ) {
    867897        $title = __( 'Home', 'buddypress' );
    868898
     
    886916
    887917    } else if ( $bp->is_directory ) {
    888         $title = get_the_title();
     918        if ( !$bp->current_component )
     919            $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( BP_MEMBERS_SLUG ) );
     920        else
     921            $title = sprintf( __( '%s Directory', 'buddypress' ), ucwords( $bp->current_component ) );
    889922
    890923    } else if ( bp_is_register_page() ) {
    891 
    892924        $title = __( 'Create an Account', 'buddypress' );
    893925
    894926    } else if ( bp_is_activation_page() ) {
    895927        $title = __( 'Activate your Account', 'buddypress' );
     928
     929    } else if ( bp_is_group_create() ) {
     930        $title = __( 'Create a Group', 'buddypress' );
     931
     932    } else if ( bp_is_create_blog() ) {
     933        $title = __( 'Create a Blog', 'buddypress' );
    896934    }
    897935
     
    952990    }
    953991
     992/**
     993 * bp_search_form_available()
     994 *
     995 * Only show the search form if there are available objects to search for.
     996 *
     997 * @global array $bp
     998 * @uses function_exists
     999 * @uses bp_core_is_multisite()
     1000 * @return bool Filterable result
     1001 */
     1002function bp_search_form_enabled() {
     1003    global $bp;
     1004
     1005    if ( function_exists( 'xprofile_install' )
     1006         || function_exists( 'groups_install' )
     1007         || ( function_exists( 'bp_blogs_install' ) && bp_core_is_multisite() )
     1008         || ( function_exists( 'bp_forums_setup' ) && !(int)$bp->site_options['bp-disable-forum-directory'] )
     1009        ) {
     1010        $search_enabled = true;
     1011    } else {
     1012        $search_enabled = false;
     1013    }
     1014
     1015    return apply_filters( 'bp_search_form_enabled', $search_enabled );
     1016}
     1017
    9541018function bp_search_form_action() {
    9551019    global $bp;
     
    9591023
    9601024function bp_search_form_type_select() {
     1025    global $bp;
     1026
    9611027    // Eventually this won't be needed and a page will be built to integrate all search results.
    9621028    $selection_box = '<select name="search-which" id="search-which" style="width: auto">';
     
    10131079function bp_custom_profile_sidebar_boxes() {
    10141080    do_action( 'bp_custom_profile_sidebar_boxes' );
    1015 }
    1016 
    1017 function bp_is_directory() {
    1018     global $bp;
    1019 
    1020     return $bp->is_directory;
    10211081}
    10221082
     
    12251285
    12261286function bp_registration_needs_activation() {
    1227     return apply_filters( 'bp_registration_needs_activation', bp_core_is_multisite() );
     1287    return apply_filters( 'bp_registration_needs_activation', true );
    12281288}
    12291289
     
    12681328   also means we dont have to use the $bp variable in the template (looks messy) */
    12691329
     1330function bp_last_activity( $user_id = false, $echo = true ) {
     1331    global $bp;
     1332
     1333    if ( !$user_id )
     1334        $user_id = $bp->displayed_user->id;
     1335
     1336    $last_activity = bp_core_get_last_activity( get_user_meta( $user_id, 'last_activity', true ), __('active %s ago', 'buddypress') );
     1337
     1338    if ( $echo )
     1339        echo apply_filters( 'bp_last_activity', $last_activity );
     1340    else
     1341        return apply_filters( 'bp_last_activity', $last_activity );
     1342}
     1343
     1344function bp_user_has_access() {
     1345    global $bp;
     1346
     1347    if ( is_super_admin() || is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
     1348        $has_access = true;
     1349    else
     1350        $has_access = false;
     1351
     1352    return apply_filters( 'bp_user_has_access', $has_access );
     1353}
     1354
     1355function bp_user_firstname() {
     1356    echo bp_get_user_firstname();
     1357}
     1358    function bp_get_user_firstname( $name = false ) {
     1359        global $bp;
     1360
     1361        // Try to get displayed user
     1362        if ( empty( $name ) )
     1363            $name = $bp->displayed_user->fullname;
     1364
     1365        // Fall back on logged in user
     1366        if ( empty( $name ) )
     1367            $name = $bp->loggedin_user->fullname;
     1368
     1369        $fullname = (array)explode( ' ', $name );
     1370
     1371        return apply_filters( 'bp_get_user_firstname', $fullname[0], $fullname );
     1372    }
     1373
     1374function bp_loggedin_user_link() {
     1375    echo bp_get_loggedin_user_link();
     1376}
     1377    function bp_get_loggedin_user_link() {
     1378        global $bp;
     1379
     1380        return apply_filters( 'bp_get_loggedin_user_link', $bp->loggedin_user->domain );
     1381    }
     1382
     1383/* @todo Deprecate incorrectly named function? */
     1384function bp_loggedinuser_link() {
     1385    global $bp;
     1386
     1387    if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) )
     1388        echo apply_filters( 'bp_loggedin_user_link', $link );
     1389}
     1390
     1391function bp_displayed_user_link() {
     1392    echo bp_get_displayed_user_link();
     1393}
     1394    function bp_get_displayed_user_link() {
     1395        global $bp;
     1396
     1397        return apply_filters( 'bp_get_displayed_user_link', $bp->displayed_user->domain );
     1398    }
     1399    function bp_user_link() { bp_displayed_user_link(); } // Deprecated.
     1400
    12701401function bp_displayed_user_id() {
    12711402    global $bp;
     
    13501481        global $bp;
    13511482
    1352         return $bp->root_domain;
     1483        return apply_filters( 'bp_get_root_domain', $bp->root_domain );
    13531484    }
    13541485
    13551486/* Template is_() functions to determine the current page */
     1487
     1488function bp_is_blog_page() {
     1489    global $bp, $is_member_page, $wp_query;
     1490
     1491    if ( $wp_query->is_home && !$bp->is_directory )
     1492        return true;
     1493
     1494    if ( !$bp->displayed_user->id && !$bp->is_single_item && !$bp->is_directory && !bp_core_is_root_component( $bp->current_component ) )
     1495        return true;
     1496
     1497    return false;
     1498}
     1499
     1500function bp_is_my_profile() {
     1501    global $bp;
     1502
     1503    if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
     1504        $my_profile = true;
     1505    else
     1506        $my_profile = false;
     1507
     1508    return apply_filters( 'bp_is_my_profile', $my_profile );
     1509}
     1510function bp_is_home() { return bp_is_my_profile(); }
    13561511
    13571512function bp_is_front_page() {
     
    13651520
    13661521function bp_is_activity_front_page() {
    1367     return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == bp_core_get_site_path() );
     1522    global $current_blog;
     1523
     1524    if ( bp_core_is_main_site() )
     1525        $path = bp_core_get_site_path();
     1526    else
     1527        $path = $current_blog->path;
     1528
     1529    return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == $path );
     1530}
     1531
     1532function bp_is_directory() {
     1533    global $bp;
     1534
     1535    return $bp->is_directory;
    13681536}
    13691537
  • trunk/bp-core/bp-core-widgets.php

    r3263 r3300  
    5959            </ul>
    6060            <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
    61             <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $instance['max_members'] ); ?>" />
     61            <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr( $instance['max_members'] ); ?>" />
    6262
    6363        <?php else: ?>
     
    8585        ?>
    8686
    87         <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>
     87        <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
    8888    <?php
    8989    }
     
    139139        ?>
    140140
    141         <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>
     141        <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
    142142    <?php
    143143    }
     
    154154        global $bp;
    155155
    156         extract( $args );
     156        extract( $args );
    157157
    158158        echo $before_widget;
     
    193193        ?>
    194194
    195         <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo attribute_escape( $max_members ); ?>" style="width: 30%" /></label></p>
     195        <p><label for="bp-core-widget-members-max"><?php _e('Max Members to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="text" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" /></label></p>
    196196    <?php
    197197    }
     
    209209            $type = 'newest';
    210210            break;
     211
    211212        case 'recently-active-members':
    212213            $type = 'active';
    213214            break;
     215
    214216        case 'popular-members':
    215217            if ( bp_is_active( 'friends' ) )
  • trunk/bp-core/bp-core-wpabstraction.php

    r3284 r3300  
    2323
    2424    return true;
     25}
     26
     27/**
     28 * bp_core_is_main_site
     29 *
     30 * Checks if current blog is root blog of site
     31 *
     32 * @since 1.2.6
     33 * @package BuddyPress
     34 *
     35 * @param int $blog_id optional blog id to test (default current blog)
     36 * @return bool True if not multisite or $blog_id is main site
     37 */
     38function bp_core_is_main_site( $blog_id = '' ) {
     39    global $current_site, $current_blog;
     40
     41    if ( !bp_core_is_multisite() )
     42        return true;
     43
     44    if ( empty( $blog_id ) )
     45        $blog_id = $current_blog->blog_id;
     46
     47    return $blog_id == $current_site->blog_id;
    2548}
    2649
     
    7497}
    7598
    76 if ( !function_exists( 'wpmu_validate_user_signup' ) ) {
    77     function wpmu_validate_user_signup( $user_name, $user_email ) {
    78         global $wpdb;
     99if ( !function_exists( 'is_subdomain_install' ) ) {
     100    function is_subdomain_install() {
     101        if ( ( defined( 'VHOST' ) && 'yes' == VHOST ) || ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) )
     102            return true;
    79103
    80         $errors = new WP_Error();
    81 
    82         $user_email = sanitize_email( $user_email );
    83 
    84         if ( empty( $user_name ) )
    85             $errors->add('user_name', __("Please enter a username"));
    86 
    87         $maybe = array();
    88         preg_match( "/[a-z0-9]+/", $user_name, $maybe );
    89 
    90         $illegal_names = get_site_option( "illegal_names" );
    91         if( is_array( $illegal_names ) == false ) {
    92             $illegal_names = array(  "www", "web", "root", "admin", "main", "invite", "administrator" );
    93             add_site_option( "illegal_names", $illegal_names );
    94         }
    95 
    96         if ( !validate_username( $user_name ) || in_array( $user_name, $illegal_names ) == true || $user_name != $maybe[0] ) {
    97             $errors->add('user_name', __("Only lowercase letters and numbers allowed"));
    98         }
    99 
    100         if( strlen( $user_name ) < 4 ) {
    101             $errors->add('user_name',  __("Username must be at least 4 characters"));
    102         }
    103 
    104         if ( strpos( " " . $user_name, "_" ) != false )
    105             $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
    106 
    107         // all numeric?
    108         $match = array();
    109         preg_match( '/[0-9]*/', $user_name, $match );
    110         if ( $match[0] == $user_name )
    111             $errors->add('user_name', __("Sorry, usernames must have letters too!"));
    112 
    113         if ( !is_email( $user_email ) )
    114             $errors->add('user_email', __("Please check your email address."));
    115 
    116         $limited_email_domains = get_site_option( 'limited_email_domains' );
    117         if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
    118             $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
    119             if( in_array( $emaildomain, $limited_email_domains ) == false ) {
    120                 $errors->add('user_email', __("Sorry, that email address is not allowed!"));
    121             }
    122         }
    123 
    124         // Check if the username has been used already.
    125         if ( username_exists($user_name) )
    126             $errors->add('user_name', __("Sorry, that username already exists!"));
    127 
    128         // Check if the email address has been used already.
    129         if ( email_exists($user_email) )
    130             $errors->add('user_email', __("Sorry, that email address is already used!"));
    131 
    132         $result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors);
    133 
    134         return apply_filters('wpmu_validate_user_signup', $result);
     104        return false;
    135105    }
    136106}
     107
     108// Deprecated - 1.2.6
     109if ( !function_exists( 'is_site_admin' ) ) {
     110    function is_site_admin( $user_id = false ) {
     111        return is_super_admin( $user_id );
     112    }
     113}
     114
    137115?>
  • trunk/bp-forums.php

    r3232 r3300  
    11<?php
     2
    23/* Define the parent forum ID */
    34if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
    45    define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
    56
     7if ( !defined( 'BP_FORUMS_SLUG' ) )
     8    define( 'BP_FORUMS_SLUG', 'forums' );
     9
    610if ( !defined( 'BB_PATH' ) )
    711    require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-bbpress.php' );
     
    1317    global $bp;
    1418
    15     if ( !defined( 'BP_FORUMS_SLUG' ) )
    16         define ( 'BP_FORUMS_SLUG', $bp->pages->forums->slug );
    17 
    1819    /* For internal identification */
    1920    $bp->forums->id = 'forums';
    20     $bp->forums->name = $bp->pages->forums->name;
    21     $bp->forums->slug = BP_FORUMS_SLUG;
    2221
    2322    $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
    2423    $bp->forums->bbconfig = $bp->site_options['bb-config-location'];
     24    $bp->forums->slug = BP_FORUMS_SLUG;
    2525
    2626    /* Register this in the active components array */
     
    4040}
    4141
     42function bp_forums_setup_root_component() {
     43    /* Register 'forums' as a root component */
     44    bp_core_add_root_component( BP_FORUMS_SLUG );
     45}
     46add_action( 'bp_setup_root_components', 'bp_forums_setup_root_component' );
     47
    4248function bp_forums_directory_forums_setup() {
    4349    global $bp;
    4450
    4551    if ( $bp->current_component == $bp->forums->slug ) {
    46         if ( (int) $bp->site_options['bp-disable-forum-directory'] || !bp_is_active( 'groups' ) )
     52        if ( (int) $bp->site_options['bp-disable-forum-directory'] || !function_exists( 'groups_install' ) )
    4753            return false;
    4854
     
    6369            if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
    6470                /* Auto join this user if they are not yet a member of this group */
    65                 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     71                if ( !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    6672                    groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
    6773
     
    7379
    7480                    bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
     81                } else {
     82                    bp_core_add_message( __( 'Please pick the group forum where you would like to post this topic.', 'buddypress' ), 'error' );
    7583                }
    7684            }
     
    8795    global $bp;
    8896
    89     if ( !is_site_admin() )
     97    if ( !is_super_admin() )
    9098        return false;
    9199
     
    119127
    120128    return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
     129}
     130
     131function bp_forums_update_forum( $args = '' ) {
     132    do_action( 'bbpress_init' );
     133
     134    $defaults = array(
     135        'forum_id'          => '',
     136        'forum_name'        => '',
     137        'forum_desc'        => '',
     138        'forum_slug'        => '',
     139        'forum_parent_id'   => BP_FORUMS_PARENT_FORUM_ID,
     140        'forum_order'       => false,
     141        'forum_is_category' => 0
     142    );
     143
     144    $r = wp_parse_args( $args, $defaults );
     145    extract( $r, EXTR_SKIP );
     146
     147    return bb_update_forum( array( 'forum_id' => (int)$forum_id, 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_slug' => stripslashes( $forum_slug ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
    121148}
    122149
     
    356383
    357384    /* Fetch fullname for the topic's last poster */
    358     if ( bp_is_active( 'xprofile' ) ) {
     385    if ( function_exists( 'xprofile_install' ) ) {
    359386        $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT t.topic_id, pd.value FROM {$bp->profile->table_name_data} pd, {$bbdb->topics} t WHERE pd.user_id = t.topic_last_poster AND pd.field_id = 1 AND t.topic_id IN ( {$topic_ids} )" ) );
    360387        for ( $i = 0; $i < count( $topics ); $i++ ) {
     
    441468        $post_position = $post->post_position;
    442469
    443     $post = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );
    444 
    445     if ( $post )
     470    $post_id = bb_insert_post( array( 'post_id' => $post_id, 'topic_id' => $topic_id, 'post_text' => stripslashes( trim( $post_text ) ), 'post_time' => $post_time, 'poster_id' => $poster_id, 'poster_ip' => $poster_ip, 'post_status' => $post_status, 'post_position' => $post_position ) );
     471
     472    if ( $post_id )
    446473        do_action( 'bp_forums_new_post', $post_id );
    447474
    448     return $post;
     475    return $post_id;
    449476}
    450477
     
    474501
    475502    /* Fetch fullname for each poster. */
    476     if ( bp_is_active( 'xprofile' ) ) {
     503    if ( function_exists( 'xprofile_install' ) ) {
    477504        $poster_names = $wpdb->get_results( $wpdb->prepare( "SELECT pd.user_id, pd.value FROM {$bp->profile->table_name_data} pd WHERE pd.user_id IN ( {$user_ids} )" ) );
    478505        for ( $i = 0; $i < count( $posts ); $i++ ) {
     
    501528    global $bp, $wp_roles, $bb_table_prefix;
    502529
    503     $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' );
     530    $bb_cap = get_user_meta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities', true );
    504531
    505532    if ( empty( $bb_cap ) )
  • trunk/bp-forums/bp-forums-admin.php

    r2665 r3300  
    122122
    123123function bp_forums_bbpress_install() {
    124     global $wpdb, $bbdb;
     124    global $wpdb, $bbdb, $bp;
    125125
    126126    check_admin_referer( 'bp_forums_new_install_init' );
     
    141141            "define( 'BB_LOGGED_I"          => array( "'put your unique phrase here'",  "'" . addslashes( LOGGED_IN_KEY ) . "'" ),
    142142            "define( 'BB_NONCE_KE"          => array( "'put your unique phrase here'",  "'" . addslashes( NONCE_KEY ) . "'" ),
    143             "\$bb_table_prefix = '"         => array( "'bb_'",                          "'" . $wpdb->base_prefix . "bb_'" ),
     143            "\$bb_table_prefix = '"         => array( "'bb_'",                          "'" . $bp->table_prefix . "bb_'" ),
    144144            "define( 'BB_LANG', '"          => array( "''",                             "'" . WPLANG . "'" )
    145145        )
     
    154154
    155155    $file = substr( $file, 0, -2 );
    156     $file .= "\n" .   '$bb->custom_user_table = "' . $wpdb->users . '";';
    157     $file .= "\n" .   '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";';
    158     $file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";';
    159     $file .= "\n" .   '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";';
     156    $file .= "\n" .   '$bb->custom_user_table = \'' . $wpdb->users . '\';';
     157    $file .= "\n" .   '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';';
     158    $file .= "\n\n" . '$bb->uri = \'' . BP_PLUGIN_URL . '/bp-forums/bbpress/\';';
     159    $file .= "\n" .   '$bb->name = \'' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '\';';
    160160
    161161    if ( bp_core_is_multisite() )
     
    163163
    164164    if ( defined( 'AUTH_SALT' ) )
    165         $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . addslashes( AUTH_SALT ) . '");';
     165        $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes( AUTH_SALT ) . '\');';
    166166
    167167    if ( defined( 'LOGGED_IN_SALT' ) )
    168         $file .= "\n" .   'define(\'BB_LOGGED_IN_SALT\', "' . addslashes( LOGGED_IN_SALT ) . '");';
     168        $file .= "\n" .   'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes( LOGGED_IN_SALT ) . '\');';
    169169
    170170    if ( defined( 'SECURE_AUTH_SALT' ) )
    171         $file .= "\n" .   'define(\'BB_SECURE_AUTH_SALT\', "' . addslashes( SECURE_AUTH_SALT ) . '");';
     171        $file .= "\n" .   'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes( SECURE_AUTH_SALT ) . '\');';
    172172
    173173    $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
  • trunk/bp-forums/bp-forums-bbpress.php

    r2209 r3300  
    6666    /* This must be loaded before functionss.bb-admin.php otherwise we get a function conflict. */
    6767    if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )
    68         require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
     68        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    6969
    7070    require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
    7171
    7272    if ( is_object( $wp_roles ) ) {
    73         $bb_roles =& $wp_roles;
     73        $bb_roles = $wp_roles;
    7474        bb_init_roles( $bb_roles );
    7575    }
     
    104104        $site_admins = get_site_option( 'site_admins', array('admin') );
    105105        foreach ( (array)$site_admins as $site_admin )
    106             update_usermeta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) );
     106            update_user_meta( bp_core_get_userid( $site_admin ), $bb_table_prefix . 'capabilities', array( 'keymaster' => true ) );
    107107
    108108        // Create the first forum.
     
    131131        extract( $args, EXTR_SKIP );
    132132
    133         return update_usermeta( $id, $meta_key, $meta_value );
     133        return update_user_meta( $id, $meta_key, $meta_value );
    134134    }
    135135}
  • trunk/bp-forums/bp-forums-filters.php

    r2770 r3300  
    33/* Apply WordPress defined filters */
    44add_filter( 'bp_forums_bbconfig_location', 'wp_filter_kses', 1 );
    5 add_filter( 'bp_forums_bbconfig_location', 'attribute_escape', 1 );
     5add_filter( 'bp_forums_bbconfig_location', 'esc_attr', 1 );
    66
    77add_filter( 'bp_get_the_topic_title', 'wp_filter_kses', 1 );
    88add_filter( 'bp_get_the_topic_latest_post_excerpt', 'bp_forums_filter_kses', 1 );
    99add_filter( 'bp_get_the_topic_post_content', 'bp_forums_filter_kses', 1 );
     10
     11add_filter( 'bp_get_the_topic_title', 'force_balance_tags' );
     12add_filter( 'bp_get_the_topic_latest_post_excerpt', 'force_balance_tags' );
     13add_filter( 'bp_get_the_topic_post_content', 'force_balance_tags' );
    1014
    1115add_filter( 'bp_get_the_topic_title', 'wptexturize' );
     
    3135add_filter( 'bp_get_the_topic_poster_name', 'stripslashes_deep' );
    3236add_filter( 'bp_get_the_topic_last_poster_name', 'stripslashes_deep' );
     37add_filter( 'bp_get_the_topic_object_name', 'stripslashes_deep' );
    3338
    3439add_filter( 'bp_get_the_topic_post_content', 'make_clickable' );
     
    8489    }
    8590
     91/**
     92 * bp_forums_add_forum_topic_to_page_title( $title )
     93 *
     94 * Append forum topic to page title
     95 *
     96 * @global object $bp
     97 * @param string $title
     98 * @return string
     99 */
     100function bp_forums_add_forum_topic_to_page_title( $title ) {
     101    global $bp;
     102
     103    if ( $bp->current_action == 'forum' && $bp->action_variables[0] == 'topic' ) {
     104        if ( bp_has_forum_topic_posts() ) {
     105            $title .= ' &#124; ' . bp_get_the_topic_title();
     106        }
     107    }
     108
     109    return $title;
     110}
     111add_filter( 'bp_page_title', 'bp_forums_add_forum_topic_to_page_title' );
     112
    86113?>
  • trunk/bp-forums/bp-forums-templatetags.php

    r3247 r3300  
    77    var $topic;
    88
     9    var $forum_id;
     10
    911    var $in_the_loop;
    1012
     
    2628        $this->type         = $type;
    2729        $this->search_terms = $search_terms;
     30        $this->forum_id     = $forum_id;
    2831
    2932        switch ( $type ) {
     
    4851
    4952        if ( !(int)$this->topics ) {
    50             $this->topic_count = 0;
     53            $this->topic_count       = 0;
    5154            $this->total_topic_count = 0;
    5255        } else {
     
    6063            }
    6164
    62             if ( !$max || $max >= $topic_count )
     65            if ( !$max || $max >= $topic_count ) {
    6366                $this->total_topic_count = $topic_count;
    64             else
     67            } else {
    6568                $this->total_topic_count = (int)$max;
     69            }
    6670
    6771            if ( $max ) {
    68                 if ( $max >= count( $this->topics ) ) {
     72                if ( $max >= count($this->topics) ) {
    6973                    $this->topic_count = count( $this->topics );
    7074                } else {
     
    99103                'base'      => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ),
    100104                'format'    => '',
    101                 'total'     => ceil( (int)$this->total_topic_count / (int)$this->pag_num ),
     105                'total'     => ceil( (int)$this->total_topic_count / (int)$this->pag_num),
    102106                'current'   => $this->pag_page,
    103107                'prev_text' => '&larr;',
     
    259263
    260264        $post = bb_get_first_post( (int)$forum_template->topic->topic_id, false );
    261         return apply_filters( 'bp_get_the_topic_text', attribute_escape( $post->post_text ) );
     265        return apply_filters( 'bp_get_the_topic_text', esc_attr( $post->post_text ) );
    262266    }
    263267
     
    295299        global $forum_template;
    296300
    297         if ( !$name = bp_core_get_userlink( $forum_template->topic->poster_id ) )
     301        $poster_id = ( empty( $forum_template->topic->poster_id ) ) ? $forum_template->topic->topic_poster : $forum_template->topic->poster_id;
     302
     303        if ( !$name = bp_core_get_userlink( $poster_id ) )
    298304            return __( 'Deleted User', 'buddypress' );
    299305
     
    467473        global $forum_template;
    468474
    469         return $forum_template->topic->topic_posts;
     475        return apply_filters( 'bp_get_the_topic_total_posts', $forum_template->topic->topic_posts );
    470476    }
    471477
     
    557563        $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit Topic', 'buddypress' ) . '</a>';
    558564
    559         if ( $bp->is_item_admin || $bp->is_item_mod || is_site_admin() ) {
     565        if ( $bp->is_item_admin || $bp->is_item_mod || is_super_admin() ) {
    560566            if ( 0 == (int)$forum_template->topic->topic_sticky )
    561567                $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'stick', 'bp_forums_stick_topic' ) . '">' . __( 'Sticky Topic', 'buddypress' ) . '</a>';
     
    592598            $class .= ' closed';
    593599
    594         return trim( $class );
     600        return apply_filters( 'bp_get_the_topic_css_class', trim( $class ) );
    595601    }
    596602
     
    670676        global $bp, $forum_template;
    671677
    672         $from_num = bp_core_number_format( intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1 );
    673         $to_num = bp_core_number_format( ( $from_num + ( $forum_template->pag_num - 1  ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 ) );
     678        $start_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1;
     679        $from_num = bp_core_number_format( $start_num );
     680        $to_num = bp_core_number_format( ( $start_num + ( $forum_template->pag_num - 1  ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $start_num + ( $forum_template->pag_num - 1 ) );
    674681        $total = bp_core_number_format( $forum_template->total_topic_count );
    675682
     
    678685            $pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms );
    679686
    680         return apply_filters( 'bp_get_forum_pagination_count', sprintf( __( 'Viewing topic %s to %s (of %s total topics%s)', 'buddypress' ), $from_num, $to_num, $total, $pag_filter ) );
     687        return apply_filters( 'bp_get_forum_pagination_count', sprintf( __( 'Viewing topic %s to %s (of %s total topics%s)', 'buddypress' ), $from_num, $to_num, $total, $pag_filter ) . '<span class="ajax-loader"></span>' );
    681688    }
    682689
     
    697704    var $post;
    698705
     706    var $forum_id;
    699707    var $topic_id;
    700708    var $topic;
     
    712720    var $order;
    713721
    714     function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {
     722    function BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order ) {
    715723        global $bp, $current_user, $forum_template;
    716724
     
    721729        $this->topic_id        = $topic_id;
    722730        $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
     731        $this->forum_id        = $forum_template->topic->forum_id;
    723732
    724733        $this->posts           = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'order' => $this->order ) );
    725734
    726735        if ( !$this->posts ) {
    727             $this->post_count = 0;
     736            $this->post_count       = 0;
    728737            $this->total_post_count = 0;
    729738        } else {
    730             if ( !$max || $max >= (int) $forum_template->topic->topic_posts ) {
    731                 $this->total_post_count = (int) $forum_template->topic->topic_posts;
     739            if ( !$max || $max >= (int)$forum_template->topic->topic_posts ) {
     740                $this->total_post_count = (int)$forum_template->topic->topic_posts;
    732741            } else {
    733742                $this->total_post_count = (int)$max;
     
    814823        'topic_id' => false,
    815824        'per_page' => 15,
    816         'max' => false
     825        'max'      => false,
     826        'order'    => 'ASC'
    817827    );
    818828
     
    823833        $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[1] );
    824834
    825     if ( is_numeric( $topic_id ) )
    826         $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max );
    827     else
     835    if ( is_numeric( $topic_id ) ) {
     836        $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order );
     837
     838        // Current topic forum_id needs to match current_group forum_id
     839        if ( $bp->current_component == $bp->groups->slug && $topic_template->forum_id != groups_get_groupmeta( $bp->groups->current_group->id, 'forum_id' ) )
     840            return false;
     841
     842    } else {
    828843        return false;
     844    }
    829845
    830846    return apply_filters( 'bp_has_topic_posts', $topic_template->has_posts(), &$topic_template );
     
    857873
    858874        return apply_filters( 'bp_get_the_topic_post_content', stripslashes( $topic_template->post->post_text ) );
     875    }
     876
     877function bp_the_topic_post_css_class() {
     878    echo bp_get_the_topic_post_css_class();
     879}
     880
     881    function bp_get_the_topic_post_css_class() {
     882        global $topic_template;
     883
     884        $class = false;
     885
     886        if ( $topic_template->current_post % 2 == 1 )
     887            $class .= 'alt';
     888
     889        if ( 1 == (int)$topic_template->post->post_status )
     890            $class .= ' deleted';
     891
     892        if ( 0 == (int)$topic_template->post->post_status )
     893            $class .= ' open';
     894
     895        return apply_filters( 'bp_get_the_topic_post_css_class', trim( $class ) );
    859896    }
    860897
     
    936973            $query_vars = '?' . $_SERVER['QUERY_STRING'];
    937974
    938         $links  = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . $topic_template->post->id . 'edit/post/' . $topic_template->post->post_id . '/' . $query_vars, 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' ';
     975        $links  = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit/post/' . $topic_template->post->post_id . '/' . $query_vars, 'bp_forums_edit_post' ) . '">' . __( 'Edit', 'buddypress' ) . '</a> ' . $seperator . ' ';
    939976        $links .= '<a class="confirm" id="post-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete/post/' . $topic_template->post->post_id, 'bp_forums_delete_post' ) . '">' . __( 'Delete', 'buddypress' ) . '</a> | ';
    940977
     
    949986
    950987        $post = bp_forums_get_post( $bp->action_variables[4] );
    951         return apply_filters( 'bp_get_the_topic_post_edit_text', attribute_escape( $post->post_text ) );
     988        return apply_filters( 'bp_get_the_topic_post_edit_text', esc_attr( $post->post_text ) );
    952989    }
    953990
     
    9641001    global $bp, $topic_template;
    9651002
    966     $from_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1;
    967     $to_num = ( $from_num + ( $topic_template->pag_num - 1  ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $from_num + ( $topic_template->pag_num - 1 );
    968 
    969     echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $topic_template->total_post_count ) );
     1003    $start_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1;
     1004    $from_num = bp_core_number_format( $start_num );
     1005    $to_num = bp_core_number_format( ( $start_num + ( $topic_template->pag_num - 1  ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $start_num + ( $topic_template->pag_num - 1 ) );
     1006    $total = bp_core_number_format( $topic_template->total_post_count );
     1007
     1008    echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %1$s to %2$s (%3$s total posts)', 'buddypress' ), $from_num, $to_num, $total ) );
    9701009?>
    9711010    <span class="ajax-loader"></span>
     
    9911030?>
    9921031    <form action="" method="get" id="search-forums-form">
    993         <label><input type="text" name="s" id="forums_search" value="<?php echo attribute_escape($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
     1032        <label><input type="text" name="s" id="forums_search" value="<?php echo esc_attr($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
    9941033        <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    9951034    </form>
     
    10391078        global $topic_template;
    10401079
    1041         return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
     1080        return apply_filters( 'bp_get_forum_action', $bp->root_domain . esc_attr( $_SERVER['REQUEST_URI'] ) );
    10421081    }
    10431082
     
    10481087        global $bp;
    10491088
    1050         return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
     1089        return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . esc_attr( $_SERVER['REQUEST_URI'] ) );
    10511090    }
    10521091
  • trunk/bp-friends.php

    r3232 r3300  
    11<?php
     2
     3define ( 'BP_FRIENDS_DB_VERSION', '1800' );
     4
     5/* Define the slug for the component */
     6if ( !defined( 'BP_FRIENDS_SLUG' ) )
     7    define ( 'BP_FRIENDS_SLUG', 'friends' );
     8
    29require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-classes.php' );
    310require ( BP_PLUGIN_DIR . '/bp-friends/bp-friends-templatetags.php' );
    411
    512function friends_setup_globals() {
    6     global $bp, $wpdb;
    7 
    8     if ( !defined( 'BP_FRIENDS_SLUG' ) )
    9         define( 'BP_FRIENDS_SLUG', 'friends' );
     13    global $bp;
    1014
    1115    /* For internal identification */
    1216    $bp->friends->id = 'friends';
    1317
    14     $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
     18    $bp->friends->slug = BP_FRIENDS_SLUG;
     19
     20    $bp->friends->table_name = $bp->table_prefix . 'bp_friends';
     21
    1522    $bp->friends->format_notification_function = 'friends_format_notifications';
    16     $bp->friends->slug = BP_FRIENDS_SLUG;
    1723
    1824    /* Register this in the active components array */
     
    103109function friends_screen_notification_settings() {
    104110    global $current_user; ?>
    105     <table class="notification-settings" id="friends-notification-settings">
    106         <tr>
    107             <th class="icon"></th>
    108             <th class="title"><?php _e( 'Friends', 'buddypress' ) ?></th>
    109             <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    110             <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    111         </tr>
    112         <tr>
    113             <td></td>
    114             <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td>
    115             <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_request') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_request') ) { ?>checked="checked" <?php } ?>/></td>
    116             <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_usermeta( $current_user->id,'notification_friends_friendship_request') == 'no' ) { ?>checked="checked" <?php } ?>/></td>
    117         </tr>
    118         <tr>
    119             <td></td>
    120             <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td>
    121             <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_usermeta( $current_user->id,'notification_friends_friendship_accepted') || 'yes' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
    122             <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id,'notification_friends_friendship_accepted') ) { ?>checked="checked" <?php } ?>/></td>
    123         </tr>
    124 
    125         <?php do_action( 'friends_screen_notification_settings' ); ?>
     111    <table class="notification-settings zebra" id="friends-notification-settings">
     112        <thead>
     113            <tr>
     114                <th class="icon"></th>
     115                <th class="title"><?php _e( 'Friends', 'buddypress' ) ?></th>
     116                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     117                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     118            </tr>
     119        </thead>
     120
     121        <tbody>
     122            <tr>
     123                <td></td>
     124                <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td>
     125                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) ) { ?>checked="checked" <?php } ?>/></td>
     126                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_user_meta( $current_user->id, 'notification_friends_friendship_request', true ) == 'no' ) { ?>checked="checked" <?php } ?>/></td>
     127            </tr>
     128            <tr>
     129                <td></td>
     130                <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td>
     131                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td>
     132                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td>
     133            </tr>
     134
     135            <?php do_action( 'friends_screen_notification_settings' ); ?>
     136        </tbody>
    126137    </table>
    127138<?php
     
    237248        'item_id' => false,
    238249        'secondary_item_id' => false,
    239         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     250        'recorded_time' => bp_core_current_time(),
    240251        'hide_sitewide' => false
    241252    );
     
    318329    $friendship->is_confirmed = 0;
    319330    $friendship->is_limited = 0;
    320     $friendship->date_created = time();
     331    $friendship->date_created = bp_core_current_time();
    321332
    322333    if ( $force_accept )
     
    372383        friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    373384
    374         /* Remove the friend request notice */
     385        // Remove the friend request notice
    375386        bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    376387
    377         /* Add a friend accepted notice for the initiating user */
     388        // Add a friend accepted notice for the initiating user
    378389        bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
    379390
     
    381392        $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
    382393
    383         /* Record in activity streams for the initiator */
     394        // Record in activity streams for the initiator
    384395        friends_record_activity( array(
    385             'user_id' => $friendship->initiator_user_id,
    386             'type' => 'friendship_created',
    387             'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
    388             'item_id' => $friendship_id
     396            'user_id'           => $friendship->initiator_user_id,
     397            'type'              => 'friendship_created',
     398            'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
     399            'item_id'           => $friendship_id,
     400            'secondary_item_id' => $friendship->friend_user_id
    389401        ) );
    390402
    391         /* Record in activity streams for the friend */
     403        // Record in activity streams for the friend
    392404        friends_record_activity( array(
    393             'user_id' => $friendship->friend_user_id,
    394             'type' => 'friendship_created',
    395             'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
    396             'item_id' => $friendship_id,
    397             'hide_sitewide' => true /* We've already got the first entry site wide */
     405            'user_id'           => $friendship->friend_user_id,
     406            'type'              => 'friendship_created',
     407            'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%1$s and %2$s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
     408            'item_id'           => $friendship_id,
     409            'secondary_item_id' => $friendship->initiator_user_id,
     410            'hide_sitewide'     => true // We've already got the first entry site wide
    398411        ) );
    399412
    400         /* Send the email notification */
     413        // Send the email notification
    401414        require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
    402415        friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
     
    444457
    445458    if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
    446         $count = get_usermeta( $user_id, 'total_friend_count' );
     459        $count = get_user_meta( $user_id, 'total_friend_count', true );
    447460        if ( empty( $count ) ) $count = 0;
    448461        wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' );
     
    547560function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
    548561    if ( 'add' == $status ) {
    549         update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) + 1 );
    550         update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) + 1 );
     562        update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) + 1 );
     563        update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) + 1 );
    551564    } else {
    552         update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 );
    553         update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );
     565        update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) - 1 );
     566        update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) - 1 );
    554567    }
    555568}
     
    559572
    560573    /* Remove usermeta */
    561     delete_usermeta( $user_id, 'total_friend_count' );
     574    delete_user_meta( $user_id, 'total_friend_count' );
    562575
    563576    /* Remove friendship requests FROM user */
     
    566579    do_action( 'friends_remove_data', $user_id );
    567580}
    568 add_action( 'wpmu_delete_user', 'friends_remove_data', 1 );
    569 add_action( 'delete_user', 'friends_remove_data', 1 );
    570 add_action( 'make_spam_user', 'friends_remove_data', 1 );
     581add_action( 'wpmu_delete_user', 'friends_remove_data' );
     582add_action( 'delete_user', 'friends_remove_data' );
     583add_action( 'make_spam_user', 'friends_remove_data' );
    571584
    572585
     
    595608    global $bp;
    596609
    597     if ( isset($_GET['new']) )
    598         bp_core_delete_notifications_for_user_by_type( $bp->displayed_user->id, $bp->friends->id, 'friendship_accepted' );
     610    if ( isset( $_GET['new'] ) )
     611        bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->friends->id, 'friendship_accepted' );
    599612}
    600613add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );
  • trunk/bp-friends/bp-friends-classes.php

    r2919 r3300  
    6161        if ( $this->id ) {
    6262            // Update
    63             $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = FROM_UNIXTIME(%d) ) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );
     63            $result = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET initiator_user_id = %d, friend_user_id = %d, is_confirmed = %d, is_limited = %d, date_created = %s ) WHERE id = %d", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created, $this->id ) );
    6464        } else {
    6565            // Save
    66             $result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->friends->table_name} ( initiator_user_id, friend_user_id, is_confirmed, is_limited, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created ) );
     66            $result = $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->friends->table_name} ( initiator_user_id, friend_user_id, is_confirmed, is_limited, date_created ) VALUES ( %d, %d, %d, %d, %s )", $this->initiator_user_id, $this->friend_user_id, $this->is_confirmed, $this->is_limited, $this->date_created ) );
    6767            $this->id = $wpdb->insert_id;
    6868        }
     
    127127        $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) AND is_confirmed = 1", $user_id, $user_id ) );
    128128
    129         if ( !$count )
     129        // Do not update meta if user has never had friends
     130        if ( !$count && !get_user_meta( $user_id, 'total_friend_count', true ) )
    130131            return 0;
    131132
    132         update_usermeta( $user_id, 'total_friend_count', $count );
    133         return $count;
     133        update_user_meta( $user_id, 'total_friend_count', (int)$count );
     134        return (int)$count;
    134135    }
    135136
     
    202203        global $wpdb, $bp;
    203204
    204         return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = FROM_UNIXTIME(%d) WHERE id = %d AND friend_user_id = %d", time(), $friendship_id, $bp->loggedin_user->id ) );
     205        return $wpdb->query( $wpdb->prepare( "UPDATE {$bp->friends->table_name} SET is_confirmed = 1, date_created = %s WHERE id = %d AND friend_user_id = %d", bp_core_current_time(), $friendship_id, $bp->loggedin_user->id ) );
    205206    }
    206207
     
    315316        global $wpdb, $bp;
    316317
     318        // Get friends of $user_id
     319        $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
     320
     321        // Delete all friendships related to $user_id
    317322        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) );
    318323
    319324        // Delete friend request notifications for members who have a notification from this user.
    320325        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) );
     326
     327        // Loop through friend_ids and update their counts
     328        foreach ( (array)$friend_ids as $friend_id ) {
     329            BP_Friends_Friendship::total_friend_count( $friend_id );
     330        }
    321331    }
    322332}
  • trunk/bp-friends/bp-friends-notifications.php

    r2941 r3300  
    66    $initiator_name = bp_core_get_user_displayname( $initiator_id );
    77
    8     if ( 'no' == get_usermeta( (int)$friend_id, 'notification_friends_friendship_request' ) )
     8    if ( 'no' == get_user_meta( (int)$friend_id, 'notification_friends_friendship_request', true ) )
    99        return false;
    1010
     
    1818
    1919    // Set up and send the message
    20     $to = $ud->user_email;
    21     $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name );
     20    $to       = $ud->user_email;
     21    $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     22    $subject  = '[' . $sitename . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name );
    2223
    2324    $message = sprintf( __(
     
    4849    $friend_name = bp_core_get_user_displayname( $friend_id );
    4950
    50     if ( 'no' == get_usermeta( (int)$initiator_id, 'notification_friends_friendship_accepted' ) )
     51    if ( 'no' == get_user_meta( (int)$initiator_id, 'notification_friends_friendship_accepted', true ) )
    5152        return false;
    5253
     
    5758
    5859    // Set up and send the message
    59     $to = $ud->user_email;
    60     $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );
     60    $to       = $ud->user_email;
     61    $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     62    $subject  = '[' . $sitename . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );
    6163
    6264    $message = sprintf( __(
  • trunk/bp-friends/bp-friends-templatetags.php

    r3263 r3300  
    105105        <form action="<?php echo $action ?>" id="friend-search-form" method="post">
    106106
    107         <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>
    108         <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
    109 
    110         <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
    111         <input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" />
     107            <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>
     108            <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
     109
     110            <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
     111            <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( $bp->displayed_user->id ) ?>" />
    112112
    113113        </form>
  • trunk/bp-groups.php

    r3273 r3300  
    1616    $bp->groups->slug = BP_GROUPS_SLUG;
    1717
    18     $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
    19     $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members';
    20     $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
     18    $bp->groups->table_name           = $bp->table_prefix . 'bp_groups';
     19    $bp->groups->table_name_members   = $bp->table_prefix . 'bp_groups_members';
     20    $bp->groups->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta';
     21
    2122    $bp->groups->format_notification_function = 'groups_format_notifications';
    2223
     
    3738    $bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) );
    3839
     40    // Auto join group when non group member performs group activity
     41    $bp->groups->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) ? false : true;
     42
    3943    do_action( 'groups_setup_globals' );
    4044}
     
    4448    global $bp;
    4549
    46     if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
     50    if ( $bp->current_component == $bp->groups->slug && $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
    4751
    4852        /* This is a single group page. */
     
    5155
    5256        /* Using "item" not "group" for generic support in other components. */
    53         if ( is_site_admin() )
     57        if ( is_super_admin() )
    5458            $bp->is_item_admin = 1;
    5559        else
     
    100104
    101105            if ( !$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) )
    102                 $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />';
     106                $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
    103107
    104108            $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
     
    106110            // If this is a private or hidden group, does the user have access?
    107111            if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
    108                 if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_site_admin() )
     112                if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_super_admin() )
    109113                    $bp->groups->current_group->user_has_access = true;
    110114                else
     
    128132
    129133            // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    130             if ( !is_site_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )
     134            if ( !is_super_admin() && is_user_logged_in() && !$bp->groups->current_group->is_user_member && !groups_check_for_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) && $bp->groups->current_group->status == 'private' )
    131135                bp_core_new_subnav_item( array( 'name' => __( 'Request Membership', 'buddypress' ), 'slug' => 'request-membership', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_request_membership', 'position' => 30 ) );
    132136
     
    166170
    167171    /* Don't show this menu to non site admins or if you're viewing your own profile */
    168     if ( !is_site_admin() )
     172    if ( !is_super_admin() )
    169173        return false;
    170174    ?>
     
    226230
    227231            groups_record_activity( array(
    228                 'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
     232                'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ),
    229233                'type' => 'joined_group',
    230234                'item_id' => $group->id
     
    292296
    293297                /* Auto join this user if they are not yet a member of this group */
    294                 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     298                if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    295299                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    296300
     
    470474
    471475                /* Auto join this user if they are not yet a member of this group */
    472                 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     476                if ( $bp->groups->auto_join && !is_super_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    473477                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    474478
     
    492496
    493497    if ( $bp->is_single_item ) {
     498        /* Refresh the group member count meta */
     499        groups_update_groupmeta( $bp->groups->current_group->id, 'total_member_count', groups_get_total_member_count( $bp->groups->current_group->id ) );
     500
    494501        do_action( 'groups_screen_group_members', $bp->groups->current_group->id );
    495502        bp_core_load_template( apply_filters( 'groups_template_group_members', 'groups/single/home' ) );
     
    711718            $status = $bp->action_variables[2];
    712719
    713             /* Check the nonce first. */
     720            // Check the nonce first.
    714721            if ( !check_admin_referer( 'groups_promote_member' ) )
    715722                return false;
    716723
    717724            // Promote a user.
    718             if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) {
     725            if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) )
    719726                bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' );
    720             } else {
     727            else
    721728                bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
    722             }
    723729
    724730            do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
     
    730736            $user_id = $bp->action_variables[2];
    731737
    732             /* Check the nonce first. */
     738            // Check the nonce first.
    733739            if ( !check_admin_referer( 'groups_demote_member' ) )
    734740                return false;
    735741
    736742            // Demote a user.
    737             if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) {
     743            if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
    738744                bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' );
    739             } else {
     745            else
    740746                bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
    741             }
    742747
    743748            do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id );
     
    749754            $user_id = $bp->action_variables[2];
    750755
    751             /* Check the nonce first. */
     756            // Check the nonce first.
    752757            if ( !check_admin_referer( 'groups_ban_member' ) )
    753758                return false;
    754759
    755760            // Ban a user.
    756             if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) {
     761            if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
    757762                bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' );
    758             } else {
     763            else
    759764                bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
    760             }
    761765
    762766            do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id );
     
    768772            $user_id = $bp->action_variables[2];
    769773
    770             /* Check the nonce first. */
     774            // Check the nonce first.
    771775            if ( !check_admin_referer( 'groups_unban_member' ) )
    772776                return false;
    773777
    774778            // Remove a ban for user.
    775             if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) {
     779            if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) )
    776780                bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' );
    777             } else {
     781            else
    778782                bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) );
    779             }
    780783
    781784            do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id );
     
    784787        }
    785788
     789        if ( 'remove' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
     790            $user_id = $bp->action_variables[2];
     791
     792            // Check the nonce first.
     793            if ( !check_admin_referer( 'groups_remove_member' ) )
     794                return false;
     795
     796            // Remove a user.
     797            if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
     798                bp_core_add_message( __( 'There was an error removing that user from the group, please try again', 'buddypress' ), 'error' );
     799            else
     800                bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
     801
     802            do_action( 'groups_removed_member', $user_id, $bp->groups->current_group->id );
     803
     804            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
     805        }
     806
    786807        do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id );
    787808
     
    795816
    796817    if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
     818
     819        /* Ask for a login if the user is coming here via an email notification */
     820        if ( !is_user_logged_in() )
     821            bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) );
    797822
    798823        if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status )
     
    850875    if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
    851876
    852         if ( !$bp->is_item_admin && !is_site_admin() )
     877        if ( !$bp->is_item_admin && !is_super_admin() )
    853878            return false;
    854879
     
    881906function groups_screen_notification_settings() {
    882907    global $current_user; ?>
    883     <table class="notification-settings" id="groups-notification-settings">
    884         <tr>
    885             <th class="icon"></th>
    886             <th class="title"><?php _e( 'Groups', 'buddypress' ) ?></th>
    887             <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    888             <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    889         </tr>
    890         <tr>
    891             <td></td>
    892             <td><?php _e( 'A member invites you to join a group', 'buddypress' ) ?></td>
    893             <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_invite') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_invite') ) { ?>checked="checked" <?php } ?>/></td>
    894             <td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_invite') ) { ?>checked="checked" <?php } ?>/></td>
    895         </tr>
    896         <tr>
    897             <td></td>
    898             <td><?php _e( 'Group information is updated', 'buddypress' ) ?></td>
    899             <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_group_updated') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
    900             <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_group_updated') ) { ?>checked="checked" <?php } ?>/></td>
    901         </tr>
    902         <tr>
    903             <td></td>
    904             <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
    905             <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_admin_promotion') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td>
    906             <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_admin_promotion') ) { ?>checked="checked" <?php } ?>/></td>
    907         </tr>
    908         <tr>
    909             <td></td>
    910             <td><?php _e( 'A member requests to join a private group for which you are an admin', 'buddypress' ) ?></td>
    911             <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_groups_membership_request') || 'yes' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
    912             <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_groups_membership_request') ) { ?>checked="checked" <?php } ?>/></td>
    913         </tr>
    914 
    915         <?php do_action( 'groups_screen_notification_settings' ); ?>
     908    <table class="notification-settings zebra" id="groups-notification-settings">
     909        <thead>
     910            <tr>
     911                <th class="icon"></th>
     912                <th class="title"><?php _e( 'Groups', 'buddypress' ) ?></th>
     913                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     914                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     915            </tr>
     916        </thead>
     917
     918        <tbody>
     919            <tr>
     920                <td></td>
     921                <td><?php _e( 'A member invites you to join a group', 'buddypress' ) ?></td>
     922                <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_invite', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_invite', true ) ) { ?>checked="checked" <?php } ?>/></td>
     923                <td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_invite', true ) ) { ?>checked="checked" <?php } ?>/></td>
     924            </tr>
     925            <tr>
     926                <td></td>
     927                <td><?php _e( 'Group information is updated', 'buddypress' ) ?></td>
     928                <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_group_updated', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_group_updated', true ) ) { ?>checked="checked" <?php } ?>/></td>
     929                <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_group_updated', true ) ) { ?>checked="checked" <?php } ?>/></td>
     930            </tr>
     931            <tr>
     932                <td></td>
     933                <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
     934                <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_admin_promotion', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_admin_promotion', true ) ) { ?>checked="checked" <?php } ?>/></td>
     935                <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_admin_promotion', true ) ) { ?>checked="checked" <?php } ?>/></td>
     936            </tr>
     937            <tr>
     938                <td></td>
     939                <td><?php _e( 'A member requests to join a private group for which you are an admin', 'buddypress' ) ?></td>
     940                <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_groups_membership_request', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_groups_membership_request', true ) ) { ?>checked="checked" <?php } ?>/></td>
     941                <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_groups_membership_request', true ) ) { ?>checked="checked" <?php } ?>/></td>
     942            </tr>
     943
     944            <?php do_action( 'groups_screen_notification_settings' ); ?>
     945        </tbody>
    916946    </table>
    917947<?php
     
    9821012            }
    9831013
    984             if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title($_POST['group-name']) ), 'date_created' => gmdate( "Y-m-d H:i:s" ), 'status' => 'public' ) ) ) {
     1014            if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'slug' => groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' => gmdate( "Y-m-d H:i:s" ), 'status' => 'public' ) ) ) {
    9851015                bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
    9861016                bp_core_redirect( $bp->root_domain . '/' . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step . '/' );
     
    10411071            /* Once we compelete all steps, record the group creation in the activity stream. */
    10421072            groups_record_activity( array(
    1043                 'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%1$s created the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
     1073                'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%1$s created the group %2$s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ) ),
    10441074                'type' => 'created_group',
    10451075                'item_id' => $bp->groups->new_group_id
     
    11051135        return false;
    11061136
    1107     // user wants to join a group
     1137    // Nonce check
     1138    if ( !check_admin_referer( 'groups_join_group' ) )
     1139        return false;
     1140
     1141    // Skip if banned or already a member
    11081142    if ( !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    1109         if ( !groups_join_group($bp->groups->current_group->id) ) {
    1110             bp_core_add_message( __('There was an error joining the group.', 'buddypress'), 'error' );
     1143
     1144        // User wants to join a group that is not public
     1145        if ( $bp->groups->current_group->status != 'public' ) {
     1146            if ( !groups_check_user_has_invite( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     1147                bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' );
     1148                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     1149            }
     1150        }
     1151
     1152        // User wants to join any group
     1153        if ( !groups_join_group( $bp->groups->current_group->id ) )
     1154            bp_core_add_message( __( 'There was an error joining the group.', 'buddypress' ), 'error' );
     1155        else
     1156            bp_core_add_message( __( 'You joined the group!', 'buddypress' ) );
     1157
     1158        bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     1159    }
     1160
     1161    bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
     1162}
     1163add_action( 'wp', 'groups_action_join_group', 3 );
     1164
     1165
     1166function groups_action_leave_group() {
     1167    global $bp;
     1168
     1169    if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'leave-group' )
     1170        return false;
     1171
     1172    // Nonce check
     1173    if ( !check_admin_referer( 'groups_leave_group' ) )
     1174        return false;
     1175
     1176    // User wants to leave any group
     1177    if ( groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     1178        if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
     1179            bp_core_add_message( __( 'There was an error leaving the group.', 'buddypress' ), 'error' );
    11111180        } else {
    1112             bp_core_add_message( __('You joined the group!', 'buddypress') );
     1181            bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) );
    11131182        }
    11141183        bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     
    11171186    bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
    11181187}
    1119 add_action( 'wp', 'groups_action_join_group', 3 );
     1188add_action( 'wp', 'groups_action_leave_group', 3 );
     1189
    11201190
    11211191function groups_action_sort_creation_steps() {
     
    12181288        'item_id' => false,
    12191289        'secondary_item_id' => false,
    1220         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     1290        'recorded_time' => bp_core_current_time(),
    12211291        'hide_sitewide' => $hide_sitewide
    12221292    );
     
    12501320
    12511321            if ( (int)$total_items > 1 ) {
    1252                 return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/?n=1" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );
     1322                return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/?n=1" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );
    12531323            } else {
    12541324                $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
    1255                 return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . $user_fullname .' requests group membership">' . sprintf( __('%1$s requests membership for the group "%2$s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
     1325                return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . sprintf( __( '%1$s requests membership for the group "%2$s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
    12561326            }
    12571327        break;
     
    12631333            $group_link = bp_get_group_permalink( $group );
    12641334
    1265             if ( (int)$total_items > 1 ) {
    1266                 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );
    1267             } else {
    1268                 return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name );
    1269             }
     1335            if ( (int)$total_items > 1 )
     1336                return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );
     1337            else
     1338                return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
     1339
    12701340        break;
    12711341
     
    12761346            $group_link = bp_get_group_permalink( $group );
    12771347
    1278             if ( (int)$total_items > 1 ) {
    1279                 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . $bp->members->slug . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
    1280             } else {
    1281                 return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
    1282             }
     1348            if ( (int)$total_items > 1 )
     1349                return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . $bp->members->slug . '/' . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
     1350            else
     1351                return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
    12831352
    12841353        break;
     
    12901359            $group_link = bp_get_group_permalink( $group );
    12911360
    1292             if ( (int)$total_items > 1 ) {
    1293                 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    1294             } else {
    1295                 return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
    1296             }
     1361            if ( (int)$total_items > 1 )
     1362                return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
     1363            else
     1364                return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to an admin in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
     1365
    12971366        break;
    12981367
     
    13031372            $group_link = bp_get_group_permalink( $group );
    13041373
    1305             if ( (int)$total_items > 1 ) {
    1306                 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    1307             } else {
    1308                 return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
    1309             }
     1374            if ( (int)$total_items > 1 )
     1375                return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
     1376            else
     1377                return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to a mod in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
     1378
    13101379        break;
    13111380
     
    13161385            $user_url = bp_core_get_user_domain( $user_id );
    13171386
    1318             if ( (int)$total_items > 1 ) {
    1319                 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    1320             } else {
    1321                 return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
    1322             }
     1387            if ( (int)$total_items > 1 )
     1388                return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
     1389            else
     1390                return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
     1391
    13231392        break;
    13241393    }
     
    14131482        $member->user_title = __( 'Group Admin', 'buddypress' );
    14141483        $member->is_confirmed = 1;
    1415         $member->date_modified = gmdate( "Y-m-d H:i:s" );
     1484        $member->date_modified = bp_core_current_time();
    14161485
    14171486        $member->save();
    14181487        do_action( 'groups_create_group', $group->id, $member, $group );
     1488
    14191489    } else {
    14201490        do_action( 'groups_update_group', $group->id, $group );
     
    14811551}
    14821552
     1553/**
     1554 * Delete a group and all of its associated meta
     1555 *
     1556 * @global object $bp BuddyPress global settings
     1557 * @param int $group_id
     1558 * @since 1.0
     1559 */
    14831560function groups_delete_group( $group_id ) {
    14841561    global $bp;
     
    14901567    // Get the group object
    14911568    $group = new BP_Groups_Group( $group_id );
    1492 
    14931569    if ( !$group->delete() )
    14941570        return false;
    14951571
    1496     /* Delete all group activity from activity streams */
    1497     if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
     1572    // Delete all group activity from activity streams
     1573    if ( bp_is_active( 'activity' ) )
    14981574        bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component' => $bp->groups->id ) );
    1499     }
    15001575
    15011576    // Remove all outstanding invites for this group
     
    15051580    bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
    15061581
    1507     do_action( 'groups_delete_group', $group_id );
     1582    // Remove forum if component is active and current group has one
     1583    if ( bp_is_active( 'forums' ) && $forum_id = groups_get_groupmeta( $group_id, 'forum_id' ) ) {
     1584        do_action( 'bbpress_init' );
     1585        bb_delete_forum( $forum_id );
     1586    }
     1587
     1588    do_action( 'groups_delete_group', $group_id);
    15081589
    15091590    return true;
     
    15671648
    15681649    /* Modify user's group memberhip count */
    1569     update_usermeta( $user_id, 'total_group_count', (int) get_usermeta( $user_id, 'total_group_count') - 1 );
     1650    update_user_meta( $user_id, 'total_group_count', (int) get_user_meta( $user_id, 'total_group_count', true ) - 1 );
    15701651
    15711652    /* If the user joined this group less than five minutes ago, remove the joined_group activity so
     
    16171698    /* Record this in activity streams */
    16181699    groups_record_activity( array(
    1619         'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' ) ),
     1700        'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' ) ),
    16201701        'type' => 'joined_group',
    16211702        'item_id' => $group_id
     
    16491730}
    16501731
     1732function groups_get_total_member_count( $group_id ) {
     1733    return BP_Groups_Group::get_total_member_count( $group_id );
     1734}
     1735
    16511736/*** Group Fetching, Filtering & Searching  *************************************/
    16521737
     
    16571742        'type' => 'active', // active, newest, alphabetical, random, popular, most-forum-topics or most-forum-posts
    16581743        'user_id' => false, // Pass a user_id to limit to only groups that this user is a member of
    1659         'include' => false, // Only include these specific groups (group_ids)
    16601744        'search_terms' => false, // Limit to groups that match these search terms
    16611745
     
    16681752    extract( $params, EXTR_SKIP );
    16691753
    1670     $groups = BP_Groups_Group::get( $type, $per_page, $page, $user_id, $search_terms, $include, $populate_extras );
     1754    switch ( $type ) {
     1755        case 'active': default:
     1756            $groups = BP_Groups_Group::get_active( $per_page, $page, $user_id, $search_terms, $populate_extras );
     1757            break;
     1758        case 'newest':
     1759            $groups = BP_Groups_Group::get_newest( $per_page, $page, $user_id, $search_terms, $populate_extras );
     1760            break;
     1761        case 'popular':
     1762            $groups = BP_Groups_Group::get_popular( $per_page, $page, $user_id, $search_terms, $populate_extras );
     1763            break;
     1764        case 'alphabetical':
     1765            $groups = BP_Groups_Group::get_alphabetically( $per_page, $page, $user_id, $search_terms, $populate_extras );
     1766            break;
     1767        case 'random':
     1768            $groups = BP_Groups_Group::get_random( $per_page, $page, $user_id, $search_terms, $populate_extras );
     1769            break;
     1770        case 'most-forum-topics':
     1771            $groups = BP_Groups_Group::get_by_most_forum_topics( $per_page, $page, $user_id, $search_terms, $populate_extras );
     1772            break;
     1773        case 'most-forum-posts':
     1774            $groups = BP_Groups_Group::get_by_most_forum_posts( $per_page, $page, $user_id, $search_terms, $populate_extras );
     1775            break;
     1776    }
    16711777
    16721778    return apply_filters( 'groups_get_groups', $groups, &$params );
     
    17191825        @wp_mkdir_p( $path );
    17201826
    1721     $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );
     1827    $newurl = BP_AVATAR_URL . '/group-avatars/' . $group_id;
    17221828    $newburl = $newurl;
    17231829    $newsubdir = '/group-avatars/' . $group_id;
     
    17421848function groups_is_user_banned( $user_id, $group_id ) {
    17431849    return BP_Groups_Member::check_is_banned( $user_id, $group_id );
     1850}
     1851
     1852/**
     1853 * Is the specified user the creator of the group?
     1854 *
     1855 * @param int $user_id
     1856 * @param int $group_id
     1857 * @since 1.2.6
     1858 * @uses BP_Groups_Member
     1859 */
     1860function groups_is_user_creator( $user_id, $group_id ) {
     1861    return BP_Groups_Member::check_is_creator( $user_id, $group_id );
    17441862}
    17451863
     
    17641882
    17651883    /* Be sure the user is a member of the group before posting. */
    1766     if ( !is_site_admin() && !groups_is_user_member( $user_id, $group_id ) )
     1884    if ( !is_super_admin() && !groups_is_user_member( $user_id, $group_id ) )
    17671885        return false;
    17681886
    17691887    /* Record this in activity streams */
    1770     $activity_action = sprintf( __( '%1$s posted an update in the group %2$s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     1888    $activity_action = sprintf( __( '%1$s posted an update in the group %2$s:', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
    17711889    $activity_content = $content;
    17721890
     
    18061924    groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
    18071925
    1808     do_action( 'groups_new_group_forum', $forum, $group_id );
    1809 }
     1926    do_action( 'groups_new_group_forum', $forum_id, $group_id );
     1927}
     1928
     1929function groups_update_group_forum( $group_id ) {
     1930
     1931    $group = new BP_Groups_Group( $group_id );
     1932
     1933    if ( !$group->enable_forum || !function_exists( 'bp_forums_setup' ) )
     1934        return false;
     1935
     1936    $args = array(
     1937        'forum_id'      => groups_get_groupmeta( $group_id, 'forum_id' ),
     1938        'forum_name'    => $group->name,
     1939        'forum_desc'    => $group->desc,
     1940        'forum_slug'    => $group->slug
     1941    );
     1942
     1943    bp_forums_update_forum( apply_filters( 'groups_update_group_forum', $args ) );
     1944}
     1945add_action( 'groups_details_updated', 'groups_update_group_forum' );
    18101946
    18111947function groups_new_group_forum_post( $post_text, $topic_id, $page = false ) {
     
    18211957        $topic = bp_forums_get_topic_details( $topic_id );
    18221958
    1823         $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     1959        $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
    18241960        $activity_content = bp_create_excerpt( $post_text );
    18251961        $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     
    18601996        $topic = bp_forums_get_topic_details( $topic_id );
    18611997
    1862         $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     1998        $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
    18631999        $activity_content = bp_create_excerpt( $topic_text );
    18642000
     
    18922028            bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component' => $bp->groups->id, 'type' => 'new_forum_topic' ) );
    18932029
    1894         $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     2030        $activity_action = sprintf( __( '%1$s started the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $topic->topic_poster ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'/">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
    18952031        $activity_content = bp_create_excerpt( $topic_text );
    18962032
     
    19262062        $topic = bp_forums_get_topic_details( $topic_id );
    19272063
    1928         $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . attribute_escape( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . attribute_escape( $bp->groups->current_group->name ) . '</a>' );
     2064        $activity_action = sprintf( __( '%1$s posted on the forum topic %2$s in the group %3$s:', 'buddypress'), bp_core_get_userlink( $post->poster_id ), '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug .'">' . esc_attr( $topic->topic_title ) . '</a>', '<a href="' . bp_get_group_permalink( $bp->groups->current_group ) . '">' . esc_attr( $bp->groups->current_group->name ) . '</a>' );
    19292065        $activity_content = bp_create_excerpt( $post_text );
    19302066        $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     
    20652201        return false;
    20662202
     2203    /* Remove request to join */
     2204    if ( $member->check_for_membership_request( $user_id, $group_id ) )
     2205        $member->delete_request( $user_id, $group_id );
     2206
    20672207    /* Modify group meta */
    20682208    groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
     
    21672307    do_action( 'groups_ban_member', $group_id, $user_id );
    21682308
    2169     if ( !$member->ban() )
    2170         return false;
    2171 
    2172     update_usermeta( $user_id, 'total_group_count', (int)$total_count - 1 );
     2309    return $member->ban();
    21732310}
    21742311
     
    21842321
    21852322    return $member->unban();
     2323}
     2324
     2325/*** Group Removal *******************************************************/
     2326
     2327function groups_remove_member( $user_id, $group_id ) {
     2328    global $bp;
     2329
     2330    if ( !$bp->is_item_admin )
     2331        return false;
     2332
     2333    $member = new BP_Groups_Member( $user_id, $group_id );
     2334
     2335    do_action( 'groups_remove_member', $group_id, $user_id );
     2336
     2337    return $member->remove();
    21862338}
    21872339
     
    22402392        return false;
    22412393
     2394    /* Check if the user has an outstanding invite, if so delete it. */
     2395    if ( groups_check_user_has_invite( $membership->user_id, $membership->group_id ) )
     2396        groups_delete_invite( $membership->user_id, $membership->group_id );
     2397
    22422398    /* Modify group member count */
    22432399    groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
    22442400
    22452401    /* Record this in activity streams */
    2246     $group = new BP_Groups_Group( $group_id );
     2402    $group = new BP_Groups_Group( $membership->group_id );
    22472403
    22482404    groups_record_activity( array(
    2249         'action' => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
    2250         'type' => 'joined_group',
    2251         'item_id' => $group->id,
    2252         'user_id' => $user_id
     2405        'action'    => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $membership->user_id, &$group ),
     2406        'type'      => 'joined_group',
     2407        'item_id'   => $membership->group_id,
     2408        'user_id'   => $membership->user_id
    22532409    ) );
    22542410
     
    24092565    do_action( 'groups_remove_data_for_user', $user_id );
    24102566}
    2411 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user', 1 );
    2412 add_action( 'delete_user', 'groups_remove_data_for_user', 1 );
    2413 add_action( 'make_spam_user', 'groups_remove_data_for_user', 1 );
     2567add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' );
     2568add_action( 'delete_user', 'groups_remove_data_for_user' );
     2569add_action( 'make_spam_user', 'groups_remove_data_for_user' );
    24142570
    24152571
  • trunk/bp-groups/bp-groups-classes.php

    r3232 r3300  
    3838
    3939            /* Get group admins and mods */
    40             $admin_mods = $wpdb->get_results( apply_filters( 'bp_group_admin_mods_user_join_filter', $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ), $this->id ) );
     40            $admin_mods = $wpdb->get_results( $wpdb->prepare( "SELECT u.ID as user_id, u.user_login, u.user_email, u.user_nicename, m.is_admin, m.is_mod FROM {$wpdb->users} u, {$bp->groups->table_name_members} m WHERE u.ID = m.user_id AND m.group_id = %d AND ( m.is_admin = 1 OR m.is_mod = 1 )", $this->id ) );
    4141            foreach( (array)$admin_mods as $user ) {
    4242                if ( (int)$user->is_admin )
     
    205205        }
    206206
    207         if ( !is_site_admin() )
     207        if ( !is_super_admin() )
    208208            $hidden_sql = "AND status != 'hidden'";
    209209
     
    256256    }
    257257
    258     function get( $type = 'newest', $per_page = null, $page = null, $user_id = false, $search_terms = false, $include = false, $populate_extras = true ) {
    259         global $wpdb, $bp;
    260 
    261         $sql = array();
    262 
    263         $sql['select'] = "SELECT g.*, gm1.meta_value AS total_member_count, gm2.meta_value AS last_activity";
    264         $sql['from']   = " FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2,";
    265 
    266         if ( !empty( $user_id ) )
    267             $sql['members_from'] = " {$bp->groups->table_name_members} m,";
    268 
    269         $sql['group_from'] = " {$bp->groups->table_name} g WHERE";
    270 
    271         if ( !empty( $user_id ) )
    272             $sql['user_where'] = " g.id = m.group_id AND";
    273 
    274         $sql['where'] = " g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count'";
    275 
    276         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    277             $sql['hidden'] = " AND g.status != 'hidden'";
     258    /* TODO: Merge all these get_() functions into one. */
     259
     260    function get_newest( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
     261        global $wpdb, $bp;
     262
     263        if ( $limit && $page )
     264            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     265
     266        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     267            $hidden_sql = "AND g.status != 'hidden'";
    278268
    279269        if ( $search_terms ) {
    280270            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
    281             $sql['search'] = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
    282         }
    283 
    284         if ( !empty( $user_id ) )
    285             $sql['user'] = $wpdb->prepare( " AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id );
    286 
    287         if ( !empty( $include ) ) {
    288             $include = $wpdb->escape( $include );
    289             $sql['include'] = " AND g.id IN ({$include})";
    290         }
    291 
    292         switch ( $type ) {
    293             case 'newest': default:
    294                 $sql['order'] = " ORDER BY g.date_created DESC";
    295                 break;
    296             case 'active':
    297                 $sql[] = "ORDER BY last_activity DESC";
    298                 break;
    299             case 'popular':
    300                 $sql[] = "ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC";
    301                 break;
    302             case 'alphabetical':
    303                 $sql[] = "ORDER BY g.name ASC";
    304                 break;
    305             case 'random':
    306                 $sql[] = "ORDER BY rand()";
    307                 break;
    308         }
    309 
    310         if ( $per_page && $page )
    311             $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $per_page), intval( $per_page ) );
    312 
    313         /* Get paginated results */
    314         $paged_groups = $wpdb->get_results( join( ' ', (array)$sql ) );
    315 
    316         $total_sql['select'] = "SELECT COUNT(g.id) FROM {$bp->groups->table_name} g";
    317 
    318         if ( !empty( $user_id ) )
    319             $total_sql['select'] .= ", {$bp->groups->table_name_members} m";
    320 
    321         if ( !empty( $sql['hidden'] ) )
    322             $total_sql['where'][] = "g.status != 'hidden'";
    323 
    324         if ( !empty( $sql['search'] ) )
    325             $total_sql['where'][] = "( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
    326 
    327         if ( !empty( $user_id ) )
    328             $total_sql['where'][] = "m.group_id = g.id AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0";
    329 
    330         $t_sql = $total_sql['select'];
    331 
    332         if ( !empty( $total_sql['where'] ) )
    333             $t_sql .= " WHERE " . join( ' AND ', (array)$total_sql['where'] );
    334 
    335         /* Get total group results */
    336         $total_groups = $wpdb->get_var( join( ' ', (array)$t_sql ) );
    337 
    338         /* Populate some extra information instead of querying each time in the loop */
     271            $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
     272        }
     273
     274        if ( $user_id ) {
     275            $user_id = $wpdb->escape( $user_id );
     276            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.date_created DESC {$pag_sql}" );
     277            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
     278        } else {
     279            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.date_created DESC {$pag_sql}" );
     280            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
     281        }
     282
    339283        if ( !empty( $populate_extras ) ) {
    340284            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
    341285            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
    342             $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, $type );
    343         }
    344 
    345         unset( $sql, $total_sql );
     286            $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
     287        }
     288
     289        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     290    }
     291
     292    function get_active( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
     293        global $wpdb, $bp;
     294
     295        if ( $limit && $page )
     296            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     297
     298        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     299            $hidden_sql = "AND g.status != 'hidden'";
     300
     301        if ( $search_terms ) {
     302            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
     303            $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
     304        }
     305
     306        if ( $user_id ) {
     307            $user_id = $wpdb->escape( $user_id );
     308            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY last_activity DESC {$pag_sql}" );
     309            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
     310        } else {
     311            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY last_activity DESC {$pag_sql}" );
     312            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
     313        }
     314
     315        if ( !empty( $populate_extras ) ) {
     316            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
     317            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     318            $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
     319        }
     320
     321        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     322    }
     323
     324    function get_popular( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
     325        global $wpdb, $bp;
     326
     327        if ( $limit && $page ) {
     328            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     329        }
     330
     331        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     332            $hidden_sql = "AND g.status != 'hidden'";
     333
     334        if ( $search_terms ) {
     335            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
     336            $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
     337        }
     338
     339        if ( $user_id ) {
     340            $user_id = $wpdb->escape( $user_id );
     341            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" );
     342            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
     343        } else {
     344            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY CONVERT(gm1.meta_value, SIGNED) DESC {$pag_sql}" );
     345            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" );
     346        }
     347
     348        if ( !empty( $populate_extras ) ) {
     349            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
     350            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     351            $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
     352        }
     353
     354        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     355    }
     356
     357    function get_alphabetically( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
     358        global $wpdb, $bp;
     359
     360        if ( $limit && $page )
     361            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     362
     363        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     364            $hidden_sql = " AND g.status != 'hidden'";
     365
     366        if ( $search_terms ) {
     367            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
     368            $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
     369        }
     370
     371        if ( $user_id ) {
     372            $user_id = $wpdb->escape( $user_id );
     373            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}" );
     374            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
     375        } else {
     376            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}" );
     377            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql}" );
     378        }
     379
     380        if ( !empty( $populate_extras ) ) {
     381            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
     382            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     383            $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
     384        }
    346385
    347386        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     
    358397        }
    359398
    360         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     399        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    361400            $hidden_sql = " AND g.status != 'hidden'";
    362401
     
    394433        }
    395434
    396         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     435        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    397436            $hidden_sql = " AND g.status != 'hidden'";
    398437
     
    420459    }
    421460
     461    function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
     462        global $wpdb, $bp;
     463
     464        // Default sql WHERE conditions are blank. TODO: generic handler function.
     465        $where_sql = null;
     466        $where_conditions = array();
     467
     468        // Limit results to public status
     469        if ( $only_public )
     470            $where_conditions[] = $wpdb->prepare( "g.status = 'public'" );
     471
     472        if ( !is_super_admin() )
     473            $where_conditions[] = $wpdb->prepare( "g.status != 'hidden'");
     474
     475        // Build where sql statement if necessary
     476        if ( !empty( $where_conditions ) )
     477            $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
     478
     479        if ( $limit && $page )
     480            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     481
     482        if ( $sort_by && $order ) {
     483            $sort_by = $wpdb->escape( $sort_by );
     484            $order = $wpdb->escape( $order );
     485            $order_sql = "ORDER BY g.$sort_by $order";
     486
     487            switch ( $sort_by ) {
     488                default:
     489                    $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );
     490                    break;
     491                case 'members':
     492                    $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
     493                    break;
     494                case 'last_active':
     495                    $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
     496                    break;
     497            }
     498        } else {
     499            $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$where_sql} {$order_sql} {$pag_sql}" );
     500        }
     501
     502        return $wpdb->get_results($sql);
     503    }
     504
    422505    function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true ) {
    423506        global $wpdb, $bp;
    424507
    425         if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
    426             return false;
    427 
    428         if ( !is_site_admin() )
     508        // Multibyte compliance
     509        if ( function_exists( 'mb_strlen' ) ) {
     510            if ( mb_strlen( $letter, 'UTF-8' ) > 1 || is_numeric( $letter ) || !$letter ) {
     511                return false;
     512            }
     513        } else {
     514            if ( strlen( $letter ) > 1 || is_numeric( $letter ) || !$letter ) {
     515                return false;
     516            }
     517        }
     518
     519        if ( !is_super_admin() )
    429520            $hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
    430521
     
    437528
    438529        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' AND g.name LIKE '$letter%%' {$hidden_sql} {$search_sql} ORDER BY g.name ASC {$pag_sql}"  ) );
     530
     531        if ( !empty( $populate_extras ) ) {
     532            foreach ( (array)$paged_groups as $group ) $group_ids[] = $group->id;
     533            $group_ids = $wpdb->escape( join( ',', (array)$group_ids ) );
     534            $paged_groups = BP_Groups_Group::get_group_extras( &$paged_groups, $group_ids, 'newest' );
     535        }
     536
     537        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     538    }
     539
     540    function get_random( $limit = null, $page = null, $user_id = false, $search_terms = false, $populate_extras = true ) {
     541        global $wpdb, $bp;
     542
     543        if ( $limit && $page )
     544            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     545
     546        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     547            $hidden_sql = "AND g.status != 'hidden'";
     548
     549        if ( $search_terms ) {
     550            $search_terms = like_escape( $wpdb->escape( $search_terms ) );
     551            $search_sql = " AND ( g.name LIKE '%%{$search_terms}%%' OR g.description LIKE '%%{$search_terms}%%' )";
     552        }
     553
     554        if ( $user_id ) {
     555            $user_id = $wpdb->escape( $user_id );
     556            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0 ORDER BY rand() {$pag_sql}" );
     557            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql} AND m.user_id = {$user_id} AND m.is_confirmed = 1 AND m.is_banned = 0" );
     558        } else {
     559            $paged_groups = $wpdb->get_results( "SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->groups->table_name} g WHERE g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = 'last_activity' AND gm1.meta_key = 'total_member_count' {$hidden_sql} {$search_sql} ORDER BY rand() {$pag_sql}" );
     560            $total_groups = $wpdb->get_var( "SELECT COUNT(DISTINCT g.id) FROM {$bp->groups->table_name_groupmeta} gm INNER JOIN {$bp->groups->table_name} g ON gm.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql} {$search_sql}" );
     561        }
    439562
    440563        if ( !empty( $populate_extras ) ) {
     
    482605        global $wpdb, $bp;
    483606
    484         if ( !is_site_admin() )
     607        if ( !is_super_admin() )
    485608            $hidden_sql = "WHERE status != 'hidden'";
    486609
     
    654777
    655778    function accept_invite() {
    656         $this->inviter_id = 0;
    657         $this->is_confirmed = 1;
     779        $this->inviter_id    = 0;
     780        $this->is_confirmed  = 1;
    658781        $this->date_modified = bp_core_current_time();
     782
     783        update_user_meta( $this->user_id, 'total_group_count', (int)get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
    659784    }
    660785
     
    662787        $this->is_confirmed = 1;
    663788        $this->date_modified = bp_core_current_time();
    664     }
    665 
    666     function remove( $user_id, $group_id ) {
    667         global $wpdb, $bp;
    668 
    669         $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id );
     789
     790        update_user_meta( $this->user_id, 'total_group_count', (int)get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
     791    }
     792
     793    function remove() {
     794        global $wpdb, $bp;
     795
     796        $sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
    670797
    671798        if ( !$result = $wpdb->query( $sql ) )
  • trunk/bp-groups/bp-groups-filters.php

    r2770 r3300  
    9393    global $bp;
    9494
    95     if ( is_site_admin() )
     95    if ( is_super_admin() )
    9696        return true;
    9797
  • trunk/bp-groups/bp-groups-notifications.php

    r2941 r3300  
    44    global $bp;
    55
    6     $group = new BP_Groups_Group( $group_id );
    7     $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
     6    $group    = new BP_Groups_Group( $group_id );
     7    $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     8    $subject  = '[' . $sitename . '] ' . __( 'Group Details Updated', 'buddypress' );
    89
    910    $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
    1011    foreach ( (array)$user_ids as $user_id ) {
    11         if ( 'no' == get_usermeta( $user_id, 'notification_groups_group_updated' ) ) continue;
     12        if ( 'no' == get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) continue;
    1213
    1314        $ud = bp_core_get_core_userdata( $user_id );
     
    4546    bp_core_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );
    4647
    47     if ( 'no' == get_usermeta( $admin_id, 'notification_groups_membership_request' ) )
     48    if ( 'no' == get_user_meta( $admin_id, 'notification_groups_membership_request', true ) )
    4849        return false;
    4950
     
    5960
    6061    // Set up and send the message
    61     $to = $ud->user_email;
    62     $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name );
     62    $to       = $ud->user_email;
     63    $sitename = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     64    $subject  = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name );
    6365
    6466$message = sprintf( __(
     
    9496        bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
    9597
    96     if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) )
     98    if ( 'no' == get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) )
    9799        return false;
    98100
     
    105107
    106108    // Set up and send the message
    107     $to = $ud->user_email;
     109    $to       = $ud->user_email;
     110    $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    108111
    109112    if ( $accepted ) {
    110         $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name );
     113        $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name );
    111114        $message = sprintf( __(
    112115'Your membership request for the group "%1$s" has been accepted.
     
    118121
    119122    } else {
    120         $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name );
     123        $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name );
    121124        $message = sprintf( __(
    122125'Your membership request for the group "%1$s" has been rejected.
     
    152155    bp_core_add_notification( $group_id, $user_id, 'groups', $type );
    153156
    154     if ( 'no' == get_usermeta( $user_id, 'notification_groups_admin_promotion' ) )
     157    if ( 'no' == get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) )
    155158        return false;
    156159
     
    162165
    163166    // Set up and send the message
    164     $to = $ud->user_email;
    165 
    166     $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name );
     167    $to       = $ud->user_email;
     168    $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     169    $subject  = '[' . $sitename . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name );
    167170
    168171    $message = sprintf( __(
     
    200203        bp_core_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );
    201204
    202         if ( 'no' == get_usermeta( $invited_user_id, 'notification_groups_invite' ) )
     205        if ( 'no' == get_user_meta( $invited_user_id, 'notification_groups_invite', true ) )
    203206            return false;
    204207
     
    210213
    211214        // Set up and send the message
    212         $to = $invited_ud->user_email;
    213 
    214         $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name );
     215        $to       = $invited_ud->user_email;
     216        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     217        $subject  = '[' . $sitename . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name );
    215218
    216219        $message = sprintf( __(
     
    241244
    242245    /* Scan for @username strings in an activity update. Notify each user. */
    243     $pattern = '/[@]+([A-Za-z0-9-_]+)/';
     246    $pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
    244247    preg_match_all( $pattern, $content, $usernames );
    245248
     
    251254
    252255    foreach( (array)$usernames as $username ) {
    253         if ( !$receiver_user_id = bp_core_get_userid($username) )
     256        if ( !$receiver_user_id = bp_core_get_userid( $username ) )
    254257            continue;
    255258
     
    259262
    260263        // Now email the user with the contents of the message (if they have enabled email notifications)
    261         if ( 'no' != get_usermeta( $user_id, 'notification_activity_new_mention' ) ) {
     264        if ( 'no' != get_user_meta( $user_id, 'notification_activity_new_mention', true ) ) {
    262265            $poster_name = bp_core_get_user_displayname( $poster_user_id );
    263266
     
    271274            $ud = bp_core_get_core_userdata( $receiver_user_id );
    272275            $to = $ud->user_email;
    273             $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%1$s mentioned you in the group "%2$s"', 'buddypress' ), $poster_name, $group->name );
     276            $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     277            $subject  = '[' . $sitename . '] ' . sprintf( __( '%1$s mentioned you in the group "%2$s"', 'buddypress' ), $poster_name, $group->name );
    274278
    275279$message = sprintf( __(
  • trunk/bp-groups/bp-groups-templatetags.php

    r3263 r3300  
    1919
    2020    var $single_group = false;
     21
     22    var $sort_by;
     23    var $order;
    2124
    2225    function bp_groups_template( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $include, $populate_extras ) {
     
    6770        if ( (int)$this->total_group_count && (int)$this->pag_num ) {
    6871            $this->pag_links = paginate_links( array(
    69                 'base'      => add_query_arg( array( 'grpage' => '%#%' ) ),
     72                'base'      => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ),
    7073                'format'    => '',
    7174                'total'     => ceil( (int)$this->total_group_count / (int)$this->pag_num ),
     
    197200    global $bp, $groups_template;
    198201
    199     if ( $bp->loggedin_user->is_site_admin )
     202    if ( $bp->loggedin_user->is_super_admin )
    200203        return true;
    201204
     
    292295        /* Fetch the avatar from the folder, if not provide backwards compat. */
    293296        if ( !$avatar = bp_core_fetch_avatar( array( 'item_id' => $groups_template->group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height ) ) )
    294             $avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />';
     297            $avatar = '<img src="' . esc_attr( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
    295298
    296299        return apply_filters( 'bp_get_group_avatar', $avatar );
     
    559562        global $bp, $groups_template;
    560563
    561         $from_num = bp_core_number_format( intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1 );
    562         $to_num = bp_core_number_format( ( $from_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $from_num + ( $groups_template->pag_num - 1 ) );
     564        $start_num = intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1;
     565        $from_num = bp_core_number_format( $start_num );
     566        $to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
    563567        $total = bp_core_number_format( $groups_template->total_group_count );
    564568
    565         return apply_filters( 'bp_get_groups_pagination_count', sprintf( __( 'Viewing group %1$s to %2$s (of %3$s groups)', 'buddypress' ), $from_num, $to_num, $total ) );
    566     }
     569        return apply_filters( 'bp_get_groups_pagination_count', sprintf( __( 'Viewing group %1$s to %2$s (of %3$s groups)', 'buddypress' ), $from_num, $to_num, $total ) . '<span class="ajax-loader"></span>' );
     570    }
     571
     572function bp_groups_auto_join() {
     573    global $bp;
     574
     575    return apply_filters( 'bp_groups_auto_join', (bool)$bp->groups->auto_join );
     576}
    567577
    568578function bp_group_total_members() {
     
    875885}
    876886    function bp_get_group_member_unban_link( $user_id = false, $group = false ) {
    877         global $members_template;
     887        global $members_template, $groups_template;
    878888
    879889        if ( !$user_id )
     
    884894
    885895        return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id, 'groups_unban_member' ) );
     896    }
     897
     898
     899function bp_group_member_remove_link( $user_id = false ) {
     900    global $members_template;
     901
     902    if ( !$user_id )
     903        $user_id = $members_template->member->user_id;
     904
     905    echo bp_get_group_member_remove_link( $user_id );
     906}
     907    function bp_get_group_member_remove_link( $user_id = false, $group = false ) {
     908        global $members_template, $groups_template;
     909
     910        if ( !$group )
     911            $group =& $groups_template->group;
     912
     913        return apply_filters( 'bp_get_group_member_remove_link', wp_nonce_url( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id, 'groups_remove_member' ) );
    886914    }
    887915
     
    962990}
    963991
     992/**
     993 * bp_group_is_member()
     994 *
     995 * Checks if current user is member of a group.
     996 *
     997 * @uses is_super_admin Check if current user is super admin
     998 * @uses apply_filters Creates bp_group_is_member filter and passes $is_member
     999 * @usedby groups/activity.php, groups/single/forum/edit.php, groups/single/forum/topic.php to determine template part visibility
     1000 * @global array $bp BuddyPress Master global
     1001 * @global object $groups_template Current Group (usually in template loop)
     1002 * @param object $group Group to check is_member
     1003 * @return bool If user is member of group or not
     1004 */
    9641005function bp_group_is_member( $group = false ) {
    9651006    global $bp, $groups_template;
    9661007
    967     if ( is_site_admin() )
     1008    // Site admins always have access
     1009    if ( is_super_admin() )
    9681010        return true;
    9691011
     1012    // Load group if none passed
    9701013    if ( !$group )
    9711014        $group =& $groups_template->group;
    9721015
     1016    // Check membership
    9731017    if ( null == $group->is_member )
    974         return false;
    975 
    976     return true;
     1018        $is_member = false;
     1019    else
     1020        $is_member = true;
     1021
     1022    // Return
     1023    return apply_filters( 'bp_group_is_member', $is_member );
    9771024}
    9781025
     
    10511098    return true;
    10521099}
     1100
    10531101function bp_group_new_topic_button() {
    10541102    if ( bp_is_group_forum() && is_user_logged_in() && !bp_is_group_forum_topic() ) {
     
    11901238function bp_group_hidden_fields() {
    11911239    if ( isset( $_REQUEST['s'] ) ) {
    1192         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
     1240        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ) . '" name="search_terms" />';
    11931241    }
    11941242
    11951243    if ( isset( $_REQUEST['letter'] ) ) {
    1196         echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
     1244        echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    11971245    }
    11981246
    11991247    if ( isset( $_REQUEST['groups_search'] ) ) {
    1200         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
     1248        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
    12011249    }
    12021250}
     
    14301478    }
    14311479
     1480function bp_group_member_css_class() {
     1481    global $members_template;
     1482
     1483    if ( $members_template->member->is_banned )
     1484        echo apply_filters( 'bp_group_member_css_class', 'banned-user' );
     1485}
     1486
    14321487function bp_group_member_joined_since() {
    14331488    echo bp_get_group_member_joined_since();
     
    14811536        global $members_template;
    14821537
    1483         $from_num = bp_core_number_format( intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1 );
    1484         $to_num = bp_core_number_format( ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ) );
     1538        $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
     1539        $from_num = bp_core_number_format( $start_num );
     1540        $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
    14851541        $total = bp_core_number_format( $members_template->total_member_count );
    14861542
    1487         return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %s to %s (of %s members)', 'buddypress' ), $from_num, $to_num, $total ) );
     1543        return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %1$s to %2$s (of %3$s members)', 'buddypress' ), $from_num, $to_num, $total ) );
    14881544    }
    14891545
     
    17451801                }
    17461802
    1747                 $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>';
     1803                $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . esc_attr( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>';
    17481804            }
    17491805        }
     
    17611817?>
    17621818    <form action="" method="get" id="search-groups-form">
    1763         <label><input type="text" name="s" id="groups_search" value="<?php echo attribute_escape($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
     1819        <label><input type="text" name="s" id="groups_search" value="<?php echo esc_attr($search_value) ?>"  onfocus="if (this.value == '<?php _e( 'Search anything...', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search anything...', 'buddypress' ) ?>';}" /></label>
    17641820        <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    17651821    </form>
     
    18281884
    18291885    if ( $bp->groups->current_group->avatar_full ) { ?>
    1830         <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
     1886        <img src="<?php echo esc_attr( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
    18311887    <?php } else { ?>
    18321888        <img src="<?php echo $bp->groups->image_base . '/none.gif' ?>" alt="<?php _e( 'No Group Avatar', 'buddypress' ) ?>" class="avatar" />
  • trunk/bp-groups/bp-groups-widgets.php

    r2656 r3300  
    5151            </ul>
    5252            <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
    53             <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
     53            <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo esc_attr( $instance['max_groups'] ); ?>" />
    5454
    5555        <?php else: ?>
     
    7777        ?>
    7878
    79         <p><label for="bp-groups-widget-groups-max"><?php _e('Max groups to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo attribute_escape( $max_groups ); ?>" style="width: 30%" /></label></p>
     79        <p><label for="bp-groups-widget-groups-max"><?php _e('Max groups to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo esc_attr( $max_groups ); ?>" style="width: 30%" /></label></p>
    8080    <?php
    8181    }
     
    130130        </ul>
    131131        <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
    132         <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $_POST['max_groups'] ); ?>" />
     132        <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo esc_attr( $_POST['max_groups'] ); ?>" />
    133133
    134134    <?php else: ?>
  • trunk/bp-loader.php

    r3282 r3300  
    77Version: 1.3-bleeding
    88Author URI: http://buddypress.org/community/members/
     9Network: true
    910*/
    1011
     
    6162        include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
    6263
    63     /**
    64     * bp_loaded()
    65     *
    66     * Allow dependent plugins and core actions to attach themselves in a safe way.
    67     *
    68     * See bp-core.php for the following core actions:
    69     *      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
    70     */
    71     function bp_loaded() {
    72         do_action( 'bp_loaded' );
    73     }
    7464    add_action( 'plugins_loaded', 'bp_loaded', 20 );
     65}
     66
     67/**
     68* bp_loaded()
     69*
     70* Allow dependent plugins and core actions to attach themselves in a safe way.
     71*
     72* See bp-core.php for the following core actions:
     73*      - bp_init|bp_setup_globals|bp_setup_root_components|bp_setup_nav|bp_register_widgets
     74*/
     75function bp_loaded() {
     76    do_action( 'bp_loaded' );
    7577}
    7678
     
    8486        switch_theme( 'bp-default', 'bp-default' );
    8587
     88    /* Install site options on activation */
     89    //TODO: Find where to put this back. Here is no good because bp-core.php isn't loaded on new installation.
     90    //bp_core_activate_site_options( array( 'bp-disable-account-deletion' => 0, 'bp-disable-avatar-uploads' => 0, 'bp-disable-blogforum-comments' => 0,  'bp-disable-forum-directory' => 0,  'bp-disable-profile-sync' => 0 ) );
     91
    8692    do_action( 'bp_loader_activate' );
    8793}
     
    9399        return false;
    94100
     101    delete_site_option( 'bp-core-db-version' );
     102    delete_site_option( 'bp-activity-db-version' );
     103    delete_site_option( 'bp-blogs-db-version' );
     104    delete_site_option( 'bp-friends-db-version' );
     105    delete_site_option( 'bp-groups-db-version' );
     106    delete_site_option( 'bp-messages-db-version' );
     107    delete_site_option( 'bp-xprofile-db-version' );
    95108    delete_site_option( 'bp-deactivated-components' );
    96109    delete_site_option( 'bp-blogs-first-install' );
  • trunk/bp-messages.php

    r2941 r3300  
    66
    77function messages_setup_globals() {
    8     global $bp, $wpdb;
     8    global $bp;
    99
    1010    if ( !defined( 'BP_MESSAGES_SLUG' ) )
     
    1414    $bp->messages->id = 'messages';
    1515
    16     $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages';
    17     $bp->messages->table_name_recipients = $wpdb->base_prefix . 'bp_messages_recipients';
    18     $bp->messages->table_name_notices = $wpdb->base_prefix . 'bp_messages_notices';
     16    $bp->messages->slug = BP_MESSAGES_SLUG;
     17    $bp->messages->table_name_notices       = $bp->table_prefix . 'bp_messages_notices';
     18    $bp->messages->table_name_messages      = $bp->table_prefix . 'bp_messages_messages';
     19    $bp->messages->table_name_recipients    = $bp->table_prefix . 'bp_messages_recipients';
    1920    $bp->messages->format_notification_function = 'messages_format_notifications';
    20     $bp->messages->slug = BP_MESSAGES_SLUG;
    2121
    2222    /* Register this in the active components array */
     
    4545    bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_my_profile() ) );
    4646
    47     if ( is_site_admin() )
    48         bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_site_admin() ) );
     47    if ( is_super_admin() )
     48        bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_super_admin() ) );
    4949
    5050    if ( $bp->current_component == $bp->messages->slug ) {
     
    8585    messages_remove_callback_values();
    8686
    87     /* Check if the message form has been submitted */
     87    // Check if the message form has been submitted
    8888    if ( isset( $_POST['send'] ) ) {
    8989
    90         /* Check the nonce */
     90        // Check the nonce
    9191        check_admin_referer( 'messages_send_message' );
    9292
    93         /* Check we have what we need */
     93        // Check we have what we need
    9494        if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {
    9595            bp_core_add_message( __( 'There was an error sending that message, please try again', 'buddypress' ), 'error' );
    9696        } else {
    97             /* If this is a notice, send it */
     97            // If this is a notice, send it
    9898            if ( isset( $_POST['send-notice'] ) ) {
    9999                if ( messages_send_notice( $_POST['subject'], $_POST['content'] ) ) {
     
    104104                }
    105105            } else {
    106                 /* Filter recipients into the format we need - array( 'username/userid', 'username/userid' ) */
     106                // Filter recipients into the format we need - array( 'username/userid', 'username/userid' )
    107107                $autocomplete_recipients = explode( ',', $_POST['send-to-input'] );
    108                 $typed_recipients = explode( ' ', $_POST['send_to_usernames'] );
    109                 $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );
    110 
    111                 /* Send the message */
     108                $typed_recipients        = explode( ' ', $_POST['send_to_usernames'] );
     109                $recipients              = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );
     110                $recipients              = apply_filters( 'bp_messages_recipients', $recipients );
     111
     112                // Send the message
    112113                if ( $thread_id = messages_new_message( array( 'recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) {
    113114                    bp_core_add_message( __( 'Message sent successfully!', 'buddypress' ) );
     
    118119            }
    119120        }
    120 
    121121    }
    122122
     
    129129    global $bp, $notice_id;
    130130
    131     if ( !is_site_admin() )
     131    if ( !is_super_admin() )
    132132        return false;
    133133
     
    166166function messages_screen_notification_settings() {
    167167    global $current_user; ?>
    168     <table class="notification-settings" id="messages-notification-settings">
    169         <tr>
    170             <th class="icon"></th>
    171             <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th>
    172             <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
    173             <th class="no"><?php _e( 'No', 'buddypress' )?></th>
    174         </tr>
    175         <tr>
    176             <td></td>
    177             <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td>
    178             <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_message' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td>
    179             <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_message' ) ) { ?>checked="checked" <?php } ?>/></td>
    180         </tr>
    181         <tr>
    182             <td></td>
    183             <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td>
    184             <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_messages_new_notice' ) || 'yes' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td>
    185             <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td>
    186         </tr>
    187 
    188         <?php do_action( 'messages_screen_notification_settings' ) ?>
     168    <table class="notification-settings zebra" id="messages-notification-settings">
     169        <thead>
     170            <tr>
     171                <th class="icon"></th>
     172                <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th>
     173                <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
     174                <th class="no"><?php _e( 'No', 'buddypress' )?></th>
     175            </tr>
     176        </thead>
     177
     178        <tbody>
     179            <tr>
     180                <td></td>
     181                <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td>
     182                <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_messages_new_message', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td>
     183                <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td>
     184            </tr>
     185            <tr>
     186                <td></td>
     187                <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td>
     188                <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td>
     189                <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_user_meta( $current_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td>
     190            </tr>
     191
     192            <?php do_action( 'messages_screen_notification_settings' ) ?>
     193        </tbody>
    189194    </table>
    190195<?php
     
    209214    $thread_id = $bp->action_variables[0];
    210215
    211     if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_site_admin() ) )
     216    if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_super_admin() ) )
    212217        bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
    213218
     
    328333        'subject' => false,
    329334        'content' => false,
    330         'date_sent' => time()
     335        'date_sent' => bp_core_current_time()
    331336    );
    332337
     
    345350    $message->date_sent = $date_sent;
    346351
    347     /* If we have a thread ID, use the existing recipients, otherwise use the recipients passed */
     352    // If we have a thread ID, use the existing recipients, otherwise use the recipients passed
    348353    if ( $thread_id ) {
    349354        $thread = new BP_Messages_Thread( $thread_id );
    350355        $message->recipients = $thread->get_recipients();
    351356
     357        // Strip the sender from the recipient list if they exist
     358        if ( isset( $message->recipients[$sender_id] ) )
     359            unset( $message->recipients[$sender_id] );
     360
    352361        if ( empty( $message->subject ) )
    353362            $message->subject = sprintf( __( 'Re: %s', 'buddypress' ), $thread->messages[0]->subject );
    354363
     364    // No thread ID, so make some adjustments
    355365    } else {
    356366        if ( empty( $recipients ) )
     
    406416
    407417function messages_send_notice( $subject, $message ) {
    408     if ( !is_site_admin() || empty( $subject ) || empty( $message ) ) {
     418    if ( !is_super_admin() || empty( $subject ) || empty( $message ) ) {
    409419        return false;
    410420    } else {
     
    413423        $notice->subject = $subject;
    414424        $notice->message = $message;
    415         $notice->date_sent = time();
     425        $notice->date_sent = bp_core_current_time();
    416426        $notice->is_active = 1;
    417427        $notice->save(); // send it.
  • trunk/bp-messages/bp-messages-classes.php

    r2576 r3300  
    244244        global $bp;
    245245
    246         $this->date_sent = time();
     246        $this->date_sent = bp_core_current_time();
    247247        $this->sender_id = $bp->loggedin_user->id;
    248248
     
    289289
    290290        // First insert the message into the messages table
    291         if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, FROM_UNIXTIME(%d) )", $this->thread_id, $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )
     291        if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, %s )", $this->thread_id, $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )
    292292            return false;
    293293
     
    388388
    389389        if ( !$this->id ) {
    390             $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, FROM_UNIXTIME(%d), %d)", $this->subject, $this->message, $this->date_sent, $this->is_active );
     390            $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, %s, %d)", $this->subject, $this->message, $this->date_sent, $this->is_active );
    391391        } else {
    392392            $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d", $this->subject, $this->message, $this->is_active, $this->id );
     
    402402        $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id ) );
    403403
    404         update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) );
     404        update_user_meta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) );
    405405
    406406        do_action( 'messages_notice_after_save', $this );
  • trunk/bp-messages/bp-messages-cssjs.php

    r2077 r3300  
    1515
    1616}
    17 add_action( 'template_redirect', 'messages_add_autocomplete_js', 1 );
     17add_action( 'wp', 'messages_add_autocomplete_js', 2 );
    1818
    1919function messages_add_autocomplete_css() {
     
    2828
    2929function messages_autocomplete_init_jsblock() {
     30    global $bp;
    3031?>
    3132    <script type="text/javascript">
  • trunk/bp-messages/bp-messages-filters.php

    r2679 r3300  
    4545add_filter( 'bp_get_the_thread_message_content', 'make_clickable' );
    4646
    47 add_filter( 'bp_get_message_notice_subject', 'wpautop' );
    4847add_filter( 'bp_get_message_notice_text', 'wpautop' );
    49 add_filter( 'bp_get_message_thread_subject', 'wpautop' );
    5048add_filter( 'bp_get_the_thread_message_content', 'wpautop' );
    5149
  • trunk/bp-messages/bp-messages-notifications.php

    r3232 r3300  
    88
    99    foreach( $recipients as $recipient ) {
    10         if ( $sender_id == $recipient->user_id || 'no' == get_usermeta( $recipient->user_id, 'notification_messages_new_message' ) ) continue;
     10        if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) continue;
    1111
    1212        $ud = get_userdata( $recipient->user_id );
     
    1919
    2020        // Set up and send the message
    21         $email_to = $ud->user_email;
    22         $email_subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name );
     21        $email_to      = $ud->user_email;
     22        $sitename      = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     23        $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name );
    2324
    2425        $email_content = sprintf( __(
    25 '%1$s sent you a new message:
     26'%s sent you a new message:
    2627
    27 Subject: %2$s
     28Subject: %s
    2829
    29 "%3$s"
     30"%s"
    3031
    31 To view and read your messages please log in and visit: %4$s
     32To view and read your messages please log in and visit: %s
    3233
    3334---------------------
    3435', 'buddypress' ), $sender_name, $subject, $content, $message_link );
    3536
    36         $content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     37        $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    3738
    3839        /* Send the message */
  • trunk/bp-messages/bp-messages-templatetags.php

    r3263 r3300  
    2828        $this->type     = $type;
    2929
    30         if ( 'notices' == $this->box )
     30        if ( 'notices' == $this->box ) {
    3131            $this->threads = BP_Messages_Notice::get_notices();
    32         else {
     32        } else {
    3333            $threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page );
    3434
     
    162162    extract( $r, EXTR_SKIP );
    163163
    164     if ( 'notices' == $bp->current_action && !is_site_admin() ) {
     164    if ( 'notices' == $bp->current_action && !is_super_admin() ) {
    165165        wp_redirect( $bp->displayed_user->id );
    166166    } else {
     
    250250    }
    251251
     252function bp_message_css_class() {
     253    echo bp_get_message_css_class();
     254}
     255
     256    function bp_get_message_css_class() {
     257        global $messages_template;
     258
     259        $class = false;
     260
     261        if ( $messages_template->current_thread % 2 == 1 )
     262            $class .= 'alt';
     263
     264        return apply_filters( 'bp_get_message_css_class', trim( $class ) );
     265    }
     266
    252267function bp_message_thread_has_unread() {
    253268    global $messages_template;
     
    313328    global $messages_template;
    314329
    315     $from_num = bp_core_number_format( intval( ( $messages_template->pag_page - 1 ) * $messages_template->pag_num ) + 1 );
    316     $to_num = bp_core_number_format( ( $from_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $from_num + ( $messages_template->pag_num - 1 ) );
     330    $start_num = intval( ( $messages_template->pag_page - 1 ) * $messages_template->pag_num ) + 1;
     331    $from_num = bp_core_number_format( $start_num );
     332    $to_num = bp_core_number_format( ( $start_num + ( $messages_template->pag_num - 1 ) > $messages_template->total_thread_count ) ? $messages_template->total_thread_count : $start_num + ( $messages_template->pag_num - 1 ) );
    317333    $total = bp_core_number_format( $messages_template->total_thread_count );
    318334
    319     echo sprintf( __( 'Viewing message %s to %s (of %s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?> &nbsp;
     335    echo sprintf( __( 'Viewing message %1$s to %2$s (of %3$s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?> &nbsp;
    320336    <span class="ajax-loader"></span><?php
    321337}
     
    327343        global $bp;
    328344
    329         return apply_filters( 'bp_get_messages_form_action', $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/' . $bp->action_variables[0] . '/' );
     345        return apply_filters( 'bp_get_messages_form_action', trailingslashit( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/' . $bp->action_variables[0] . '/' ) );
    330346    }
    331347
     
    460476        return false;
    461477
    462     $closed_notices = get_usermeta( $userdata->ID, 'closed_notices' );
     478    $closed_notices = get_user_meta( $userdata->ID, 'closed_notices', true );
    463479
    464480    if ( !$closed_notices )
  • trunk/bp-messages/css/autocomplete/jquery.autocompletefb.css

    r2191 r3300  
    3636
    3737.ac_loading {
    38     background : url('../../images/ajax-loader.gif') right center no-repeat;
     38    background : url('../../../bp-themes/bp-default/_inc/images/ajax-loader.gif') right center no-repeat;
    3939}
    4040
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r2733 r3300  
    184184            <li id="acomment-<?php bp_activity_id() ?>">
    185185                <div class="acomment-avatar">
    186                     <?php bp_activity_avatar( array( 'width' => 25, 'height' => 25 ) ) ?>
     186                    <?php bp_activity_avatar() ?>
    187187                </div>
    188188
    189189                <div class="acomment-meta">
    190                     <?php echo bp_core_get_userlink( bp_get_activity_user_id() ) ?> &middot; <?php printf( __( '%s ago', 'buddypress' ), bp_core_time_since( gmdate( "Y-m-d H:i:s" ) ) ) ?> &middot;
    191                     <a class="acomment-reply" href="#acomment-<?php bp_activity_id() ?>" id="acomment-reply-<?php echo attribute_escape( $_POST['form_id'] ) ?>"><?php _e( 'Reply', 'buddypress' ) ?></a>
     190                    <?php echo bp_core_get_userlink( bp_get_activity_user_id() ) ?> &middot; <?php printf( __( '%s ago', 'buddypress' ), bp_core_time_since( bp_core_current_time() ) ) ?> &middot;
     191                    <a class="acomment-reply" href="#acomment-<?php bp_activity_id() ?>" id="acomment-reply-<?php echo esc_attr( $_POST['form_id'] ) ?>"><?php _e( 'Reply', 'buddypress' ) ?></a>
    192192                     &middot; <a href="<?php echo wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . bp_get_activity_id() . '?cid=' . $comment_id, 'bp_activity_delete_link' ) ?>" class="delete acomment-delete confirm"><?php _e( 'Delete', 'buddypress' ) ?></a>
    193193                </div>
     
    217217
    218218    /* Check access */
    219     if ( !is_site_admin() && $activity->user_id != $bp->loggedin_user->id )
     219    if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id )
    220220        return false;
    221221
     
    250250
    251251    /* Check access */
    252     if ( !is_site_admin() && $comment->user_id != $bp->loggedin_user->id )
     252    if ( !is_super_admin() && $comment->user_id != $bp->loggedin_user->id )
    253253        return false;
    254254
     
    313313        echo '<span class="activity">' . esc_attr( $user->last_active ) . '</span>';
    314314        echo '<div class="action">
    315                 <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . attribute_escape( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
     315                <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
    316316              </div>';
    317317        echo '</li>';
     
    405405                _e( 'Error joining group', 'buddypress' );
    406406            } else {
    407                 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
     407                echo '<a id="group-' . esc_attr( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    408408            }
    409409
     
    415415                _e( 'Error requesting membership', 'buddypress' );
    416416            } else {
    417                 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';
     417                echo '<a id="group-' . esc_attr( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';
    418418            }
    419419        }
     
    427427        } else {
    428428            if ( 'public' == $group->status ) {
    429                 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
     429                echo '<a id="group-' . esc_attr( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
    430430            } else if ( 'private' == $group->status ) {
    431                 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
     431                echo '<a id="group-' . esc_attr( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
    432432            }
    433433        }
     
    443443        echo "-1<div id='message' class='error'><p>" . __('There was a problem closing the notice.', 'buddypress') . '</p></div>';
    444444    } else {
    445         $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' );
     445        $notice_ids = get_user_meta( $userdata->ID, 'closed_notices', true );
    446446
    447447        $notice_ids[] = (int) $_POST['notice_id'];
    448448
    449         update_usermeta( $userdata->ID, 'closed_notices', $notice_ids );
     449        update_user_meta( $userdata->ID, 'closed_notices', $notice_ids );
    450450    }
    451451}
     
    466466                <?php echo bp_loggedin_user_avatar( 'type=thumb&width=30&height=30' ); ?>
    467467
    468                 <strong><a href="<?php echo $bp->loggedin_user->domain ?>"><?php echo $bp->loggedin_user->fullname ?></a> <span class="activity"><?php printf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( time() ) ) ?></span></strong>
     468                <strong><a href="<?php echo $bp->loggedin_user->domain ?>"><?php echo $bp->loggedin_user->fullname ?></a> <span class="activity"><?php printf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( bp_core_current_time() ) ) ?></span></strong>
    469469
    470470                <?php do_action( 'bp_after_message_meta' ) ?>
  • trunk/bp-themes/bp-default/_inc/css/default.css

    r3232 r3300  
    3636a:focus { outline: 1px dotted #ccc; }
    3737
    38 .padder { padding: 20px; }
     38.padder { padding: 19px; }
    3939.clear { clear: left; }
    4040
     
    180180    margin-left: -226px;
    181181    margin-top: 1px;
    182     border-left: 1px solid #e4e4e4;
     182    border-left: 1px solid #ddd;
    183183    -moz-border-radius-topright: 3px;
    184184    -webkit-border-top-right-radius: 3px;
     
    226226
    227227    div#sidebar ul.item-list img.avatar {
    228         width: 25px;
    229         height: 25px;
     228        width: 20px;
     229        height: 20px;
    230230        margin-right: 10px;
    231231    }
     
    274274div#content .padder {
    275275    margin-right: 225px;
    276     border-right: 1px solid #e4e4e4;
     276    border-right: 1px solid #ddd;
    277277    -moz-border-radius-topleft: 6px;
    278278    -webkit-border-top-left-radius: 6px;
     
    400400    }
    401401        ul.single-line li { border: none; }
    402         body.activity-permalink ul.item-list li { padding-top: 0; }
    403402
    404403        ul.item-list li img.avatar {
     
    449448    clear: left;
    450449    overflow: hidden;
    451     margin: 25px -20px 20px -20px;
     450    margin: 25px -19px 20px -19px;
    452451    background: #eaeaea;
    453452}
     
    525524    div.item-list-tabs#subnav {
    526525        background: #fff;
    527         margin: -15px -20px 15px -20px;
     526        margin: -15px -19px 15px -19px;
    528527        border-bottom: 1px solid #eaeaea;
    529528        min-height: 35px;
     
    575574
    576575div.pagination {
    577     margin: -15px -20px 9px -20px;
     576    margin: -20px -20px 9px -20px;
    578577    border-bottom: 1px solid #eaeaea;
    579578    padding: 10px 20px 10px 20px;
     
    604603                font-weight: bold;
    605604            }
     605
     606div#pag-bottom {
     607    margin-top: 0;
     608}
    606609
    607610/* > Error / Success Messages
     
    645648-------------------------------------------------------------- */
    646649
    647 a.button, input[type=submit], input[type=button],
     650a.button, input[type=submit], input[type=button], input[type=reset],
    648651ul.button-nav li a, div.generic-button a {
    649652    background: url( ../images/white-grad.png ) top left repeat-x;
     
    660663    cursor: pointer;
    661664}
    662     a.button:hover, a.button:focus, input[type=submit]:hover, input[type=button]:hover,
     665    a.button:hover, a.button:focus, input[type=submit]:hover, input[type=button]:hover, input[type=reset]:hover,
    663666    ul.button-nav li a:hover, ul.button-nav li.current a,
    664667    div.generic-button a:hover {
     
    803806        }
    804807
     808    form.standard-form a.clear-value {
     809        display: block;
     810        margin-top: 5px;
     811        outline: none;
     812    }
     813
    805814form.standard-form #basic-details-section, form.standard-form #blog-details-section,
    806815form.standard-form #profile-details-section {
     
    841850    width: 100%;
    842851}
     852    table thead tr {
     853        background: #eaeaea;
     854    }
     855
    843856    table#message-threads {
    844857        margin: 0 -20px;
     
    889902    width: auto;
    890903}
    891     table.forum tr:first-child {
    892         background: #fafafa;
    893     }
    894 
    895904    table.forum tr.sticky td {
    896905        background: #FFF9DB;
     
    9921001    form#whats-new-form textarea {
    9931002        width: 100%;
    994         height: 60px;
     1003        height: 50px;
    9951004        font-size: 14px;
    9961005        font-family: inherit;
     
    11071116
    11081117.activity-list .activity-avatar img {
    1109     width: 60px;
    1110     height: 60px;
     1118    width: 50px;
     1119    height: 50px;
    11111120}
    11121121        body.activity-permalink .activity-list .activity-avatar img {
     
    11461155        line-height: 220%;
    11471156    }
     1157   
     1158    .activity-list .activity-content .activity-header img.avatar {
     1159        float: none !important;
     1160        margin: 0 5px -8px 0 !important;
     1161    }
    11481162
    11491163    .activity-list .activity-header a:first-child, span.highlight {
     
    12761290    -moz-border-radius: 4px;
    12771291    -webkit-border-radius: 4px;
     1292    padding: 0 10px 0;
    12781293}
    12791294div.activity-comments ul, div.activity-comments ul li {
     
    12881303    div.activity-comments ul li {
    12891304        border-top: 2px solid #fff;
    1290         padding: 10px 15px 10px 0;
    1291         margin-left: 15px;
     1305        padding: 10px 0 0;
    12921306    }
    12931307        body.activity-permalink div.activity-comments ul li {
    12941308            border-width: 1px;
    1295             padding: 15px 0 15px 0;
     1309            padding: 10px 0 0;
    12961310        }
    12971311
    12981312        div.activity-comments ul li p:last-child {
    1299             margin-bottom: 0;
     1313            margin-bottom: 10px;
    13001314        }
    13011315
     
    13091323
    13101324    div.activity-comments ul li > ul {
    1311         margin-top: 5px;
    1312         margin-left: 25px;
     1325        margin-top: 0;
     1326        margin-left: 20px;
    13131327    }
    13141328        body.activity-permalink div.activity-comments ul li > ul {
     
    13431357        display: none;
    13441358        margin: 10px 0 10px 33px;
    1345         background: #eee;
    1346         border-bottom: 1px solid #ddd;
    1347         border-right: 1px solid #ddd;
     1359        background: #fafafa;
     1360        border: 1px solid #ddd;
    13481361        -moz-border-radius: 4px;
    13491362        -webkit-border-radius: 4px;
     
    14001413
    14011414        div.activity-comments form div.ac-reply-content {
    1402             margin-left: 25px;
     1415            margin-left: 50px;
    14031416            padding-left: 15px;
    14041417            color: #888;
  • trunk/bp-themes/bp-default/_inc/global.js

    r3232 r3300  
    825825        jq(this).removeClass('over');
    826826    });
    827 
     827       
    828828    jq('body#bp-default table.zebra tbody tr:odd').addClass('alt');
    829829
  • trunk/bp-themes/bp-default/activity/entry.php

    r2761 r3300  
    5656            <?php if ( is_user_logged_in() ) : ?>
    5757            <form action="<?php bp_activity_comment_form_action() ?>" method="post" id="ac-form-<?php bp_activity_id() ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display() ?>>
    58                 <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=25&height=25' ) ?></div>
     58                <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ) ?></div>
    5959                <div class="ac-reply-content">
    6060                    <div class="ac-textarea">
  • trunk/bp-themes/bp-default/activity/index.php

    r2908 r3300  
    5858            <div class="item-list-tabs no-ajax" id="subnav">
    5959                <ul>
    60                     <li class="feed"><a href="<?php bp_sitewide_activity_feed_link() ?>" title="RSS Feed"><?php _e( 'RSS', 'buddypress' ) ?></a></li>
     60                    <li class="feed"><a href="<?php bp_sitewide_activity_feed_link() ?>" title="<?php _e( 'RSS Feed', 'buddypress' ); ?>"><?php _e( 'RSS', 'buddypress' ) ?></a></li>
    6161
    6262                    <?php do_action( 'bp_activity_syndication_options' ) ?>
  • trunk/bp-themes/bp-default/activity/post-form.php

    r2696 r3300  
    1111    <div id="whats-new-avatar">
    1212        <a href="<?php echo bp_loggedin_user_domain() ?>">
    13             <?php bp_loggedin_user_avatar( 'width=60&height=60' ) ?>
     13            <?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ) ?>
    1414        </a>
    1515    </div>
     
    2525    <div id="whats-new-content">
    2626        <div id="whats-new-textarea">
    27             <textarea name="whats-new" id="whats-new" value="" /><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea>
     27            <textarea name="whats-new" id="whats-new" cols="50" rows="10"><?php if ( isset( $_GET['r'] ) ) : ?>@<?php echo esc_attr( $_GET['r'] ) ?> <?php endif; ?></textarea>
    2828        </div>
    2929
  • trunk/bp-themes/bp-default/archive.php

    r2694 r3300  
    3333                            <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    3434
    35                             <p class="date"><?php the_time('F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>
     35                            <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>
    3636
    3737                            <div class="entry">
  • trunk/bp-themes/bp-default/blogs/blogs-loop.php

    r3263 r3300  
    55<?php if ( bp_has_blogs( bp_ajax_querystring( 'blogs' ) ) ) : ?>
    66
    7     <div class="pagination">
     7    <div id="pag-top" class="pagination">
    88
    9         <div class="pag-count" id="blog-dir-count">
     9        <div class="pag-count" id="blog-dir-count-top">
    1010            <?php bp_blogs_pagination_count() ?>
    1111        </div>
    1212
    13         <div class="pagination-links" id="blog-dir-pag">
     13        <div class="pagination-links" id="blog-dir-pag-top">
    1414            <?php bp_blogs_pagination_links() ?>
    1515        </div>
    1616
    1717    </div>
     18
     19    <?php do_action( 'bp_before_directory_blogs_list' ) ?>
    1820
    1921    <ul id="blogs-list" class="item-list">
     
    5254    <?php bp_blog_hidden_fields() ?>
    5355
     56    <div id="pag-bottom" class="pagination">
     57
     58        <div class="pag-count" id="blog-dir-count-bottom">
     59            <?php bp_blogs_pagination_count() ?>
     60        </div>
     61
     62        <div class="pagination-links" id="blog-dir-pag-bottom">
     63            <?php bp_blogs_pagination_links() ?>
     64        </div>
     65
     66    </div>
     67
    5468<?php else: ?>
    5569
  • trunk/bp-themes/bp-default/comments.php

    r3232 r3300  
    1515
    1616            <?php
    17             $numTrackBacks = 0; $numComments = 0;
    18             foreach ( (array)$comments as $comment ) if ( get_comment_type() != "comment") $numTrackBacks++; else $numComments++;
     17                // Only include comments
     18                $numTrackBacks = 0; $numComments = 0;
     19                foreach ( (array)$comments as $comment )
     20                    if ( 'comment' != get_comment_type() )
     21                        $numTrackBacks++;
     22                    else
     23                        $numComments++;
    1924            ?>
    2025
    21             <span class="title"><?php the_title() ?></span>
    22             <h3 id="comments"><?php comments_number( 'No Comments', 'One Comment', $numComments . ' Comments' );?></h3>
     26            <h3 id="comments">
     27                <?php
     28                    printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', $numComments, 'buddypress' ),
     29                    number_format_i18n( $numComments ), '<em>' . get_the_title() . '</em>' );
     30                ?>
     31            </h3>
    2332
    2433            <?php do_action( 'bp_before_blog_comment_list' ) ?>
     
    96105                    <?php do_action( 'bp_before_blog_comment_form' ) ?>
    97106
    98                     <form action="<?php echo get_option( 'siteurl' ); ?>/wp-comments-post.php" method="post" id="commentform" class="standard-form">
     107                    <form action="<?php echo site_url( 'wp-comments-post.php' ) ?>" method="post" id="commentform" class="standard-form">
    99108
    100109                        <?php if ( $user_ID ) : ?>
  • trunk/bp-themes/bp-default/footer.php

    r2284 r3300  
    55
    66        <div id="footer">
    7             <p><?php printf( __( '%s is proudly powered by <a href="http://wordpress.org">WordPress</a> and <a href="http://buddypress.org">BuddyPress</a>', 'buddypress' ), bloginfo('name') ); ?></p>
     7            <p><?php printf( __( '%s is proudly powered by <a href="http://wordpress.org">WordPress</a> and <a href="http://buddypress.org">BuddyPress</a>', 'buddypress' ), get_bloginfo( 'name' ) ); ?></p>
    88
    99            <?php do_action( 'bp_footer' ) ?>
  • trunk/bp-themes/bp-default/forums/index.php

    r3232 r3300  
    11<?php get_header() ?>
    2 
    3     <?php do_action( 'bp_before_directory_forums_content' ) ?>
    42
    53    <div id="content">
     
    75
    86        <form action="" method="post" id="forums-search-form" class="dir-form">
     7
    98            <h3><?php _e( 'Group Forums Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="#new-topic" id="new-topic-button"><?php _e( 'New Topic', 'buddypress' ) ?></a><?php endif; ?></h3>
     9
     10            <?php do_action( 'bp_before_directory_forums_content' ) ?>
    1011
    1112            <div id="forums-dir-search" class="dir-search">
     
    1415        </form>
    1516
    16             <div id="new-topic-post">
    17                 <?php if ( is_user_logged_in() ) : ?>
     17        <div id="new-topic-post">
     18            <?php if ( is_user_logged_in() ) : ?>
    1819
    19                     <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : ?>
     20                <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : ?>
    2021
    21                         <form action="" method="post" id="forum-topic-form" class="standard-form">
     22                    <form action="" method="post" id="forum-topic-form" class="standard-form">
    2223
    23                             <?php do_action( 'groups_forum_new_topic_before' ) ?>
     24                        <?php do_action( 'groups_forum_new_topic_before' ) ?>
    2425
    25                             <a name="post-new"></a>
    26                             <h5><?php _e( 'Post a New Topic:', 'buddypress' ) ?></h5>
     26                        <a name="post-new"></a>
     27                        <h5><?php _e( 'Post a New Topic:', 'buddypress' ) ?></h5>
    2728
    28                             <label><?php _e( 'Title:', 'buddypress' ) ?></label>
    29                             <input type="text" name="topic_title" id="topic_title" value="" />
     29                        <label><?php _e( 'Title:', 'buddypress' ) ?></label>
     30                        <input type="text" name="topic_title" id="topic_title" value="" />
    3031
    31                             <label><?php _e( 'Content:', 'buddypress' ) ?></label>
    32                             <textarea name="topic_text" id="topic_text"></textarea>
     32                        <label><?php _e( 'Content:', 'buddypress' ) ?></label>
     33                        <textarea name="topic_text" id="topic_text"></textarea>
    3334
    34                             <label><?php _e( 'Tags (comma separated):', 'buddypress' ) ?></label>
    35                             <input type="text" name="topic_tags" id="topic_tags" value="" />
     35                        <label><?php _e( 'Tags (comma separated):', 'buddypress' ) ?></label>
     36                        <input type="text" name="topic_tags" id="topic_tags" value="" />
    3637
    37                             <label><?php _e( 'Post In Group Forum:', 'buddypress' ) ?></label>
    38                             <select id="topic_group_id" name="topic_group_id">
    39                                 <?php while ( bp_groups() ) : bp_the_group(); ?>
    40                                     <?php if ( 'public' == bp_get_group_status() ) : ?>
    41                                         <option value="<?php bp_group_id() ?>"><?php bp_group_name() ?></option>
    42                                     <?php endif; ?>
    43                                 <?php endwhile; ?>
    44                             </select>
     38                        <label><?php _e( 'Post In Group Forum:', 'buddypress' ) ?></label>
     39                        <select id="topic_group_id" name="topic_group_id">
    4540
    46                             <?php do_action( 'groups_forum_new_topic_after' ) ?>
     41                            <option value="">----</option>
    4742
    48                             <div class="submit">
    49                                 <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ) ?>" />
    50                                 <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ) ?>" />
    51                             </div>
     43                            <?php while ( bp_groups() ) : bp_the_group(); ?>
    5244
    53                             <?php wp_nonce_field( 'bp_forums_new_topic' ) ?>
     45                                <?php if ( bp_group_is_forum_enabled() && 'public' == bp_get_group_status() ) : ?>
    5446
    55                         </form>
     47                                    <option value="<?php bp_group_id() ?>"><?php bp_group_name() ?></option>
    5648
    57                     <?php else : ?>
     49                                <?php endif; ?>
    5850
    59                         <div id="message" class="info">
    60                             <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( BP_GROUPS_SLUG . '/create/' ) ) ?></p>
     51                            <?php endwhile; ?>
     52
     53                        </select><!-- #topic_group_id -->
     54
     55                        <?php do_action( 'groups_forum_new_topic_after' ) ?>
     56
     57                        <div class="submit">
     58                            <input type="submit" name="submit_topic" id="submit" value="<?php _e( 'Post Topic', 'buddypress' ) ?>" />
     59                            <input type="button" name="submit_topic_cancel" id="submit_topic_cancel" value="<?php _e( 'Cancel', 'buddypress' ) ?>" />
    6160                        </div>
    6261
    63                     <?php endif; ?>
     62                        <?php wp_nonce_field( 'bp_forums_new_topic' ) ?>
     63
     64                    </form><!-- #forum-topic-form -->
     65
     66                <?php else : ?>
     67
     68                    <div id="message" class="info">
     69                        <p><?php printf( __( "You are not a member of any groups so you don't have any group forums you can post in. To start posting, first find a group that matches the topic subject you'd like to start. If this group does not exist, why not <a href='%s'>create a new group</a>? Once you have joined or created the group you can post your topic in that group's forum.", 'buddypress' ), site_url( BP_GROUPS_SLUG . '/create/' ) ) ?></p>
     70                    </div>
    6471
    6572                <?php endif; ?>
    66             </div>
     73
     74            <?php endif; ?>
     75        </div><!-- #new-topic-post -->
    6776
    6877        <form action="" method="post" id="forums-directory-form" class="dir-form">
  • trunk/bp-themes/bp-default/functions.php

    r3263 r3300  
    11<?php
    22
    3 /* Stop the theme from killing WordPress if BuddyPress is not enabled. */
     3// Stop the theme from killing WordPress if BuddyPress is not enabled.
    44if ( !class_exists( 'BP_Core_User' ) )
    55    return false;
    66
    7 /* Register the widget columns */
     7// Register the widget columns
    88register_sidebars( 1,
    99    array(
    10         'name' => 'Sidebar',
     10        'name'          => 'Sidebar',
    1111        'before_widget' => '<div id="%1$s" class="widget %2$s">',
    12         'after_widget' => '</div>',
    13         'before_title' => '<h3 class="widgettitle">',
    14         'after_title' => '</h3>'
     12        'after_widget'  => '</div>',
     13        'before_title'  => '<h3 class="widgettitle">',
     14        'after_title'   => '</h3>'
    1515    )
    1616);
    1717
    18 /* Load the AJAX functions for the theme */
     18// Load the AJAX functions for the theme
    1919require_once( TEMPLATEPATH . '/_inc/ajax.php' );
    2020
    21 /* Load the javascript for the theme */
     21// Load the javascript for the theme
    2222wp_enqueue_script( 'dtheme-ajax-js', get_template_directory_uri() . '/_inc/global.js', array( 'jquery' ) );
    2323
    24 /* Add the JS needed for blog comment replies */
     24// Add words that we need to use in JS to the end of the page so they can be translated and still used.
     25$params = array(
     26    'my_favs'           => __( 'My Favorites', 'buddypress' ),
     27    'accepted'          => __( 'Accepted', 'buddypress' ),
     28    'rejected'          => __( 'Rejected', 'buddypress' ),
     29    'show_all_comments' => __( 'Show all comments for this thread', 'buddypress' ),
     30    'show_all'          => __( 'Show all', 'buddypress' ),
     31    'comments'          => __( 'comments', 'buddypress' ),
     32    'close'             => __( 'Close', 'buddypress' ),
     33    'mention_explain'   => sprintf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", 'buddypress' ), '@' . bp_get_displayed_user_username(), bp_get_user_firstname( bp_get_displayed_user_fullname() ), bp_get_user_firstname( bp_get_displayed_user_fullname() ) )
     34);
     35wp_localize_script( 'dtheme-ajax-js', 'BP_DTheme', $params );
     36
     37/**
     38 * Add the JS needed for blog comment replies
     39 *
     40 * @package BuddyPress Theme
     41 * @since 1.2
     42 */
    2543function bp_dtheme_add_blog_comments_js() {
    2644    if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
     
    2846add_action( 'template_redirect', 'bp_dtheme_add_blog_comments_js' );
    2947
    30 /* HTML for outputting blog comments as defined by the WP comment API */
     48/**
     49 * HTML for outputting blog comments as defined by the WP comment API
     50 *
     51 * @param mixed $comment Comment record from database
     52 * @param array $args Arguments from wp_list_comments() call
     53 * @param int $depth Comment nesting level
     54 * @see wp_list_comments()
     55 * @package BuddyPress Theme
     56 * @since 1.2
     57 */
    3158function bp_dtheme_blog_comments( $comment, $args, $depth ) {
    3259    $GLOBALS['comment'] = $comment; ?>
     
    6693
    6794        </div>
    68     </li>
    6995<?php
    7096}
    7197
    72 /* Filter the dropdown for selecting the page to show on front to include "Activity Stream" */
     98/**
     99 * Filter the dropdown for selecting the page to show on front to include "Activity Stream"
     100 *
     101 * @param string $page_html A list of pages as a dropdown (select list)
     102 * @see wp_dropdown_pages()
     103 * @return string
     104 * @package BuddyPress Theme
     105 * @since 1.2
     106 */
    73107function bp_dtheme_wp_pages_filter( $page_html ) {
     108    if ( !bp_is_active( 'activity' ) )
     109        return $page_html;
     110
    74111    if ( 'page_on_front' != substr( $page_html, 14, 13 ) )
    75112        return $page_html;
     
    86123add_filter( 'wp_dropdown_pages', 'bp_dtheme_wp_pages_filter' );
    87124
    88 /* Hijack the saving of page on front setting to save the activity stream setting */
     125/**
     126 * Hijack the saving of page on front setting to save the activity stream setting
     127 *
     128 * @param $string $oldvalue Previous value of get_option( 'page_on_front' )
     129 * @param $string $oldvalue New value of get_option( 'page_on_front' )
     130 * @return string
     131 * @package BuddyPress Theme
     132 * @since 1.2
     133 */
    89134function bp_dtheme_page_on_front_update( $oldvalue, $newvalue ) {
    90     if ( !is_admin() || !is_site_admin() )
     135    if ( !is_admin() || !is_super_admin() )
    91136        return false;
    92137
     
    98143add_action( 'pre_update_option_page_on_front', 'bp_dtheme_page_on_front_update', 10, 2 );
    99144
    100 /* Load the activity stream template if settings allow */
     145/**
     146 * Load the activity stream template if settings allow
     147 *
     148 * @param string $template Absolute path to the page template
     149 * @return string
     150 * @global WP_Query $wp_query WordPress query object
     151 * @package BuddyPress Theme
     152 * @since 1.2
     153 */
    101154function bp_dtheme_page_on_front_template( $template ) {
    102155    global $wp_query;
     
    109162add_filter( 'page_template', 'bp_dtheme_page_on_front_template' );
    110163
    111 /* Return the ID of a page set as the home page. */
     164/**
     165 * Return the ID of a page set as the home page.
     166 *
     167 * @return false|int ID of page set as the home page
     168 * @package BuddyPress Theme
     169 * @since 1.2
     170 */
    112171function bp_dtheme_page_on_front() {
    113172    if ( 'page' != get_option( 'show_on_front' ) )
     
    117176}
    118177
    119 /* Force the page ID as a string to stop the get_posts query from kicking up a fuss. */
     178/**
     179 * Force the page ID as a string to stop the get_posts query from kicking up a fuss.
     180 *
     181 * @global WP_Query $wp_query WordPress query object
     182 * @package BuddyPress Theme
     183 * @since 1.2
     184 */
    120185function bp_dtheme_fix_get_posts_on_activity_front() {
    121186    global $wp_query;
     
    126191add_action( 'pre_get_posts', 'bp_dtheme_fix_get_posts_on_activity_front' );
    127192
    128 /****
     193/**
     194 * WP 3.0 requires there to be a non-null post in the posts array
     195 *
     196 * @param array $posts Posts as retrieved by WP_Query
     197 * @global WP_Query $wp_query WordPress query object
     198 * @return array
     199 * @package BuddyPress Theme
     200 * @since 1.2.5
     201 */
     202function bp_dtheme_fix_the_posts_on_activity_front( $posts ) {
     203    global $wp_query;
     204
     205    // NOTE: the double quotes around '"activity"' are thanks to our previous function bp_dtheme_fix_get_posts_on_activity_front()
     206    if ( empty( $posts ) && !empty( $wp_query->query_vars['page_id'] ) && '"activity"' == $wp_query->query_vars['page_id'] )
     207        $posts = array( (object) array( 'ID' => 'activity' ) );
     208
     209    return $posts;
     210}
     211add_filter( 'the_posts', 'bp_dtheme_fix_the_posts_on_activity_front' );
     212
     213/**
     214 * Add secondary avatar image to this activity stream's record, if supported
     215 *
     216 * @param string $action The text of this activity
     217 * @param BP_Activity_Activity $activity Activity object
     218 * @return string
     219 * @package BuddyPress Theme
     220 * @since 1.2.6
     221 */
     222function bp_dtheme_activity_secondary_avatars( $action, $activity ) {
     223    switch ( $activity->component ) {
     224        case 'groups' :
     225        case 'blogs' :
     226        case 'friends' :
     227            // Only insert avatar if one exists
     228            if ( $secondary_avatar = bp_get_activity_secondary_avatar() ) {
     229                $reverse_content = strrev( $action );
     230                $position        = strpos( $reverse_content, 'a<' );
     231                $action          = substr_replace( $action, $secondary_avatar, -$position - 2, 0 );
     232            }
     233            break;
     234    }
     235
     236    return $action;
     237}
     238add_filter( 'bp_get_activity_action_pre_meta', 'bp_dtheme_activity_secondary_avatars', 10, 2 );
     239
     240/**
    129241 * Custom header image support. You can remove this entirely in a child theme by adding this line
    130242 * to your functions.php: define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true );
     243 *
     244 * @package BuddyPress Theme
     245 * @since 1.2
    131246 */
    132247function bp_dtheme_add_custom_header_support() {
    133     /* Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/) */
     248    // Set the defaults for the custom header image (http://ryan.boren.me/2007/01/07/custom-image-header-api/)
    134249    define( 'HEADER_TEXTCOLOR', 'FFFFFF' );
    135250    define( 'HEADER_IMAGE', '%s/_inc/images/default_header.jpg' ); // %s is theme dir uri
     
    203318    add_action( 'init', 'bp_dtheme_add_custom_header_support' );
    204319
    205 /* Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html) */
     320/**
     321 * Show a notice when the theme is activated - workaround by Ozh (http://old.nabble.com/Activation-hook-exist-for-themes--td25211004.html)
     322 *
     323 * @package BuddyPress Theme
     324 * @since 1.2
     325 */
    206326function bp_dtheme_show_notice() { ?>
    207327    <div id="message" class="updated fade">
     
    215335    add_action( 'admin_notices', 'bp_dtheme_show_notice' );
    216336
    217 /* Add words that we need to use in JS to the end of the page so they can be translated and still used. */
    218 function bp_dtheme_js_terms() { ?>
    219 <script type="text/javascript">
    220     var bp_terms_my_favs = '<?php _e( "My Favorites", "buddypress" ) ?>';
    221     var bp_terms_accepted = '<?php _e( "Accepted", "buddypress" ) ?>';
    222     var bp_terms_rejected = '<?php _e( "Rejected", "buddypress" ) ?>';
    223     var bp_terms_show_all_comments = '<?php _e( "Show all comments for this thread", "buddypress" ) ?>';
    224     var bp_terms_show_all = '<?php _e( "Show all", "buddypress" ) ?>';
    225     var bp_terms_comments = '<?php _e( "comments", "buddypress" ) ?>';
    226     var bp_terms_close = '<?php _e( "Close", "buddypress" ) ?>';
    227     var bp_terms_mention_explain = '<?php printf( __( "%s is a unique identifier for %s that you can type into any message on this site. %s will be sent a notification and a link to your message any time you use it.", "buddypress" ), '@' . bp_get_displayed_user_username(), bp_get_user_firstname(bp_get_displayed_user_fullname()), bp_get_user_firstname(bp_get_displayed_user_fullname()) ); ?>';
    228     </script>
    229 <?php
    230 }
    231 add_action( 'wp_footer', 'bp_dtheme_js_terms' );
    232337
    233338// Member Buttons
    234 add_action( 'bp_member_header_actions',    'bp_add_friend_button' );
    235 add_action( 'bp_member_header_actions',    'bp_send_public_message_button' );
    236 add_action( 'bp_member_header_actions',    'bp_send_private_message_button' );
     339if ( bp_is_active( 'friends' ) )
     340    add_action( 'bp_member_header_actions',    'bp_add_friend_button' );
     341
     342if ( bp_is_active( 'activity' ) )
     343    add_action( 'bp_member_header_actions',    'bp_send_public_message_button' );
     344
     345if ( bp_is_active( 'messages' ) )
     346    add_action( 'bp_member_header_actions',    'bp_send_private_message_button' );
    237347
    238348// Group Buttons
    239 add_action( 'bp_group_header_actions',     'bp_group_join_button' );
    240 add_action( 'bp_group_header_actions',     'bp_group_new_topic_button' );
    241 add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
     349if ( bp_is_active( 'groups' ) ) {
     350    add_action( 'bp_group_header_actions',     'bp_group_join_button' );
     351    add_action( 'bp_group_header_actions',     'bp_group_new_topic_button' );
     352    add_action( 'bp_directory_groups_actions', 'bp_group_join_button' );
     353}
    242354
    243355// Blog Buttons
    244 add_action( 'bp_directory_blogs_actions',  'bp_blogs_visit_blog_button' );
     356if ( bp_is_active( 'blogs' ) )
     357    add_action( 'bp_directory_blogs_actions',  'bp_blogs_visit_blog_button' );
    245358
    246359?>
  • trunk/bp-themes/bp-default/groups/create.php

    r2770 r3300  
    5353                            </div>
    5454                        <?php else : ?>
    55                             <?php if ( is_site_admin() ) : ?>
     55                            <?php if ( is_super_admin() ) : ?>
    5656                                <div class="checkbox">
    5757                                    <label><input type="checkbox" disabled="disabled" name="disabled" id="disabled" value="0" /> <?php printf( __('<strong>Attention Site Admin:</strong> Group forums require the <a href="%s">correct setup and configuration</a> of a bbPress installation.', 'buddypress' ), bp_get_root_domain() . '/wp-admin/admin.php?page=bb-forums-setup' ) ?></label>
  • trunk/bp-themes/bp-default/groups/groups-loop.php

    r3263 r3300  
    55<?php if ( bp_has_groups( bp_ajax_querystring( 'groups' ) ) ) : ?>
    66
    7     <div class="pagination">
     7    <div id="pag-top" class="pagination">
    88
    9         <div class="pag-count" id="group-dir-count">
     9        <div class="pag-count" id="group-dir-count-top">
    1010            <?php bp_groups_pagination_count() ?>
    1111        </div>
    1212
    13         <div class="pagination-links" id="group-dir-pag">
     13        <div class="pagination-links" id="group-dir-pag-top">
    1414            <?php bp_groups_pagination_links() ?>
    1515        </div>
    1616
    1717    </div>
     18
     19    <?php do_action( 'bp_before_directory_groups_list' ) ?>
    1820
    1921    <ul id="groups-list" class="item-list">
     
    5355    </ul>
    5456
    55     <?php do_action( 'bp_after_groups_loop' ) ?>
     57    <?php do_action( 'bp_after_directory_groups_list' ) ?>
     58
     59    <div id="pag-bottom" class="pagination">
     60
     61        <div class="pag-count" id="group-dir-count-bottom">
     62            <?php bp_groups_pagination_count() ?>
     63        </div>
     64
     65        <div class="pagination-links" id="group-dir-pag-bottom">
     66            <?php bp_groups_pagination_links() ?>
     67        </div>
     68
     69    </div>
    5670
    5771<?php else: ?>
     
    6276
    6377<?php endif; ?>
     78
     79<?php do_action( 'bp_after_groups_loop' ) ?>
  • trunk/bp-themes/bp-default/groups/index.php

    r3232 r3300  
    1515            <div class="item-list-tabs">
    1616                <ul>
    17                     <li class="selected" id="groups-all"><a href="<?php bp_root_domain() ?>"><?php printf( __( 'All Groups (%s)', 'buddypress' ), bp_get_total_group_count() ) ?></a></li>
     17                    <li class="selected" id="groups-all"><a href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG ?>"><?php printf( __( 'All Groups (%s)', 'buddypress' ), bp_get_total_group_count() ) ?></a></li>
    1818
    1919                    <?php if ( is_user_logged_in() && bp_get_total_group_count_for_user( bp_loggedin_user_id() ) ) : ?>
     
    3838            </div><!-- .item-list-tabs -->
    3939
    40             <?php do_action( 'bp_before_directory_groups_list' ) ?>
    41 
    4240            <div id="groups-dir-list" class="groups dir-list">
    4341                <?php locate_template( array( 'groups/groups-loop.php' ), true ) ?>
  • trunk/bp-themes/bp-default/groups/single/activity.php

    r2539 r3300  
    11<div class="item-list-tabs no-ajax" id="subnav">
    22    <ul>
    3         <li class="feed"><a href="<?php bp_group_activity_feed_link() ?>" title="RSS Feed"><?php _e( 'RSS', 'buddypress' ) ?></a></li>
     3        <li class="feed"><a href="<?php bp_group_activity_feed_link() ?>" title="<?php _e( 'RSS Feed', 'buddypress' ); ?>"><?php _e( 'RSS', 'buddypress' ) ?></a></li>
    44
    55        <?php do_action( 'bp_group_activity_syndication_options' ) ?>
     
    3434<div class="activity single-group">
    3535    <?php locate_template( array( 'activity/activity-loop.php' ), true ) ?>
    36 </div><!-- .activity -->
     36</div><!-- .activity.single-group -->
    3737
    3838<?php do_action( 'bp_after_group_activity_content' ) ?>
  • trunk/bp-themes/bp-default/groups/single/admin.php

    r3263 r3300  
    195195                <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
    196196
    197                     <?php if ( bp_get_group_member_is_banned() ) : ?>
    198 
    199                         <li class="banned-user">
    200                             <?php bp_group_member_avatar_mini() ?>
    201 
    202                             <h5><?php bp_group_member_link() ?> <?php _e( '(banned)', 'buddypress') ?> <span class="small"> - <a href="<?php bp_group_member_unban_link() ?>" class="confirm" title="<?php _e( 'Kick and ban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a> </h5>
    203 
    204                     <?php else : ?>
    205 
    206                         <li>
    207                             <?php bp_group_member_avatar_mini() ?>
    208                             <h5><?php bp_group_member_link() ?>  <span class="small"> - <a href="<?php bp_group_member_ban_link() ?>" class="confirm" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick &amp; Ban', 'buddypress' ); ?></a> | <a href="<?php bp_group_member_promote_mod_link() ?>" class="confirm" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a> | <a href="<?php bp_group_member_promote_admin_link() ?>" class="confirm" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a></span></h5>
    209 
    210                     <?php endif; ?>
    211 
    212                             <?php do_action( 'bp_group_manage_members_admin_item' ); ?>
    213                         </li>
     197                    <li class="<?php bp_group_member_css_class(); ?>">
     198                        <?php bp_group_member_avatar_mini() ?>
     199
     200                        <h5>
     201                            <?php bp_group_member_link() ?>
     202                           
     203                            <?php if ( bp_get_group_member_is_banned() ) _e( '(banned)', 'buddypress'); ?>
     204
     205                            <span class="small"> -
     206                           
     207                            <?php if ( bp_get_group_member_is_banned() ) : ?>
     208                               
     209                                <a href="<?php bp_group_member_unban_link() ?>" class="confirm" title="<?php _e( 'Unban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a>
     210
     211                            <?php else : ?>
     212
     213                                <a href="<?php bp_group_member_ban_link() ?>" class="confirm" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick &amp; Ban', 'buddypress' ); ?></a>
     214                                | <a href="<?php bp_group_member_promote_mod_link() ?>" class="confirm" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a>
     215                                | <a href="<?php bp_group_member_promote_admin_link() ?>" class="confirm" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a>
     216
     217                            <?php endif; ?>
     218
     219                                | <a href="<?php bp_group_member_remove_link() ?>" class="confirm" title="<?php _e( 'Remove this member', 'buddypress' ); ?>"><?php _e( 'Remove from group', 'buddypress' ); ?></a>
     220
     221                                <?php do_action( 'bp_group_manage_members_admin_item' ); ?>
     222
     223                            </span>
     224                        </h5>
     225                    </li>
    214226
    215227                <?php endwhile; ?>
     
    299311
    300312<?php /* This is important, don't forget it */ ?>
    301 <input type="hidden" name="group-id" id="group-id" value="<?php bp_group_id() ?>" />
     313    <input type="hidden" name="group-id" id="group-id" value="<?php bp_group_id() ?>" />
    302314
    303315<?php do_action( 'bp_after_group_admin_content' ) ?>
    304316
    305 </form>
    306 
     317</form><!-- #group-settings-form -->
     318
  • trunk/bp-themes/bp-default/groups/single/forum.php

    r2488 r3300  
    1111    <div class="forums single-forum">
    1212        <?php locate_template( array( 'forums/forums-loop.php' ), true ) ?>
    13     </div><!-- .forums -->
     13    </div><!-- .forums.single-forum -->
    1414
    15     <?php do_action( 'bp_after_group_forum_content' ) ?>
     15<?php endif; ?>
     16
     17<?php do_action( 'bp_after_group_forum_content' ) ?>
     18
     19<?php if ( !bp_is_group_forum_topic_edit() && !bp_is_group_forum_topic() ) : ?>
    1620
    1721    <?php if ( ( is_user_logged_in() && 'public' == bp_get_group_status() ) || bp_group_is_member() ) : ?>
     
    2226                <?php do_action( 'bp_before_group_forum_post_new' ) ?>
    2327
    24                 <?php if ( !bp_group_is_member() ) : ?>
     28                <?php if ( bp_groups_auto_join() && !bp_group_is_member() ) : ?>
    2529                    <p><?php _e( 'You will auto join this group when you start a new topic.', 'buddypress' ) ?></p>
    2630                <?php endif; ?>
     
    4650                <?php wp_nonce_field( 'bp_forums_new_topic' ) ?>
    4751            </div><!-- #post-new-topic -->
    48         </form>
     52        </form><!-- #forum-topic-form -->
    4953
    5054    <?php endif; ?>
  • trunk/bp-themes/bp-default/groups/single/forum/edit.php

    r2714 r3300  
     1<?php do_action( 'bp_before_group_forum_edit_form' ) ?>
     2
    13<?php if ( bp_has_forum_topic_posts() ) : ?>
    24
     
    57        <div id="topic-meta">
    68            <h3><?php bp_the_topic_title() ?> (<?php bp_the_topic_total_post_count() ?>)</h3>
    7             <a class="button" href="<?php bp_forum_permalink() ?>/">&larr; <?php _e( 'Group Forum', 'buddypress' ) ?></a> &nbsp; <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a></span>
     9            <a class="button" href="<?php bp_forum_permalink() ?>/">&larr; <?php _e( 'Group Forum', 'buddypress' ) ?></a> &nbsp; <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a>
    810
    911            <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_is_mine() ) : ?>
     
    5860        <?php endif; ?>
    5961
    60     </form>
     62    </form><!-- #forum-topic-form -->
    6163
    6264<?php else: ?>
     
    6769
    6870<?php endif;?>
     71
     72<?php do_action( 'bp_after_group_forum_edit_form' ) ?>
  • trunk/bp-themes/bp-default/groups/single/forum/topic.php

    r2695 r3300  
     1<?php do_action( 'bp_before_group_forum_topic' ) ?>
     2
    13<?php if ( bp_has_forum_topic_posts() ) : ?>
    24
     
    1719        <div id="topic-meta">
    1820            <h3><?php bp_the_topic_title() ?> (<?php bp_the_topic_total_post_count() ?>)</h3>
    19             <a class="button" href="<?php bp_forum_permalink() ?>/">&larr; <?php _e( 'Group Forum', 'buddypress' ) ?></a> &nbsp; <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a></span>
     21            <a class="button" href="<?php bp_forum_permalink() ?>/">&larr; <?php _e( 'Group Forum', 'buddypress' ) ?></a> &nbsp; <a class="button" href="<?php bp_forum_directory_permalink() ?>/"><?php _e( 'Group Forum Directory', 'buddypress') ?></a>
    2022
    21             <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_is_mine() ) : ?>
    22                 <div class="admin-links"><?php bp_the_topic_admin_links() ?></div>
    23             <?php endif; ?>
     23            <div class="admin-links">
     24                <?php if ( bp_group_is_admin() || bp_group_is_mod() || bp_get_the_topic_is_mine() ) : ?>
     25                    <?php bp_the_topic_admin_links() ?>
     26                <?php endif; ?>
     27
     28                <?php do_action( 'bp_group_forum_topic_meta' ); ?>
     29            </div>
    2430        </div>
     31
     32        <?php do_action( 'bp_before_group_forum_topic_posts' ) ?>
    2533
    2634        <ul id="topic-post-list" class="item-list">
    2735            <?php while ( bp_forum_topic_posts() ) : bp_the_forum_topic_post(); ?>
    2836
    29                 <li id="post-<?php bp_the_topic_post_id() ?>">
     37                <li id="post-<?php bp_the_topic_post_id() ?>" class="<?php bp_the_topic_post_css_class() ?>">
    3038                    <div class="poster-meta">
    3139                        <a href="<?php bp_the_topic_post_poster_link() ?>">
     
    4351                            <?php bp_the_topic_post_admin_links() ?>
    4452                        <?php endif; ?>
     53
     54                        <?php do_action( 'bp_group_forum_post_meta' ); ?>
     55
    4556                        <a href="#post-<?php bp_the_topic_post_id() ?>" title="<?php _e( 'Permanent link to this post', 'buddypress' ) ?>">#</a>
    4657                    </div>
     
    4859
    4960            <?php endwhile; ?>
    50         </ul>
     61        </ul><!-- #topic-post-list -->
     62
     63        <?php do_action( 'bp_after_group_forum_topic_posts' ) ?>
    5164
    5265        <div class="pagination no-ajax">
     
    7184                        <p id="post-reply"></p>
    7285
    73                         <?php if ( !bp_group_is_member() ) : ?>
     86                        <?php if ( bp_groups_auto_join() && !bp_group_is_member() ) : ?>
    7487                            <p><?php _e( 'You will auto join this group when you reply to this topic.', 'buddypress' ) ?></p>
    7588                        <?php endif; ?>
     
    102115        <?php endif; ?>
    103116
    104     </form>
     117    </form><!-- #forum-topic-form -->
    105118<?php else: ?>
    106119
     
    110123
    111124<?php endif;?>
     125
     126<?php do_action( 'bp_after_group_forum_topic' ) ?>
  • trunk/bp-themes/bp-default/groups/single/group-header.php

    r2626 r3300  
    3636        <?php bp_group_description() ?>
    3737
    38         <?php bp_group_join_button() ?>
     38        <div id="item-buttons">
     39
     40            <?php do_action( 'bp_group_header_actions' ); ?>
     41
     42        </div><!-- #item-buttons -->
    3943
    4044        <?php do_action( 'bp_group_header_meta' ) ?>
  • trunk/bp-themes/bp-default/groups/single/home.php

    r2740 r3300  
    99            <div id="item-header">
    1010                <?php locate_template( array( 'groups/single/group-header.php' ), true ) ?>
    11             </div>
     11            </div><!-- #item-header -->
    1212
    1313            <div id="item-nav">
     
    1919                    </ul>
    2020                </div>
    21             </div>
     21            </div><!-- #item-nav -->
    2222
    2323            <div id="item-body">
     
    6161
    6262                <?php do_action( 'bp_after_group_body' ) ?>
    63             </div>
     63            </div><!-- #item-body -->
    6464
    6565            <?php do_action( 'bp_after_group_home_content' ) ?>
  • trunk/bp-themes/bp-default/groups/single/plugins.php

    r2822 r3300  
    99            <div id="item-header">
    1010                <?php locate_template( array( 'groups/single/group-header.php' ), true ) ?>
    11             </div>
     11            </div><!-- #item-header -->
    1212
    1313            <div id="item-nav">
     
    1919                    </ul>
    2020                </div>
    21             </div>
     21            </div><!-- #item-nav -->
    2222
    2323            <div id="item-body">
    2424
     25                <?php do_action( 'bp_before_group_body' ) ?>
     26
    2527                <?php do_action( 'bp_template_content' ) ?>
    2628
     29                <?php do_action( 'bp_after_group_body' ) ?>
    2730            </div><!-- #item-body -->
    2831
  • trunk/bp-themes/bp-default/groups/single/request-membership.php

    r2278 r3300  
    22
    33<?php if ( !bp_group_has_requested_membership() ) : ?>
    4     <p><?php printf( __( "You are requesting to become a member of the group '%s'.", "buddypress" ), bp_group_name( false, false ) ); ?></p>
     4    <p><?php printf( __( "You are requesting to become a member of the group '%s'.", "buddypress" ), bp_get_group_name( false ) ); ?></p>
    55
    66    <form action="<?php bp_group_form_action('request-membership') ?>" method="post" name="request-membership-form" id="request-membership-form" class="standard-form">
     
    1313
    1414        <?php wp_nonce_field( 'groups_request_membership' ) ?>
    15     </form>
     15    </form><!-- #request-membership-form -->
    1616<?php endif; ?>
    1717
  • trunk/bp-themes/bp-default/groups/single/send-invites.php

    r2339 r3300  
    1515            </div>
    1616
    17         </div>
     17        </div><!-- .left-menu -->
    1818
    1919        <div class="main-column">
     
    4949
    5050            <?php endif; ?>
    51             </ul>
     51            </ul><!-- #friend-list -->
    5252
    5353            <?php do_action( 'bp_after_group_send_invites_list' ) ?>
    5454
    55         </div>
     55        </div><!-- .main-column -->
    5656
    5757        <div class="clear"></div>
     
    6363        <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites') ?>
    6464
    65         <!-- Don't leave out this hidden field -->
     65        <?php /* This is important, don't forget it */ ?>
    6666        <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id() ?>" />
    67     </form>
     67
     68    </form><!-- #send-invite-form -->
    6869
    6970<?php else : ?>
  • trunk/bp-themes/bp-default/header.php

    r2863 r3300  
    5757                <div class="padder">
    5858
    59                 <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
    60                     <input type="text" id="search-terms" name="search-terms" value="" />
    61                     <?php echo bp_search_form_type_select() ?>
     59                <?php if ( bp_search_form_enabled() ) : ?>
    6260
    63                     <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    64                     <?php wp_nonce_field( 'bp_search_form' ) ?>
    65                 </form><!-- #search-form -->
     61                    <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
     62                        <input type="text" id="search-terms" name="search-terms" value="" />
     63                        <?php echo bp_search_form_type_select() ?>
     64
     65                        <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
     66                        <?php wp_nonce_field( 'bp_search_form' ) ?>
     67                    </form><!-- #search-form -->
     68
     69                <?php endif; ?>
    6670
    6771                <?php do_action( 'bp_search_login_bar' ) ?>
  • trunk/bp-themes/bp-default/index.php

    r2694 r3300  
    2424                            <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    2525
    26                             <p class="date"><?php the_time('F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>
     26                            <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>
    2727
    2828                            <div class="entry">
  • trunk/bp-themes/bp-default/members/index.php

    r2908 r3300  
    4141            </div><!-- .item-list-tabs -->
    4242
    43             <?php do_action( 'bp_before_directory_members_list' ) ?>
    44 
    4543            <div id="members-dir-list" class="members dir-list">
    4644                <?php locate_template( array( 'members/members-loop.php' ), true ) ?>
  • trunk/bp-themes/bp-default/members/members-loop.php

    r3263 r3300  
    55<?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>
    66
    7     <div class="pagination">
     7    <div id="pag-top" class="pagination">
    88
    9         <div class="pag-count" id="member-dir-count">
     9        <div class="pag-count" id="member-dir-count-top">
    1010            <?php bp_members_pagination_count() ?>
    1111        </div>
    1212
    13         <div class="pagination-links" id="member-dir-pag">
     13        <div class="pagination-links" id="member-dir-pag-top">
    1414            <?php bp_members_pagination_links() ?>
    1515        </div>
     
    7070    <?php bp_member_hidden_fields() ?>
    7171
     72    <div id="pag-bottom" class="pagination">
     73
     74        <div class="pag-count" id="member-dir-count-bottom">
     75            <?php bp_members_pagination_count() ?>
     76        </div>
     77
     78        <div class="pagination-links" id="member-dir-pag-bottom">
     79            <?php bp_members_pagination_links() ?>
     80        </div>
     81
     82    </div>
     83
    7284<?php else: ?>
    7385
  • trunk/bp-themes/bp-default/members/single/blogs.php

    r2586 r3300  
    2020<div class="blogs myblogs">
    2121    <?php locate_template( array( 'blogs/blogs-loop.php' ), true ) ?>
    22 </div><!-- .blogs -->
     22</div><!-- .blogs.myblogs -->
    2323
    2424<?php do_action( 'bp_after_member_blogs_content' ) ?>
  • trunk/bp-themes/bp-default/members/single/friends.php

    r2488 r3300  
    2828    <div class="members friends">
    2929        <?php locate_template( array( 'members/members-loop.php' ), true ) ?>
    30     </div>
     30    </div><!-- .members.friends -->
    3131
    3232    <?php do_action( 'bp_after_member_friends_content' ) ?>
  • trunk/bp-themes/bp-default/members/single/groups.php

    r2586 r3300  
    99
    1010            <?php _e( 'Order By:', 'buddypress' ) ?>
    11             <select id="groups-all">
     11            <select id="groups-sort-by">
    1212                <option value="active"><?php _e( 'Last Active', 'buddypress' ) ?></option>
    1313                <option value="popular"><?php _e( 'Most Members', 'buddypress' ) ?></option>
     
    2020        <?php endif; ?>
    2121    </ul>
    22 </div>
     22</div><!-- .item-list-tabs -->
    2323
    2424<?php if ( 'invites' == bp_current_action() ) : ?>
  • trunk/bp-themes/bp-default/members/single/home.php

    r3232 r3300  
    1515                        <?php bp_get_displayed_user_nav() ?>
    1616
    17                         <?php do_action( 'bp_members_directory_member_types' ) ?>
     17                        <?php do_action( 'bp_member_options_nav' ) ?>
    1818                    </ul>
    1919                </div>
     
    4141                    <?php locate_template( array( 'members/single/profile.php' ), true ) ?>
    4242
     43                <?php else : ?>
     44                    <?php
     45                        /* If nothing sticks, just load a member front template if one exists. */
     46                        locate_template( array( 'members/single/front.php' ), true );
     47                    ?>
    4348                <?php endif; ?>
    4449
  • trunk/bp-themes/bp-default/members/single/member-header.php

    r3263 r3300  
    99<div id="item-header-content">
    1010
    11     <h2 class="fn"><a href="<?php bp_user_link() ?>"><?php bp_displayed_user_fullname() ?></a> <span class="highlight">@<?php bp_displayed_user_username() ?> <span>?</span></span></h2>
     11    <h2 class="fn"><a href="<?php bp_displayed_user_link() ?>"><?php bp_displayed_user_fullname() ?></a> <span class="highlight">@<?php bp_displayed_user_username() ?> <span>?</span></span></h2>
    1212    <span class="activity"><?php bp_last_activity( bp_displayed_user_id() ) ?></span>
    1313
  • trunk/bp-themes/bp-default/members/single/messages.php

    r2397 r3300  
    33        <?php bp_get_options_nav() ?>
    44    </ul>
    5 </div>
     5</div><!-- .item-list-tabs -->
    66
    77<?php if ( 'compose' == bp_current_action() ) : ?>
     
    2323
    2424        <?php endif; ?>
    25     </div>
     25    </div><!-- .messages -->
    2626
    2727    <?php do_action( 'bp_after_member_messages_content' ) ?>
  • trunk/bp-themes/bp-default/members/single/messages/compose.php

    r2191 r3300  
    1111    </ul>
    1212
    13     <?php if ( is_site_admin() ) : ?>
     13    <?php if ( is_super_admin() ) : ?>
    1414        <input type="checkbox" id="send-notice" name="send-notice" value="1" /> <?php _e( "This is a notice to all users.", "buddypress" ) ?>
    1515    <?php endif; ?>
  • trunk/bp-themes/bp-default/members/single/messages/messages-loop.php

    r2502 r3300  
    1818    <?php do_action( 'bp_before_member_messages_threads' ) ?>
    1919
    20     <table id="message-threads">
     20    <table id="message-threads" class="zebra">
    2121        <?php while ( bp_message_threads() ) : bp_message_thread(); ?>
    2222
  • trunk/bp-themes/bp-default/members/single/messages/notices-loop.php

    r2397 r3300  
    1818    <?php do_action( 'bp_before_notices' ) ?>
    1919
    20     <table id="message-threads">
     20    <table id="message-threads" class="zebra">
    2121        <?php while ( bp_message_threads() ) : bp_message_thread(); ?>
    2222            <tr>
  • trunk/bp-themes/bp-default/members/single/plugins.php

    r2822 r3300  
    88            <div id="item-header">
    99                <?php locate_template( array( 'members/single/member-header.php' ), true ) ?>
    10             </div>
     10            </div><!-- #item-header -->
    1111
    1212            <div id="item-nav">
     
    1414                    <ul>
    1515                        <?php bp_get_displayed_user_nav() ?>
     16
     17                        <?php do_action( 'bp_member_options_nav' ) ?>
    1618                    </ul>
    1719                </div>
    18             </div>
     20            </div><!-- #item-nav -->
    1921
    2022            <div id="item-body">
     23                <?php do_action( 'bp_before_member_body' ) ?>
    2124
    2225                <div class="item-list-tabs no-ajax" id="subnav">
     
    2629                        <?php do_action( 'bp_member_plugin_options_nav' ) ?>
    2730                    </ul>
    28                 </div>
     31                </div><!-- .item-list-tabs -->
     32
     33                <?php do_action( 'bp_template_title' ) ?>
    2934
    3035                <?php do_action( 'bp_template_content' ) ?>
     36
     37                <?php do_action( 'bp_after_member_body' ) ?>
    3138
    3239            </div><!-- #item-body -->
     
    3946    <?php locate_template( array( 'sidebar.php' ), true ) ?>
    4047
    41     <?php do_action( 'bp_after_member_plugin_template' ) ?>
    42 
    4348<?php get_footer() ?>
  • trunk/bp-themes/bp-default/members/single/profile.php

    r2287 r3300  
    44            <?php bp_get_options_nav() ?>
    55        </ul>
    6     </div>
     6    </div><!-- .item-list-tabs -->
    77<?php endif; ?>
    88
  • trunk/bp-themes/bp-default/members/single/profile/edit.php

    r3232 r3300  
    4848                        <?php bp_the_profile_field_options() ?>
    4949                    </select>
     50
     51                    <?php if ( !bp_get_the_profile_field_is_required() ) : ?>
     52                        <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a>
     53                    <?php endif; ?>
    5054
    5155                <?php endif; ?>
  • trunk/bp-themes/bp-default/members/single/profile/profile-loop.php

    r2585 r3300  
    1616                    <?php endif; ?>
    1717
    18                     <table class="profile-fields">
     18                    <table class="profile-fields zebra">
    1919                        <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    2020
    2121                            <?php if ( bp_field_has_data() ) : ?>
    22                                 <tr>
     22                                <tr<?php bp_field_css_class() ?>>
    2323
    2424                                    <td class="label">
  • trunk/bp-themes/bp-default/registration/register.php

    r2784 r3300  
    4646                <?php do_action( 'bp_after_account_details_fields' ) ?>
    4747
    48                 <?php do_action( 'bp_before_blog_details_fields' ) ?>
    49 
    50 
    5148                <?php /***** Extra Profile Details ******/ ?>
    5249
    5350                <?php if ( bp_is_active( 'xprofile' ) ) : ?>
    54                 <div class="register-section" id="profile-details-section">
    55 
    56                     <h4><?php _e( 'Profile Details', 'buddypress' ) ?></h4>
    57 
    58                     <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    59                     <?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    60 
    61                     <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    62 
    63                         <div class="editfield">
    64 
    65                             <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>
    66 
    67                                 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    68                                 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    69                                 <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="<?php bp_the_profile_field_edit_value() ?>" />
    70 
    71                             <?php endif; ?>
    72 
    73                             <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?>
    74 
    75                                 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    76                                 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    77                                 <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_edit_value() ?></textarea>
    78 
    79                             <?php endif; ?>
    80 
    81                             <?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?>
    82 
    83                                 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    84                                 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    85                                 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>">
    86                                     <?php bp_the_profile_field_options() ?>
    87                                 </select>
    88 
    89                             <?php endif; ?>
    90 
    91                             <?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?>
    92 
    93                                 <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    94                                 <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    95                                 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple">
    96                                     <?php bp_the_profile_field_options() ?>
    97                                 </select>
    98 
    99                             <?php endif; ?>
    100 
    101                             <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?>
    102 
    103                                 <div class="radio">
    104                                     <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
    105 
     51
     52                    <?php do_action( 'bp_before_signup_profile_fields' ) ?>
     53
     54                    <div class="register-section" id="profile-details-section">
     55
     56                        <h4><?php _e( 'Profile Details', 'buddypress' ) ?></h4>
     57
     58                        <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
     59                        <?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
     60
     61                        <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
     62
     63                            <div class="editfield">
     64
     65                                <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>
     66
     67                                    <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    10668                                    <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    107                                     <?php bp_the_profile_field_options() ?>
    108 
    109                                     <?php if ( !bp_get_the_profile_field_is_required() ) : ?>
    110                                         <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a>
    111                                     <?php endif; ?>
    112                                 </div>
    113 
    114                             <?php endif; ?>
    115 
    116                             <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?>
    117 
    118                                 <div class="checkbox">
    119                                     <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
    120 
     69                                    <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="<?php bp_the_profile_field_edit_value() ?>" />
     70
     71                                <?php endif; ?>
     72
     73                                <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?>
     74
     75                                    <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    12176                                    <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    122                                     <?php bp_the_profile_field_options() ?>
    123                                 </div>
    124 
    125                             <?php endif; ?>
    126 
    127                             <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?>
    128 
    129                                 <div class="datebox">
    130                                     <label for="<?php bp_the_profile_field_input_name() ?>_day"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
     77                                    <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_edit_value() ?></textarea>
     78
     79                                <?php endif; ?>
     80
     81                                <?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?>
     82
     83                                    <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    13184                                    <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    132 
    133                                     <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day">
    134                                         <?php bp_the_profile_field_options( 'type=day' ) ?>
     85                                    <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>">
     86                                        <?php bp_the_profile_field_options() ?>
    13587                                    </select>
    13688
    137                                     <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month">
    138                                         <?php bp_the_profile_field_options( 'type=month' ) ?>
     89                                <?php endif; ?>
     90
     91                                <?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?>
     92
     93                                    <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
     94                                    <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
     95                                    <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple">
     96                                        <?php bp_the_profile_field_options() ?>
    13997                                    </select>
    14098
    141                                     <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year">
    142                                         <?php bp_the_profile_field_options( 'type=year' ) ?>
    143                                     </select>
    144                                 </div>
    145 
    146                             <?php endif; ?>
    147 
    148                             <?php do_action( 'bp_custom_profile_edit_fields' ) ?>
    149 
    150                             <p class="description"><?php bp_the_profile_field_description() ?></p>
    151 
    152                         </div>
    153 
    154                     <?php endwhile; ?>
    155 
    156                     <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />
    157 
    158                     <?php endwhile; endif; endif; ?>
    159 
    160                 </div><!-- #profile-details-section -->
     99                                <?php endif; ?>
     100
     101                                <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?>
     102
     103                                    <div class="radio">
     104                                        <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
     105
     106                                        <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
     107                                        <?php bp_the_profile_field_options() ?>
     108
     109                                        <?php if ( !bp_get_the_profile_field_is_required() ) : ?>
     110                                            <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a>
     111                                        <?php endif; ?>
     112                                    </div>
     113
     114                                <?php endif; ?>
     115
     116                                <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?>
     117
     118                                    <div class="checkbox">
     119                                        <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
     120
     121                                        <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
     122                                        <?php bp_the_profile_field_options() ?>
     123                                    </div>
     124
     125                                <?php endif; ?>
     126
     127                                <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?>
     128
     129                                    <div class="datebox">
     130                                        <label for="<?php bp_the_profile_field_input_name() ?>_day"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
     131                                        <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
     132
     133                                        <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day">
     134                                            <?php bp_the_profile_field_options( 'type=day' ) ?>
     135                                        </select>
     136
     137                                        <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month">
     138                                            <?php bp_the_profile_field_options( 'type=month' ) ?>
     139                                        </select>
     140
     141                                        <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year">
     142                                            <?php bp_the_profile_field_options( 'type=year' ) ?>
     143                                        </select>
     144                                    </div>
     145
     146                                <?php endif; ?>
     147
     148                                <?php do_action( 'bp_custom_profile_edit_fields' ) ?>
     149
     150                                <p class="description"><?php bp_the_profile_field_description() ?></p>
     151
     152                            </div>
     153
     154                        <?php endwhile; ?>
     155
     156                        <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />
     157
     158                        <?php endwhile; endif; endif; ?>
     159
     160                    </div><!-- #profile-details-section -->
     161
     162                    <?php do_action( 'bp_after_signup_profile_fields' ) ?>
     163
    161164                <?php endif; ?>
    162 
    163                 <?php do_action( 'bp_after_signup_profile_fields' ) ?>
    164 
     165               
    165166                <?php if ( bp_get_blog_signup_allowed() ) : ?>
    166167
     
    180181                            <?php do_action( 'bp_signup_blog_url_errors' ) ?>
    181182
    182                             <?php if ( 'yes' == VHOST ) : ?>
     183                            <?php if ( is_subdomain_install() ) : ?>
    183184                                http:// <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value() ?>" /> .<?php echo str_replace( 'http://', '', site_url() ) ?>
    184185                            <?php else : ?>
     
    207208
    208209                <div class="submit">
    209                     <input type="submit"name="signup_submit" id="signup_submit" value="<?php _e( 'Complete Sign Up', 'buddypress' ) ?> &rarr;" />
     210                    <input type="submit" name="signup_submit" id="signup_submit" value="<?php _e( 'Complete Sign Up', 'buddypress' ) ?> &rarr;" />
    210211                </div>
    211212
  • trunk/bp-themes/bp-default/search.php

    r2425 r3300  
    3333                            <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    3434
    35                             <p class="date"><?php the_time('F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>
     35                            <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>
    3636
    3737                            <div class="entry">
  • trunk/bp-themes/bp-default/sidebar.php

    r3232 r3300  
    1515            </a>
    1616
    17             <h4><?php bp_loggedinuser_link() ?></h4>
     17            <h4><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></h4>
    1818            <a class="button logout" href="<?php echo wp_logout_url( bp_get_root_domain() ) ?>"><?php _e( 'Log Out', 'buddypress' ) ?></a>
    1919
     
    3838        </p>
    3939
    40         <form name="login-form" id="sidebar-login-form" class="standard-form" action="<?php echo site_url( 'wp-login.php', 'login' ) ?>" method="post">
     40        <form name="login-form" id="sidebar-login-form" class="standard-form" action="<?php echo site_url( 'wp-login.php', 'login_post' ) ?>" method="post">
    4141            <label><?php _e( 'Username', 'buddypress' ) ?><br />
    42             <input type="text" name="log" id="sidebar-user-login" class="input" value="<?php echo attribute_escape(stripslashes($user_login)); ?>" /></label>
     42            <input type="text" name="log" id="sidebar-user-login" class="input" value="<?php echo esc_attr(stripslashes($user_login)); ?>" /></label>
    4343
    4444            <label><?php _e( 'Password', 'buddypress' ) ?><br />
  • trunk/bp-themes/bp-default/single.php

    r2694 r3300  
    2727                        <h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    2828
    29                         <p class="date"><?php the_time('F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em></p>
     29                        <p class="date"><?php the_time() ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink( $post->post_author ) ) ?></em> <?php edit_post_link( __( 'Edit this entry', 'buddypress' ), '<em class="edit-link">', '</em>' ); ?></p>
    3030
    3131                        <div class="entry">
  • trunk/bp-xprofile.php

    r3232 r3300  
    1616 * @uses site_url() Returns the site URL
    1717 */
    18 
    1918function xprofile_setup_globals() {
    2019    global $bp, $wpdb;
     
    3029    $bp->profile->id = 'profile';
    3130
    32     $bp->profile->table_name_groups = $wpdb->base_prefix . 'bp_xprofile_groups';
    33     $bp->profile->table_name_fields = $wpdb->base_prefix . 'bp_xprofile_fields';
    34     $bp->profile->table_name_data = $wpdb->base_prefix . 'bp_xprofile_data';
     31    $bp->profile->slug = BP_XPROFILE_SLUG;
     32
     33    $bp->profile->table_name_data   = $bp->table_prefix . 'bp_xprofile_data';
     34    $bp->profile->table_name_groups = $bp->table_prefix . 'bp_xprofile_groups';
     35    $bp->profile->table_name_fields = $bp->table_prefix . 'bp_xprofile_fields';
    3536
    3637    $bp->profile->format_notification_function = 'xprofile_format_notifications';
    37     $bp->profile->slug = BP_XPROFILE_SLUG;
    3838
    3939    /* Register this in the active components array */
     
    5656 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    5757 * @global $wpdb WordPress DB access object.
    58  * @uses is_site_admin() returns true if the current user is a site admin, false if not
     58 * @uses is_super_admin() returns true if the current user is a site admin, false if not
    5959 * @uses bp_xprofile_install() runs the installation of DB tables for the xprofile component
    6060 * @uses wp_enqueue_script() Adds a JS file to the JS queue ready for output
     
    6666    global $wpdb, $bp;
    6767
    68     if ( !is_site_admin() )
     68    if ( !is_super_admin() )
    6969        return false;
    7070
     
    127127
    128128    /* Don't show this menu to non site admins or if you're viewing your own profile */
    129     if ( !is_site_admin() || bp_is_my_profile() )
    130         return false; ?>
    131 
     129    if ( !is_super_admin() || bp_is_my_profile() )
     130        return false;
     131    ?>
    132132    <li id="bp-adminbar-adminoptions-menu">
    133133        <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
    134134
    135135        <ul>
    136             <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
    137             <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
    138 <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
    139             <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>
    140 <?php else : ?>
    141 
    142             <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
    143 <?php endif; ?>
    144 
    145             <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
    146 <?php do_action( 'xprofile_adminbar_menu_items' ) ?>
    147 
     136            <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     137            <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     138
     139            <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
     140                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>
     141            <?php else : ?>
     142                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
     143            <?php endif; ?>
     144
     145            <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     146
     147            <?php do_action( 'xprofile_adminbar_menu_items' ) ?>
    148148        </ul>
    149149    </li>
    150 <?php
     150    <?php
    151151}
    152152add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 );
     
    188188    global $bp;
    189189
    190     if ( !bp_is_my_profile() && !is_site_admin() )
     190    if ( !bp_is_my_profile() && !is_super_admin() )
    191191        return false;
    192192
     
    235235        }
    236236
    237         if ( $errors )
     237        if ( !empty( $errors ) )
    238238            bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );
    239239        else {
     
    249249            }
    250250
    251             do_action( 'xprofile_updated_profile', $posted_field_ids, $errors );
     251            do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors );
    252252
    253253            /* Set the feedback messages */
     
    278278    global $bp;
    279279
    280     if ( !bp_is_my_profile() && !is_site_admin() )
     280    if ( !bp_is_my_profile() && !is_super_admin() )
    281281        return false;
    282282
     
    347347    check_admin_referer( 'bp_delete_avatar_link' );
    348348
    349     if ( !bp_is_my_profile() && !is_site_admin() )
     349    if ( !bp_is_my_profile() && !is_super_admin() )
    350350        return false;
    351351
     
    406406        'item_id' => false,
    407407        'secondary_item_id' => false,
    408         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     408        'recorded_time' => bp_core_current_time(),
    409409        'hide_sitewide' => false
    410410    );
     
    642642        return false;
    643643
     644    /* If the value is empty, then delete any field data that exists */
     645    if ( empty( $value ) ) {
     646        xprofile_delete_field_data( $field_id, $user_id );
     647        return true;
     648    }
     649
    644650    $field = new BP_XProfile_Field( $field_id );
    645651
    646     /* Check that value is acceptable */
     652    /* Check the value is an acceptable value */
    647653    if ( 'checkbox' == $field->type || 'radio' == $field->type || 'selectbox' == $field->type || 'multiselectbox' == $field->type ) {
    648654        $options = $field->get_children();
    649 
    650         /* Not required fields can have empty value */
    651         if ( !$is_required )
    652             $possible_values[] = '';
    653655
    654656        foreach( $options as $option )
     
    661663            }
    662664
    663             /* Field must be required to trigger error */
    664             if ( $is_required && empty( $value ) )
     665            if ( empty( $value ) )
    665666                return false;
    666667
     
    687688        $field_id = xprofile_get_field_id_from_name( $field );
    688689
    689     if ( !$field_id )
    690         return false;
    691 
    692     $field = new BP_XProfile_ProfileData( $field_id );
     690    if ( empty( $field_id ) || empty( $user_id ) )
     691        return false;
     692
     693    $field = new BP_XProfile_ProfileData( $field_id, $user_id );
    693694    return $field->delete();
    694695}
     
    796797        @wp_mkdir_p( $path );
    797798
    798     $newurl = str_replace( BP_AVATAR_UPLOAD_PATH, BP_AVATAR_URL, $path );
     799    $newurl  = BP_AVATAR_URL . '/avatars/' . $user_id;
    799800    $newburl = $newurl;
    800801    $newsubdir = '/avatars/' . $user_id;
     
    833834    }
    834835
    835     update_usermeta( $user_id, 'nickname', $fullname );
    836     update_usermeta( $user_id, 'first_name', $firstname );
    837     update_usermeta( $user_id, 'last_name', $lastname );
     836    update_user_meta( $user_id, 'nickname', $fullname );
     837    update_user_meta( $user_id, 'first_name', $firstname );
     838    update_user_meta( $user_id, 'last_name', $lastname );
    838839
    839840    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
     
    842843add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
    843844add_action( 'bp_core_signup_user', 'xprofile_sync_wp_profile' );
     845
     846
     847/* xprofile_sync_bp_profile()
     848 *
     849 * Syncs the standard built in WordPress profile data to XProfile.
     850 *
     851 * @since 1.2.4
     852 * @package BuddyPress Core
     853 */
     854function xprofile_sync_bp_profile( &$errors, $update, &$user ) {
     855    global $bp;
     856
     857    if ( (int)$bp->site_options['bp-disable-profile-sync'] || !$update || $errors->get_error_codes() )
     858        return;
     859
     860    xprofile_set_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $user->ID, $user->display_name );
     861}
     862add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 10, 3 );
    844863
    845864/**
     
    869888 * @package BuddyPress XProfile
    870889 * @param $user_id The ID of the deleted user
    871  * @uses get_usermeta() Get a user meta value based on meta key from wp_usermeta
    872  * @uses delete_usermeta() Delete user meta value based on meta key from wp_usermeta
     890 * @uses get_user_meta() Get a user meta value based on meta key from wp_usermeta
     891 * @uses delete_user_meta() Delete user meta value based on meta key from wp_usermeta
    873892 * @uses delete_data_for_user() Removes all profile data from the xprofile tables for the user
    874893 */
     
    919938}
    920939
    921 /* List actions to clear object caches on */
     940// List actions to clear object caches on
    922941add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' );
    923942add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' );
    924943add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' );
    925944
    926 /* List actions to clear super cached pages on, if super cache is installed */
     945// List actions to clear super cached pages on, if super cache is installed
    927946add_action( 'xprofile_updated_profile', 'bp_core_clear_cache' );
    928947
  • trunk/bp-xprofile/admin/css/admin.css

    r3232 r3300  
    165165    }
    166166
    167     select.multi-select{
     167    select.multi-select {
    168168        width:90%;
    169169        height:10em !important;
     
    180180}
    181181
    182 ul.multi-checkbox li{
     182ul.multi-checkbox li {
    183183    padding: 0;
    184184    margin: 0;
  • trunk/bp-xprofile/admin/js/admin.js

    r2887 r3300  
    3737   
    3838    toDeleteText = document.createTextNode('[x]');
    39 
    4039    toDelete.setAttribute('href',"javascript:hide('" + forWhat + '_div' + theId + "')");
     40   
    4141    toDelete.setAttribute('class','delete');
     42
    4243    toDelete.appendChild(toDeleteText);
    4344
     
    5051    holder.appendChild(newDiv);
    5152   
     53   
    5254    theId++
    5355    document.getElementById(forWhat + "_option_number").value = theId;
     
    7476
    7577function hide(id) {
    76     if ( !document.getElementById(id) ) return;
     78    if ( !document.getElementById(id) ) return false;
    7779   
    7880    document.getElementById(id).style.display = "none";
     
    8082}
    8183
    82 /* Set up deleting options ajax */
     84// Set up deleting options ajax
    8385jQuery(document).ready( function() {
     86   
    8487    jQuery("a.ajax-option-delete").click(
    8588        function() {
     
    9194                'cookie': encodeURIComponent(document.cookie),
    9295                '_wpnonce': jQuery("input#_wpnonce").val(),
     96               
    9397                'option_id': theId
    9498            },
    95             function(response){});
     99            function(response)
     100            {});
    96101        }
    97     );
     102    );             
    98103});
    99104
    100 /* Main XProfile behavior layer */
     105var fixHelper = function(e, ui) {
     106    ui.children().each(function() {
     107        jQuery(this).width( jQuery(this).width() );
     108    });
     109    return ui;
     110};
     111
     112// Main XProfile behavior layer
    101113jQuery(document).ready( function() {
    102114    /* Show object if JS is enabled */
     
    137149                'field_group_id': jQuery(this).attr( 'id' )
    138150            },
    139             function(response){});
     151            function(response)
     152            {});
    140153        }
    141154    })
  • trunk/bp-xprofile/bp-xprofile-admin.php

    r3232 r3300  
    5959
    6060                <div id="message" class="<?php echo $type; ?> fade">
    61                     <p><?php echo wp_specialchars( attribute_escape( $message ) ); ?></p>
     61                    <p><?php echo wp_specialchars( esc_attr( $message ) ); ?></p>
    6262                </div>
    6363<?php       endif; ?>
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r3232 r3300  
    202202<?php endif; ?>
    203203            <div id="poststuff">
    204                 <form action="<?php echo attribute_escape( $action ); ?>" method="post">
     204                <form action="<?php echo esc_attr( $action ); ?>" method="post">
    205205                    <div id="titlediv">
    206206                        <h3><label for="group_name"><?php _e( "Field Group Title", 'buddypress') ?> *</label></h3>
    207207                        <div id="titlewrap">
    208                             <input type="text" name="group_name" id="title" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" />
     208                            <input type="text" name="group_name" id="title" value="<?php echo esc_attr( $this->name ); ?>" style="width:50%" />
    209209                        </div>
    210210                    </div>
     
    220220
    221221                    <p class="submit">
    222                         <input type="hidden" name="group_order" id="group_order" value="<?php echo attribute_escape( $this->group_order ); ?>" />
    223                         <input type="submit" name="save_group" value="<?php echo attribute_escape( $button ); ?>" class="button-primary"/>
     222                        <input type="hidden" name="group_order" id="group_order" value="<?php echo esc_attr( $this->group_order ); ?>" />
     223                        <input type="submit" name="save_group" value="<?php echo esc_attr( $button ); ?>" class="button-primary"/>
    224224                        <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a>
    225225                    </p>
     
    321321            $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET group_id = %d, parent_id = 0, type = %s, name = %s, description = %s, is_required = %d, order_by = %s, field_order = %d WHERE id = %d", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order, $this->id );
    322322        else
    323             $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, 0, %s, %s, %s, %d, %s, %d )", $this->group_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order );
     323            $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_fields} (group_id, parent_id, type, name, description, is_required, order_by, field_order ) VALUES (%d, %d, %s, %s, %s, %d, %s, %d )", $this->group_id, $this->parent_id, $this->type, $this->name, $this->description, $this->is_required, $this->order_by, $this->field_order );
    324324
    325325        /*
     
    547547?>
    548548                        <p><?php _e('Option', 'buddypress'); ?> <?php echo $j; ?>:
    549                            <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo attribute_escape( $options[$i]->name ); ?>" />
     549                           <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo esc_attr( $options[$i]->name ); ?>" />
    550550                           <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j; ?>" /> <?php _e( 'Default Value', 'buddypress' ); ?>
    551551<?php
     
    610610                    <h3><label for="title"><?php _e( 'Field Title', 'buddypress' ); ?> *</label></h3>
    611611                    <div id="titlewrap">
    612                         <input type="text" name="title" id="title" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" />
     612                        <input type="text" name="title" id="title" value="<?php echo esc_attr( $this->name ); ?>" style="width:50%" />
    613613                    </div>
    614614                </div>
     
    650650<?php   } ?>
    651651                <p class="submit">
    652                     <input type="hidden" name="field_order" id="field_order" value="<?php echo attribute_escape( $this->field_order ); ?>" />
     652                    <input type="hidden" name="field_order" id="field_order" value="<?php echo esc_attr( $this->field_order ); ?>" />
    653653                    <input type="submit" value="<?php _e( 'Save', 'buddypress' ); ?>" name="saveField" id="saveField" style="font-weight: bold" class="button-primary" />
    654654                    <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a>
  • trunk/bp-xprofile/bp-xprofile-filters.php

    r3254 r3300  
    129129    if ( $fullnames = BP_XProfile_ProfileData::get_value_byid( 1, $user_ids ) ) {
    130130        foreach( (array)$fullnames as $user ) {
    131             $users[$user->user_id] = trim( $user->value );
     131            $users[$user->user_id] = trim($user->value);
    132132        }
    133133    }
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r3232 r3300  
    2121    function bp_xprofile_data_template( $user_id, $profile_group_id ) {
    2222        $this->groups = BP_XProfile_Group::get( array(
    23             'profile_group_id'  => $profile_group_id,
    24             'user_id'           => $user_id,
    25             'hide_empty_groups' => true,
    26             'fetch_fields'      => true,
    27             'fetch_field_data'  => true
     23            'profile_group_id' => $profile_group_id,
     24            'user_id' => $user_id,
     25            'hide_empty_groups' => true,
     26            'fetch_fields' => true,
     27            'fetch_field_data' => true
    2828        ) );
    2929
    30         $this->group_count = count( $this->groups );
     30        $this->group_count = count($this->groups);
    3131        $this->user_id = $user_id;
    3232    }
     
    5151    function rewind_groups() {
    5252        $this->current_group = -1;
    53 
    54         if ( $this->group_count > 0 )
     53        if ( $this->group_count > 0 ) {
    5554            $this->group = $this->groups[0];
     55        }
    5656    }
    5757
     
    6060            return true;
    6161        } elseif ( $this->current_group + 1 == $this->group_count ) {
    62             do_action( 'xprofile_template_loop_end' );
    63             /* Do some cleaning up after the loop */
     62            do_action('xprofile_template_loop_end');
     63            // Do some cleaning up after the loop
    6464            $this->rewind_groups();
    6565        }
     
    7575        $group = $this->next_group();
    7676
    77         if ( 0 == $this->current_group ) /* loop has just started */
    78             do_action( 'xprofile_template_loop_start' );
     77        if ( 0 == $this->current_group ) // loop has just started
     78            do_action('xprofile_template_loop_start');
    7979    }
    8080
     
    9090    function rewind_fields() {
    9191        $this->current_field = -1;
    92 
    93         if ( $this->field_count > 0 )
     92        if ( $this->field_count > 0 ) {
    9493            $this->field = $this->group->fields[0];
     94        }
    9595    }
    9696
     
    101101            $field = &$this->group->fields[$i];
    102102
    103             if ( $field->data->value != null )
     103            if ( $field->data->value != null ) {
    104104                $has_data = true;
     105            }
    105106        }
    106107
     
    112113
    113114    function profile_fields() {
    114         if ( $this->current_field + 1 < $this->field_count )
     115        if ( $this->current_field + 1 < $this->field_count ) {
    115116            return true;
    116 
    117         /* Do some cleaning up after the loop */
    118         elseif ( $this->current_field + 1 == $this->field_count )
     117        } elseif ( $this->current_field + 1 == $this->field_count ) {
     118            // Do some cleaning up after the loop
    119119            $this->rewind_fields();
     120        }
    120121
    121122        return false;
     
    127128        $field = $this->next_field();
    128129
    129         if ( !empty( $field->data->value ) )
     130        if ( !empty( $field->data->value ) ) {
    130131            $this->field_has_data = true;
    131         else
     132        }
     133        else {
    132134            $this->field_has_data = false;
     135        }
    133136    }
    134137}
     
    177180
    178181        if ( $class )
    179             $css_classes[] = sanitize_title( attribute_escape( $class ) );
     182            $css_classes[] = sanitize_title( esc_attr( $class ) );
    180183
    181184        /* Set a class with the field ID */
     
    185188        $css_classes[] = 'field_' . sanitize_title( $profile_template->field->name );
    186189
    187         if ( $profile_template->current_field % 2 )
     190        if ( $profile_template->current_field % 2 == 1 )
    188191            $css_classes[] = 'alt';
    189192
     
    254257        global $group;
    255258
    256         foreach ( (array) $group->fields as $field ) {
     259        foreach ( (array) $group->fields as $field )
    257260            $field_ids .= $field->id . ',';
    258         }
    259261
    260262        return substr( $field_ids, 0, -1 );
     
    343345        global $field;
    344346
    345         return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id );
     347        $array_box = false;
     348        if ( 'multiselectbox' == $field->type )
     349            $array_box = '[]';
     350
     351        return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id . $array_box );
    346352    }
    347353
     
    369375                if ( 'multiselectbox' != $field->type )
    370376                    $html .= '<option value="">--------</option>';
     377
     378                for ( $k = 0; $k < count($options); $k++ ) {
     379                    $option_values = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id );
     380                    $option_values = (array)$option_values;
     381
     382                    /* Check for updated posted values, but errors preventing them from being saved first time */
     383                    foreach( (array)$option_values as $i => $option_value ) {
     384                        if ( isset( $_POST['field_' . $field->id] ) && $_POST['field_' . $field->id] != $option_value ) {
     385                            if ( !empty( $_POST['field_' . $field->id] ) )
     386                                $option_values[$i] = $_POST['field_' . $field->id];
     387                        }
     388                    }
     389
     390                    if ( in_array( $options[$k]->name, (array)$option_values ) || $options[$k]->is_default_option ) {
     391                        $selected = ' selected="selected"';
     392                    } else {
     393                        $selected = '';
     394                    }
     395
     396                    $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . esc_attr( $options[$k]->name ) . '">' . esc_attr( $options[$k]->name ) . '</option>', $options[$k] );
     397                }
     398                break;
     399
     400            case 'radio':
     401                $html = '<div id="field_' . $field->id . '">';
    371402
    372403                for ( $k = 0; $k < count($options); $k++ ) {
     
    379410                    }
    380411
    381                     if ( in_array( $options[$k]->name, (array)$option_values ) || $options[$k]->is_default_option )
    382                         $selected = ' selected="selected"';
    383                     else
     412                    if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option ) {
     413                        $selected = ' checked="checked"';
     414                    } else {
    384415                        $selected = '';
    385 
    386                     $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . attribute_escape( stripslashes( $options[$k]->name ) ) . '">' . attribute_escape( stripslashes( $options[$k]->name ) ) . '</option>', $options[$k] );
    387                 }
    388                 break;
    389 
    390             case 'radio':
    391                 $html = '<div id="field_' . $field->id . '">';
    392 
    393                 for ( $k = 0; $k < count( $options ); $k++ ) {
    394                     $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id );
    395 
    396                     /* Check for updated posted values, but errors preventing them from being saved first time */
    397                     if ( isset( $_POST['field_' . $field->id] ) && $option_value != $_POST['field_' . $field->id] ) {
    398                         if ( !empty( $_POST['field_' . $field->id] ) )
    399                             $option_value = $_POST['field_' . $field->id];
    400416                    }
    401417
    402                     if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option )
    403                         $selected = ' checked="checked"';
    404                     else
    405                         $selected = '';
    406 
    407                     $html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . attribute_escape( $options[$k]->name ) . '"> ' . attribute_escape( $options[$k]->name ) . '</label>', $options[$k] );
     418                    $html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . esc_attr( $options[$k]->name ) . '"> ' . esc_attr( $options[$k]->name ) . '</label>', $options[$k] );
    408419                }
    409420
     
    412423
    413424            case 'checkbox':
    414                 $option_values = BP_XProfile_ProfileData::get_value_byid( $options[0]->parent_id );
     425                $option_values = BP_XProfile_ProfileData::get_value_byid($options[0]->parent_id);
    415426
    416427                /* Check for updated posted values, but errors preventing them from being saved first time */
     
    420431                }
    421432
    422                 $option_values = maybe_unserialize( $option_values );
    423 
    424                 for ( $k = 0; $k < count( $options ); $k++ ) {
    425                     for ( $j = 0; $j < count( $option_values ); $j++ ) {
     433                $option_values = maybe_unserialize($option_values);
     434
     435                for ( $k = 0; $k < count($options); $k++ ) {
     436                    for ( $j = 0; $j < count($option_values); $j++ ) {
    426437                        if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) || $options[$k]->is_default_option ) {
    427438                            $selected = ' checked="checked"';
     
    430441                    }
    431442
    432                     $html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', '<label><input' . $selected . ' type="checkbox" name="field_' . $field->id . '[]" id="field_' . $options[$k]->id . '_' . $k . '" value="' . attribute_escape( $options[$k]->name ) . '"> ' . attribute_escape( $options[$k]->name ) . '</label>', $options[$k] );
     443                    $html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', '<label><input' . $selected . ' type="checkbox" name="field_' . $field->id . '[]" id="field_' . $options[$k]->id . '_' . $k . '" value="' . esc_attr( $options[$k]->name ) . '"> ' . esc_attr( $options[$k]->name ) . '</label>', $options[$k] );
    433444                    $selected = '';
    434445                }
     
    438449
    439450                if ( !empty( $field->data->value ) ) {
    440                     $day            = date("j", $field->data->value);
    441                     $month          = date("F", $field->data->value);
    442                     $year           = date("Y", $field->data->value);
    443                     $default_select = ' selected="selected"';
     451                    $day = date("j", $field->data->value);
     452                    $month = date("F", $field->data->value);
     453                    $year = date("Y", $field->data->value);
     454                    $default_select = ' selected="selected"';
    444455                }
    445456
     
    462473                switch ( $type ) {
    463474                    case 'day':
    464                         $html .= '<option value=""' . attribute_escape( $default_select ) . '>--</option>';
     475                        $html .= '<option value=""' . esc_attr( $default_select ) . '>--</option>';
    465476
    466477                        for ( $i = 1; $i < 32; $i++ ) {
    467                             if ( $day == $i )
     478                            if ( $day == $i ) {
    468479                                $selected = ' selected = "selected"';
    469                             else
     480                            } else {
    470481                                $selected = '';
    471 
     482                            }
    472483                            $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>';
    473484                        }
     
    483494                                );
    484495
    485                         $html .= '<option value=""' . attribute_escape( $default_select ) . '>------</option>';
     496                        $html .= '<option value=""' . esc_attr( $default_select ) . '>------</option>';
    486497
    487498                        for ( $i = 0; $i < 12; $i++ ) {
    488                             if ( $month == $eng_months[$i] )
     499                            if ( $month == $eng_months[$i] ) {
    489500                                $selected = ' selected = "selected"';
    490                             else
     501                            } else {
    491502                                $selected = '';
     503                            }
    492504
    493505                            $html .= '<option value="' . $eng_months[$i] . '"' . $selected . '>' . $months[$i] . '</option>';
     
    496508
    497509                    case 'year':
    498                         $html .= '<option value=""' . attribute_escape( $default_select ) . '>----</option>';
     510                        $html .= '<option value=""' . esc_attr( $default_select ) . '>----</option>';
    499511
    500512                        for ( $i = date( 'Y', time() ); $i > 1899; $i-- ) {
    501                             if ( $year == $i )
     513                            if ( $year == $i ) {
    502514                                $selected = ' selected = "selected"';
    503                             else
     515                            } else {
    504516                                $selected = '';
     517                            }
    505518
    506519                            $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>';
     
    523536        global $field;
    524537
    525         return apply_filters( 'bp_get_the_profile_field_is_required', (int) $field->is_required );
     538        return apply_filters( 'bp_get_the_profile_field_is_required', (int)$field->is_required );
    526539    }
    527540
    528541function bp_unserialize_profile_field( $value ) {
    529     if ( is_serialized( $value ) ) {
    530         $field_value = maybe_unserialize( $value );
     542    if ( is_serialized($value) ) {
     543        $field_value = maybe_unserialize($value);
    531544        $field_value = implode( ', ', $field_value );
    532545        return $field_value;
     
    541554    function bp_get_profile_field_data( $args = '' ) {
    542555        $defaults = array(
    543             'field'     => false, /* Field name or ID. */
    544             'user_id'   => $bp->displayed_user->id
    545         );
     556            'field' => false, // Field name or ID.
     557            'user_id' => $bp->displayed_user->id
     558            );
    546559
    547560        $r = wp_parse_args( $args, $defaults );
     
    562575        $group_name = bp_profile_group_name(false);
    563576
    564     for ( $i = 0; $i < count( $groups ); $i++ ) {
    565         if ( $group_name == $groups[$i]->name )
     577    for ( $i = 0; $i < count($groups); $i++ ) {
     578        if ( $group_name == $groups[$i]->name ) {
    566579            $selected = ' class="current"';
    567         else
     580        } else {
    568581            $selected = '';
     582        }
    569583
    570584        if ( $groups[$i]->fields )
    571             echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . attribute_escape( $groups[$i]->name ) . '</a></li>';
     585            echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . esc_attr( $groups[$i]->name ) . '</a></li>';
    572586    }
    573587
     
    584598
    585599    if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
    586         $group = new BP_XProfile_Group( $group_id );
     600        $group = new BP_XProfile_Group($group_id);
    587601        wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' );
    588602    }
    589603
    590     if ( !$deprecated )
     604    if ( !$deprecated ) {
    591605        return bp_get_profile_group_name();
    592     else
     606    } else {
    593607        echo bp_get_profile_group_name();
     608    }
    594609}
    595610    function bp_get_profile_group_name() {
     
    602617
    603618        if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) {
    604             $group = new BP_XProfile_Group( $group_id );
     619            $group = new BP_XProfile_Group($group_id);
    605620            wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' );
    606621        }
     
    623638    $last_updated = bp_get_profile_last_updated();
    624639
    625     if ( !$last_updated )
     640    if ( !$last_updated ) {
    626641        _e( 'Profile not recently updated', 'buddypress' ) . '.';
    627     else
     642    } else {
    628643        echo $last_updated;
     644    }
    629645}
    630646    function bp_get_profile_last_updated() {
    631647        global $bp;
    632648
    633         $last_updated = get_usermeta( $bp->displayed_user->id, 'profile_last_updated' );
     649        $last_updated = get_user_meta( $bp->displayed_user->id, 'profile_last_updated', true );
    634650
    635651        if ( $last_updated )
     
    648664            $profile_group_id = 1;
    649665
    650         /* admin/profile/edit/[group-id] */
    651         return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id );
     666        return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); // admin/profile/edit/[group-id]
    652667    }
    653668
     
    671686    global $bp;
    672687
     688    bp_button( array (
     689        'id'                => 'edit_profile',
     690        'component'         => 'xprofile',
     691        'must_be_logged_in' => true,
     692        'block_self'        => true,
     693        'link_href'         => trailingslashit( $bp->displayed_user->domain . $bp->profile->slug . '/edit' ),
     694        'link_class'        => 'edit',
     695        'link_text'         => __( 'Edit Profile', 'buddypress' ),
     696        'link_title'        => __( 'Edit Profile', 'buddypress' ),
     697    ) );
     698}
     699
    673700?>
    674 
    675     <div class="generic-button">
    676         <a class="edit" title="<?php _e( 'Edit Profile', 'buddypress' ); ?>" href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit"><?php _e( 'Edit Profile', 'buddypress' ); ?></a>
    677     </div>
    678 <?php
    679 }
    680 
    681 ?>
Note: See TracChangeset for help on using the changeset viewer.