Skip to:
Content

BuddyPress.org

Changes from tags/1.2.5.2 at r12731 to tags/1.2.6 at r12731


Ignore:
Location:
tags/1.2.6
Files:
106 edited

Legend:

Unmodified
Added
Removed
  • tags/1.2.6/bp-activity.php

    • Property svn:eol-style deleted
    r12731 r12731  
    6767               ) {$charset_collate};";
    6868
    69     require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
     69    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    7070    dbDelta($sql);
    7171
     
    7474
    7575function bp_activity_setup_globals() {
    76     global $bp, $wpdb, $current_blog;
     76    global $bp, $current_blog;
    7777
    7878    /* Internal identifier */
    7979    $bp->activity->id = 'activity';
    8080
    81     $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity';
    82     $bp->activity->table_name_meta = $wpdb->base_prefix . 'bp_activity_meta';
    8381    $bp->activity->slug = BP_ACTIVITY_SLUG;
     82
     83    $bp->activity->table_name      = $bp->table_prefix . 'bp_activity';
     84    $bp->activity->table_name_meta = $bp->table_prefix . 'bp_activity_meta';
     85
    8486    $bp->activity->format_notification_function = 'bp_activity_format_notifications';
    8587
     
    9294
    9395function bp_activity_check_installed() {
    94     global $wpdb, $bp;
     96    global $bp;
    9597
    9698    if ( get_site_option( 'bp-activity-db-version' ) < BP_ACTIVITY_DB_VERSION )
     
    172174        return false;
    173175
    174     if ( !is_site_admin() )
     176    if ( !is_super_admin() )
    175177        $bp->is_item_admin = false;
    176178
     
    185187        return false;
    186188
    187     if ( !is_site_admin() )
     189    if ( !is_super_admin() )
    188190        $bp->is_item_admin = false;
    189191
     
    195197    global $bp;
    196198
    197     if ( !is_site_admin() )
     199    if ( !is_super_admin() )
    198200        $bp->is_item_admin = false;
    199201
     
    205207    global $bp;
    206208
    207     if ( !is_site_admin() )
     209    if ( !is_super_admin() )
    208210        $bp->is_item_admin = false;
    209211
     
    252254            bp_core_redirect( $bp->loggedin_user->domain );
    253255        else
    254             bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . clean_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) );
     256            bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( $bp->root_domain . '/' . $bp->activity->slug . '/p/' . $bp->current_action ) ) );
    255257    }
    256258
     
    276278                <td></td>
    277279                <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>
    278                 <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>
    279                 <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>
     280                <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>
     281                <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>
    280282            </tr>
    281283            <tr>
    282284                <td></td>
    283285                <td><?php printf( __( "A member replies to an update or comment you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
    284                 <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>
    285                 <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>
     286                <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>
     287                <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>
    286288            </tr>
    287289
     
    354356
    355357    /* Check access */
    356     if ( !is_site_admin() && $activity->user_id != $bp->loggedin_user->id )
     358    if ( !is_super_admin() && $activity->user_id != $bp->loggedin_user->id )
    357359        return false;
    358360
     
    624626
    625627function bp_activity_add( $args = '' ) {
    626     global $bp, $wpdb;
     628    global $bp;
    627629
    628630    $defaults = array(
    629         'id' => false, // Pass an existing activity ID to update an existing entry.
    630 
    631         'action' => '', // The activity action - e.g. "Jon Doe posted an update"
    632         'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
    633 
    634         'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent
    635         'type' => false, // The activity type e.g. activity_update, profile_updated
    636         'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
    637 
    638         '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.
    639         'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
     631        'id'                => false, // Pass an existing activity ID to update an existing entry.
     632
     633        'action'            => '', // The activity action - e.g. "Jon Doe posted an update"
     634        'content'           => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
     635
     636        'component'         => false, // The name/ID of the component e.g. groups, profile, mycomponent
     637        'type'              => false, // The activity type e.g. activity_update, profile_updated
     638        'primary_link'      => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink)
     639
     640        '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.
     641        'item_id'           => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id
    640642        'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id
    641         'recorded_time' => gmdate( "Y-m-d H:i:s" ), // The GMT time that this activity was recorded
    642         'hide_sitewide' => false // Should this be hidden on the sitewide activity stream?
     643        'recorded_time'     => bp_core_current_time(), // The GMT time that this activity was recorded
     644        'hide_sitewide'     => false // Should this be hidden on the sitewide activity stream?
    643645    );
    644646
     
    711713
    712714    /* Add this update to the "latest update" usermeta so it can be fetched anywhere. */
    713     update_usermeta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
     715    update_user_meta( $bp->loggedin_user->id, 'bp_latest_update', array( 'id' => $activity_id, 'content' => wp_filter_kses( $content ) ) );
    714716
    715717    /* Require the notifications code so email notifications can be set on the 'bp_activity_posted_update' action. */
     
    838840        $user_id = $args['user_id'];
    839841
    840     $latest_update = get_usermeta( $user_id, 'bp_latest_update' );
     842    $latest_update = get_user_meta( $user_id, 'bp_latest_update', true );
    841843    if ( !empty( $latest_update ) ) {
    842844        if ( in_array( (int)$latest_update['id'], (array)$activity_ids_deleted ) )
    843             delete_usermeta( $user_id, 'bp_latest_update' );
     845            delete_user_meta( $user_id, 'bp_latest_update' );
    844846    }
    845847
     
    992994
    993995function bp_activity_get_user_favorites( $user_id ) {
    994     $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
     996    $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
    995997    $existing_favs = bp_activity_get_specific( array( 'activity_ids' => $my_favs ) );
    996998
     
    9991001
    10001002    $new_favs = array_unique( (array)$new_favs );
    1001     update_usermeta( $user_id, 'bp_favorite_activities', $new_favs );
     1003    update_user_meta( $user_id, 'bp_favorite_activities', $new_favs );
    10021004
    10031005    return apply_filters( 'bp_activity_get_user_favorites', $new_favs );
     
    10111013
    10121014    /* Update the user's personal favorites */
    1013     $my_favs = maybe_unserialize( get_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities' ) );
     1015    $my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) );
    10141016    $my_favs[] = $activity_id;
    10151017
     
    10221024        $fav_count = 1;
    10231025
    1024     update_usermeta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
     1026    update_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', $my_favs );
    10251027    bp_activity_update_meta( $activity_id, 'favorite_count', $fav_count );
    10261028
     
    10371039
    10381040    /* Remove the fav from the user's favs */
    1039     $my_favs = maybe_unserialize( get_usermeta( $user_id, 'bp_favorite_activities' ) );
     1041    $my_favs = maybe_unserialize( get_user_meta( $user_id, 'bp_favorite_activities', true ) );
    10401042    $my_favs = array_flip( (array) $my_favs );
    10411043    unset( $my_favs[$activity_id] );
     
    10501052    }
    10511053
    1052     update_usermeta( $user_id, 'bp_favorite_activities', $my_favs );
     1054    update_user_meta( $user_id, 'bp_favorite_activities', $my_favs );
    10531055
    10541056    do_action( 'bp_activity_remove_user_favorite', $activity_id, $user_id );
     
    11721174
    11731175    // Remove any usermeta
    1174     delete_usermeta( $user_id, 'bp_latest_update' );
    1175     delete_usermeta( $user_id, 'bp_favorite_activities' );
     1176    delete_user_meta( $user_id, 'bp_latest_update' );
     1177    delete_user_meta( $user_id, 'bp_favorite_activities' );
    11761178
    11771179    do_action( 'bp_activity_remove_data', $user_id );
     
    11811183add_action( 'make_spam_user', 'bp_activity_remove_data' );
    11821184
     1185/**
     1186 * updates_register_activity_actions()
     1187 *
     1188 * Register the activity stream actions for updates
     1189 *
     1190 * @global array $bp
     1191 */
     1192function updates_register_activity_actions() {
     1193    global $bp;
     1194
     1195    bp_activity_set_action( $bp->activity->id, 'activity_update', __( 'Posted an update', 'buddypress' ) );
     1196
     1197    do_action( 'updates_register_activity_actions' );
     1198}
     1199add_action( 'bp_register_activity_actions', 'updates_register_activity_actions' );
    11831200
    11841201/********************************************************************************
  • tags/1.2.6/bp-activity/bp-activity-classes.php

    • Property svn:eol-style deleted
    r12731 r12731  
    532532        global $bp;
    533533
    534         if ( !$favorite_activity_entries = get_usermeta( $user_id, 'bp_favorite_activities' ) )
     534        if ( !$favorite_activity_entries = get_user_meta( $user_id, 'bp_favorite_activities', true ) )
    535535            return 0;
    536536
  • tags/1.2.6/bp-activity/bp-activity-filters.php

    • Property svn:eol-style deleted
    r12731 r12731  
    22
    33/* Apply WordPress defined filters */
    4 add_filter( 'bp_get_activity_action', 'bp_activity_filter_kses', 1 );
    5 add_filter( 'bp_get_activity_content_body', 'bp_activity_filter_kses', 1 );
    6 add_filter( 'bp_get_activity_content', 'bp_activity_filter_kses', 1 );
    7 add_filter( 'bp_get_activity_parent_content', 'bp_activity_filter_kses', 1 );
    8 add_filter( 'bp_get_activity_latest_update', 'bp_activity_filter_kses', 1 );
     4add_filter( 'bp_get_activity_action',                'bp_activity_filter_kses', 1 );
     5add_filter( 'bp_get_activity_content_body',          'bp_activity_filter_kses', 1 );
     6add_filter( 'bp_get_activity_content',               'bp_activity_filter_kses', 1 );
     7add_filter( 'bp_get_activity_parent_content',        'bp_activity_filter_kses', 1 );
     8add_filter( 'bp_get_activity_latest_update',         'bp_activity_filter_kses', 1 );
    99add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_filter_kses', 1 );
    1010add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_filter_kses', 1 );
    11 add_filter( 'bp_activity_content_before_save', 'bp_activity_filter_kses', 1 );
    12 add_filter( 'bp_activity_action_before_save', 'bp_activity_filter_kses', 1 );
     11add_filter( 'bp_activity_content_before_save',       'bp_activity_filter_kses', 1 );
     12add_filter( 'bp_activity_action_before_save',        'bp_activity_filter_kses', 1 );
    1313
    14 add_filter( 'bp_get_activity_action', 'force_balance_tags' );
    15 add_filter( 'bp_get_activity_content_body', 'force_balance_tags' );
    16 add_filter( 'bp_get_activity_content', 'force_balance_tags' );
    17 add_filter( 'bp_get_activity_latest_update', 'force_balance_tags' );
     14add_filter( 'bp_get_activity_action',                'force_balance_tags' );
     15add_filter( 'bp_get_activity_content_body',          'force_balance_tags' );
     16add_filter( 'bp_get_activity_content',               'force_balance_tags' );
     17add_filter( 'bp_get_activity_latest_update',         'force_balance_tags' );
    1818add_filter( 'bp_get_activity_latest_update_excerpt', 'force_balance_tags' );
    1919add_filter( 'bp_get_activity_feed_item_description', 'force_balance_tags' );
     20add_filter( 'bp_activity_content_before_save',       'force_balance_tags' );
     21add_filter( 'bp_activity_action_before_save',        'force_balance_tags' );
    2022
    21 add_filter( 'bp_get_activity_action', 'wptexturize' );
    22 add_filter( 'bp_get_activity_content_body', 'wptexturize' );
    23 add_filter( 'bp_get_activity_content', 'wptexturize' );
    24 add_filter( 'bp_get_activity_parent_content', 'wptexturize' );
    25 add_filter( 'bp_get_activity_latest_update', 'wptexturize' );
     23add_filter( 'bp_get_activity_action',                'wptexturize' );
     24add_filter( 'bp_get_activity_content_body',          'wptexturize' );
     25add_filter( 'bp_get_activity_content',               'wptexturize' );
     26add_filter( 'bp_get_activity_parent_content',        'wptexturize' );
     27add_filter( 'bp_get_activity_latest_update',         'wptexturize' );
    2628add_filter( 'bp_get_activity_latest_update_excerpt', 'wptexturize' );
    2729
    28 add_filter( 'bp_get_activity_action', 'convert_smilies' );
    29 add_filter( 'bp_get_activity_content_body', 'convert_smilies' );
    30 add_filter( 'bp_get_activity_content', 'convert_smilies' );
    31 add_filter( 'bp_get_activity_parent_content', 'convert_smilies' );
    32 add_filter( 'bp_get_activity_latest_update', 'convert_smilies' );
     30add_filter( 'bp_get_activity_action',                'convert_smilies' );
     31add_filter( 'bp_get_activity_content_body',          'convert_smilies' );
     32add_filter( 'bp_get_activity_content',               'convert_smilies' );
     33add_filter( 'bp_get_activity_parent_content',        'convert_smilies' );
     34add_filter( 'bp_get_activity_latest_update',         'convert_smilies' );
    3335add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_smilies' );
    3436
    35 add_filter( 'bp_get_activity_action', 'convert_chars' );
    36 add_filter( 'bp_get_activity_content_body', 'convert_chars' );
    37 add_filter( 'bp_get_activity_content', 'convert_chars' );
    38 add_filter( 'bp_get_activity_parent_content', 'convert_chars' );
    39 add_filter( 'bp_get_activity_latest_update', 'convert_chars' );
     37add_filter( 'bp_get_activity_action',                'convert_chars' );
     38add_filter( 'bp_get_activity_content_body',          'convert_chars' );
     39add_filter( 'bp_get_activity_content',               'convert_chars' );
     40add_filter( 'bp_get_activity_parent_content',        'convert_chars' );
     41add_filter( 'bp_get_activity_latest_update',         'convert_chars' );
    4042add_filter( 'bp_get_activity_latest_update_excerpt', 'convert_chars' );
    4143
    42 add_filter( 'bp_get_activity_action', 'wpautop' );
    43 add_filter( 'bp_get_activity_content_body', 'wpautop' );
    44 add_filter( 'bp_get_activity_content', 'wpautop' );
     44add_filter( 'bp_get_activity_action',                'wpautop' );
     45add_filter( 'bp_get_activity_content_body',          'wpautop' );
     46add_filter( 'bp_get_activity_content',               'wpautop' );
    4547add_filter( 'bp_get_activity_feed_item_description', 'wpautop' );
    4648
    47 add_filter( 'bp_get_activity_action', 'make_clickable' );
    48 add_filter( 'bp_get_activity_content_body', 'make_clickable' );
    49 add_filter( 'bp_get_activity_content', 'make_clickable' );
    50 add_filter( 'bp_get_activity_parent_content', 'make_clickable' );
    51 add_filter( 'bp_get_activity_latest_update', 'make_clickable' );
     49add_filter( 'bp_get_activity_action',                'make_clickable' );
     50add_filter( 'bp_get_activity_content_body',          'make_clickable' );
     51add_filter( 'bp_get_activity_content',               'make_clickable' );
     52add_filter( 'bp_get_activity_parent_content',        'make_clickable' );
     53add_filter( 'bp_get_activity_latest_update',         'make_clickable' );
    5254add_filter( 'bp_get_activity_latest_update_excerpt', 'make_clickable' );
    5355add_filter( 'bp_get_activity_feed_item_description', 'make_clickable' );
    5456
    55 add_filter( 'bp_acomment_name', 'stripslashes_deep' );
    56 add_filter( 'bp_get_activity_action', 'stripslashes_deep' );
    57 add_filter( 'bp_get_activity_content', 'stripslashes_deep' );
    58 add_filter( 'bp_get_activity_content_body', 'stripslashes_deep' );
    59 add_filter( 'bp_get_activity_parent_content', 'stripslashes_deep' );
    60 add_filter( 'bp_get_activity_latest_update', 'stripslashes_deep' );
     57add_filter( 'bp_acomment_name',                      'stripslashes_deep' );
     58add_filter( 'bp_get_activity_action',                'stripslashes_deep' );
     59add_filter( 'bp_get_activity_content',               'stripslashes_deep' );
     60add_filter( 'bp_get_activity_content_body',          'stripslashes_deep' );
     61add_filter( 'bp_get_activity_parent_content',        'stripslashes_deep' );
     62add_filter( 'bp_get_activity_latest_update',         'stripslashes_deep' );
    6163add_filter( 'bp_get_activity_latest_update_excerpt', 'stripslashes_deep' );
    6264add_filter( 'bp_get_activity_feed_item_description', 'stripslashes_deep' );
    6365
    64 add_filter( 'bp_get_activity_content', 'bp_activity_make_nofollow_filter' );
    65 add_filter( 'bp_get_activity_content_body', 'bp_activity_make_nofollow_filter' );
    66 add_filter( 'bp_get_activity_parent_content', 'bp_activity_make_nofollow_filter' );
    67 add_filter( 'bp_get_activity_latest_update', 'bp_activity_make_nofollow_filter' );
     66/* Apply BuddyPress defined filters */
     67add_filter( 'bp_get_activity_content',               'bp_activity_make_nofollow_filter' );
     68add_filter( 'bp_get_activity_content_body',          'bp_activity_make_nofollow_filter' );
     69add_filter( 'bp_get_activity_parent_content',        'bp_activity_make_nofollow_filter' );
     70add_filter( 'bp_get_activity_latest_update',         'bp_activity_make_nofollow_filter' );
    6871add_filter( 'bp_get_activity_latest_update_excerpt', 'bp_activity_make_nofollow_filter' );
    6972add_filter( 'bp_get_activity_feed_item_description', 'bp_activity_make_nofollow_filter' );
     
    7982
    8083    $activity_allowedtags = $allowedtags;
    81     $activity_allowedtags['span'] = array();
     84    $activity_allowedtags['span']          = array();
    8285    $activity_allowedtags['span']['class'] = array();
    83     $activity_allowedtags['div'] = array();
    84     $activity_allowedtags['div']['class'] = array();
    85     $activity_allowedtags['div']['id'] = array();
    86     $activity_allowedtags['a']['class'] = array();
    87     $activity_allowedtags['img'] = array();
    88     $activity_allowedtags['img']['src'] = array();
    89     $activity_allowedtags['img']['alt'] = array();
    90     $activity_allowedtags['img']['class'] = array();
    91     $activity_allowedtags['img']['width'] = array();
     86    $activity_allowedtags['div']           = array();
     87    $activity_allowedtags['div']['class']  = array();
     88    $activity_allowedtags['div']['id']     = array();
     89    $activity_allowedtags['a']['class']    = array();
     90    $activity_allowedtags['img']           = array();
     91    $activity_allowedtags['img']['src']    = array();
     92    $activity_allowedtags['img']['alt']    = array();
     93    $activity_allowedtags['img']['class']  = array();
     94    $activity_allowedtags['img']['width']  = array();
    9295    $activity_allowedtags['img']['height'] = array();
    93     $activity_allowedtags['img']['class'] = array();
    94     $activity_allowedtags['img']['id'] = array();
    95     $activity_allowedtags['img']['title'] = array();
    96     $activity_allowedtags['code'] = array();
     96    $activity_allowedtags['img']['class']  = array();
     97    $activity_allowedtags['img']['id']     = array();
     98    $activity_allowedtags['img']['title']  = array();
     99    $activity_allowedtags['code']          = array();
    97100
    98101    $activity_allowedtags = apply_filters( 'bp_activity_allowed_tags', $activity_allowedtags );
     
    103106    include_once( ABSPATH . WPINC . '/registration.php' );
    104107
    105     $pattern = '/[@]+([A-Za-z0-9-_]+)/';
     108    $pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
    106109    preg_match_all( $pattern, $content, $usernames );
    107110
    108     /* Make sure there's only one instance of each username */
     111    // Make sure there's only one instance of each username
    109112    if ( !$usernames = array_unique( $usernames[1] ) )
    110113        return $content;
     
    114117            continue;
    115118
    116         /* Increase the number of new @ mentions for the user */
    117         $new_mention_count = (int)get_usermeta( $user_id, 'bp_new_mention_count' );
    118         update_usermeta( $user_id, 'bp_new_mention_count', $new_mention_count + 1 );
     119        // Increase the number of new @ mentions for the user
     120        $new_mention_count = (int)get_user_meta( $user_id, 'bp_new_mention_count', true );
     121        update_user_meta( $user_id, 'bp_new_mention_count', $new_mention_count + 1 );
    119122
    120123        $content = str_replace( "@$username", "<a href='" . bp_core_get_user_domain( bp_core_get_userid( $username ) ) . "' rel='nofollow'>@$username</a>", $content );
     
    123126    return $content;
    124127}
    125 add_filter( 'bp_activity_new_update_content', 'bp_activity_at_name_filter' );
     128add_filter( 'bp_activity_new_update_content',     'bp_activity_at_name_filter' );
    126129add_filter( 'groups_activity_new_update_content', 'bp_activity_at_name_filter' );
    127 add_filter( 'pre_comment_content', 'bp_activity_at_name_filter' );
     130add_filter( 'pre_comment_content',                'bp_activity_at_name_filter' );
    128131add_filter( 'group_forum_topic_text_before_save', 'bp_activity_at_name_filter' );
    129 add_filter( 'group_forum_post_text_before_save', 'bp_activity_at_name_filter' );
    130 add_filter( 'bp_activity_comment_content', 'bp_activity_at_name_filter' );
     132add_filter( 'group_forum_post_text_before_save',  'bp_activity_at_name_filter' );
     133add_filter( 'bp_activity_comment_content',        'bp_activity_at_name_filter' );
    131134
    132135function bp_activity_make_nofollow_filter( $text ) {
  • tags/1.2.6/bp-activity/bp-activity-notifications.php

    r12731 r12731  
    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
     
    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 );
  • tags/1.2.6/bp-activity/bp-activity-templatetags.php

    • Property svn:eol-style deleted
    r12731 r12731  
    2020
    2121        $this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : $page;
    22         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    23 
    24         /* Check if blog/forum replies are disabled */
     22        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     23
     24        // Check if blog/forum replies are disabled
    2525        $this->disable_blogforum_replies = $bp->site_options['bp-disable-blogforum-comments'];
    2626
    27         /* 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' ) );
    29 
    30         if ( !empty( $include ) ) {
    31             /* Fetch specific activity items based on ID's */
     27        // Get an array of the logged in user's favorite activities
     28        $this->my_favs = maybe_unserialize( get_user_meta( $bp->loggedin_user->id, 'bp_favorite_activities', true ) );
     29
     30        // Fetch specific activity items based on ID's
     31        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         } else {
     33        // Fetch all activity items
     34        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 ) );
    35         }
    3636
    3737        if ( !$max || $max >= (int)$this->activities['total'] )
     
    4343
    4444        if ( $max ) {
    45             if ( $max >= count($this->activities) )
    46                 $this->activity_count = count($this->activities);
    47             else
     45            if ( $max >= count($this->activities) ) {
     46                $this->activity_count = count( $this->activities );
     47            } else {
    4848                $this->activity_count = (int)$max;
     49            }
    4950        } else {
    50             $this->activity_count = count($this->activities);
     51            $this->activity_count = count( $this->activities );
    5152        }
    5253
    5354        $this->full_name = $bp->displayed_user->fullname;
    5455
    55         /* Fetch parent content for activity comments so we do not have to query in the loop */
     56        // Fetch parent content for activity comments so we do not have to query in the loop
    5657        foreach ( (array)$this->activities as $activity ) {
    57             if ( 'activity_comment' != $activity->type ) continue;
     58            if ( 'activity_comment' != $activity->type )
     59                continue;
     60
    5861            $parent_ids[] = $activity->item_id;
    5962        }
     
    6366
    6467        if ( !empty( $activity_parents['activities'] ) ) {
    65             foreach( $activity_parents['activities'] as $parent ) $this->activity_parents[$parent->id] = $parent;
     68            foreach( $activity_parents['activities'] as $parent )
     69                $this->activity_parents[$parent->id] = $parent;
     70
    6671            unset( $activity_parents );
    6772        }
    6873
    69         if ( (int) $this->total_activity_count && (int) $this->pag_num ) {
     74        if ( (int)$this->total_activity_count && (int)$this->pag_num ) {
    7075            $this->pag_links = paginate_links( array(
    71                 'base' => add_query_arg( 'acpage', '%#%' ),
    72                 'format' => '',
    73                 'total' => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
    74                 'current' => (int)$this->pag_page,
     76                'base'      => add_query_arg( 'acpage', '%#%' ),
     77                'format'    => '',
     78                'total'     => ceil( (int)$this->total_activity_count / (int)$this->pag_num ),
     79                'current'   => (int)$this->pag_page,
    7580                'prev_text' => '&larr;',
    7681                'next_text' => '&rarr;',
    77                 'mid_size' => 1
    78             ));
     82                'mid_size'  => 1
     83            ) );
    7984        }
    8085    }
     
    151156        $primary_id = $bp->groups->current_group->id;
    152157
    153         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 ) )
    154159            $show_hidden = true;
    155160    }
     
    395400    }
    396401
     402/**
     403 * bp_activity_avatar( $args )
     404 *
     405 * Output the avatar of the user that performed the action
     406 *
     407 * @param array $args
     408 */
    397409function bp_activity_avatar( $args = '' ) {
    398410    echo bp_get_activity_avatar( $args );
    399411}
     412    /**
     413     * bp_get_activity_avatar( $args )
     414     *
     415     * Return the avatar of the user that performed the action
     416     *
     417     * @global array $bp
     418     * @global object $activities_template
     419     * @param array $args optional
     420     * @return string
     421     */
    400422    function bp_get_activity_avatar( $args = '' ) {
    401423        global $bp, $activities_template;
    402424
    403425        $defaults = array(
    404             'type' => 'thumb',
    405             'width' => 20,
     426            'type'   => 'thumb',
     427            'width'  => 20,
    406428            'height' => 20,
    407             'class' => 'avatar',
    408             'alt' => __( 'Avatar', 'buddypress' ),
    409             'email' => false
     429            'class'  => 'avatar',
     430            'alt'    => __( 'Avatar', 'buddypress' ),
     431            'email'  => false
    410432        );
    411433
     
    413435        extract( $r, EXTR_SKIP );
    414436
    415         $item_id = false;
    416         if ( (int)$activities_template->activity->user_id )
    417             $item_id = $activities_template->activity->user_id;
    418         else if ( $activities_template->activity->item_id )
    419             $item_id = $activities_template->activity->item_id;
    420 
    421         $object = 'user';
    422         if ( $bp->groups->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id )
    423             $object = 'group';
    424         if ( $bp->blogs->id == $activities_template->activity->component && !(int) $activities_template->activity->user_id )
    425             $object = 'blog';
    426 
    427         $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, $object );
    428 
    429         /* If this is a user object pass the users' email address for Gravatar so we don't have to refetch it. */
    430         if ( 'user' == $object && empty($email) )
     437        // Primary activity avatar is always a user, but can be modified via a filter
     438        $object  = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component, 'user' );
     439        $item_id = apply_filters( 'bp_get_activity_avatar_item_id', $activities_template->activity->user_id );
     440
     441        // If this is a user object pass the users' email address for Gravatar so we don't have to refetch it.
     442        if ( 'user' == $object && empty( $email ) )
    431443            $email = $activities_template->activity->user_email;
    432444
    433445        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 ) ) );
     446    }
     447
     448/**
     449 * bp_activity_secondary_avatar( $args )
     450 *
     451 * Output the avatar of the object that action was performed on
     452 *
     453 * @param array $args optional
     454 */
     455function bp_activity_secondary_avatar( $args = '' ) {
     456    echo bp_get_activity_secondary_avatar( $args );
     457}
     458    /**
     459     * bp_get_activity_secondary_avatar( $args )
     460     *
     461     * Return the avatar of the object that action was performed on
     462     *
     463     * @global array $bp
     464     * @global object $activities_template
     465     * @param array $args optional
     466     * @return string
     467     */
     468    function bp_get_activity_secondary_avatar( $args = '' ) {
     469        global $bp, $activities_template;
     470
     471        $defaults = array(
     472            'type'   => 'thumb',
     473            'width'  => 20,
     474            'height' => 20,
     475            'class'  => 'avatar',
     476            'alt'    => __( 'Avatar', 'buddypress' ),
     477            'email'  => false
     478        );
     479
     480        $r = wp_parse_args( $args, $defaults );
     481        extract( $r, EXTR_SKIP );
     482
     483        // Set item_id and object (default to user)
     484        switch ( $activities_template->activity->component ) {
     485            case 'groups' :
     486                $object = 'group';
     487                $item_id = $activities_template->activity->item_id;
     488                break;
     489            case 'blogs' :
     490                $object = 'blog';
     491                $item_id = $activities_template->activity->item_id;
     492                break;
     493            case 'friends' :
     494                $object  = 'user';
     495                $item_id = $activities_template->activity->secondary_item_id;
     496                break;
     497            default :
     498                $object  = 'user';
     499                $item_id = $activities_template->activity->user_id;
     500                $email = $activities_template->activity->user_email;
     501                break;
     502        }
     503
     504        // Allow object and item_id to be filtered
     505        $object  = apply_filters( 'bp_get_activity_secondary_avatar_object_' . $activities_template->activity->component, $object );
     506        $item_id = apply_filters( 'bp_get_activity_secondary_avatar_item_id', $item_id );
     507
     508        // If we have no item_id or object, there is no avatar to display
     509        if ( empty( $item_id ) || empty( $object ) )
     510            return false;
     511
     512        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 ) ) );
    434513    }
    435514
     
    441520
    442521        $action = $activities_template->activity->action;
     522
     523        $action = apply_filters( 'bp_get_activity_action_pre_meta', $action, &$activities_template->activity );
    443524
    444525        if ( !empty( $action ) )
     
    500581
    501582        /* Add the delete link if the user has permission on this item */
    502         if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_site_admin )
     583        if ( ( is_user_logged_in() && $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || $bp->loggedin_user->is_super_admin )
    503584             $content .= apply_filters( 'bp_activity_delete_link', ' &middot; ' . bp_get_activity_delete_link(), &$activities_template->activity );
    504585
     
    576657
    577658                $content .= '<li id="acomment-' . $comment->id . '">';
    578                 $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>';
     659                $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>';
    579660                $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 ) );
    580661
     
    584665
    585666                /* Delete link */
    586                 if ( $bp->loggedin_user->is_site_admin || $bp->loggedin_user->id == $comment->user_id )
     667                if ( $bp->loggedin_user->is_super_admin || $bp->loggedin_user->id == $comment->user_id )
    587668                    $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>';
    588669
     
    730811            $user_id = $bp->displayed_user->id;
    731812
    732         if ( !$update = get_usermeta( $user_id, 'bp_latest_update' ) )
     813        if ( !$update = get_user_meta( $user_id, 'bp_latest_update', true ) )
    733814            return false;
    734815
     
    768849                unset($selected);
    769850
    770             $component = attribute_escape( $component );
     851            $component = esc_attr( $component );
    771852
    772853            switch ( $style ) {
     
    796877            $translatable_components = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
    797878
    798             $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;
     879            $component_links[] = $before . '<a href="' . esc_attr( $link ) . '">' . ucwords( __( $component, 'buddypress' ) ) . '</a>' . $after;
    799880        }
    800881
     
    802883
    803884        if ( isset( $_GET['afilter'] ) )
    804             $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
     885            $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . esc_attr( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
    805886
    806887        return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
     
    832913}
    833914    function bp_get_total_mention_count_for_user( $user_id = false ) {
    834         return apply_filters( 'bp_get_total_mention_count_for_user', get_usermeta( $user_id, 'bp_new_mention_count' ) );
     915        return apply_filters( 'bp_get_total_mention_count_for_user', get_user_meta( $user_id, 'bp_new_mention_count', true ) );
    835916    }
    836917
     
    841922        global $bp;
    842923
    843         return apply_filters( 'bp_get_send_public_message_link', $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) );
     924        if ( bp_is_my_profile() || !is_user_logged_in() )
     925            return false;
     926
     927        return apply_filters( 'bp_get_send_public_message_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->activity->slug . '/?r=' . bp_core_get_username( $bp->displayed_user->user_id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) );
     928    }
     929
     930/**
     931 * bp_send_public_message_button( $args )
     932 *
     933 * Output button for sending a public message
     934 *
     935 * @param array $args
     936 */
     937function bp_send_public_message_button( $args = '' ) {
     938    echo bp_get_send_public_message_button( $args );
     939}
     940    /**
     941     * bp_get_send_public_message_button( $args )
     942     *
     943     * Return button for sending a public message
     944     *
     945     * @param array $args
     946     * @return string
     947     */
     948    function bp_get_send_public_message_button( $args = '' ) {
     949        $defaults = array(
     950            'id'                => 'public_message',
     951            'component'         => 'activity',
     952            'must_be_logged_in' => true,
     953            'block_self'        => true,
     954            'wrapper_id'        => 'post-mention',
     955            'link_href'         => bp_get_send_public_message_link(),
     956            'link_title'        => __( 'Mention this user in a new public message, this will send the user a notification to get their attention.', 'buddypress' ),
     957            'link_text'         => __( 'Mention this User', 'buddypress' )
     958        );
     959
     960        $button = wp_parse_args( $args, $defaults );
     961
     962        // Filter and return the HTML button
     963        return bp_get_button( apply_filters( 'bp_get_send_public_message_button', $button ) );
    844964    }
    845965
  • tags/1.2.6/bp-activity/feeds/bp-activity-friends-feed.php

    • Property svn:eol-style deleted
  • tags/1.2.6/bp-activity/feeds/bp-activity-personal-feed.php

    • Property svn:eol-style deleted
  • tags/1.2.6/bp-activity/feeds/bp-activity-sitewide-feed.php

    • Property svn:eol-style deleted
  • tags/1.2.6/bp-blogs.php

    • Property svn:eol-style deleted
    r12731 r12731  
    3838
    3939
    40     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
     40    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    4141
    4242    dbDelta($sql);
     
    5555
    5656    /* Only create the bp-blogs tables if this is a multisite install */
    57     if ( is_site_admin() && bp_core_is_multisite() ) {
     57    if ( is_super_admin() && bp_core_is_multisite() ) {
    5858        /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    5959        if ( get_site_option( 'bp-blogs-db-version' ) < BP_BLOGS_DB_VERSION )
     
    6969    $bp->blogs->id = 'blogs';
    7070
    71     $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
    72     $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
     71    $bp->blogs->slug = BP_BLOGS_SLUG;
     72
     73    $bp->blogs->table_name          = $bp->table_prefix . 'bp_user_blogs';
     74    $bp->blogs->table_name_blogmeta = $bp->table_prefix . 'bp_user_blogs_blogmeta';
     75
    7376    $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
    74     $bp->blogs->slug = BP_BLOGS_SLUG;
    7577
    7678    /* Register this in the active components array */
     
    214216        'item_id' => false,
    215217        'secondary_item_id' => false,
    216         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     218        'recorded_time' => bp_core_current_time(),
    217219        'hide_sitewide' => false
    218220    );
     
    229231
    230232    if ( !empty( $content ) )
    231         $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ) );
     233        $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content );
    232234
    233235    /* Check for an existing entry and update if one exists. */
     
    319321}
    320322
     323/**
     324 * Makes BuddyPress aware of a new site so that it can track its activity.
     325 *
     326 * @global object $bp BuddyPress global settings
     327 * @param int $blog_id
     328 * @param int $user_id
     329 * @param $bool $no_activity ; optional.
     330 * @since 1.0
     331 * @uses BP_Blogs_Blog
     332 */
    321333function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = false ) {
    322334    global $bp;
     
    339351    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
    340352    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
    341     bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
    342 
    343     /* Only record this activity if the blog is public */
     353    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', bp_core_current_time() );
     354
     355    // Only record this activity if the blog is public
    344356    if ( (int)$_POST['blog_public'] && !$no_activity ) {
    345         /* Record this in activity streams */
     357        // Record this in activity streams
    346358        bp_blogs_record_activity( array(
    347             'user_id' => $recorded_blog->user_id,
    348             '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_blog_option( $recorded_blog->blog_id, 'siteurl' ) . '">' . attribute_escape( $name ) . '</a>' ), &$recorded_blog, $name, $description ),
    349             'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
    350             'type' => 'new_blog',
    351             'item_id' => $recorded_blog->blog_id
     359            'user_id'      => $recorded_blog->user_id,
     360            '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 ),
     361            'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_site_url( $recorded_blog->blog_id ), $recorded_blog->blog_id ),
     362            'type'         => 'new_blog',
     363            'item_id'      => $recorded_blog->blog_id
    352364        ) );
    353365    }
     
    426438        bp_blogs_remove_post( $post_id, $blog_id );
    427439
    428     bp_blogs_update_blogmeta( $blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     440    bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() );
    429441
    430442    do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id );
     
    440452 * @global object $wpdb
    441453 * @global $bp $bp
    442  * @param <type> $comment_id
    443  * @param <type> $is_approved
    444  * @return <type>
     454 * @param int $comment_id
     455 * @param bool $is_approved
     456 * @return mixed
    445457 */
     458
    446459function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
    447460    global $wpdb, $bp;
     
    451464
    452465    // Don't record activity if the comment hasn't been approved
    453     if ( !$is_approved || true != $recorded_comment->comment_approved )
     466    if ( !$is_approved || !$recorded_comment->comment_approved )
     467        return false;
     468
     469    // Don't record activity if no email address has been included
     470    if ( empty( $recorded_comment->comment_author_email ) )
     471        return false;
     472   
     473    // Get the user_id from the comment author email.
     474    $user = get_user_by_email( $recorded_comment->comment_author_email );
     475    $user_id = (int)$user->ID;
     476
     477    // If there's no registered user id, don't record activity
     478    if ( empty( $user_id ) )
    454479        return false;
    455480
     
    458483    $recorded_comment->post = get_post( $recorded_comment->comment_post_ID );
    459484
    460     // Get the user_id from the comment author email.
    461     $user = get_user_by_email( $recorded_comment->comment_author_email );
    462     $user_id = (int)$user->ID;
    463 
    464     // If there's no registered user id, don't record activity
    465     if ( !$user_id )
    466         return false;
    467 
    468485    // If this is a password protected post, don't record the comment
    469486    if ( !empty( $recorded_comment->post->post_password ) )
     
    474491
    475492        // Get activity related links
    476         $post_permalink     = get_permalink( $recorded_comment->comment_post_ID );
    477         $comment_link       = htmlspecialchars( get_comment_link( $recorded_comment->comment_ID ) );
     493        $post_permalink = get_permalink( $recorded_comment->comment_post_ID );
     494        $comment_link   = htmlspecialchars( get_comment_link( $recorded_comment->comment_ID ) );
    478495
    479496        // Prepare to record in activity streams
    480         $activity_action    = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . $recorded_comment->post->post_title . '</a>' );
     497        $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>' );
    481498        $activity_content   = $recorded_comment->comment_content;
    482499
    483500        // Record in activity streams
    484501        bp_blogs_record_activity( array(
    485             'user_id'           => $user_id,
    486             'action'            => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, &$recorded_comment, $comment_link ),
    487             'content'           => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, &$recorded_comment, $comment_link ),
    488             'primary_link'      => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$recorded_comment ),
    489             'type'              => 'new_blog_comment',
    490             'item_id'           => $blog_id,
    491             'secondary_item_id' => $comment_id,
    492             'recorded_time'     => $recorded_comment->comment_date_gmt
     502            'user_id'           => $user_id,
     503            'action'            => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, &$recorded_comment, $comment_link ),
     504            'content'           => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, &$recorded_comment, $comment_link ),
     505            'primary_link'      => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$recorded_comment ),
     506            'type'              => 'new_blog_comment',
     507            'item_id'           => $blog_id,
     508            'secondary_item_id' => $comment_id,
     509            'recorded_time'     => $recorded_comment->comment_date_gmt
    493510        ) );
    494511
    495512        // Update the blogs last active date
    496         bp_blogs_update_blogmeta( $blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     513        bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() );
    497514    }
    498515
     
    643660        $blog = bp_blogs_get_random_blogs( 1, 1 );
    644661
    645         bp_core_redirect( get_blog_option( $blog['blogs'][0]->blog_id, 'siteurl') );
     662        bp_core_redirect( get_site_url( $blog['blogs'][0]->blog_id ) );
    646663    }
    647664}
  • tags/1.2.6/bp-blogs/bp-blogs-classes.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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
     
    210210
    211211        // If the user is logged in return the blog count including their hidden blogs.
    212         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() )
    213213            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) );
    214214        else
     
    224224        $filter = like_escape( $wpdb->escape( $filter ) );
    225225
    226         if ( !is_site_admin() )
     226        if ( !is_super_admin() )
    227227            $hidden_sql = "AND wb.public = 1";
    228228
     
    242242            bp_blogs_setup_globals();
    243243
    244         if ( !is_site_admin() )
     244        if ( !is_super_admin() )
    245245            $hidden_sql = "AND wb.public = 1";
    246246
     
    262262        $letter = like_escape( $wpdb->escape( $letter ) );
    263263
    264         if ( !is_site_admin() )
     264        if ( !is_super_admin() )
    265265            $hidden_sql = "AND wb.public = 1";
    266266
     
    280280            return $paged_blogs;
    281281
    282         for ( $i = 0; $i < count( $paged_blogs ); $i++ )
    283             $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $paged_blogs[$i]->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
     282        for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
     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" );
     285        }
    284286
    285287        /* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
  • tags/1.2.6/bp-blogs/bp-blogs-templatetags.php

    • Property svn:eol-style deleted
    r12731 r12731  
    3737
    3838        if ( $max ) {
    39             if ( $max >= count($this->blogs) )
    40                 $this->blog_count = count($this->blogs);
    41             else
     39            if ( $max >= count($this->blogs) ) {
     40                $this->blog_count = count( $this->blogs );
     41            } else {
    4242                $this->blog_count = (int)$max;
     43            }
    4344        } else {
    44             $this->blog_count = count($this->blogs);
    45         }
    46 
    47         $this->pag_links = paginate_links( array(
    48             'base' => add_query_arg( 'bpage', '%#%' ),
    49             'format' => '',
    50             'total' => ceil( (int) $this->total_blog_count / (int) $this->pag_num ),
    51             'current' => (int) $this->pag_page,
    52             'prev_text' => '&larr;',
    53             'next_text' => '&rarr;',
    54             'mid_size' => 1
    55         ));
     45            $this->blog_count = count( $this->blogs );
     46        }
     47
     48        if ( (int)$this->total_blog_count && (int)$this->pag_num ) {
     49            $this->pag_links = paginate_links( array(
     50                'base'      => add_query_arg( 'bpage', '%#%' ),
     51                'format'    => '',
     52                'total'     => ceil( (int)$this->total_blog_count / (int)$this->pag_num ),
     53                'current'   => (int)$this->pag_page,
     54                'prev_text' => '&larr;',
     55                'next_text' => '&rarr;',
     56                'mid_size'  => 1
     57            ) );
     58        }
    5659    }
    5760
     
    268271function bp_blog_hidden_fields() {
    269272    if ( isset( $_REQUEST['s'] ) ) {
    270         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" />';
    271274    }
    272275
    273276    if ( isset( $_REQUEST['letter'] ) ) {
    274         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" />';
    275278    }
    276279
    277280    if ( isset( $_REQUEST['blogs_search'] ) ) {
    278         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" />';
    279282    }
    280283}
     
    345348
    346349            <input type="hidden" name="stage" value="gimmeanotherblog" />
    347             <?php do_action( "signup_hidden_fields" ); ?>
     350            <?php do_action( 'signup_hidden_fields' ); ?>
    348351
    349352            <?php bp_blogs_signup_blog($blogname, $blog_title, $errors); ?>
     
    502505}
    503506
     507/**
     508 * bp_blogs_visit_blog_button()
     509 *
     510 * Output button for visiting a blog in a loop
     511 *
     512 * @param array $args Custom button properties
     513 */
     514function bp_blogs_visit_blog_button( $args = '' ) {
     515    echo bp_get_blogs_visit_blog_button( $args );
     516}
     517    /**
     518     * bp_get_blogs_visit_blog_button()
     519     *
     520     * Return button for visiting a blog in a loop
     521     *
     522     * @param array $args Custom button properties
     523     * @return string
     524     */
     525    function bp_get_blogs_visit_blog_button( $args = '' ) {
     526        $defaults = array(
     527            'id'                => 'visit_blog',
     528            'component'         => 'blogs',
     529            'must_be_logged_in' => false,
     530            'block_self'        => false,
     531            'wrapper_class'     => 'blog-button visit',
     532            'link_href'         => bp_get_blog_permalink(),
     533            'link_class'        => 'visit',
     534            'link_text'         => __( 'Visit Blog', 'buddypress' ),
     535            'link_title'        => __( 'Visit Blog', 'buddypress' ),
     536        );
     537
     538        $button = wp_parse_args( $args, $defaults );
     539
     540        // Filter and return the HTML button
     541        return bp_get_button( apply_filters( 'bp_get_blogs_visit_blog_button', $button ) );
     542    }
     543
    504544?>
  • tags/1.2.6/bp-blogs/bp-blogs-widgets.php

    • Property svn:eol-style deleted
    r12731 r12731  
    7878        ?>
    7979
    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 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>
    8181    <?php
    8282    }
  • tags/1.2.6/bp-core.php

    • Property svn:eol-style deleted
    r12731 r12731  
    8585 */
    8686function bp_core_setup_globals() {
    87     global $bp, $wpdb;
     87    global $bp;
    8888    global $current_user, $current_component, $current_action, $current_blog;
    8989    global $displayed_user_id;
     
    9292    $current_user = wp_get_current_user();
    9393
     94    /* Get the base database prefix */
     95    $bp->table_prefix = bp_core_get_table_prefix();
     96
    9497    /* The domain for the root of the site where the main blog resides */
    9598    $bp->root_domain = bp_core_get_root_domain();
     
    104107    $bp->loggedin_user->userdata = bp_core_get_core_userdata( $bp->loggedin_user->id );
    105108
    106     /* 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. */
    107     $bp->loggedin_user->is_site_admin = is_site_admin();
     109    /* 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. */
     110    $bp->loggedin_user->is_super_admin = is_super_admin();
     111    $bp->loggedin_user->is_site_admin  = $bp->loggedin_user->is_super_admin; // deprecated 1.2.6
    108112
    109113    /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
     
    154158
    155159    /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
    156     $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );
     160    $bp->grav_default->user  = apply_filters( 'bp_user_gravatar_default', $bp->site_options['user-avatar-default'] );
    157161    $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
    158     $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
     162    $bp->grav_default->blog  = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
    159163
    160164    /* Fetch the full name for the logged in and current user */
    161     $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
     165    $bp->loggedin_user->fullname  = bp_core_get_user_displayname( $bp->loggedin_user->id );
    162166    $bp->displayed_user->fullname = bp_core_get_user_displayname( $bp->displayed_user->id );
    163167
     
    171175    $bp->is_item_mod = false;
    172176
    173     $bp->core->table_name_notifications = $wpdb->base_prefix . 'bp_notifications';
     177    $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
    174178
    175179    if ( !$bp->current_component && $bp->displayed_user->id )
     
    199203add_action( 'bp_setup_root_components', 'bp_core_setup_root_uris' );
    200204
     205/**
     206 * bp_core_get_table_prefix()
     207 *
     208 * Allow filtering of database prefix. Intended for use in multinetwork installations.
     209 *
     210 * @global object $wpdb WordPress database object
     211 * @return string Filtered database prefix
     212 */
     213function bp_core_get_table_prefix() {
     214    global $wpdb;
     215
     216    return apply_filters( 'bp_core_get_table_prefix', $wpdb->base_prefix );
     217}
    201218
    202219/**
     
    235252               ) {$charset_collate};";
    236253
    237     require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
     254    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    238255    dbDelta( $sql );
    239256
     
    252269 * @package BuddyPress Core
    253270 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    254  * @global $wpdb WordPress DB access object.
    255271 * @global $current_user WordPress global variable containing current logged in user information
    256  * @uses is_site_admin() returns true if the current user is a site admin, false if not
     272 * @uses is_super_admin() returns true if the current user is a site admin, false if not
    257273 * @uses get_site_option() fetches the value for a meta_key in the wp_sitemeta table
    258274 * @uses bp_core_install() runs the installation of DB tables for the core component
    259275 */
    260276function bp_core_check_installed() {
    261     global $wpdb, $bp;
    262 
    263     if ( !is_site_admin() )
     277    global $bp;
     278
     279    if ( !is_super_admin() )
    264280        return false;
    265281
     
    279295 * @package BuddyPress Core
    280296 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    281  * @global $wpdb WordPress DB access object.
    282  * @uses is_site_admin() returns true if the current user is a site admin, false if not
     297 * @uses is_super_admin() returns true if the current user is a site admin, false if not
    283298 * @uses add_submenu_page() WP function to add a submenu item
    284299 */
    285300function bp_core_add_admin_menu() {
    286     if ( !is_site_admin() )
     301    if ( !is_super_admin() )
    287302        return false;
    288303
     
    417432    global $bp, $wpdb, $wp_version;
    418433
    419     if ( !is_site_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
     434    if ( !is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
    420435        return false;
    421436
     
    485500    global $bp;
    486501
    487     if ( !is_site_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
     502    if ( !is_super_admin() || bp_is_my_profile() || !$bp->displayed_user->id )
    488503        return false;
    489504
     
    557572 * @global $current_user WordPress global variable containing current logged in user information
    558573 * @param user_id The ID of the user.
    559  * @uses get_usermeta() WordPress function to get the usermeta for a user.
     574 * @uses get_user_meta() WordPress function to get the usermeta for a user.
    560575 */
    561576function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) {
     
    667682
    668683    /* If this is for site admins only and the user is not one, don't create the subnav item */
    669     if ( $site_admin_only && !is_site_admin() )
     684    if ( $site_admin_only && !is_super_admin() )
    670685        return false;
    671686
     
    804819
    805820    /* If this is for site admins only and the user is not one, don't create the subnav item */
    806     if ( $site_admin_only && !is_site_admin() )
     821    if ( $site_admin_only && !is_super_admin() )
    807822        return false;
    808823
     
    934949 * @package BuddyPress Core
    935950 * @param $username str Username to check.
    936  * @global $wpdb WordPress DB access object.
    937951 * @return false on no match
    938952 * @return int the user ID of the matched user.
     
    976990 * @package BuddyPress Core
    977991 * @param $username str Username to check.
    978  * @global $wpdb WordPress DB access object.
    979992 * @return false on no match
    980993 * @return int the user ID of the matched user.
    981994 */
    982995function bp_core_get_random_member() {
    983     global $bp, $wpdb;
     996    global $bp;
    984997
    985998    if ( isset( $_GET['random-member'] ) ) {
     
    12901303
    12911304/**
    1292  * bp_core_format_time()
    1293  */
    1294 function bp_core_format_time( $time, $just_date = false ) {
    1295     if ( !$time )
    1296         return false;
    1297 
    1298     $date = date( "F j, Y ", $time );
    1299 
    1300     if ( !$just_date ) {
    1301         $date .= __('at', 'buddypress') . date( ' g:iA', $time );
    1302     }
    1303 
    1304     return $date;
     1305 * bp_core_current_time()
     1306 *
     1307 * Get the current GMT time to save into the DB
     1308 *
     1309 * @package BuddyPress Core
     1310 * @since 1.2.6
     1311 */
     1312function bp_core_current_time( $gmt = true ) {
     1313    // Get current time in MYSQL format
     1314    $current_time = current_time( 'mysql', $gmt );
     1315
     1316    return apply_filters( 'bp_core_current_time', $current_time );
    13051317}
    13061318
     
    13761388    ?>
    13771389        <div id="message" class="<?php echo $type; ?>">
    1378             <p><?php echo stripslashes( attribute_escape( $bp->template_message ) ); ?></p>
     1390            <p><?php echo stripslashes( esc_attr( $bp->template_message ) ); ?></p>
    13791391        </div>
    13801392    <?php
     
    14001412 */
    14011413function bp_core_time_since( $older_date, $newer_date = false ) {
     1414
    14021415    // array of time period chunks
    1403 
    14041416    $chunks = array(
    1405     array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
    1406     array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
    1407     array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
    1408     array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
    1409     array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
    1410     array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
    1411     array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
     1417        array( 60 * 60 * 24 * 365 , __( 'year', 'buddypress' ), __( 'years', 'buddypress' ) ),
     1418        array( 60 * 60 * 24 * 30 , __( 'month', 'buddypress' ), __( 'months', 'buddypress' ) ),
     1419        array( 60 * 60 * 24 * 7, __( 'week', 'buddypress' ), __( 'weeks', 'buddypress' ) ),
     1420        array( 60 * 60 * 24 , __( 'day', 'buddypress' ), __( 'days', 'buddypress' ) ),
     1421        array( 60 * 60 , __( 'hour', 'buddypress' ), __( 'hours', 'buddypress' ) ),
     1422        array( 60 , __( 'minute', 'buddypress' ), __( 'minutes', 'buddypress' ) ),
     1423        array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
    14121424    );
    14131425
     
    14211433    /* $newer_date will equal false if we want to know the time elapsed between a date and the current time */
    14221434    /* $newer_date will have a value if we want to work out time elapsed between two known dates */
    1423     $newer_date = ( !$newer_date ) ? gmmktime( gmdate( 'H' ), gmdate( 'i' ), gmdate( 's' ), gmdate( 'n' ), gmdate( 'j' ), gmdate( 'Y' ) ) : $newer_date;
     1435    $newer_date = ( !$newer_date ) ? strtotime( bp_core_current_time() ) : $newer_date;
    14241436
    14251437    /* Difference in seconds */
     
    14561468        if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
    14571469            /* Add to output var */
    1458             $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];
     1470            $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];
    14591471        }
    14601472    }
     
    14761488 * @package BuddyPress Core
    14771489 * @global $userdata WordPress user data for the current logged in user.
    1478  * @uses update_usermeta() WordPress function to update user metadata in the usermeta table.
     1490 * @uses update_user_meta() WordPress function to update user metadata in the usermeta table.
    14791491 */
    14801492function bp_core_record_activity() {
     
    14841496        return false;
    14851497
    1486     $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
     1498    $activity = get_user_meta( $bp->loggedin_user->id, 'last_activity', true );
    14871499
    14881500    if ( !is_numeric( $activity ) )
    14891501        $activity = strtotime( $activity );
    14901502
    1491     if ( '' == $activity || strtotime( gmdate( "Y-m-d H:i:s" ) ) >= strtotime( '+5 minutes', $activity ) )
    1492         update_usermeta( $bp->loggedin_user->id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     1503    // Get current time
     1504    $current_time = bp_core_current_time();
     1505
     1506    if ( '' == $activity || strtotime( $current_time ) >= strtotime( '+5 minutes', $activity ) )
     1507        update_user_meta( $bp->loggedin_user->id, 'last_activity', $current_time );
    14931508}
    14941509add_action( 'wp_head', 'bp_core_record_activity' );
     
    15491564 *
    15501565 * @package BuddyPress Core
    1551  * @global $comment WordPress comment global for the current comment.
    1552  * @uses bp_core_get_userlink_by_email() Fetches a userlink via email address.
     1566 *
     1567 * @global $bp $bp
     1568 * @global object $current_site
     1569 * @return string
    15531570 */
    15541571function bp_core_get_site_path() {
     
    16401657
    16411658    // Make sure we don't call status_header() in bp_core_do_catch_uri()
    1642     // as this conflicts with wp_redirect()
     1659    // as this conflicts with wp_redirect()
    16431660    $bp_no_status_set = true;
    16441661
     
    16991716 * @package BuddyPress Core
    17001717 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    1701  * @uses is_site_admin() Checks to see if the user is a site administrator.
     1718 * @uses is_super_admin() Checks to see if the user is a site administrator.
    17021719 * @uses wpmu_delete_user() Deletes a user from the system on multisite installs.
    17031720 * @uses wp_delete_user() Deletes a user from the system on singlesite installs.
     
    17051722 */
    17061723function bp_core_delete_account( $user_id = false ) {
    1707     global $bp, $wpdb, $wp_version;
     1724    global $bp, $wp_version;
    17081725
    17091726    if ( !$user_id )
     
    17151732
    17161733    /* Site admins cannot be deleted */
    1717     if ( is_site_admin( bp_core_get_username( $user_id ) ) )
     1734    if ( is_super_admin( bp_core_get_username( $user_id ) ) )
    17181735        return false;
    17191736
     
    17911808function bp_core_ucfirst( $str ) {
    17921809    if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
    1793         $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
    1794         return $fc.mb_substr( $str, 1 );
     1810        $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
     1811        return $fc.mb_substr( $str, 1 );
    17951812    } else {
    17961813        return ucfirst( $str );
     
    18391856 */
    18401857function bp_core_print_generation_time() {
    1841     global $wpdb;
    1842     ?>
     1858?>
    18431859
    18441860<!-- Generated in <?php timer_stop(1); ?> seconds. -->
     
    19271943 * @package BuddyPress Core
    19281944 * @param $user_id The user id for the user to delete usermeta for
    1929  * @uses delete_usermeta() deletes a row from the wp_usermeta table based on meta_key
     1945 * @uses delete_user_meta() deletes a row from the wp_usermeta table based on meta_key
    19301946 */
    19311947function bp_core_remove_data( $user_id ) {
    19321948    /* Remove usermeta */
    1933     delete_usermeta( $user_id, 'last_activity' );
     1949    delete_user_meta( $user_id, 'last_activity' );
    19341950
    19351951    /* Flush the cache to remove the user from all cached objects */
     
    19902006        return false;
    19912007
    1992     if ( !is_site_admin() )
     2008    if ( !is_super_admin() )
    19932009        return false;
    19942010
     
    21212137
    21222138/**
     2139 * bp_core_add_global_group()
     2140 *
     2141 * Add's 'bp' to global group of network wide cachable objects
     2142 *
     2143 * @package BuddyPress Core
     2144 */
     2145function bp_core_add_global_group() {
     2146    wp_cache_init();
     2147
     2148    if ( function_exists( 'wp_cache_add_global_groups' ) )
     2149        wp_cache_add_global_groups( array( 'bp' ) );
     2150}
     2151add_action( 'init', 'bp_core_add_global_group' );
     2152
     2153/**
    21232154 * bp_core_clear_user_object_cache()
    21242155 *
  • tags/1.2.6/bp-core/bp-core-admin.php

    • Property svn:eol-style deleted
  • tags/1.2.6/bp-core/bp-core-adminbar.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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' );
  • tags/1.2.6/bp-core/bp-core-avatars.php

    • Property svn:eol-style deleted
    r12731 r12731  
    478478 */
    479479function bp_core_fetch_avatar_filter( $avatar, $user, $size, $default, $alt ) {
    480 
     480    global $pagenow;
     481   
     482    // Do not filter if inside WordPress options page
     483    if ( 'options-discussion.php' == $pagenow )
     484        return $avatar;
     485   
    481486    // If passed an object, assume $user->user_id
    482487    if ( is_object( $user ) )
     
    541546    // If multisite, and current blog does not match root blog, make adjustments
    542547    if ( bp_core_is_multisite() && BP_ROOT_BLOG != $current_blog->blog_id )
    543         $upload_dir['basedir'] = WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/';
     548        $upload_dir['basedir'] = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
    544549
    545550    return apply_filters( 'bp_core_avatar_upload_path', $upload_dir['basedir'] );
  • tags/1.2.6/bp-core/bp-core-catchuri.php

    • Property svn:eol-style deleted
    r12731 r12731  
    3333    global $bp, $current_blog;
    3434
    35     if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && bp_core_is_multisite() ) {
    36         /* Only catch URI's on the root blog if we are not running BP on multiple blogs */
     35    // Only catch URI's on the root blog if we are not running BP on multiple blogs
     36    if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && bp_core_is_multisite() )
    3737        if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
    3838            return false;
    39     }
    40 
     39
     40    // Ajax or not?
    4141    if ( strpos( $_SERVER['REQUEST_URI'], 'wp-load.php' ) )
    4242        $path = bp_core_referrer();
    4343    else
    44         $path = clean_url( $_SERVER['REQUEST_URI'] );
     44        $path = esc_url( $_SERVER['REQUEST_URI'] );
    4545
    4646    $path = apply_filters( 'bp_uri', $path );
    4747
    48     // Firstly, take GET variables off the URL to avoid problems,
    49     // they are still registered in the global $_GET variable */
     48    // Take GET variables off the URL to avoid problems,
     49    // they are still registered in the global $_GET variable
    5050    $noget = substr( $path, 0, strpos( $path, '?' ) );
    51     if ( $noget != '' ) $path = $noget;
    52 
    53     /* Fetch the current URI and explode each part separated by '/' into an array */
    54     $bp_uri = explode( "/", $path );
    55 
    56     /* Loop and remove empties */
     51    if ( $noget != '' )
     52        $path = $noget;
     53
     54    // Fetch the current URI and explode each part separated by '/' into an array
     55    $bp_uri = explode( '/', $path );
     56
     57    // Loop and remove empties
    5758    foreach ( (array)$bp_uri as $key => $uri_chunk )
    5859        if ( empty( $bp_uri[$key] ) ) unset( $bp_uri[$key] );
    5960
     61    // Running off blog other than root
    6062    if ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != BP_ROOT_BLOG ) {
    61         /* If we are running BuddyPress on any blog, not just a root blog, we need to first
    62            shift off the blog name if we are running a subdirectory install of WPMU. */
    63         if ( $current_blog->path != '/' )
    64             array_shift( $bp_uri );
    65     }
    66 
    67     /* Set the indexes, these are incresed by one if we are not on a VHOST install */
     63
     64        // Any subdirectory names must be removed from $bp_uri.
     65        // This includes two cases: (1) when WP is installed in a subdirectory,
     66        // and (2) when BP is running on secondary blog of a subdirectory
     67        // multisite installation. Phew!
     68        if ( $chunks = explode( '/', $current_blog->path ) ) {
     69            foreach( $chunks as $key => $chunk ) {
     70                $bkey = array_search( $chunk, $bp_uri );
     71
     72                if ( $bkey !== false )
     73                    unset( $bp_uri[$bkey] );
     74
     75                $bp_uri = array_values( $bp_uri );
     76            }
     77        }
     78    }
     79
     80    // Set the indexes, these are incresed by one if we are not on a VHOST install
    6881    $component_index = 0;
    69     $action_index = $component_index + 1;
     82    $action_index    = $component_index + 1;
    7083
    7184    // If this is a WordPress page, return from the function.
     
    7386        return false;
    7487
    75     /* Get site path items */
     88    // Get site path items
    7689    $paths = explode( '/', bp_core_get_site_path() );
    7790
    78     /* Take empties off the end of path */
     91    // Take empties off the end of path
    7992    if ( empty( $paths[count($paths) - 1] ) )
    8093        array_pop( $paths );
    8194
    82     /* Take empties off the start of path */
     95    // Take empties off the start of path
    8396    if ( empty( $paths[0] ) )
    8497        array_shift( $paths );
    8598
    86     foreach ( (array)$bp_uri as $key => $uri_chunk ) {
    87         if ( in_array( $uri_chunk, $paths )) {
     99    foreach ( (array)$bp_uri as $key => $uri_chunk )
     100        if ( in_array( $uri_chunk, $paths ))
    88101            unset( $bp_uri[$key] );
    89         }
    90     }
    91 
    92     /* Reset the keys by merging with an empty array */
    93     $bp_uri = array_merge( array(), $bp_uri );
     102
     103    // Reset the keys by merging with an empty array
     104    $bp_uri            = array_merge( array(), $bp_uri );
    94105    $bp_unfiltered_uri = $bp_uri;
    95106
    96     /* If we are under anything with a members slug, set the correct globals */
     107    // If we are under anything with a members slug, set the correct globals
    97108    if ( $bp_uri[0] == BP_MEMBERS_SLUG ) {
    98         $is_member_page = true;
     109        $is_member_page    = true;
    99110        $is_root_component = true;
    100111    }
    101112
    102     /* Catch a member page and set the current member ID */
     113    // Catch a member page and set the current member ID
    103114    if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
    104115        if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {
    105116            // We are within a member page, set up user id globals
    106117            if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
    107                 $displayed_user_id = bp_core_get_userid( $bp_uri[1] );
     118                $displayed_user_id = bp_core_get_userid( urldecode( $bp_uri[1] ) );
    108119            else
    109                 $displayed_user_id = bp_core_get_userid_from_nicename( $bp_uri[1] );
    110 
    111             unset($bp_uri[0]);
    112             unset($bp_uri[1]);
    113 
    114             /* Reset the keys by merging with an empty array */
     120                $displayed_user_id = bp_core_get_userid_from_nicename( urldecode( $bp_uri[1] ) );
     121
     122            unset( $bp_uri[0] );
     123            unset( $bp_uri[1] );
     124
     125            // Reset the keys by merging with an empty array
    115126            $bp_uri = array_merge( array(), $bp_uri );
    116127        }
    117128    } else {
    118129        if ( get_userdatabylogin( $bp_uri[0] ) || in_array( 'wp-load.php', $bp_uri ) ) {
    119             $is_member_page = true;
     130            $is_member_page    = true;
    120131            $is_root_component = true;
    121132
    122133            // We are within a member page, set up user id globals
    123134            if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
    124                 $displayed_user_id = bp_core_get_userid( $bp_uri[0] );
     135                $displayed_user_id = bp_core_get_userid( urldecode( $bp_uri[0] ) );
    125136            else
    126                 $displayed_user_id = bp_core_get_userid_from_nicename( $bp_uri[0] );
    127 
    128             unset($bp_uri[0]);
    129 
    130             /* Reset the keys by merging with an empty array */
     137                $displayed_user_id = bp_core_get_userid_from_nicename( urldecode( $bp_uri[0] ) );
     138
     139            unset( $bp_uri[0] );
     140
     141            // Reset the keys by merging with an empty array
    131142            $bp_uri = array_merge( array(), $bp_uri );
    132143        }
    133144    }
    134145
    135     if ( !isset($is_root_component) )
     146    if ( !isset( $is_root_component ) )
    136147        $is_root_component = in_array( $bp_uri[0], $bp->root_components );
    137148
     
    141152    }
    142153
    143     /* Set the current component */
     154    // Set the current component
    144155    $current_component = $bp_uri[$component_index];
    145156
    146     /* Set the current action */
    147     $current_action = $bp_uri[$action_index];
    148 
    149     /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
    150     $action_variables = $bp_uri;
    151 
    152     /* Unset the current_component and action from action_variables */
    153     unset($action_variables[$component_index]);
    154     unset($action_variables[$action_index]);
    155 
    156     /* Remove the username from action variables if this is not a VHOST install */
     157    // Set the current action
     158    $current_action    = $bp_uri[$action_index];
     159
     160    // Set the entire URI as the action variables, we will unset the current_component and action in a second
     161    $action_variables  = $bp_uri;
     162
     163    // Unset the current_component and action from action_variables
     164    unset( $action_variables[$component_index] );
     165    unset( $action_variables[$action_index] );
     166
     167    // Remove the username from action variables if this is not a VHOST install
    157168    if ( !is_subdomain_install() && !$is_root_component )
    158         array_shift($action_variables);
    159 
    160     /* Reset the keys by merging with an empty array */
     169        array_shift( $action_variables );
     170
     171    // Reset the keys by merging with an empty array
    161172    $action_variables = array_merge( array(), $action_variables );
    162173}
     
    246257    /* If this user has been marked as a spammer and the logged in user is not a site admin, redirect. */
    247258    if ( isset( $bp->displayed_user->id ) && bp_core_is_user_spammer( $bp->displayed_user->id ) ) {
    248         if ( !is_site_admin() )
     259        if ( !is_super_admin() )
    249260            bp_core_redirect( $bp->root_domain );
    250261        else
  • tags/1.2.6/bp-core/bp-core-classes.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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
     
    191191
    192192        /* Get paginated results */
    193         $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 );
    194195
    195196        /* Re-jig the SQL so we can get the total user count */
     
    211212
    212213        /* Get total user results */
    213         $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 );
    214216
    215217        /***
     
    236238            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    237239
    238         if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
    239             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        }
    240250
    241251        $letter = like_escape( $wpdb->escape( $letter ) );
     
    425435        if ( $this->id ) {
    426436            // Update
    427             $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 );
     437            $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 );
    428438        } else {
    429439            // Save
    430             $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 );
     440            $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 );
    431441        }
    432442
     
    486496}
    487497
     498/**
     499 * BP_Button
     500 *
     501 * API to create BuddyPress buttons
     502 *
     503 * @package BuddyPress Core
     504 * @since 1.2.6
     505 */
     506class BP_Button {
     507
     508    // Button properties
     509    var $id;
     510    var $component;
     511    var $must_be_logged_in;
     512    var $block_self;
     513
     514    // Wrapper div
     515    var $wrapper_class;
     516    var $wrapper_id;
     517
     518    // Button
     519    var $link_href;
     520    var $link_class;
     521    var $link_id;
     522    var $link_rel;
     523    var $link_title;
     524    var $link_text;
     525
     526    // HTML result
     527    var $contents;
     528
     529    /**
     530     * bp_button()
     531     *
     532     * Builds the button based on passed parameters:
     533     *
     534     * component: Which component this button is for
     535     * must_be_logged_in: Button only appears for logged in users
     536     * block_self: Button will not appear when viewing your own profile.
     537     * wrapper_id: The DOM ID of the button wrapper
     538     * wrapper_class: The DOM class of the button wrapper
     539     * link_href: The destination link of the button
     540     * link_title: Title of the button
     541     * link_id: The DOM ID of the button
     542     * link_class: The DOM class of the button
     543     * link_rel: The DOM rel of the button
     544     * link_text: The contents of the button
     545     *
     546     * @param array $args
     547     * @return bool False if not allowed
     548     */
     549    function bp_button( $args = '' ) {
     550
     551        $defaults = array(
     552            'id'                => '',
     553            'component'         => 'core',
     554            'must_be_logged_in' => true,
     555            'block_self'        => true,
     556
     557            'wrapper_id'        => '',
     558            'wrapper_class'     => '',
     559
     560            'link_href'         => '',
     561            'link_title'        => '',
     562            'link_id'           => '',
     563            'link_class'        => '',
     564            'link_rel'          => '',
     565            'link_text'         => '',
     566        );
     567
     568        $r = wp_parse_args( $args, $defaults );
     569        extract( $r, EXTR_SKIP );
     570
     571        // Required button properties
     572        $this->id                = $id;
     573        $this->component         = $component;
     574        $this->must_be_logged_in = (bool)$must_be_logged_in;
     575        $this->block_self        = (bool)$block_self;
     576
     577        // $id and $component are required
     578        if ( empty( $id ) || empty( $component ) )
     579            return false;
     580
     581        // No button if component is not active
     582        if ( !bp_is_active( $this->component ) )
     583            return false;
     584
     585        // No button for guests if must be logged in
     586        if ( true == $this->must_be_logged_in && !is_user_logged_in() )
     587            return false;
     588
     589        // No button if viewing your own profile
     590        if ( true == $this->block_self && bp_is_my_profile() )
     591            return false;
     592
     593        // Wrapper properties
     594        if ( !empty( $wrapper_id ) )
     595            $this->wrapper_id    = ' id="' . $wrapper_id . '"';
     596
     597        if ( !empty( $wrapper_class ) )
     598            $this->wrapper_class = ' class="generic-button ' . $wrapper_class . '"';
     599        else
     600            $this->wrapper_class = ' class="generic-button"';
     601
     602        // Link properties
     603        if ( !empty( $link_id ) )
     604            $this->link_id       = ' id="' . $link_id . '"';
     605
     606        if ( !empty( $link_href ) )
     607            $this->link_href     = ' href="' . $link_href . '"';
     608
     609        if ( !empty( $link_title ) )
     610            $this->link_title    = ' title="' . $link_title . '"';
     611
     612        if ( !empty( $link_rel ) )
     613            $this->link_rel      = ' rel="' . $link_rel . '"';
     614
     615        if ( !empty( $link_class ) )
     616            $this->link_class    = ' class="' . $link_class . '"';
     617
     618        if ( !empty( $link_text ) )
     619            $this->link_text     = $link_text;
     620
     621        // Build the button
     622        $this->contents  = '<div' . $this->wrapper_class . $this->wrapper_id . '>';
     623        $this->contents .= '<a'. $this->link_href . $this->link_title . $this->link_id . $this->link_rel . $this->link_class . '>' . $this->link_text . '</a>';
     624        $this->contents .= '</div>';
     625
     626        // Allow button to be manipulated externally
     627        $this->contents = apply_filters( 'bp_button_' . $component . '_' . $id, $this->contents, $this );
     628    }
     629
     630    /**
     631     * contents()
     632     *
     633     * Return contents of button
     634     *
     635     * @return string
     636     */
     637    function contents() {
     638        return $this->contents;
     639    }
     640
     641    /**
     642     * display()
     643     *
     644     * Output contents of button
     645     */
     646    function display() {
     647        if ( !empty( $this->contents ) )
     648            echo $this->contents;
     649    }
     650}
    488651
    489652?>
  • tags/1.2.6/bp-core/bp-core-cssjs.php

    • Property svn:eol-style deleted
    r12731 r12731  
    3636    global $bp;
    3737?>
     38
    3839    <style type="text/css">
    3940        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; }
     
    4142        ul#adminmenu li.toplevel_page_bp-general-settings .wp-menu-image a img { display: none; }
    4243    </style>
     44
    4345<?php
    4446}
     
    5153        return false;
    5254?>
     55
    5356    <script type="text/javascript"> jQuery(document).ready( function() { jQuery("a.confirm").click( function() { if ( confirm( '<?php _e( 'Are you sure?', 'buddypress' ) ?>' ) ) return true; else return false; }); });</script>
     57
    5458<?php
    5559}
     
    8286    $aspect_ratio = 1;
    8387
    84     /* Calculate Aspect Ratio */
     88    // Calculate Aspect Ratio
    8589    if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) )
    86          $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
     90        $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
    8791?>
     92
    8893    <script type="text/javascript">
    8994        jQuery(window).load( function(){
     
    120125        }
    121126    </script>
     127
    122128<?php
    123129}
     
    133139    global $bp;
    134140?>
     141
    135142    <style type="text/css">
    136143        .jcrop-holder { float: left; margin: 0 20px 20px 0; text-align: left; }
     
    146153        #avatar-upload-form img, #create-group-form img, #group-settings-form img { border: none !important; }
    147154    </style>
     155
    148156<?php
    149157}
     
    158166function bp_core_add_ajax_url_js() {
    159167    global $bp;
     168?>
    160169
    161     echo
    162 '<script type="text/javascript">var ajaxurl = "' . site_url( 'wp-load.php' ) . '";</script>
    163 ';
     170    <script type="text/javascript">var ajaxurl = "<?php echo site_url( 'wp-load.php' ); ?>";</script>
     171
     172<?php
    164173}
    165174add_action( 'wp_head', 'bp_core_add_ajax_url_js' );
    166175
    167 /**
    168  * bp_core_override_adminbar_css()
    169  *
    170  * Overrides the theme's admin bar CSS to hide the adminbar if disabled.
    171  *
    172  * @package BuddyPress Core
    173  */
    174 function bp_core_override_adminbar_css() {
    175     global $bp;
    176 
    177     if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
    178     ?>
    179 <style type="text/css">body { padding-top: 0 !important; } #wp-admin-bar { display: none; }</style>
    180     <?php }
    181 }
    182 add_action( 'wp_footer', 'bp_core_override_adminbar_css' );
    183176?>
  • tags/1.2.6/bp-core/bp-core-filters.php

    r12731 r12731  
    1111 */
    1212function bp_core_email_from_name_filter() {
    13     return apply_filters( 'bp_core_email_from_name_filter', get_blog_option( BP_ROOT_BLOG, 'blogname' ) );
     13    return apply_filters( 'bp_core_email_from_name_filter', wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ) );
    1414}
    1515add_filter( 'wp_mail_from_name', 'bp_core_email_from_name_filter' );
     
    4444    global $bp, $current_blog;
    4545
    46     if ( !is_site_admin() )
     46    if ( !is_super_admin() )
    4747        return $themes;
    4848
     
    166166    // Send email with activation link.
    167167    $activate_url = bp_get_activation_page() ."?key=$key";
    168     $activate_url = clean_url($activate_url);
     168    $activate_url = esc_url($activate_url);
    169169
    170170    $admin_email = get_site_option( "admin_email" );
     
    175175    $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    176176    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    177     $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
    178     $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
     177    $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, esc_url("http://{$domain}{$path}" ) );
     178    $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), esc_url('http://' . $domain . $path));
    179179
    180180    /* Send the message */
     
    195195
    196196    $activate_url = bp_get_activation_page() ."?key=$key";
    197     $activate_url = clean_url($activate_url);
     197    $activate_url = esc_url($activate_url);
    198198    $admin_email = get_site_option( "admin_email" );
    199199
     
    207207    $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    208208    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    209     $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}" ) );
     209    $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}" ) );
    210210    $subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' );
    211211
  • tags/1.2.6/bp-core/bp-core-notifications.php

    • Property svn:eol-style deleted
    r12731 r12731  
    55
    66    if ( !$date_notified )
    7         $date_notified = time();
     7        $date_notified = bp_core_current_time();
    88
    99    $notification = new BP_Core_Notification;
  • tags/1.2.6/bp-core/bp-core-settings.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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>
     
    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        }
  • tags/1.2.6/bp-core/bp-core-signup.php

    • Property svn:eol-style deleted
    r12731 r12731  
    425425        if ( !bp_core_is_multisite() ) {
    426426            $activation_key = wp_hash( $user_id );
    427             update_usermeta( $user_id, 'activation_key', $activation_key );
     427            update_user_meta( $user_id, 'activation_key', $activation_key );
    428428            bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key );
    429429        }
     
    475475    } else {
    476476        /* Get the user_id based on the $key */
    477         $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_value = %s", $key ) );
     477        $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'activation_key' AND meta_value = %s", $key ) );
    478478
    479479        if ( empty( $user_id ) )
     
    488488
    489489        /* Remove the activation key meta */
    490         delete_usermeta( $user_id, 'activation_key' );
     490        delete_user_meta( $user_id, 'activation_key' );
    491491    }
    492492
     
    495495
    496496    /* Add a last active entry */
    497     update_usermeta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     497    update_user_meta( $user_id, 'last_activity', bp_core_current_time() );
    498498
    499499    /* Set the password on multisite installs */
     
    538538
    539539    /* Add a last active entry */
    540     update_usermeta( $user_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
     540    update_user_meta( $user_id, 'last_activity', bp_core_current_time() );
    541541
    542542    /* Add the user's fullname to Xprofile */
    543543    if ( function_exists( 'xprofile_set_field_data' ) ) {
    544         $firstname = get_usermeta( $user_id, 'first_name' );
    545         $lastname = ' ' . get_usermeta( $user_id, 'last_name' );
     544        $firstname = get_user_meta( $user_id, 'first_name', true );
     545        $lastname = ' ' . get_user_meta( $user_id, 'last_name', true );
    546546        $name = $firstname . $lastname;
    547547
    548548        if ( empty( $name ) || ' ' == $name )
    549             $name = get_usermeta( $user_id, 'nickname' );
     549            $name = get_user_meta( $user_id, 'nickname', true );
    550550
    551551        xprofile_set_field_data( 1, $user_id, $name );
     
    575575function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) {
    576576    $activate_url = bp_get_activation_page() ."?key=$key";
    577     $activate_url = clean_url( $activate_url );
     577    $activate_url = esc_url( $activate_url );
    578578    $admin_email = get_site_option( "admin_email" );
    579579
  • tags/1.2.6/bp-core/bp-core-templatetags.php

    • Property svn:eol-style deleted
    r12731 r12731  
    2222
    2323        $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : $page_number;
    24         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    25         $this->type = $type;
    26 
    27         if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
     24        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     25        $this->type     = $type;
     26
     27        if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
    2828            $this->members = BP_Core_User::get_users_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras );
    29         } else {
     29        else
    3030            $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 ) );
    31         }
    3231
    3332        if ( !$max || $max >= (int)$this->members['total'] )
     
    3938
    4039        if ( $max ) {
    41             if ( $max >= count($this->members) )
    42                 $this->member_count = count($this->members);
    43             else
     40            if ( $max >= count($this->members) ) {
     41                $this->member_count = count( $this->members );
     42            } else {
    4443                $this->member_count = (int)$max;
     44            }
    4545        } else {
    46             $this->member_count = count($this->members);
     46            $this->member_count = count( $this->members );
    4747        }
    4848
    49         if ( (int) $this->total_member_count && (int) $this->pag_num ) {
     49        if ( (int)$this->total_member_count && (int)$this->pag_num ) {
    5050            $this->pag_links = paginate_links( array(
    51                 'base' => add_query_arg( 'upage', '%#%' ),
    52                 'format' => '',
    53                 'total' => ceil( (int) $this->total_member_count / (int) $this->pag_num ),
    54                 'current' => (int) $this->pag_page,
     51                'base'      => add_query_arg( 'upage', '%#%' ),
     52                'format'    => '',
     53                'total'     => ceil( (int)$this->total_member_count / (int)$this->pag_num ),
     54                'current'   => (int)$this->pag_page,
    5555                'prev_text' => '&larr;',
    5656                'next_text' => '&rarr;',
    57                 'mid_size' => 1
    58             ));
     57                'mid_size'  => 1
     58            ) );
    5959        }
    6060    }
     
    413413        global $members_template;
    414414
    415         $registered = attribute_escape( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
     415        $registered = esc_attr( bp_core_get_last_activity( $members_template->member->user_registered, __( 'registered %s ago', 'buddypress' ) ) );
    416416
    417417        return apply_filters( 'bp_member_last_active', $registered );
    418     }
    419 
    420 function bp_member_add_friend_button() {
    421     global $members_template;
    422 
    423     if ( function_exists( 'bp_add_friend_button' ) ) {
    424         if ( null === $members_template->member->is_friend )
    425             $friend_status = 'not_friends';
    426         else
    427             $friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend';
    428 
    429         echo bp_add_friend_button( $members_template->member->id, $friend_status );
    430     }
    431 }
    432 
    433 function bp_member_total_friend_count() {
    434     global $members_template;
    435 
    436     echo bp_get_member_total_friend_count();
    437 }
    438     function bp_get_member_total_friend_count() {
    439         global $members_template;
    440 
    441         if ( 1 == (int) $members_template->member->total_friend_count )
    442             return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
    443         else
    444             return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
    445418    }
    446419
     
    457430function bp_member_hidden_fields() {
    458431    if ( isset( $_REQUEST['s'] ) ) {
    459         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
     432        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['s'] ) . '" name="search_terms" />';
    460433    }
    461434
    462435    if ( isset( $_REQUEST['letter'] ) ) {
    463         echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
     436        echo '<input type="hidden" id="selected_letter" value="' . esc_attr( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    464437    }
    465438
    466439    if ( isset( $_REQUEST['members_search'] ) ) {
    467         echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['members_search'] ) . '" name="search_terms" />';
     440        echo '<input type="hidden" id="search_terms" value="' . esc_attr( $_REQUEST['members_search'] ) . '" name="search_terms" />';
    468441    }
    469442}
     
    478451    ?>
    479452    <form action="" method="get" id="search-members-form">
    480         <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>
     453        <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>
    481454        <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    482455    </form>
     
    516489    foreach( (array) $bp->bp_nav as $nav_item ) {
    517490        /* If the current component matches the nav item id, then add a highlight CSS class. */
    518         if ( !bp_is_directory && $bp->active_components[$bp->current_component] == $nav_item['css_id'] )
     491        if ( !bp_is_directory() && $bp->active_components[$bp->current_component] == $nav_item['css_id'] )
    519492            $selected = ' class="current selected"';
    520493        else
     
    626599        $bp->bp_options_title = __( 'Options', 'buddypress' );
    627600
    628     echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) );
     601    echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
    629602}
    630603
     
    841814
    842815function bp_format_time( $time, $just_date = false ) {
    843     $date = date( get_option('date_format'), $time );
    844 
     816    if ( !$time )
     817        return false;
     818
     819    // Get GMT offset from root blog
     820    $root_blog_offset = get_blog_option( BP_ROOT_BLOG, 'gmt_offset' );
     821
     822    // Calculate offset time
     823    $time_offest = $time + ( $root_blog_offset * 3600 );
     824
     825    // Current date (January 1, 2010)
     826    $date = date( 'F j, Y ', $time_offest );
     827
     828    // Should we show the time also?
    845829    if ( !$just_date ) {
    846         $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time );
     830        // Current time (9:50pm)
     831        $time = date( ' g:ia', $time_offest );
     832
     833        // Return string formatted with date and time
     834        $date = sprintf( __( '%1$s at %2$s', 'buddypress' ), $date, $time );
    847835    }
    848836
     
    901889    global $bp, $post, $wp_query, $current_blog;
    902890
    903     if ( is_front_page() || !bp_current_component() || ( is_home() && bp_is_page( 'home' ) ) ) {
     891    if ( is_front_page() || ( is_home() && bp_is_page( 'home' ) ) ) {
    904892        $title = __( 'Home', 'buddypress' );
    905893
     
    10851073
    10861074/**
     1075 * bp_button( $button )
     1076 *
     1077 * Creates and outputs a button.
     1078 * Args: div_id | div_class | a_href | a_title | a_id | a_class | a_rel | a_text
     1079 *
     1080 * @param array $button
     1081 */
     1082function bp_button( $button = '' ) {
     1083    echo bp_get_button( $button );
     1084}
     1085    /**
     1086     * bp_get_button( $button )
     1087     *
     1088     * Creates and returns a button.
     1089     * Args: div_id | div_class | a_href | a_title | a_id | a_class | a_rel | a_text
     1090     *
     1091     * @param array $button
     1092     * @return string
     1093     */
     1094    function bp_get_button( $button = '' ) {
     1095        $btn = new BP_Button( $button );
     1096        return apply_filters( 'bp_get_button', $btn->contents, $button );
     1097    }
     1098
     1099/**
    10871100 * bp_create_excerpt()
    10881101 *
     
    11181131add_filter( 'bp_create_excerpt', 'stripslashes_deep' );
    11191132add_filter( 'bp_create_excerpt', 'force_balance_tags' );
    1120 
    1121 /**
    1122  * bp_is_serialized()
    1123  *
    1124  * Checks to see if the data passed has been serialized.
    1125  *
    1126  * @package BuddyPress Core
    1127  * @param $data str The data that will be checked
    1128  * @return bool false if the data is not serialized
    1129  * @return bool true if the data is serialized
    1130  */
    1131 function bp_is_serialized( $data ) {
    1132     if ( '' == trim($data) )
    1133         return false;
    1134 
    1135     if ( preg_match( "/^(i|s|a|o|d)(.*);/si", $data ) )
    1136         return true;
    1137 
    1138     return false;
    1139 }
    11401133
    11411134function bp_total_member_count() {
     
    13321325        $user_id = $bp->displayed_user->id;
    13331326
    1334     $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') );
     1327    $last_activity = bp_core_get_last_activity( get_user_meta( $user_id, 'last_activity', true ), __('active %s ago', 'buddypress') );
    13351328
    13361329    if ( $echo )
     
    13431336    global $bp;
    13441337
    1345     if ( is_site_admin() || is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
     1338    if ( is_super_admin() || is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
    13461339        $has_access = true;
    13471340    else
     
    15181511
    15191512function bp_is_activity_front_page() {
    1520     return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == bp_core_get_site_path() );
     1513    global $current_blog;
     1514
     1515    if ( bp_core_is_main_site() )
     1516        $path = bp_core_get_site_path();
     1517    else
     1518        $path = $current_blog->path;
     1519
     1520    return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == $path );
    15211521}
    15221522
  • tags/1.2.6/bp-core/bp-core-widgets.php

    • Property svn:eol-style deleted
    r12731 r12731  
    2222        global $bp;
    2323
    24         extract( $args );
     24        extract( $args );
    2525
    2626        echo $before_widget;
     
    3232            <div class="item-options" id="members-list-options">
    3333                <span class="ajax-loader" id="ajax-loader-members"></span>
    34                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
    35                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
    36                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
     34                <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a>
     35                |  <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a>
     36
     37                <?php if ( bp_is_active( 'friends' ) ) : ?>
     38
     39                    | <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
     40
     41                <?php endif; ?>
     42
    3743            </div>
    3844
     
    5359            </ul>
    5460            <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
    55             <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'] ); ?>" />
    5662
    5763        <?php else: ?>
     
    7985        ?>
    8086
    81         <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>
    8288    <?php
    8389    }
     
    133139        ?>
    134140
    135         <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>
    136142    <?php
    137143    }
     
    148154        global $bp;
    149155
    150         extract( $args );
     156        extract( $args );
    151157
    152158        echo $before_widget;
     
    187193        ?>
    188194
    189         <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>
    190196    <?php
    191197    }
     
    202208        case 'newest-members':
    203209            $type = 'newest';
    204         break;
     210            break;
     211
    205212        case 'recently-active-members':
    206213            $type = 'active';
    207         break;
     214            break;
     215
    208216        case 'popular-members':
    209             $type = 'popular';
    210         break;
     217            if ( bp_is_active( 'friends' ) )
     218                $type = 'popular';
     219            else
     220                $type = 'active';
     221
     222            break;
    211223    }
    212224
     
    224236                        <?php if ( 'active' == $type || 'newest' == $type ) : ?>
    225237                            <div class="item-meta"><span class="activity"><?php bp_member_last_active() ?></span></div>
    226                         <?php else : ?>
     238                        <?php elseif ( bp_is_active( 'friends' ) ) : ?>
    227239                            <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count() ?></span></div>
    228240                        <?php endif; ?>
  • tags/1.2.6/bp-core/bp-core-wpabstraction.php

    r12731 r12731  
    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
     
    6891}
    6992
    70 if ( !function_exists( 'is_site_admin' ) ) {
    71     function is_site_admin( $user_id = false ) {
    72         if ( current_user_can( 'manage_options' ) )
    73             return true;
    74 
    75         return false;
    76     }
    77 }
    78 
    79 if ( !function_exists( 'get_current_user_id' ) ) {
    80     function get_current_user_id() {
    81         global $current_user;
    82         get_currentuserinfo();
    83         return $current_user->data->ID;
    84     }
    85 }
    86 
    8793if ( !function_exists( 'update_blog_status' ) ) {
    8894    function update_blog_status() {
     
    99105    }
    100106}
     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
     115?>
  • tags/1.2.6/bp-forums

    • Property svn:externals
      •  

        old new  
        1 bbpress http://svn.automattic.com/bbpress/branches/1.0
         1bbpress http://svn.automattic.com/bbpress/tags/1.0.2/
    • Property svn:ignore deleted
  • tags/1.2.6/bp-forums

    • Property svn:externals
      •  

        old new  
        1 bbpress http://svn.automattic.com/bbpress/branches/1.0
         1bbpress http://svn.automattic.com/bbpress/tags/1.0.2/
    • Property svn:ignore deleted
  • tags/1.2.6/bp-forums.php

    • Property svn:eol-style deleted
    r12731 r12731  
    6969            if ( $bp->groups->current_group = groups_get_group( array( 'group_id' => $_POST['topic_group_id'] ) ) ) {
    7070                /* Auto join this user if they are not yet a member of this group */
    71                 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 ) )
    7272                    groups_join_group( $bp->groups->current_group->id, $bp->groups->current_group->id );
    7373
     
    9595    global $bp;
    9696
    97     if ( !is_site_admin() )
     97    if ( !is_super_admin() )
    9898        return false;
    9999
     
    528528    global $bp, $wp_roles, $bb_table_prefix;
    529529
    530     $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 );
    531531
    532532    if ( empty( $bb_cap ) )
  • tags/1.2.6/bp-forums/bb-config.php

    • Property svn:eol-style deleted
  • tags/1.2.6/bp-forums/bp-forums-admin.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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        )
  • tags/1.2.6/bp-forums/bp-forums-bbpress.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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}
  • tags/1.2.6/bp-forums/bp-forums-filters.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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 );
     
    8989    }
    9090
     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
    91113?>
  • tags/1.2.6/bp-forums/bp-forums-templatetags.php

    • Property svn:eol-style deleted
    r12731 r12731  
    2424        global $bp;
    2525
    26         $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page;
    27         $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
    28         $this->type = $type;
     26        $this->pag_page     = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : $page;
     27        $this->pag_num      = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
     28        $this->type         = $type;
    2929        $this->search_terms = $search_terms;
    30         $this->forum_id = $forum_id;
     30        $this->forum_id     = $forum_id;
    3131
    3232        switch ( $type ) {
     
    5151
    5252        if ( !(int)$this->topics ) {
    53             $this->topic_count = 0;
     53            $this->topic_count       = 0;
    5454            $this->total_topic_count = 0;
    5555        } else {
     
    6363            }
    6464
    65             if ( !$max || $max >= $topic_count )
     65            if ( !$max || $max >= $topic_count ) {
    6666                $this->total_topic_count = $topic_count;
    67             else
     67            } else {
    6868                $this->total_topic_count = (int)$max;
     69            }
    6970
    7071            if ( $max ) {
    71                 if ( $max >= count($this->topics) )
     72                if ( $max >= count($this->topics) ) {
    7273                    $this->topic_count = count( $this->topics );
    73                 else
     74                } else {
    7475                    $this->topic_count = (int)$max;
     76                }
    7577            } else {
    7678                $this->topic_count = count( $this->topics );
     
    7880        }
    7981
    80         $this->topic_count = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
     82        $this->topic_count       = apply_filters( 'bp_forums_template_topic_count', $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
    8183        $this->total_topic_count = apply_filters( 'bp_forums_template_total_topic_count', $this->total_topic_count, $this->topic_count, &$topics, $type, $forum_id, $per_page, $max, $no_stickies );
    8284
    83         if ( !$no_stickies) {
    84             /* Place stickies at the top - not sure why bbPress doesn't do this? */
     85        if ( !$no_stickies ) {
     86            // Place stickies at the top - not sure why bbPress doesn't do this?
    8587            foreach( (array)$this->topics as $topic ) {
    86                 if ( 1 == (int)$topic->topic_sticky )
     88                if ( 1 == (int)$topic->topic_sticky ) {
    8789                    $stickies[] = $topic;
    88                 else
     90                } else {
    8991                    $standard[] = $topic;
     92                }
    9093            }
     94
    9195            $this->topics = array_merge( (array)$stickies, (array)$standard );
    9296        }
    9397
    94         /* Fetch extra information for topics, so we don't have to query inside the loop */
     98        // Fetch extra information for topics, so we don't have to query inside the loop
    9599        $this->topics = bp_forums_get_topic_extras( &$this->topics );
    96100
    97         $this->pag_links = paginate_links( array(
    98             'base' => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ),
    99             'format' => '',
    100             'total' => ceil($this->total_topic_count / $this->pag_num),
    101             'current' => $this->pag_page,
    102             'prev_text' => '&larr;',
    103             'next_text' => '&rarr;',
    104             'mid_size' => 1
    105         ));
     101        if ( (int)$this->total_topic_count && (int)$this->pag_num ) {
     102            $this->pag_links = paginate_links( array(
     103                'base'      => add_query_arg( array( 'p' => '%#%', 'n' => $this->pag_num ) ),
     104                'format'    => '',
     105                'total'     => ceil( (int)$this->total_topic_count / (int)$this->pag_num),
     106                'current'   => $this->pag_page,
     107                'prev_text' => '&larr;',
     108                'next_text' => '&rarr;',
     109                'mid_size'  => 1
     110            ) );
     111        }
    106112    }
    107113
     
    257263
    258264        $post = bb_get_first_post( (int)$forum_template->topic->topic_id, false );
    259         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 ) );
    260266    }
    261267
     
    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>';
     
    714720    var $order;
    715721
    716     function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {
     722    function BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order ) {
    717723        global $bp, $current_user, $forum_template;
    718724
    719         $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
    720         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    721 
    722         $this->topic_id = $topic_id;
     725        $this->pag_page        = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
     726        $this->pag_num         = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     727
     728        $this->order           = $order;
     729        $this->topic_id        = $topic_id;
    723730        $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
    724         $this->forum_id = $forum_template->topic->forum_id;
    725 
    726         $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) );
     731        $this->forum_id        = $forum_template->topic->forum_id;
     732
     733        $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 ) );
    727734
    728735        if ( !$this->posts ) {
    729             $this->post_count = 0;
     736            $this->post_count       = 0;
    730737            $this->total_post_count = 0;
    731738        } else {
    732             if ( !$max || $max >= (int) $forum_template->topic->topic_posts )
    733                 $this->total_post_count = (int) $forum_template->topic->topic_posts;
    734             else
     739            if ( !$max || $max >= (int)$forum_template->topic->topic_posts ) {
     740                $this->total_post_count = (int)$forum_template->topic->topic_posts;
     741            } else {
    735742                $this->total_post_count = (int)$max;
     743            }
    736744
    737745            if ( $max ) {
    738                 if ( $max >= count($this->posts) )
     746                if ( $max >= count( $this->posts ) ) {
    739747                    $this->post_count = count( $this->posts );
    740                 else
     748                } else {
    741749                    $this->post_count = (int)$max;
     750                }
    742751            } else {
    743752                $this->post_count = count( $this->posts );
     
    745754        }
    746755
    747         $this->pag_links = paginate_links( array(
    748             'base' => add_query_arg( array( 'topic_page' => '%#%', 'num' => $this->pag_num ) ),
    749             'format' => '',
    750             'total' => ceil($this->total_post_count / $this->pag_num),
    751             'current' => $this->pag_page,
    752             'prev_text' => '&larr;',
    753             'next_text' => '&rarr;',
    754             'mid_size' => 1
    755         ));
    756         $this->pag->total_pages = ceil($this->total_post_count / $this->pag_num);
     756        if ( (int)$this->total_post_count && (int)$this->pag_num ) {
     757            $this->pag_links = paginate_links( array(
     758                'base'      => add_query_arg( array( 'topic_page' => '%#%', 'num' => (int)$this->pag_num ) ),
     759                'format'    => '',
     760                'total'     => ceil( (int)$this->total_post_count / (int)$this->pag_num ),
     761                'current'   => $this->pag_page,
     762                'prev_text' => '&larr;',
     763                'next_text' => '&rarr;',
     764                'mid_size'  => 1
     765            ) );
     766
     767            $this->pag->total_pages = ceil( (int)$this->total_post_count / (int)$this->pag_num );
     768        } else {
     769            $this->pag->total_pages = 1;
     770        }
    757771    }
    758772
     
    809823        'topic_id' => false,
    810824        'per_page' => 15,
    811         'max' => false
     825        'max'      => false,
     826        'order'    => 'ASC'
    812827    );
    813828
     
    819834
    820835    if ( is_numeric( $topic_id ) ) {
    821         $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max );
     836        $topic_template = new BP_Forums_Template_Topic( $topic_id, $per_page, $max, $order );
    822837
    823838        // Current topic forum_id needs to match current_group forum_id
     
    971986
    972987        $post = bp_forums_get_post( $bp->action_variables[4] );
    973         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 ) );
    974989    }
    975990
     
    10151030?>
    10161031    <form action="" method="get" id="search-forums-form">
    1017         <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>
    10181033        <input type="submit" id="forums_search_submit" name="forums_search_submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    10191034    </form>
     
    10631078        global $topic_template;
    10641079
    1065         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'] ) );
    10661081    }
    10671082
     
    10721087        global $bp;
    10731088
    1074         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'] ) );
    10751090    }
    10761091
  • tags/1.2.6/bp-friends.php

    • Property svn:eol-style deleted
    r12731 r12731  
    2727               ) {$charset_collate};";
    2828
    29     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
     29    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    3030    dbDelta($sql);
    3131
     
    3434
    3535function friends_setup_globals() {
    36     global $bp, $wpdb;
     36    global $bp;
    3737
    3838    /* For internal identification */
    3939    $bp->friends->id = 'friends';
    4040
    41     $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
     41    $bp->friends->slug = BP_FRIENDS_SLUG;
     42
     43    $bp->friends->table_name = $bp->table_prefix . 'bp_friends';
     44
    4245    $bp->friends->format_notification_function = 'friends_format_notifications';
    43     $bp->friends->slug = BP_FRIENDS_SLUG;
    4446
    4547    /* Register this in the active components array */
     
    5153
    5254function friends_check_installed() {
    53     global $wpdb, $bp;
    54 
    55     if ( !is_site_admin() )
     55    global $bp;
     56
     57    if ( !is_super_admin() )
    5658        return false;
    5759
     
    156158                <td></td>
    157159                <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td>
    158                 <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>
    159                 <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>
     160                <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>
     161                <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>
    160162            </tr>
    161163            <tr>
    162164                <td></td>
    163165                <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td>
    164                 <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>
    165                 <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>
     166                <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>
     167                <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>
    166168            </tr>
    167169
     
    281283        'item_id' => false,
    282284        'secondary_item_id' => false,
    283         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     285        'recorded_time' => bp_core_current_time(),
    284286        'hide_sitewide' => false
    285287    );
     
    362364    $friendship->is_confirmed = 0;
    363365    $friendship->is_limited = 0;
    364     $friendship->date_created = time();
     366    $friendship->date_created = bp_core_current_time();
    365367
    366368    if ( $force_accept )
     
    416418        friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    417419
    418         /* Remove the friend request notice */
     420        // Remove the friend request notice
    419421        bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    420422
    421         /* Add a friend accepted notice for the initiating user */
     423        // Add a friend accepted notice for the initiating user
    422424        bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' );
    423425
     
    425427        $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
    426428
    427         /* Record in activity streams for the initiator */
     429        // Record in activity streams for the initiator
    428430        friends_record_activity( array(
    429             'user_id' => $friendship->initiator_user_id,
    430             'type' => 'friendship_created',
    431             'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
    432             'item_id' => $friendship_id
     431            'user_id'           => $friendship->initiator_user_id,
     432            'type'              => 'friendship_created',
     433            'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $initiator_link, $friend_link ), &$friendship ),
     434            'item_id'           => $friendship_id,
     435            'secondary_item_id' => $friendship->friend_user_id
    433436        ) );
    434437
    435         /* Record in activity streams for the friend */
     438        // Record in activity streams for the friend
    436439        friends_record_activity( array(
    437             'user_id' => $friendship->friend_user_id,
    438             'type' => 'friendship_created',
    439             'action' => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
    440             'item_id' => $friendship_id,
    441             'hide_sitewide' => true /* We've already got the first entry site wide */
     440            'user_id'           => $friendship->friend_user_id,
     441            'type'              => 'friendship_created',
     442            'action'            => apply_filters( 'friends_activity_friendship_accepted_action', sprintf( __( '%s and %s are now friends', 'buddypress' ), $friend_link, $initiator_link ), &$friendship ),
     443            'item_id'           => $friendship_id,
     444            'secondary_item_id' => $friendship->initiator_user_id,
     445            'hide_sitewide'     => true // We've already got the first entry site wide
    442446        ) );
    443447
    444         /* Send the email notification */
     448        // Send the email notification
    445449        require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
    446450        friends_notification_accepted_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
     
    488492
    489493    if ( !$count = wp_cache_get( 'bp_total_friend_count_' . $user_id, 'bp' ) ) {
    490         $count = get_usermeta( $user_id, 'total_friend_count' );
     494        $count = get_user_meta( $user_id, 'total_friend_count', true );
    491495        if ( empty( $count ) ) $count = 0;
    492496        wp_cache_set( 'bp_total_friend_count_' . $user_id, $count, 'bp' );
     
    591595function friends_update_friend_totals( $initiator_user_id, $friend_user_id, $status = 'add' ) {
    592596    if ( 'add' == $status ) {
    593         update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) + 1 );
    594         update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) + 1 );
     597        update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) + 1 );
     598        update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) + 1 );
    595599    } else {
    596         update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 );
    597         update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );
     600        update_user_meta( $initiator_user_id, 'total_friend_count', (int)get_user_meta( $initiator_user_id, 'total_friend_count', true ) - 1 );
     601        update_user_meta( $friend_user_id, 'total_friend_count', (int)get_user_meta( $friend_user_id, 'total_friend_count', true ) - 1 );
    598602    }
    599603}
     
    603607
    604608    /* Remove usermeta */
    605     delete_usermeta( $user_id, 'total_friend_count' );
     609    delete_user_meta( $user_id, 'total_friend_count' );
    606610
    607611    /* Remove friendship requests FROM user */
  • tags/1.2.6/bp-friends/bp-friends-classes.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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        }
     
    128128
    129129        // Do not update meta if user has never had friends
    130         if ( !$count && !get_usermeta( $user_id, 'total_friend_count' ) )
     130        if ( !$count && !get_user_meta( $user_id, 'total_friend_count', true ) )
    131131            return 0;
    132132
    133         update_usermeta( $user_id, 'total_friend_count', (int)$count );
     133        update_user_meta( $user_id, 'total_friend_count', (int)$count );
    134134        return (int)$count;
    135135    }
     
    203203        global $wpdb, $bp;
    204204
    205         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 ) );
    206206    }
    207207
  • tags/1.2.6/bp-friends/bp-friends-notifications.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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( __(
  • tags/1.2.6/bp-friends/bp-friends-templatetags.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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>
     
    115115}
    116116
    117 function bp_add_friend_button( $potential_friend_id = false, $friend_status = false ) {
     117function bp_member_add_friend_button() {
     118    global $members_template;
     119
     120    if ( null === $members_template->member->is_friend )
     121        $friend_status = 'not_friends';
     122    else
     123        $friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend';
     124
     125    echo bp_get_add_friend_button( $members_template->member->id, $friend_status );
     126}
     127add_action( 'bp_directory_members_actions', 'bp_member_add_friend_button' );
     128
     129function bp_member_total_friend_count() {
     130    global $members_template;
     131
     132    echo bp_get_member_total_friend_count();
     133}
     134    function bp_get_member_total_friend_count() {
     135        global $members_template;
     136
     137        if ( 1 == (int) $members_template->member->total_friend_count )
     138            return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
     139        else
     140            return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) );
     141    }
     142
     143/**
     144 * bp_potential_friend_id( $user_id )
     145 *
     146 * Outputs the ID of the potential friend
     147 *
     148 * @uses bp_get_potential_friend_id()
     149 * @param <type> $user_id
     150 */
     151function bp_potential_friend_id( $user_id = 0 ) {
     152    echo bp_get_potential_friend_id( $user_id );
     153}
     154    /**
     155     * bp_get_potential_friend_id( $user_id )
     156     *
     157     * Returns the ID of the potential friend
     158     *
     159     * @global object $bp
     160     * @global object $friends_template
     161     * @param int $user_id
     162     * @return int ID of potential friend
     163     */
     164    function bp_get_potential_friend_id( $user_id = 0 ) {
     165        global $bp, $friends_template;
     166
     167        if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) )
     168            $user_id = $friends_template->friendship->friend->id;
     169        else if ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) )
     170            $user_id = $bp->displayed_user->id;
     171
     172        return apply_filters( 'bp_get_potential_friend_id', (int)$user_id );
     173    }
     174
     175/**
     176 * bp_is_friend( $user_id )
     177 *
     178 * Returns - 'is_friend', 'not_friends', 'pending'
     179 *
     180 * @global object $bp
     181 * @param int $potential_friend_id
     182 * @return string
     183 */
     184function bp_is_friend( $user_id = 0 ) {
     185    global $bp;
     186
     187    if ( !is_user_logged_in() )
     188        return false;
     189
     190    if ( empty( $user_id ) )
     191        $user_id = bp_get_potential_friend_id( $user_id );
     192
     193    if ( $bp->loggedin_user->id == $user_id )
     194        return false;
     195
     196    return apply_filters( 'bp_is_friend', friends_check_friendship_status( $bp->loggedin_user->id, $user_id ), $user_id );
     197}
     198
     199function bp_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
    118200    echo bp_get_add_friend_button( $potential_friend_id, $friend_status );
    119201}
    120     function bp_get_add_friend_button( $potential_friend_id = false, $friend_status = false ) {
     202    function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
    121203        global $bp, $friends_template;
    122204
    123         if ( !is_user_logged_in() )
     205        if ( empty( $potential_friend_id ) )
     206            $potential_friend_id = bp_get_potential_friend_id( $potential_friend_id );
     207
     208        $is_friend = bp_is_friend( $potential_friend_id );
     209
     210        if ( empty( $is_friend ) )
    124211            return false;
    125212
    126         if ( !$potential_friend_id && $friends_template->friendship->friend )
    127             $potential_friend_id = $friends_template->friendship->friend->id;
    128         else if ( !$potential_friend_id && !$friends_template->friendship->friend )
    129             $potential_friend_id = $bp->displayed_user->id;
    130 
    131         if ( $bp->loggedin_user->id == $potential_friend_id )
    132             return false;
    133 
    134         if ( empty( $friend_status ) )
    135             $friend_status = friends_check_friendship_status( $bp->loggedin_user->id, $potential_friend_id );
    136 
    137         $button = '<div class="generic-button friendship-button ' . $friend_status . '" id="friendship-button-' . $potential_friend_id . '">';
    138         if ( 'pending' == $friend_status ) {
    139             $button .= '<a class="requested" href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/">' . __( 'Friendship Requested', 'buddypress' ) . '</a>';
    140         } else if ( 'is_friend' == $friend_status ) {
    141             $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ) . '" title="' . __('Cancel Friendship', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="remove" class="remove">' . __('Cancel Friendship', 'buddypress') . '</a>';
    142         } else {
    143             $button .= '<a href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ) . '" title="' . __('Add Friend', 'buddypress') . '" id="friend-' . $potential_friend_id . '" rel="add" class="add">' . __('Add Friend', 'buddypress') . '</a>';
     213        switch ( $is_friend ) {
     214            case 'pending' :
     215                $button = array(
     216                    'id'                => 'pending',
     217                    'component'         => 'friends',
     218                    'must_be_logged_in' => true,
     219                    'block_self'        => true,
     220                    'wrapper_class'     => 'friendship-button pending',
     221                    'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
     222                    'link_class'        => 'requested',
     223                    'link_href'         => trailingslashit( $bp->loggedin_user->domain . $bp->friends->slug ),
     224                    'link_text'         => __( 'Friendship Requested', 'buddypress' ),
     225                    'link_title'        => __( 'Friendship Requested', 'buddypress' )
     226                );
     227                break;
     228
     229            case 'is_friend' :
     230                $button = array(
     231                    'id'                => 'is_friend',
     232                    'component'         => 'friends',
     233                    'must_be_logged_in' => true,
     234                    'block_self'        => true,
     235                    'wrapper_class'     => 'friendship-button is_friend',
     236                    'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
     237                    'link_class'        => '',
     238                    'link_href'         => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ),
     239                    'link_text'         => __( 'Cancel Friendship', 'buddypress' ),
     240                    'link_title'        => __( 'Cancel Friendship', 'buddypress' ),
     241                    'link_id'           => 'friend-' . $potential_friend_id,
     242                    'link_rel'          => 'remove',
     243                    'link_class'        => 'remove'
     244                );
     245                break;
     246
     247            default:
     248                $button = array(
     249                    'id'                => 'not_friends',
     250                    'component'         => 'friends',
     251                    'must_be_logged_in' => true,
     252                    'block_self'        => true,
     253                    'wrapper_class'     => 'friendship-button not_friends',
     254                    'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
     255                    'link_class'        => '',
     256                    'link_href'         => wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ),
     257                    'link_text'         => __( 'Add Friend', 'buddypress' ),
     258                    'link_title'        => __( 'Add Friend', 'buddypress' ),
     259                    'link_id'           => 'friend-' . $potential_friend_id,
     260                    'link_rel'          => 'add',
     261                    'link_class'        => 'add'
     262                );
     263                break;
    144264        }
    145         $button .= '</div>';
    146 
    147         return apply_filters( 'bp_get_add_friend_button', $button );
     265
     266        // Filter and return the HTML button
     267        return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) );
    148268    }
    149269
     
    209329    }
    210330
    211 function bp_total_friend_count( $user_id = false ) {
     331function bp_total_friend_count( $user_id = 0 ) {
    212332    echo bp_get_total_friend_count( $user_id );
    213333}
    214     function bp_get_total_friend_count( $user_id = false ) {
     334    function bp_get_total_friend_count( $user_id = 0 ) {
    215335        return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) );
    216336    }
    217337    add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' );
    218338
    219 function bp_friend_total_requests_count( $user_id = false ) {
     339function bp_friend_total_requests_count( $user_id = 0 ) {
    220340    echo bp_friend_get_total_requests_count( $user_id );
    221341}
    222     function bp_friend_get_total_requests_count( $user_id = false ) {
     342    function bp_friend_get_total_requests_count( $user_id = 0 ) {
    223343        global $bp;
    224344
    225         if ( !$user_id )
     345        if ( empty( $user_id ) )
    226346            $user_id = $bp->loggedin_user->id;
    227347
  • tags/1.2.6/bp-groups.php

    • Property svn:eol-style deleted
    r12731 r12731  
    6161           ) {$charset_collate};";
    6262
    63     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
     63    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    6464    dbDelta($sql);
    6565
     
    7575    $bp->groups->id = 'groups';
    7676
    77     $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
    78     $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members';
    79     $bp->groups->table_name_groupmeta = $wpdb->base_prefix . 'bp_groups_groupmeta';
     77    $bp->groups->slug = BP_GROUPS_SLUG;
     78
     79    $bp->groups->table_name           = $bp->table_prefix . 'bp_groups';
     80    $bp->groups->table_name_members   = $bp->table_prefix . 'bp_groups_members';
     81    $bp->groups->table_name_groupmeta = $bp->table_prefix . 'bp_groups_groupmeta';
     82
    8083    $bp->groups->format_notification_function = 'groups_format_notifications';
    81     $bp->groups->slug = BP_GROUPS_SLUG;
    8284
    8385    /* Register this in the active components array */
     
    9799    $bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) );
    98100
     101    // Auto join group when non group member performs group activity
     102    $bp->groups->auto_join = defined( 'BP_DISABLE_AUTO_GROUP_JOIN' ) ? false : true;
     103
    99104    do_action( 'groups_setup_globals' );
    100105}
     
    124129
    125130        /* Using "item" not "group" for generic support in other components. */
    126         if ( is_site_admin() )
     131        if ( is_super_admin() )
    127132            $bp->is_item_admin = 1;
    128133        else
     
    173178
    174179            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' ) ) ) )
    175                 $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />';
     180                $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
    176181
    177182            $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
     
    179184            // If this is a private or hidden group, does the user have access?
    180185            if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
    181                 if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_site_admin() )
     186                if ( $bp->groups->current_group->is_user_member && is_user_logged_in() || is_super_admin() )
    182187                    $bp->groups->current_group->user_has_access = true;
    183188                else
     
    201206
    202207            // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    203             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' )
     208            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' )
    204209                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 ) );
    205210
     
    239244
    240245    /* Don't show this menu to non site admins or if you're viewing your own profile */
    241     if ( !is_site_admin() )
     246    if ( !is_super_admin() )
    242247        return false;
    243248    ?>
     
    299304
    300305            groups_record_activity( array(
    301                 'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%s joined the group %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 ),
     306                'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%s joined the group %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 ),
    302307                'type' => 'joined_group',
    303308                'item_id' => $group->id
     
    365370
    366371                /* Auto join this user if they are not yet a member of this group */
    367                 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     372                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 ) )
    368373                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    369374
     
    543548
    544549                /* Auto join this user if they are not yet a member of this group */
    545                 if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     550                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 ) )
    546551                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    547552
     
    787792            $status = $bp->action_variables[2];
    788793
    789             /* Check the nonce first. */
     794            // Check the nonce first.
    790795            if ( !check_admin_referer( 'groups_promote_member' ) )
    791796                return false;
    792797
    793798            // Promote a user.
    794             if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) {
     799            if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) )
    795800                bp_core_add_message( __( 'There was an error when promoting that user, please try again', 'buddypress' ), 'error' );
    796             } else {
     801            else
    797802                bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
    798             }
    799803
    800804            do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
     
    806810            $user_id = $bp->action_variables[2];
    807811
    808             /* Check the nonce first. */
     812            // Check the nonce first.
    809813            if ( !check_admin_referer( 'groups_demote_member' ) )
    810814                return false;
    811815
    812816            // Demote a user.
    813             if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) {
     817            if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
    814818                bp_core_add_message( __( 'There was an error when demoting that user, please try again', 'buddypress' ), 'error' );
    815             } else {
     819            else
    816820                bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
    817             }
    818821
    819822            do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id );
     
    825828            $user_id = $bp->action_variables[2];
    826829
    827             /* Check the nonce first. */
     830            // Check the nonce first.
    828831            if ( !check_admin_referer( 'groups_ban_member' ) )
    829832                return false;
    830833
    831834            // Ban a user.
    832             if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) {
     835            if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
    833836                bp_core_add_message( __( 'There was an error when banning that user, please try again', 'buddypress' ), 'error' );
    834             } else {
     837            else
    835838                bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
    836             }
    837839
    838840            do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id );
     
    844846            $user_id = $bp->action_variables[2];
    845847
    846             /* Check the nonce first. */
     848            // Check the nonce first.
    847849            if ( !check_admin_referer( 'groups_unban_member' ) )
    848850                return false;
    849851
    850852            // Remove a ban for user.
    851             if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) {
     853            if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) )
    852854                bp_core_add_message( __( 'There was an error when unbanning that user, please try again', 'buddypress' ), 'error' );
    853             } else {
     855            else
    854856                bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) );
    855             }
    856857
    857858            do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id );
     859
     860            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
     861        }
     862
     863        if ( 'remove' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
     864            $user_id = $bp->action_variables[2];
     865
     866            // Check the nonce first.
     867            if ( !check_admin_referer( 'groups_remove_member' ) )
     868                return false;
     869
     870            // Remove a user.
     871            if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
     872                bp_core_add_message( __( 'There was an error removing that user from the group, please try again', 'buddypress' ), 'error' );
     873            else
     874                bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
     875
     876            do_action( 'groups_removed_member', $user_id, $bp->groups->current_group->id );
    858877
    859878            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/manage-members/' );
     
    930949    if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
    931950
    932         if ( !$bp->is_item_admin && !is_site_admin() )
     951        if ( !$bp->is_item_admin && !is_super_admin() )
    933952            return false;
    934953
     
    975994                <td></td>
    976995                <td><?php _e( 'A member invites you to join a group', 'buddypress' ) ?></td>
    977                 <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>
    978                 <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>
     996                <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>
     997                <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>
    979998            </tr>
    980999            <tr>
    9811000                <td></td>
    9821001                <td><?php _e( 'Group information is updated', 'buddypress' ) ?></td>
    983                 <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>
    984                 <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>
     1002                <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>
     1003                <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>
    9851004            </tr>
    9861005            <tr>
    9871006                <td></td>
    9881007                <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
    989                 <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>
    990                 <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>
     1008                <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>
     1009                <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>
    9911010            </tr>
    9921011            <tr>
    9931012                <td></td>
    9941013                <td><?php _e( 'A member requests to join a private group for which you are an admin', 'buddypress' ) ?></td>
    995                 <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>
    996                 <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>
     1014                <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>
     1015                <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>
    9971016            </tr>
    9981017
     
    11261145            /* Once we compelete all steps, record the group creation in the activity stream. */
    11271146            groups_record_activity( array(
    1128                 'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%s created the group %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>' ) ),
     1147                'action' => apply_filters( 'groups_activity_created_group_action', sprintf( __( '%s created the group %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>' ) ),
    11291148                'type' => 'created_group',
    11301149                'item_id' => $bp->groups->new_group_id
     
    13431362        'item_id' => false,
    13441363        'secondary_item_id' => false,
    1345         'recorded_time' => gmdate( "Y-m-d H:i:s" ),
     1364        'recorded_time' => bp_core_current_time(),
    13461365        'hide_sitewide' => $hide_sitewide
    13471366    );
     
    15301549
    15311550    if ( !$group_id ) {
    1532         /* If this is a new group, set up the creator as the first member and admin */
     1551        // If this is a new group, set up the creator as the first member and admin
    15331552        $member = new BP_Groups_Member;
    15341553        $member->group_id = $group->id;
     
    15401559
    15411560        $member->save();
     1561        do_action( 'groups_create_group', $group->id, $member, $group );
     1562
     1563    } else {
     1564        do_action( 'groups_update_group', $group->id, $group );
    15421565    }
    15431566
     
    16021625}
    16031626
     1627/**
     1628 * Delete a group and all of its associated meta
     1629 *
     1630 * @global object $bp BuddyPress global settings
     1631 * @param int $group_id
     1632 * @since 1.0
     1633 */
    16041634function groups_delete_group( $group_id ) {
    16051635    global $bp;
     
    16111641    // Get the group object
    16121642    $group = new BP_Groups_Group( $group_id );
    1613 
    16141643    if ( !$group->delete() )
    16151644        return false;
    16161645
    1617     /* Delete all group activity from activity streams */
    1618     if ( function_exists( 'bp_activity_delete_by_item_id' ) ) {
     1646    // Delete all group activity from activity streams
     1647    if ( bp_is_active( 'activity' ) )
    16191648        bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component' => $bp->groups->id ) );
    1620     }
    16211649
    16221650    // Remove all outstanding invites for this group
     
    16261654    bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
    16271655
    1628     do_action( 'groups_delete_group', $group_id );
     1656    // Remove forum if component is active and current group has one
     1657    if ( bp_is_active( 'forums' ) && $forum_id = groups_get_groupmeta( $group_id, 'forum_id' ) ) {
     1658        do_action( 'bbpress_init' );
     1659        bb_delete_forum( $forum_id );
     1660    }
     1661
     1662    do_action( 'groups_delete_group', $group_id);
    16291663
    16301664    return true;
     
    16881722
    16891723    /* Modify user's group memberhip count */
    1690     update_usermeta( $user_id, 'total_group_count', (int) get_usermeta( $user_id, 'total_group_count') - 1 );
     1724    update_user_meta( $user_id, 'total_group_count', (int) get_user_meta( $user_id, 'total_group_count', true ) - 1 );
    16911725
    16921726    /* If the user joined this group less than five minutes ago, remove the joined_group activity so
     
    17381772    /* Record this in activity streams */
    17391773    groups_record_activity( array(
    1740         'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %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>' ) ),
     1774        'action' => apply_filters( 'groups_activity_joined_group', sprintf( __( '%s joined the group %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>' ) ),
    17411775        'type' => 'joined_group',
    17421776        'item_id' => $group_id
     
    18901924}
    18911925
     1926/**
     1927 * Is the specified user the creator of the group?
     1928 *
     1929 * @param int $user_id
     1930 * @param int $group_id
     1931 * @since 1.2.6
     1932 * @uses BP_Groups_Member
     1933 */
     1934function groups_is_user_creator( $user_id, $group_id ) {
     1935    return BP_Groups_Member::check_is_creator( $user_id, $group_id );
     1936}
     1937
    18921938/*** Group Activity Posting **************************************************/
    18931939
     
    19101956
    19111957    /* Be sure the user is a member of the group before posting. */
    1912     if ( !is_site_admin() && !groups_is_user_member( $user_id, $group_id ) )
     1958    if ( !is_super_admin() && !groups_is_user_member( $user_id, $group_id ) )
    19131959        return false;
    19141960
    19151961    /* Record this in activity streams */
    1916     $activity_action = sprintf( __( '%s posted an update in the group %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>' );
     1962    $activity_action = sprintf( __( '%s posted an update in the group %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>' );
    19171963    $activity_content = $content;
    19181964
     
    19592005    $group = new BP_Groups_Group( $group_id );
    19602006
    1961     if ( !$group->enable_forum )
     2007    if ( !$group->enable_forum || !function_exists( 'bp_forums_setup' ) )
    19622008        return false;
    19632009
    19642010    $args = array(
    1965         'forum_id'      => groups_get_groupmeta( $group, 'forum_id' ),
    1966         'forum_name'    => $group->name,
    1967         'forum_desc'    => $group->desc,
    1968         'forum_slug'    => $group->slug
     2011        'forum_id'      => groups_get_groupmeta( $group_id, 'forum_id' ),
     2012        'forum_name'    => $group->name,
     2013        'forum_desc'    => $group->desc,
     2014        'forum_slug'    => $group->slug
    19692015    );
    19702016
     
    19852031        $topic = bp_forums_get_topic_details( $topic_id );
    19862032
    1987         $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %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>' );
     2033        $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %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>' );
    19882034        $activity_content = bp_create_excerpt( $post_text );
    19892035        $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     
    20242070        $topic = bp_forums_get_topic_details( $topic_id );
    20252071
    2026         $activity_action = sprintf( __( '%s started the forum topic %s in the group %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>' );
     2072        $activity_action = sprintf( __( '%s started the forum topic %s in the group %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>' );
    20272073        $activity_content = bp_create_excerpt( $topic_text );
    20282074
     
    20562102            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' ) );
    20572103
    2058         $activity_action = sprintf( __( '%s started the forum topic %s in the group %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>' );
     2104        $activity_action = sprintf( __( '%s started the forum topic %s in the group %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>' );
    20592105        $activity_content = bp_create_excerpt( $topic_text );
    20602106
     
    20902136        $topic = bp_forums_get_topic_details( $topic_id );
    20912137
    2092         $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %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>' );
     2138        $activity_action = sprintf( __( '%s posted on the forum topic %s in the group %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>' );
    20932139        $activity_content = bp_create_excerpt( $post_text );
    20942140        $primary_link = bp_get_group_permalink( $bp->groups->current_group ) . 'forum/topic/' . $topic->topic_slug . '/';
     
    23352381    do_action( 'groups_ban_member', $group_id, $user_id );
    23362382
    2337     if ( !$member->ban() )
    2338         return false;
    2339 
    2340     update_usermeta( $user_id, 'total_group_count', (int)$total_count - 1 );
     2383    return $member->ban();
    23412384}
    23422385
     
    23522395
    23532396    return $member->unban();
     2397}
     2398
     2399/*** Group Removal *******************************************************/
     2400
     2401function groups_remove_member( $user_id, $group_id ) {
     2402    global $bp;
     2403
     2404    if ( !$bp->is_item_admin )
     2405        return false;
     2406
     2407    $member = new BP_Groups_Member( $user_id, $group_id );
     2408
     2409    do_action( 'groups_remove_member', $group_id, $user_id );
     2410
     2411    return $member->remove();
    23542412}
    23552413
     
    24192477
    24202478    groups_record_activity( array(
    2421         'action'    => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $membership->user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $membership->user_id, &$group ),
     2479        'action'    => apply_filters( 'groups_activity_membership_accepted_action', sprintf( __( '%s joined the group %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 ),
    24222480        'type'      => 'joined_group',
    24232481        'item_id'   => $membership->group_id,
  • tags/1.2.6/bp-groups/bp-groups-classes.php

    • Property svn:eol-style deleted
    r12731 r12731  
    205205        }
    206206
    207         if ( !is_site_admin() )
     207        if ( !is_super_admin() )
    208208            $hidden_sql = "AND status != 'hidden'";
    209209
     
    264264            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    265265
    266         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     266        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    267267            $hidden_sql = "AND g.status != 'hidden'";
    268268
     
    296296            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    297297
    298         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     298        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    299299            $hidden_sql = "AND g.status != 'hidden'";
    300300
     
    329329        }
    330330
    331         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     331        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    332332            $hidden_sql = "AND g.status != 'hidden'";
    333333
     
    361361            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    362362
    363         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     363        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    364364            $hidden_sql = " AND g.status != 'hidden'";
    365365
     
    397397        }
    398398
    399         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 ) ) )
    400400            $hidden_sql = " AND g.status != 'hidden'";
    401401
     
    433433        }
    434434
    435         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 ) ) )
    436436            $hidden_sql = " AND g.status != 'hidden'";
    437437
     
    470470            $where_conditions[] = $wpdb->prepare( "g.status = 'public'" );
    471471
    472         if ( !is_site_admin() )
     472        if ( !is_super_admin() )
    473473            $where_conditions[] = $wpdb->prepare( "g.status != 'hidden'");
    474474
     
    506506        global $wpdb, $bp;
    507507
    508         if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
    509             return false;
    510 
    511         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() )
    512520            $hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
    513521
     
    536544            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    537545
    538         if ( !is_user_logged_in() || ( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
     546        if ( !is_user_logged_in() || ( !is_super_admin() && ( $user_id != $bp->loggedin_user->id ) ) )
    539547            $hidden_sql = "AND g.status != 'hidden'";
    540548
     
    597605        global $wpdb, $bp;
    598606
    599         if ( !is_site_admin() )
     607        if ( !is_super_admin() )
    600608            $hidden_sql = "WHERE status != 'hidden'";
    601609
     
    749757        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
    750758
    751         $group_count = get_usermeta( $this->user_id, 'total_group_count' );
     759        $group_count = get_user_meta( $this->user_id, 'total_group_count', true );
    752760        if ( !empty( $group_count ) )
    753             update_usermeta( $this->user_id, 'total_group_count', (int)$group_count - 1 );
     761            update_user_meta( $this->user_id, 'total_group_count', (int)$group_count - 1 );
    754762
    755763        return $this->save();
     
    763771
    764772        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
    765         update_usermeta( $this->user_id, 'total_group_count', (int)get_usermeta( $this->user_id, 'total_group_count' ) + 1 );
     773        update_user_meta( $this->user_id, 'total_group_count', (int)get_user_meta( $this->user_id, 'total_group_count', true ) + 1 );
    766774
    767775        return $this->save();
     
    769777
    770778    function accept_invite() {
    771         $this->inviter_id = 0;
    772         $this->is_confirmed = 1;
    773         $this->date_modified = gmdate( "Y-m-d H:i:s" );
     779        $this->inviter_id    = 0;
     780        $this->is_confirmed  = 1;
     781        $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 );
    774784    }
    775785
    776786    function accept_request() {
    777787        $this->is_confirmed = 1;
    778         $this->date_modified = gmdate( "Y-m-d H:i:s" );
     788        $this->date_modified = bp_core_current_time();
     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 );
     797
     798        if ( !$result = $wpdb->query( $sql ) )
     799            return false;
     800
     801        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
     802
     803        $group_count = get_user_meta( $this->user_id, 'total_group_count', true );
     804        if ( !empty( $group_count ) )
     805            update_user_meta( $this->user_id, 'total_group_count', (int)$group_count - 1 );
     806
     807        return $result;
    779808    }
    780809
     
    873902            $user_id = $bp->displayed_user->id;
    874903
    875         if ( $user_id != $bp->loggedin_user->id && !is_site_admin() ) {
     904        if ( $user_id != $bp->loggedin_user->id && !is_super_admin() ) {
    876905            return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND g.status != 'hidden' AND m.user_id = %d AND m.is_confirmed = 1 AND m.is_banned = 0", $user_id ) );
    877906        } else {
     
    953982
    954983        return $wpdb->get_var( $wpdb->prepare( "SELECT is_banned FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
     984    }
     985
     986    /**
     987     * Is the specified user the creator of the group?
     988     *
     989     * @global object $bp BuddyPress global settings
     990     * @global wpdb $wpdb WordPress database object
     991     * @param int $user_id
     992     * @param int $group_id
     993     * @since 1.2.6
     994     */
     995    function check_is_creator( $user_id, $group_id ) {
     996        global $bp, $wpdb;
     997
     998        if ( !$user_id )
     999            return false;
     1000
     1001        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name} WHERE creator_id = %d AND id = %d", $user_id, $group_id ) );
    9551002    }
    9561003
     
    10471094    }
    10481095
     1096    /**
     1097     * Delete all group membership information for the specified user
     1098     *
     1099     * @global object $bp BuddyPress global settings
     1100     * @global wpdb $wpdb WordPress database object
     1101     * @param int $user_id
     1102     * @since 1.0
     1103     * @uses BP_Groups_Member
     1104     */
    10491105    function delete_all_for_user( $user_id ) {
    1050         global $wpdb, $bp;
     1106        global $bp, $wpdb;
    10511107
    10521108        // Get all the group ids for the current user's groups and update counts
     
    10541110        foreach ( $group_ids['groups'] as $group_id ) {
    10551111            groups_update_groupmeta( $group_id, 'total_member_count', groups_get_total_member_count( $group_id ) - 1 );
     1112
     1113            // If current user is the creator of a group and is the sole admin, delete that group to avoid counts going out-of-sync
     1114            if ( groups_is_user_admin( $user_id, $group_id ) && count( groups_get_group_admins( $group_id ) ) < 2 && groups_is_user_creator( $user_id, $group_id ) )
     1115                groups_delete_group( $group_id );
    10561116        }
    10571117
     
    11251185
    11261186        if ( $this->enable_create_step ) {
    1127             /* Insert the group creation step for the new group extension */
     1187            // Insert the group creation step for the new group extension
    11281188            $bp->groups->group_creation_steps[$this->slug] = array( 'name' => $this->name, 'slug' => $this->slug, 'position' => $this->create_step_position );
    11291189
    1130             /* Attach the group creation step display content action */
     1190            // Attach the group creation step display content action
    11311191            add_action( 'groups_custom_create_steps', array( &$this, 'create_screen' ) );
    11321192
    1133             /* Attach the group creation step save content action */
     1193            // Attach the group creation step save content action
    11341194            add_action( 'groups_create_group_step_save_' . $this->slug, array( &$this, 'create_screen_save' ) );
    11351195        }
    11361196
    1137         /* Construct the admin edit tab for the new group extension */
     1197        // Construct the admin edit tab for the new group extension
    11381198        if ( $this->enable_edit_item ) {
    1139             add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . attribute_escape( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . attribute_escape( $this->slug ) . '\">' . attribute_escape( $this->name ) . '</a></li>";' ), 10, 2 );
    1140 
    1141             /* Catch the edit screen and forward it to the plugin template */
     1199            add_action( 'groups_admin_tabs', create_function( '$current, $group_slug', 'if ( "' . esc_attr( $this->slug ) . '" == $current ) $selected = " class=\"current\""; echo "<li{$selected}><a href=\"' . $bp->root_domain . '/' . $bp->groups->slug . '/{$group_slug}/admin/' . esc_attr( $this->slug ) . '\">' . esc_attr( $this->name ) . '</a></li>";' ), 10, 2 );
     1200
     1201            // Make sure user has access
     1202            if ( !$bp->is_item_admin )
     1203                return false;
     1204
     1205            // Catch the edit screen and forward it to the plugin template
    11421206            if ( $bp->current_component == $bp->groups->slug && 'admin' == $bp->current_action && $this->slug == $bp->action_variables[0] ) {
    11431207                add_action( 'wp', array( &$this, 'edit_screen_save' ) );
     
    11541218        }
    11551219
    1156         /* When we are viewing a single group, add the group extension nav item */
    1157         if ( $this->visbility == 'public' || ( $this->visbility != 'public' && $bp->groups->current_group->user_has_access ) ) {
     1220        // When we are viewing a single group, add the group extension nav item
     1221        if ( $this->visibility == 'public' || ( $this->visibility != 'public' && $bp->groups->current_group->user_has_access ) ) {
    11581222            if ( $this->enable_nav_item ) {
    11591223                if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item )
    11601224                    bp_core_new_subnav_item( array( 'name' => ( !$this->nav_item_name ) ? $this->name : $this->nav_item_name, 'slug' => $this->slug, 'parent_slug' => BP_GROUPS_SLUG, 'parent_url' => bp_get_group_permalink( $bp->groups->current_group ), 'position' => $this->nav_item_position, 'item_css_id' => 'nav-' . $this->slug, 'screen_function' => array( &$this, '_display_hook' ), 'user_has_access' => $this->enable_nav_item ) );
    11611225
    1162                 /* When we are viewing the extension display page, set the title and options title */
     1226                // When we are viewing the extension display page, set the title and options title
    11631227                if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && $bp->current_action == $this->slug ) {
    1164                     add_action( 'bp_template_content_header', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );
    1165                     add_action( 'bp_template_title', create_function( '', 'echo "' . attribute_escape( $this->name ) . '";' ) );
     1228                    add_action( 'bp_template_content_header', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
     1229                    add_action( 'bp_template_title', create_function( '', 'echo "' . esc_attr( $this->name ) . '";' ) );
    11661230                }
    11671231            }
    11681232
    1169             /* Hook the group home widget */
     1233            // Hook the group home widget
    11701234            if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
    11711235                add_action( $this->display_hook, array( &$this, 'widget_display' ) );
  • tags/1.2.6/bp-groups/bp-groups-filters.php

    • Property svn:eol-style deleted
    r12731 r12731  
    9393    global $bp;
    9494
    95     if ( is_site_admin() )
     95    if ( is_super_admin() )
    9696        return true;
    9797
  • tags/1.2.6/bp-groups/bp-groups-notifications.php

    • Property svn:eol-style deleted
    r12731 r12731  
    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 );
    111         $message = sprintf( __(
     113        $subject  = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name );
     114        $message  = sprintf( __(
    112115'Your membership request for the group "%s" has been accepted.
    113116
     
    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 "%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
     
    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
     
    269272
    270273            // Set up and send the message
    271             $ud = bp_core_get_core_userdata( $receiver_user_id );
    272             $to = $ud->user_email;
    273             $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in the group "%s"', 'buddypress' ), $poster_name, $group->name );
     274            $ud       = bp_core_get_core_userdata( $receiver_user_id );
     275            $to       = $ud->user_email;
     276            $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
     277            $subject  = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in the group "%s"', 'buddypress' ), $poster_name, $group->name );
    274278
    275279$message = sprintf( __(
  • tags/1.2.6/bp-groups/bp-groups-templatetags.php

    • Property svn:eol-style deleted
    r12731 r12731  
    2727
    2828        $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : $page;
    29         $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    30 
    31         if ( 'invites' == $type )
     29        $this->pag_num  = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     30
     31        if ( 'invites' == $type ) {
    3232            $this->groups = groups_get_invites_for_user( $user_id, $this->pag_num, $this->pag_page );
    33         else if ( 'single-group' == $type ) {
     33        } else if ( 'single-group' == $type ) {
    3434            $group = new stdClass;
    3535            $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
    36             $this->groups = array( $group );
    37         } else
     36            $this->groups    = array( $group );
     37        } else {
    3838            $this->groups = groups_get_groups( array( 'type' => $type, 'per_page' => $this->pag_num, 'page' =>$this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras ) );
     39        }
    3940
    4041        if ( 'invites' == $type ) {
    4142            $this->total_group_count = (int)$this->groups['total'];
    42             $this->group_count = (int)$this->groups['total'];
     43            $this->group_count       = (int)$this->groups['total'];
     44            $this->groups            = $this->groups['groups'];
     45        } else if ( 'single-group' == $type ) {
     46            $this->single_group      = true;
     47            $this->total_group_count = 1;
     48            $this->group_count       = 1;
     49        } else {
     50            if ( !$max || $max >= (int)$this->groups['total'] ) {
     51                $this->total_group_count = (int)$this->groups['total'];
     52            } else {
     53                $this->total_group_count = (int)$max;
     54            }
     55
    4356            $this->groups = $this->groups['groups'];
    44         } else if ( 'single-group' == $type ) {
    45             $this->single_group = true;
    46             $this->total_group_count = 1;
    47             $this->group_count = 1;
    48         } else {
    49             if ( !$max || $max >= (int)$this->groups['total'] )
    50                 $this->total_group_count = (int)$this->groups['total'];
    51             else
    52                 $this->total_group_count = (int)$max;
    53 
    54             $this->groups = $this->groups['groups'];
    5557
    5658            if ( $max ) {
    57                 if ( $max >= count($this->groups) )
    58                     $this->group_count = count($this->groups);
    59                 else
     59                if ( $max >= count($this->groups) ) {
     60                    $this->group_count = count( $this->groups );
     61                } else {
    6062                    $this->group_count = (int)$max;
     63                }
    6164            } else {
    62                 $this->group_count = count($this->groups);
     65                $this->group_count = count( $this->groups );
    6366            }
    6467        }
    6568
    66         $this->pag_links = paginate_links( array(
    67             'base' => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ),
    68             'format' => '',
    69             'total' => ceil($this->total_group_count / $this->pag_num),
    70             'current' => $this->pag_page,
    71             'prev_text' => '&larr;',
    72             'next_text' => '&rarr;',
    73             'mid_size' => 1
    74         ));
     69        // Build pagination links
     70        if ( (int)$this->total_group_count && (int)$this->pag_num ) {
     71            $this->pag_links = paginate_links( array(
     72                'base'      => add_query_arg( array( 'grpage' => '%#%', 'num' => $this->pag_num, 's' => $search_terms, 'sortby' => $this->sort_by, 'order' => $this->order ) ),
     73                'format'    => '',
     74                'total'     => ceil( (int)$this->total_group_count / (int)$this->pag_num ),
     75                'current'   => $this->pag_page,
     76                'prev_text' => '&larr;',
     77                'next_text' => '&rarr;',
     78                'mid_size'  => 1
     79            ) );
     80        }
    7581    }
    7682
     
    193199    global $bp, $groups_template;
    194200
    195     if ( $bp->loggedin_user->is_site_admin )
     201    if ( $bp->loggedin_user->is_super_admin )
    196202        return true;
    197203
     
    288294        /* Fetch the avatar from the folder, if not provide backwards compat. */
    289295        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 ) ) )
    290             $avatar = '<img src="' . attribute_escape( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . attribute_escape( $groups_template->group->name ) . '" />';
     296            $avatar = '<img src="' . esc_attr( $groups_template->group->avatar_thumb ) . '" class="avatar" alt="' . esc_attr( $groups_template->group->name ) . '" />';
    291297
    292298        return apply_filters( 'bp_get_group_avatar', $avatar );
     
    559565    echo sprintf( __( 'Viewing group %1$s to %2$s (of %3$s groups)', 'buddypress' ), $from_num, $to_num, $total ); ?> &nbsp;
    560566    <span class="ajax-loader"></span><?php
     567}
     568
     569function bp_groups_auto_join() {
     570    global $bp;
     571
     572    return apply_filters( 'bp_groups_auto_join', (bool)$bp->groups->auto_join );
    561573}
    562574
     
    870882}
    871883    function bp_get_group_member_unban_link( $user_id = false, $group = false ) {
    872         global $members_template;
     884        global $members_template, $groups_template;
    873885
    874886        if ( !$user_id )
     
    879891
    880892        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' ) );
     893    }
     894
     895
     896function bp_group_member_remove_link( $user_id = false ) {
     897    global $members_template;
     898
     899    if ( !$user_id )
     900        $user_id = $members_template->member->user_id;
     901
     902    echo bp_get_group_member_remove_link( $user_id );
     903}
     904    function bp_get_group_member_remove_link( $user_id = false, $group = false ) {
     905        global $members_template, $groups_template;
     906
     907        if ( !$group )
     908            $group =& $groups_template->group;
     909
     910        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' ) );
    881911    }
    882912
     
    962992 * Checks if current user is member of a group.
    963993 *
    964  * @uses is_site_admin Check if current user is super admin
     994 * @uses is_super_admin Check if current user is super admin
    965995 * @uses apply_filters Creates bp_group_is_member filter and passes $is_member
    966996 * @usedby groups/activity.php, groups/single/forum/edit.php, groups/single/forum/topic.php to determine template part visibility
     
    9741004
    9751005    // Site admins always have access
    976     if ( is_site_admin() )
     1006    if ( is_super_admin() )
    9771007        return true;
    9781008
     
    10661096}
    10671097
     1098function bp_group_new_topic_button() {
     1099    if ( bp_is_group_forum() && is_user_logged_in() && !bp_is_group_forum_topic() ) {
     1100        bp_button( array (
     1101            'id'                => 'new_topic',
     1102            'component'         => 'groups',
     1103            'must_be_logged_in' => true,
     1104            'block_self'        => true,
     1105            'wrapper_class'     => 'group-button',
     1106            'link_href'         => '#post-new',
     1107            'link_class'        => '',
     1108            'link_text'         => __( 'New Topic', 'buddypress' ),
     1109            'link_title'        => __( 'New Topic', 'buddypress' ),
     1110        ) );
     1111    }
     1112}
     1113
    10681114function bp_group_join_button( $group = false ) {
    1069     global $bp, $groups_template;
    1070 
    1071     if ( !$group )
    1072         $group =& $groups_template->group;
    1073 
    1074     // If they're not logged in or are banned from the group, no join button.
    1075     if ( !is_user_logged_in() || $group->is_banned )
    1076         return false;
    1077 
    1078     if ( !$group->status )
    1079         return false;
    1080 
    1081     if ( 'hidden' == $group->status && !$group->is_member )
    1082         return false;
    1083 
    1084     echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
    1085 
    1086     switch ( $group->status ) {
    1087         case 'public':
    1088             if ( $group->is_member )
    1089                 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    1090             else
    1091                 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
    1092         break;
    1093 
    1094         case 'private':
    1095             if ( $group->is_member ) {
    1096                 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    1097             } else {
    1098                 if ( !bp_group_has_requested_membership( $group ) )
    1099                     echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
    1100                 else
    1101                     echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
     1115    echo bp_get_group_join_button();
     1116}
     1117    function bp_get_group_join_button( $group = false ) {
     1118        global $bp, $groups_template;
     1119
     1120        if ( !$group )
     1121            $group =& $groups_template->group;
     1122
     1123        // If they're not logged in or are banned from the group, no join button.
     1124        if ( !is_user_logged_in() || $group->is_banned )
     1125            return false;
     1126
     1127        // Group creation was not completed or status is unknown
     1128        if ( !$group->status )
     1129            return false;
     1130
     1131        // Already a member
     1132        if ( $group->is_member ) {
     1133
     1134            // Stop sole admins from abandoning their group
     1135            if ( $bp->is_item_admin && count( groups_get_group_admins( $group->id ) ) < 2 )
     1136                return false;
     1137
     1138            $button = array(
     1139                'id'                => 'leave_group',
     1140                'component'         => 'groups',
     1141                'must_be_logged_in' => true,
     1142                'block_self'        => false,
     1143                'wrapper_class'     => 'group-button ' . $group->status,
     1144                'wrapper_id'        => 'groupbutton-' . $group->id,
     1145                'link_class'        => 'leave-group',
     1146                'link_href'         => wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ),
     1147                'link_text'         => __( 'Leave Group', 'buddypress' ),
     1148                'link_title'        => __( 'Leave Group', 'buddypress' )
     1149            );
     1150
     1151        // Not a member
     1152        } else {
     1153
     1154            // Show different buttons based on group status
     1155            switch ( $group->status ) {
     1156                case 'hidden' :
     1157                    return false;
     1158                    break;