Skip to:
Content

BuddyPress.org

Changeset 2077


Ignore:
Timestamp:
11/02/2009 07:54:21 PM (15 years ago)
Author:
apeatling
Message:

Merging 1.1 branch changes and syncing.

Location:
trunk
Files:
118 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2002 r2077  
    1414/* Include deprecated functions if settings allow */
    1515if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    16     require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );   
    17    
     16    require ( BP_PLUGIN_DIR . '/bp-activity/deprecated/bp-activity-deprecated.php' );
     17
    1818function bp_activity_install() {
    1919    global $wpdb, $bp;
    20    
     20
    2121    if ( !empty($wpdb->charset) )
    2222        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    23    
     23
    2424    $sql[] = "CREATE TABLE {$bp->activity->table_name} (
    2525                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    4141    require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    4242    dbDelta($sql);
    43    
     43
    4444    /* Drop the old sitewide and user activity tables */
    4545    $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_user_activity" );
    4646    $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->base_prefix}bp_activity_sitewide" );
    47    
     47
    4848    /* TODO: Rename the old user activity cached table */
    4949    //$wpdb->query( "RENAME TABLE {$wpdb->base_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}" );
     
    5757    /* Internal identifier */
    5858    $bp->activity->id = 'activity';
    59    
     59
    6060    $bp->activity->table_name = $wpdb->base_prefix . 'bp_activity_user_activity_cached';
    6161    $bp->activity->slug = BP_ACTIVITY_SLUG;
    62        
     62
    6363    /* Register this in the active components array */
    6464    $bp->active_components[$bp->activity->slug] = $bp->activity->id;
    65    
     65
    6666    do_action( 'bp_activity_setup_globals' );
    6767}
     
    6969add_action( 'admin_menu', 'bp_activity_setup_globals', 2 );
    7070
    71 function bp_activity_check_installed() {   
     71function bp_activity_check_installed() {
    7272    global $wpdb, $bp;
    73    
     73
    7474    if ( get_site_option('bp-activity-db-version') < BP_ACTIVITY_DB_VERSION )
    7575        bp_activity_install();
     
    100100        } else {
    101101            $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    102             $bp->bp_options_title = $bp->displayed_user->fullname; 
     102            $bp->bp_options_title = $bp->displayed_user->fullname;
    103103        }
    104104    }
     
    120120function bp_activity_screen_my_activity() {
    121121    do_action( 'bp_activity_screen_my_activity' );
    122     bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );   
     122    bp_core_load_template( apply_filters( 'bp_activity_template_my_activity', 'activity/just-me' ) );
    123123}
    124124
    125125function bp_activity_screen_friends_activity() {
    126126    do_action( 'bp_activity_screen_friends_activity' );
    127     bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );   
     127    bp_core_load_template( apply_filters( 'bp_activity_template_friends_activity', 'activity/my-friends' ) );
    128128}
    129129
     
    148148    /* Check the nonce */
    149149    check_admin_referer( 'bp_activity_delete_link' );
    150    
     150
    151151    $activity_id = $bp->action_variables[0];
    152    
     152
    153153    /* Check access */
    154154    if ( !is_site_admin() ) {
    155155        $activity = new BP_Activity_Activity( $activity_id );
    156        
     156
    157157        if ( $activity->user_id != $bp->loggedin_user->id )
    158158            return false;
    159159    }
    160    
     160
    161161    /* Now delete the activity item */
    162162    if ( bp_activity_delete_by_activity_id( $activity_id ) )
     
    164164    else
    165165        bp_core_add_message( __( 'There was an error when deleting that activity', 'buddypress' ), 'error' );
    166        
     166
    167167    do_action( 'bp_activity_action_delete_activity', $activity_id );
    168    
     168
    169169    bp_core_redirect( $_SERVER['HTTP_REFERER'] );
    170170}
     
    187187
    188188function bp_activity_action_personal_feed() {
    189     global $bp, $wp_query; 
     189    global $bp, $wp_query;
    190190
    191191    if ( $bp->current_component != $bp->activity->slug || !$bp->displayed_user->id || $bp->current_action != 'feed' )
    192192        return false;
    193    
     193
    194194    $wp_query->is_404 = false;
    195195    status_header( 200 );
     
    206206        return false;
    207207
    208     $wp_query->is_404 = false; 
     208    $wp_query->is_404 = false;
    209209    status_header( 200 );
    210210
    211211    include_once( 'bp-activity/feeds/bp-activity-friends-feed.php' );
    212     die;   
     212    die;
    213213}
    214214add_action( 'wp', 'bp_activity_action_friends_feed', 3 );
     
    226226function bp_activity_add( $args = '' ) {
    227227    global $bp, $wpdb;
    228    
     228
    229229    $defaults = array(
    230230        'content' => false, // The content of the activity item
     
    232232        'component_name' => false, // The name/ID of the component e.g. groups, profile, mycomponent
    233233        'component_action' => false, // The component action e.g. new_wire_post, profile_updated
    234        
     234
    235235        '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.
    236236        'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id, or wire_post_id
     
    242242    $r = wp_parse_args( $args, $defaults );
    243243    extract( $r, EXTR_SKIP );
    244    
     244
    245245    /* Insert the "time-since" placeholder */
    246246    if ( $content )
     
    257257    $activity->date_recorded = $recorded_time;
    258258    $activity->hide_sitewide = $hide_sitewide;
    259    
     259
    260260    if ( !$activity->save() )
    261261        return false;
    262262
    263263    do_action( 'bp_activity_add', $args );
    264    
     264
    265265    return true;
    266266}
     
    296296    do_action( 'bp_activity_delete_by_activity_id', $activity_id );
    297297
    298     return true;   
     298    return true;
    299299}
    300300
     
    316316
    317317    do_action( 'bp_activity_delete_for_user_by_component', $user_id, $component_name );
    318    
     318
    319319    return true;
    320320}
     
    322322function bp_activity_add_timesince_placeholder( $content ) {
    323323    /* Check a time-since span doesn't already exist */
    324     if ( false === strpos( $content, '<span class="time-since">' ) ) {     
     324    if ( false === strpos( $content, '<span class="time-since">' ) ) {
    325325        if ( !$pos = strpos( $content, '<blockquote' ) ) {
    326326            if ( !$pos = strpos( $content, '<div' ) ) {
     
    331331        }
    332332    }
    333    
     333
    334334    if ( (int) $pos ) {
    335335        $before = substr( $content, 0, (int) $pos );
    336336        $after = substr( $content, (int) $pos, strlen( $content ) );
    337        
     337
    338338        $content = $before . ' <span class="time-since">%s</span>' . $after;
    339339    }
     
    342342}
    343343
    344 function bp_activity_set_action( $component_id, $key, $value ) { 
    345     global $bp; 
    346 
    347     if ( empty( $component_id ) || empty( $key ) || empty( $value ) ) 
    348         return false; 
    349 
    350     $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array( 
    351         'key' => $key, 
    352         'value' => $value 
    353     ), $component_id, $key, $value ); 
    354 } 
    355 
    356 function bp_activity_get_action( $component_id, $key ) { 
    357     global $bp; 
    358 
    359     if ( empty( $component_id ) || empty( $key ) ) 
    360         return false; 
    361 
    362     return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key ); 
    363 } 
     344function bp_activity_set_action( $component_id, $key, $value ) {
     345    global $bp;
     346
     347    if ( empty( $component_id ) || empty( $key ) || empty( $value ) )
     348        return false;
     349
     350    $bp->activity->actions->{$component_id}->{$key} = apply_filters( 'bp_activity_set_action', array(
     351        'key' => $key,
     352        'value' => $value
     353    ), $component_id, $key, $value );
     354}
     355
     356function bp_activity_get_action( $component_id, $key ) {
     357    global $bp;
     358
     359    if ( empty( $component_id ) || empty( $key ) )
     360        return false;
     361
     362    return apply_filters( 'bp_activity_get_action', $bp->activity->actions->{$component_id}->{$key}, $component_id, $key );
     363}
    364364
    365365function bp_activity_check_exists_by_content( $content ) {
     
    389389    // Clear the user's activity from the sitewide stream and clear their activity tables
    390390    BP_Activity_Activity::delete_for_user( $user_id );
    391    
     391
    392392    do_action( 'bp_activity_remove_data', $user_id );
    393393}
     
    398398/* Ordering function - don't call this directly */
    399399function bp_activity_order_by_date( $a, $b ) {
    400     return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );   
     400    return apply_filters( 'bp_activity_order_by_date', strcasecmp( $b['date_recorded'], $a['date_recorded'] ) );
    401401}
    402402
  • trunk/bp-activity/bp-activity-classes.php

    r2036 r2077  
    1111    var $date_recorded;
    1212    var $hide_sitewide = false;
    13    
     13
    1414    function bp_activity_activity( $id = false ) {
    1515        global $bp;
    16        
     16
    1717        if ( $id ) {
    1818            $this->id = $id;
     
    2020        }
    2121    }
    22    
     22
    2323    function populate() {
    2424        global $wpdb, $bp;
    25        
     25
    2626        $activity = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE id = %d", $this->id ) );
    27        
     27
    2828        $this->id = $activity->id;
    2929        $this->item_id = $activity->item_id;
     
    3737        $this->hide_sitewide = $activity->hide_sitewide;
    3838    }
    39    
     39
    4040    function save() {
    4141        global $wpdb, $bp, $current_user;
    42        
     42
    4343        do_action( 'bp_activity_before_save', $this );
    4444
    4545        if ( !$this->component_name || !$this->component_action )
    4646            return false;
    47        
     47
    4848        /***
    4949         * Before v1.1 of BuddyPress, activity content was calculated at a later point. This is no longer the
     
    5454                if ( !$fetched_content = call_user_func( $bp->{$this->component_name}->format_activity_function, $this->item_id, $this->user_id, $this->component_action, $this->secondary_item_id, $this->for_secondary_user ) )
    5555                    return false;
    56                
     56
    5757                $this->content = $fetched_content['content'];
    5858                $this->primary_link = $fetched_content['primary_link'];
    5959            }
    6060        }
    61        
     61
    6262        if ( !$this->primary_link )
    6363            $this->primary_link = $bp->loggedin_user->domain;
    64        
     64
    6565        if ( $existing_activity_id = $this->exists() )
    6666            BP_Activity_Activity::delete_by_activity_id( $existing_activity_id );
    67        
     67
    6868        /* If we have an existing ID, update the activity item, otherwise insert it. */
    6969        if ( $this->id ) {
     
    8181        return false;
    8282    }
    83    
     83
    8484    function exists() {
    8585        global $wpdb, $bp;
    86        
     86
    8787        /* This doesn't seem to be working correctly at the moment, so it is disabled [TODO] */
    8888        return false;
    89        
     89
    9090        /* If we have an item id, try and match on that, if not do a content match */
    9191        if ( $this->item_id ) {
    9292            if ( $this->secondary_item_id )
    9393                $secondary_sql = $wpdb->prepare( " AND secondary_item_id = %s", $secondary_item_id );
    94                
    95             return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) );     
     94
     95            return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND item_id = %s{$secondary_sql} AND component_name = %s AND component_action = %s", $this->user_id, $this->item_id, $this->component_name, $this->component_action ) );
    9696        } else {
    97             return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) );             
    98         }
    99     }
    100    
    101     /* Static Functions */ 
     97            return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $this->user_id, $this->content, $this->component_name, $this->component_action ) );
     98        }
     99    }
     100
     101    /* Static Functions */
    102102
    103103    function delete( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
     
    106106        if ( $secondary_item_id )
    107107            $secondary_sql = $wpdb->prepare( "AND secondary_item_id = %s", $secondary_item_id );
    108        
     108
    109109        if ( $component_action )
    110110            $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
    111        
     111
    112112        if ( $user_id )
    113113            $user_sql = $wpdb->prepare( "AND user_id = %d", $user_id );
     
    115115        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE item_id = %s {$secondary_sql} AND component_name = %s {$component_action_sql} {$user_sql}", $item_id, $component_name ) );
    116116    }
    117    
     117
    118118    function delete_by_item_id( $item_id, $component_name, $component_action, $user_id = false, $secondary_item_id = false ) {
    119119        return BP_Activity_Activity::delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
     
    122122    function delete_by_activity_id( $activity_id ) {
    123123        global $bp, $wpdb;
    124        
     124
    125125        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE id = %d", $activity_id ) );
    126126    }
    127    
     127
    128128    function delete_by_content( $user_id, $content, $component_name, $component_action ) {
    129129        global $bp, $wpdb;
    130        
    131         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $user_id, $content, $component_name, $component_action ) );       
    132     }
    133    
     130
     131        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND content = %s AND component_name = %s AND component_action = %s", $user_id, $content, $component_name, $component_action ) );
     132    }
     133
    134134    function delete_for_user_by_component( $user_id, $component_name ) {
    135135        global $bp, $wpdb;
    136        
    137         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component_name = %s", $user_id, $component_name ) );       
    138     }
    139    
     136
     137        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d AND component_name = %s", $user_id, $component_name ) );
     138    }
     139
    140140    function delete_for_user( $user_id ) {
    141141        global $wpdb, $bp;
     
    143143        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->activity->table_name} WHERE user_id = %d", $user_id ) );
    144144    }
    145    
     145
    146146    function get_activity_for_user( $user_id, $max_items, $limit, $page, $filter ) {
    147147        global $wpdb, $bp;
    148                
     148
    149149        if ( $limit && $page )
    150150            $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    152152        if ( $max_items )
    153153            $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
    154        
     154
    155155        /* Sort out filtering */
    156156        if ( $filter )
    157157            $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
    158        
     158
    159159        if ( $limit && $page && $max_items )
    160160            $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql", $user_id ) );
    161161        else
    162162            $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql", $user_id ) );
    163        
     163
    164164        $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE user_id = %d $filter_sql ORDER BY date_recorded DESC $max_sql", $user_id ) );
    165        
     165
    166166        return array( 'activities' => $activities, 'total' => (int)$total_activities );
    167167    }
    168    
     168
    169169    function get_activity_for_friends( $user_id, $max_items, $max_items_per_friend, $limit, $page, $filter ) {
    170170        global $wpdb, $bp;
    171        
     171
    172172        // TODO: Max items per friend not yet implemented.
    173        
     173
    174174        if ( !function_exists('friends_get_friend_user_ids') )
    175175            return false;
     
    177177        if ( $limit && $page )
    178178            $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    179        
     179
    180180        if ( $max_items )
    181181            $max_sql = $wpdb->prepare( "LIMIT %d", $max_items );
     
    189189        if ( !$friend_ids )
    190190            return false;
    191            
     191
    192192        $friend_ids = implode( ',', $friend_ids );
    193        
     193
    194194        if ( $limit && $page && $max_items )
    195             $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql"  ) ); 
     195            $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql"  ) );
    196196        else
    197             $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );           
    198 
    199         $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $max_sql" ) ); 
    200        
     197            $activities = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT id, user_id, content, primary_link, date_recorded, component_name, component_action FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $pag_sql $max_sql" ) );
     198
     199        $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(user_id) FROM {$bp->activity->table_name} WHERE user_id IN ({$friend_ids}) $filter_sql ORDER BY date_recorded DESC $max_sql" ) );
     200
    201201        return array( 'activities' => $activities, 'total' => (int)$total_activities );
    202202    }
    203    
     203
    204204    function get_sitewide_activity( $max, $limit, $page, $filter ) {
    205205        global $wpdb, $bp;
    206        
     206
    207207        if ( $limit && $page )
    208208            $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    209        
     209
    210210        if ( $max )
    211211            $max_sql = $wpdb->prepare( "LIMIT %d", $max );
    212            
     212
    213213        /* Sort out filtering */
    214214        if ( $filter )
     
    224224        return array( 'activities' => $activities, 'total' => (int)$total_activities );
    225225    }
    226    
     226
    227227    function get_recorded_component_names() {
    228228        global $wpdb, $bp;
    229        
     229
    230230        return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT component_name FROM {$bp->activity->table_name} ORDER BY component_name ASC" ) );
    231231    }
    232    
     232
    233233    function get_sitewide_items_for_feed( $limit = 35 ) {
    234234        global $wpdb, $bp;
    235        
     235
    236236        $activities = bp_activity_get_sitewide_activity( $limit );
    237237        for ( $i = 0; $i < count($activities); $i++ ) {
     
    244244        }
    245245
    246         return $activity_feed; 
    247     }
    248    
     246        return $activity_feed;
     247    }
     248
    249249    function get_filter_sql( $filter_array ) {
    250250        global $wpdb;
    251        
     251
    252252        if ( !empty( $filter_array['object'] ) ) {
    253253            $object_filter = explode( ',', $filter_array['object'] );
    254254            $object_sql = ' AND ( ';
    255            
     255
    256256            $counter = 1;
    257257            foreach( (array) $object_filter as $object ) {
    258258                $object_sql .= $wpdb->prepare( "component_name = %s", trim( $object ) );
    259                
     259
    260260                if ( $counter != count( $object_filter ) )
    261261                    $object_sql .= ' || ';
    262                
     262
    263263                $counter++;
    264264            }
    265            
     265
    266266            $object_sql .= ' )';
    267267        }
     
    270270            $action_filter = explode( ',', $filter_array['action'] );
    271271            $action_sql = ' AND ( ';
    272            
     272
    273273            $counter = 1;
    274274            foreach( (array) $action_filter as $action ) {
    275275                $action_sql .= $wpdb->prepare( "component_action = %s", trim( $action ) );
    276                
     276
    277277                if ( $counter != count( $action_filter ) )
    278278                    $action_sql .= ' || ';
    279                
     279
    280280                $counter++;
    281281            }
    282            
     282
    283283            $action_sql .= ' )';
    284284        }
     
    287287            $pid_filter = explode( ',', $filter_array['primary_id'] );
    288288            $pid_sql = ' AND ( ';
    289            
     289
    290290            $counter = 1;
    291291            foreach( (array) $pid_filter as $pid ) {
    292292                $pid_sql .= $wpdb->prepare( "item_id = %s", trim( $pid ) );
    293                
     293
    294294                if ( $counter != count( $pid_filter ) )
    295295                    $pid_sql .= ' || ';
    296                
     296
    297297                $counter++;
    298298            }
    299            
     299
    300300            $pid_sql .= ' )';
    301301        }
     
    304304            $sid_filter = explode( ',', $filter_array['secondary_id'] );
    305305            $sid_sql = ' AND ( ';
    306            
     306
    307307            $counter = 1;
    308308            foreach( (array) $sid_filter as $sid ) {
    309309                $sid_sql .= $wpdb->prepare( "secondary_item_id = %s", trim( $sid ) );
    310                
     310
    311311                if ( $counter != count( $sid_filter ) )
    312312                    $sid_sql .= ' || ';
    313                
     313
    314314                $counter++;
    315315            }
    316            
     316
    317317            $sid_sql .= ' )';
    318318        }
    319        
     319
    320320        return $object_sql . $action_sql . $pid_sql . $sid_sql;
    321321    }
    322    
     322
    323323    function get_last_updated() {
    324324        global $bp, $wpdb;
    325        
     325
    326326        return $wpdb->get_var( $wpdb->prepare( "SELECT date_recorded FROM {$bp->activity->table_name} ORDER BY date_recorded ASC LIMIT 1" ) );
    327327    }
    328    
     328
    329329    function check_exists_by_content( $content ) {
    330330        global $wpdb, $bp;
  • trunk/bp-activity/bp-activity-filters.php

    r2055 r2077  
    1515function bp_activity_filter_kses( $content ) {
    1616    global $allowedtags;
    17    
     17
    1818    $activity_allowedtags = $allowedtags;
    1919    $activity_allowedtags['span'] = array();
    2020    $activity_allowedtags['span']['class'] = array();
    2121    $activity_allowedtags['a']['class'] = array();
    22     $activity_allowedtags['img'] = array(); 
     22    $activity_allowedtags['img'] = array();
    2323    $activity_allowedtags['img']['src'] = array();
    2424    $activity_allowedtags['img']['alt'] = array();
  • trunk/bp-activity/bp-activity-templatetags.php

    r2071 r2077  
    88    var $activity;
    99    var $activity_type;
    10    
     10
    1111    var $in_the_loop;
    12    
     12
    1313    var $pag_page;
    1414    var $pag_num;
     
    2626        if ( $type == 'sitewide' )
    2727            $this->activities = bp_activity_get_sitewide_activity( $max, $this->pag_num, $this->pag_page, $filter );
    28        
     28
    2929        if ( $type == 'personal' )
    3030            $this->activities = bp_activity_get_user_activity( $user_id, $max, $this->pag_num, $this->pag_page, $filter );
     
    3232        if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) )
    3333            $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter );
    34        
     34
    3535        if ( !$max || $max >= (int)$this->activities['total'] )
    3636            $this->total_activity_count = (int)$this->activities['total'];
    3737        else
    3838            $this->total_activity_count = (int)$max;
    39        
     39
    4040        $this->activities = $this->activities['activities'];
    41        
     41
    4242        if ( $max ) {
    4343            if ( $max >= count($this->activities) )
     
    4848            $this->activity_count = count($this->activities);
    4949        }
    50        
     50
    5151        $this->full_name = $bp->displayed_user->fullname;
    5252
     
    6363        }
    6464    }
    65    
     65
    6666    function has_activities() {
    6767        if ( $this->activity_count )
    6868            return true;
    69        
     69
    7070        return false;
    7171    }
    72    
     72
    7373    function next_activity() {
    7474        $this->current_activity++;
    7575        $this->activity = $this->activities[$this->current_activity];
    76        
     76
    7777        return $this->activity;
    7878    }
    79    
     79
    8080    function rewind_activities() {
    8181        $this->current_activity = -1;
     
    8484        }
    8585    }
    86    
    87     function user_activities() { 
     86
     87    function user_activities() {
    8888        if ( $this->current_activity + 1 < $this->activity_count ) {
    8989            return true;
     
    9797        return false;
    9898    }
    99    
     99
    100100    function the_activity() {
    101101        global $activity;
     
    103103        $this->in_the_loop = true;
    104104        $this->activity = $this->next_activity();
    105        
     105
    106106        if ( is_array( $this->activity ) )
    107107            $this->activity = (object) $this->activity;
     
    114114function bp_has_activities( $args = '' ) {
    115115    global $bp, $activities_template;
    116    
     116
    117117    /* Note: any params used for filtering can be a single value, or multiple values comma separated. */
    118    
     118
    119119    $defaults = array(
    120120        'type' => 'sitewide',
     
    138138            $per_page = $max;
    139139    }
    140    
     140
    141141    if ( isset( $_GET['afilter'] ) )
    142142        $filter = array( 'object' => $_GET['afilter'] );
    143143    else
    144144        $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
    145    
    146     $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter );       
     145
     146    $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $filter );
    147147    return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
    148148}
     
    160160function bp_activity_pagination_count() {
    161161    global $bp, $activities_template;
    162    
     162
    163163    $from_num = intval( ( $activities_template->pag_page - 1 ) * $activities_template->pag_num ) + 1;
    164164    $to_num = ( $from_num + ( $activities_template->pag_num - 1 ) > $activities_template->total_activity_count ) ? $activities_template->total_activity_count : $from_num + ( $activities_template->pag_num - 1) ;
     
    173173    function bp_get_activity_pagination_links() {
    174174        global $activities_template;
    175        
     175
    176176        return apply_filters( 'bp_get_activity_pagination_links', $activities_template->pag_links );
    177177    }
     
    179179function bp_activities_title() {
    180180    global $bp_activity_title;
    181    
     181
    182182    echo bp_get_activities_title();
    183183}
     
    190190function bp_activities_no_activity() {
    191191    global $bp_activity_no_activity;
    192    
     192
    193193    echo bp_get_activities_no_activity();
    194194}
    195195    function bp_get_activities_no_activity() {
    196196        global $bp_activity_no_activity;
    197        
     197
    198198        return apply_filters( 'bp_get_activities_no_activity', $bp_activity_no_activity );
    199199    }
     
    218218            'height' => 20,
    219219            'class' => 'avatar',
    220             'alt' => __( 'Avatar', 'buddypress' ) 
     220            'alt' => __( 'Avatar', 'buddypress' )
    221221        );
    222222
    223223        $r = wp_parse_args( $args, $defaults );
    224224        extract( $r, EXTR_SKIP );
    225        
     225
    226226        $item_id = false;
    227227        if ( (int)$activities_template->activity->user_id )
     
    235235        if ( $bp->blogs->id == $activities_template->activity->component_name && !(int) $activities_template->activity->user_id )
    236236            $object = 'blog';
    237        
     237
    238238        $object = apply_filters( 'bp_get_activity_avatar_object_' . $activities_template->activity->component_name, $object );
    239        
     239
    240240        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 ) ) );
    241241    }
     
    248248
    249249        if ( bp_is_home() && $activities_template->activity_type == 'personal' )
    250             $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name );                       
     250            $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name );
    251251        else
    252252            $content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name, true, false, false );
     
    254254        /* Add 'the_content' filter to activity to allow existing plugins to replace text as they would on post text. (extra smilies etc) */
    255255        $content = apply_filters( 'the_content', $content );
    256        
     256
    257257        return apply_filters( 'bp_get_activity_content', $content );
    258258    }
     
    260260function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $filter_words = true, $filter_you = true ) {
    261261    global $activities_template, $bp;
    262    
     262
    263263    if ( !$content )
    264264        return false;
    265        
     265
    266266    /* Split the content so we don't evaluate and replace text on content we don't want to */
    267267    $content = explode( '%s', $content );
     
    273273    if ( $insert_time )
    274274        $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded );
    275    
     275
    276276    // The "You" and "Your" conversion is only done in english, if a translation file is present
    277277    // then do not translate as it causes problems in other languages.
     
    284284        /* Remove the 'You' and replace if with the persons name */
    285285        if ( $filter_you && $full_name != '' ) {
    286             $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 );             
     286            $content[0] = preg_replace( "/{$full_name}[<]/", 'You<', $content[0], 1 );
    287287        }
    288288    }
     
    290290    /* Add the delete link if the user has permission on this item */
    291291    if ( ( $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() )
    292         $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1]; 
    293    
     292        $content[1] = '</span> <span class="activity-delete-link">' . bp_get_activity_delete_link() . '</span>' . $content[1];
     293
    294294    $content_new = '';
    295    
     295
    296296    for ( $i = 0; $i < count($content); $i++ )
    297297        $content_new .= $content[$i];
    298    
     298
    299299    return apply_filters( 'bp_activity_content_filter', $content_new );
    300300}
     
    306306    // Make sure we don't have any URL encoding in links when trying to insert the time.
    307307    $content = urldecode($content);
    308    
     308
    309309    return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( '&nbsp; %s ago', 'buddypress' ), bp_core_time_since( strtotime( $date ) ) ) ) );
    310310}
     
    315315    function bp_get_activity_css_class() {
    316316        global $activities_template;
    317        
     317
    318318        return apply_filters( 'bp_get_activity_css_class', $activities_template->activity->component_name );
    319319    }
     
    333333    function bp_get_activity_filter_links( $args = false ) {
    334334        global $activities_template, $bp;
    335        
     335
    336336        $defaults = array(
    337337            'style' => 'list'
     
    340340        $r = wp_parse_args( $args, $defaults );
    341341        extract( $r, EXTR_SKIP );
    342        
     342
    343343        /* Fetch the names of components that have activity recorded in the DB */
    344344        $component_names = BP_Activity_Activity::get_recorded_component_names();
    345        
     345
    346346        if ( !$component_names )
    347347            return false;
    348        
     348
    349349        foreach ( (array) $component_names as $component_name ) {
    350350            if ( isset( $_GET['afilter'] ) && $component_name == $_GET['afilter'] )
     
    352352            else
    353353                unset($selected);
    354            
     354
     355            $component_name = attribute_escape( $component_name );
     356
    355357            $component_name = attribute_escape( $component_name );
    356358
     
    372374                break;
    373375            }
    374            
     376
    375377            $link = add_query_arg( 'afilter', $component_name );
    376378            $link = remove_query_arg( 'acpage' , $link );
    377379
    378380            $link = apply_filters( 'bp_get_activity_filter_link_href', $link, $component_name );
    379            
     381
    380382            /* Make sure all core internal component names are translatable */
    381383            $translatable_component_names = array( __( 'profile', 'buddypress'), __( 'friends', 'buddypress' ), __( 'groups', 'buddypress' ), __( 'status', 'buddypress' ), __( 'blogs', 'buddypress' ) );
    382            
     384
    383385            $component_links[] = $before . '<a href="' . attribute_escape( $link ) . '">' . ucwords( __( $component_name, 'buddypress' ) ) . '</a>' . $after;
    384386        }
     
    388390        if ( isset( $_GET['afilter'] ) )
    389391            $component_links[] = '<' . $tag . ' id="afilter-clear"><a href="' . attribute_escape( $link ) . '"">' . __( 'Clear Filter', 'buddypress' ) . '</a></' . $tag . '>';
    390        
    391         return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
     392
     393        return apply_filters( 'bp_get_activity_filter_links', implode( "\n", $component_links ) );
    392394    }
    393395
     
    410412            return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/feed' );
    411413        else
    412             return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' );       
     414            return apply_filters( 'bp_get_activities_member_rss_link', $bp->displayed_user->domain . $bp->activity->slug . '/my-friends/feed' );
    413415    }
    414416
     
    421423        global $activities_template;
    422424
    423         return apply_filters( 'bp_get_activity_feed_item_title', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) );   
     425        return apply_filters( 'bp_get_activity_feed_item_title', md5( $activities_template->activity->date_recorded . '-' . $activities_template->activity->content ) );
    424426    }
    425427
     
    453455
    454456function bp_activity_feed_item_description() {
    455     echo bp_get_activity_feed_item_description();   
     457    echo bp_get_activity_feed_item_description();
    456458}
    457459    function bp_get_activity_feed_item_description() {
    458460        global $activities_template;
    459461
    460         return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) );   
     462        return apply_filters( 'bp_get_activity_feed_item_description', html_entity_decode( str_replace( '%s', '', $activities_template->activity->content ), ENT_COMPAT, 'UTF-8' ) );
    461463    }
    462464
  • trunk/bp-activity/bp-activity-widgets.php

    r1926 r2077  
    1414    function widget($args, $instance) {
    1515        global $bp;
    16        
     16
    1717        extract( $args );
    18        
     18
    1919        echo $before_widget;
    2020        echo $before_title
    21            . $widget_name . 
    22              ' <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>' 
     21           . $widget_name .
     22             ' <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>'
    2323           . $after_title; ?>
    24    
     24
    2525    <?php if ( bp_has_activities( 'type=sitewide&max=' . $instance['max_items'] . '&per_page=' . $instance['per_page'] ) ) : ?>
    2626
     
    3030                    <?php bp_activity_pagination_count() ?>
    3131                </div>
    32        
     32
    3333                <div class="pagination-links" id="activity-pag">
    3434                    &nbsp; <?php bp_activity_pagination_links() ?>
    3535                </div>
    3636            </div>
    37        
     37
    3838            <ul id="activity-filter-links">
    3939                <?php bp_activity_filter_links() ?>
    4040            </ul>
    4141        <?php endif; ?>
    42        
     42
    4343        <ul id="site-wide-stream" class="activity-list">
    4444        <?php while ( bp_activities() ) : bp_the_activity(); ?>
     
    4949                    </div>
    5050                <?php endif; ?>
    51                
     51
    5252                <?php bp_activity_content() ?>
    5353            </li>
     
    6161        </div>
    6262    <?php endif;?>
    63    
     63
    6464    <?php echo $after_widget; ?>
    6565    <?php
  • trunk/bp-activity/deprecated/bp-activity-deprecated.php

    r1909 r2077  
    44 *
    55 * This file contains functions that are deprecated.
    6  * You should not under any circumstance use these functions as they are 
     6 * You should not under any circumstance use these functions as they are
    77 * either no longer valid, or have been replaced with something much more awesome.
    88 *
     
    1313 * Of course, things will still work if you use these functions but you will
    1414 * be the laughing stock of the BuddyPress community. We will all point and laugh at
    15  * you. You'll also be making things harder for yourself in the long run, 
     15 * you. You'll also be making things harder for yourself in the long run,
    1616 * and you will miss out on lovely performance and functionality improvements.
    17  * 
     17 *
    1818 * If you've checked you are not using any deprecated functions and finished your little
    1919 * dance, you can add the following line to your wp-config.php file to prevent any of
     
    2525function bp_activity_deprecated_globals() {
    2626    global $bp;
    27    
     27
    2828    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    2929    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     
    3232    $bp->activity->image_base = BP_PLUGIN_URL . '/bp-activity/images';
    3333}
    34 add_action( 'plugins_loaded', 'bp_activity_deprecated_globals', 5 );   
     34add_action( 'plugins_loaded', 'bp_activity_deprecated_globals', 5 );
    3535add_action( 'admin_menu', 'bp_activity_deprecated_globals', 2 );
    3636
     
    3838function bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id = false, $user_id = false, $secondary_user_id = false, $recorded_time = false ) {
    3939    global $bp, $wpdb;
    40    
     40
    4141    if ( !$user_id )
    4242        $user_id = $bp->loggedin_user->id;
     
    4444    if ( !$recorded_time )
    4545        $recorded_time = time();
    46    
     46
    4747    $args = compact( 'user_id', 'content', 'component_name', 'component_action', 'item_id', 'secondary_item_id', 'recorded_time' );
    4848    bp_activity_add( $args );
    49    
     49
    5050    if ( $secondary_user_id  ) {
    5151        $hide_sitewide = true;
     
    5353        bp_activity_add( $args );
    5454    }
    55    
     55
    5656    do_action( 'bp_activity_record', $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id );
    57    
     57
    5858    return true;
    5959}
    6060
    6161/* DEPRECATED - use bp_activity_delete_by_item_id() */
    62 function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) { 
     62function bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ) {
    6363    if ( !bp_activity_delete_by_item_id( array( 'item_id' => $item_id, 'component_name' => $component_name, 'component_action' => $component_action, 'user_id' => $user_id, 'secondary_item_id' => $secondary_item_id ) ) )
    6464        return false;
    65        
     65
    6666    do_action( 'bp_activity_delete', $item_id, $component_name, $component_action, $user_id, $secondary_item_id );
    67    
     67
    6868    return true;
    6969}
     
    7272function bp_activity_get_list( $user_id, $title, $no_activity, $limit = false ) {
    7373    global $bp_activity_user_id, $bp_activity_limit, $bp_activity_title, $bp_activity_no_activity;
    74    
     74
    7575    $bp_activity_user_id = $user_id;
    7676    $bp_activity_limit = $limit;
    7777    $bp_activity_title = $title;
    7878    $bp_activity_no_activity = $no_activity;
    79    
     79
    8080    locate_template( array( '/activity/activity-list.php' ), true );
    8181}
     
    8787    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    8888        return $template;
    89        
     89
    9090    /* Enqueue the structure CSS file to give basic positional formatting for components */
    91     wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/deprecated/css/structure.css' );   
     91    wp_enqueue_style( 'bp-activity-structure', BP_PLUGIN_URL . '/bp-activity/deprecated/css/structure.css' );
    9292}
    9393add_action( 'bp_styles', 'bp_activity_add_structure_css' );
  • trunk/bp-blogs.php

    r2055 r2077  
    1313/* Include deprecated functions if settings allow */
    1414if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    15     require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' ); 
    16    
     15    require ( BP_PLUGIN_DIR . '/bp-blogs/deprecated/bp-blogs-deprecated.php' );
     16
    1717function bp_blogs_install() {
    1818    global $wpdb, $bp;
    19    
     19
    2020    if ( !empty($wpdb->charset) )
    2121        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    22    
     22
    2323    $sql[] = "CREATE TABLE {$bp->blogs->table_name} (
    2424                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    5252                KEY comment_post_id (comment_post_id)
    5353             ) {$charset_collate};";
    54    
     54
    5555    $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
    5656            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    6161            KEY meta_key (meta_key)
    6262           ) {$charset_collate};";
    63        
    64    
     63
     64
    6565    require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    6666
     
    6969    // On first installation - record all existing blogs in the system.
    7070    if ( !(int)get_site_option( 'bp-blogs-first-install') ) {
    71        
     71
    7272        bp_blogs_record_existing_blogs();
    7373        add_site_option( 'bp-blogs-first-install', 1 );
    74        
     74
    7575    } else {
    76        
    77         // Import blog titles and descriptions into the blogmeta table 
     76
     77        // Import blog titles and descriptions into the blogmeta table
    7878        if ( get_site_option( 'bp-blogs-version' ) <= '0.1.5' ) {
    7979            $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM " . $bp->blogs->table_name ) );
     
    8282                $name = get_blog_option( $blog_ids[$i], 'blogname' );
    8383                $desc = get_blog_option( $blog_ids[$i], 'blogdescription' );
    84                
     84
    8585                bp_blogs_update_blogmeta( $blog_ids[$i], 'name', $name );
    8686                bp_blogs_update_blogmeta( $blog_ids[$i], 'description', $desc );
     
    8888            }
    8989        }
    90        
    91     }
    92    
     90
     91    }
     92
    9393    update_site_option( 'bp-blogs-db-version', BP_BLOGS_DB_VERSION );
    9494}
    9595
    96 function bp_blogs_check_installed() {   
     96function bp_blogs_check_installed() {
    9797    global $wpdb, $bp, $userdata;
    98    
     98
    9999    if ( is_site_admin() ) {
    100100        /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
     
    107107function bp_blogs_setup_globals() {
    108108    global $bp, $wpdb;
    109    
     109
    110110    /* For internal identification */
    111111    $bp->blogs->id = 'blogs';
    112    
     112
    113113    $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
    114114    $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts';
     
    117117    $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
    118118    $bp->blogs->slug = BP_BLOGS_SLUG;
    119    
     119
    120120    /* Register this in the active components array */
    121121    $bp->active_components[$bp->blogs->slug] = $bp->blogs->id;
     
    123123    do_action( 'bp_blogs_setup_globals' );
    124124}
    125 add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 );   
     125add_action( 'plugins_loaded', 'bp_blogs_setup_globals', 5 );
    126126add_action( 'admin_menu', 'bp_blogs_setup_globals', 2 );
    127127
     
    136136 *
    137137 * Adds "Blog" to the navigation arrays for the current and logged in user.
    138  * 
     138 *
    139139 * @package BuddyPress Blogs
    140140 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    143143function bp_blogs_setup_nav() {
    144144    global $bp;
    145    
     145
    146146    /* Add 'Blogs' to the main navigation */
    147147    bp_core_new_nav_item( array( 'name' => __( 'Blogs', 'buddypress' ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );
    148    
     148
    149149    $blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';
    150    
     150
    151151    /* Add the subnav items to the blogs nav item */
    152152    bp_core_new_subnav_item( array( 'name' => __( 'My Blogs', 'buddypress' ), 'slug' => 'my-blogs', 'parent_url' => $blogs_link, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10, 'item_css_id' => 'my-blogs-list' ) );
     
    159159        if ( bp_is_home() ) {
    160160            if ( function_exists('xprofile_setup_nav') ) {
    161                 $bp->bp_options_title = __('My Blogs', 'buddypress'); 
     161                $bp->bp_options_title = __('My Blogs', 'buddypress');
    162162            }
    163163        } else {
    164164            /* If we are not viewing the logged in user, set up the current users avatar and name */
    165165            $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    166             $bp->bp_options_title = $bp->displayed_user->fullname; 
     166            $bp->bp_options_title = $bp->displayed_user->fullname;
    167167        }
    168168    }
    169    
     169
    170170    do_action( 'bp_blogs_setup_nav' );
    171171}
     
    178178    if ( $bp->current_component == $bp->blogs->slug && empty( $bp->current_action ) ) {
    179179        $bp->is_directory = true;
    180        
     180
    181181        do_action( 'bp_blogs_directory_blogs_setup' );
    182182        bp_core_load_template( apply_filters( 'bp_blogs_template_directory_blogs_setup', 'directories/blogs/index' ) );
     
    196196function bp_blogs_screen_my_blogs() {
    197197    do_action( 'bp_blogs_screen_my_blogs' );
    198     bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) );   
     198    bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'blogs/my-blogs' ) );
    199199}
    200200
     
    224224function bp_blogs_register_activity_actions() {
    225225    global $bp;
    226    
     226
    227227    if ( !function_exists( 'bp_activity_set_action' ) )
    228228        return false;
     
    238238function bp_blogs_record_activity( $args = '' ) {
    239239    global $bp;
    240    
     240
    241241    if ( !function_exists( 'bp_activity_add' ) )
    242242        return false;
    243        
     243
    244244    /* Because blog, comment, and blog post code execution happens before anything else
    245245       we may need to manually instantiate the activity component globals */
    246246    if ( !$bp->activity && function_exists('bp_activity_setup_globals') )
    247247        bp_activity_setup_globals();
    248        
     248
    249249    $defaults = array(
    250250        'user_id' => $bp->loggedin_user->id,
     
    260260
    261261    $r = wp_parse_args( $args, $defaults );
    262     extract( $r, EXTR_SKIP );   
    263    
     262    extract( $r, EXTR_SKIP );
     263
    264264    return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    265265}
     
    268268    if ( function_exists('bp_activity_delete_by_item_id') ) {
    269269        extract($args);
    270        
    271         bp_activity_delete_by_item_id( array( 
    272             'item_id' => $item_id, 
     270
     271        bp_activity_delete_by_item_id( array(
     272            'item_id' => $item_id,
    273273            'component_name' => $component_name,
    274             'component_action' => $component_action, 
     274            'component_action' => $component_action,
    275275            'user_id' => $user_id,
    276276            'secondary_item_id' => $secondary_item_id
     
    292292
    293293    $blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->base_prefix}blogs WHERE public = 1 AND mature = 0 AND spam = 0 AND deleted = 0" ) );
    294    
     294
    295295    if ( $blog_ids ) {
    296296        foreach( $blog_ids as $blog_id ) {
     
    311311function bp_blogs_record_blog( $blog_id, $user_id, $no_activity = true ) {
    312312    global $bp;
    313    
     313
    314314    if ( !$user_id )
    315315        $user_id = $bp->loggedin_user->id;
    316    
     316
    317317    $name = get_blog_option( $blog_id, 'blogname' );
    318318    $description = get_blog_option( $blog_id, 'blogdescription' );
    319    
     319
    320320    $recorded_blog = new BP_Blogs_Blog;
    321321    $recorded_blog->user_id = $user_id;
     
    323323
    324324    $recorded_blog_id = $recorded_blog->save();
    325    
     325
    326326    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'name', $name );
    327327    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'description', $description );
    328328    bp_blogs_update_blogmeta( $recorded_blog->blog_id, 'last_activity', time() );
    329    
     329
    330330    /* Only record this activity if the blog is public */
    331331    if ( (int)$_POST['blog_public'] || !$no_activity ) {
     
    333333        bp_blogs_record_activity( array(
    334334            'user_id' => $recorded_blog->user_id,
    335             'content' => apply_filters( 'bp_blogs_activity_created_blog', 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 ), 
     335            'content' => apply_filters( 'bp_blogs_activity_created_blog', 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 ),
    336336            'primary_link' => apply_filters( 'bp_blogs_activity_created_blog_primary_link', get_blog_option( $recorded_blog->blog_id, 'siteurl' ), $recorded_blog->blog_id ),
    337337            'component_action' => 'new_blog',
     
    339339        ) );
    340340    }
    341    
     341
    342342    do_action( 'bp_blogs_new_blog', &$recorded_blog, $is_private, $is_recorded );
    343343}
     
    346346function bp_blogs_record_post( $post_id, $post, $user_id = false ) {
    347347    global $bp, $wpdb;
    348    
     348
    349349    $post_id = (int)$post_id;
    350350    $blog_id = (int)$wpdb->blogid;
    351    
     351
    352352    if ( !$user_id )
    353353        $user_id = (int)$post->post_author;
    354    
    355354    /* This is to stop infinate loops with Donncha's sitewide tags plugin */
    356355    if ( (int)get_site_option( 'tags_blog_id' ) == (int)$blog_id )
    357356        return false;
    358    
     357
    359358    /* Don't record this if it's not a post */
    360359    if ( $post->post_type != 'post' )
    361360        return false;
    362    
     361
    363362    if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
    364363        if ( 'publish' == $post->post_status && '' == $post->post_password ) {
    365            
     364
    366365            $recorded_post = new BP_Blogs_Post;
    367366            $recorded_post->user_id = $user_id;
     
    369368            $recorded_post->post_id = $post_id;
    370369            $recorded_post->date_created = strtotime( $post->post_date );
    371            
     370
    372371            $recorded_post_id = $recorded_post->save();
    373            
     372
    374373            bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', time() );
    375374
     
    380379                $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
    381380                $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    382            
     381
    383382                bp_blogs_record_activity( array(
    384383                    'user_id' => (int)$post->post_author,
    385                     'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 
     384                    'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
    386385                    'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    387386                    'component_action' => 'new_blog_post',
     
    399398        /* Delete the recorded post if the status is not published or it is password protected */
    400399        if ( 'publish' != $post->post_status || '' != $post->post_password ) {
    401             return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );         
    402        
     400            return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
     401
    403402        /* If the post author has changed, delete the post and re-add it. */
    404403        } else if ( (int)$existing_post->user_id != (int)$post->post_author ) {
    405404            // Delete the existing recorded post
    406405            bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
    407            
     406
    408407            // Re-record the post with the new author.
    409             bp_blogs_record_post( $post_id );               
     408            bp_blogs_record_post( $post_id );
    410409        }
    411410
    412411        if ( (int)get_blog_option( $blog_id, 'blog_public' ) ) {
    413             /* Now re-record the post in the activity streams */       
     412            /* Now re-record the post in the activity streams */
    414413            $post_permalink = bp_post_get_permalink( $post, $blog_id );
    415414
    416415            $activity_content = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
    417416            $activity_content .= "<blockquote>" . bp_create_excerpt( $post->post_content ) . "</blockquote>";
    418        
     417
    419418            /* Record this in activity streams */
    420419            bp_blogs_record_activity( array(
    421420                'user_id' => (int)$post->post_author,
    422                 'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ), 
     421                'content' => apply_filters( 'bp_blogs_activity_new_post', $activity_content, &$post, $post_permalink ),
    423422                'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
    424423                'component_action' => 'new_blog_post',
     
    435434function bp_blogs_record_comment( $comment_id, $is_approved ) {
    436435    global $wpdb, $bp;
    437    
     436
    438437    if ( !$is_approved )
    439438        return false;
    440        
     439
    441440    $comment = get_comment($comment_id);
    442441    $comment->post = get_post( $comment->comment_post_ID );
    443    
     442
    444443    /* Get the user_id from the author email. */
    445444    $user = get_user_by_email( $comment->comment_author_email );
    446445    $user_id = (int)$user->ID;
    447    
     446
    448447    if ( !$user_id )
    449448        return false;
     
    457456
    458457    $recorded_commment_id = $recorded_comment->save();
    459    
     458
    460459    bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );
    461460
     
    463462        /* Record in activity streams */
    464463        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    465         $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );         
     464        $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
    466465        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    467466
     
    469468        bp_blogs_record_activity( array(
    470469            'user_id' => $recorded_comment->user_id,
    471             'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 
     470            'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    472471            'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    473472            'component_action' => 'new_blog_comment',
     
    484483function bp_blogs_approve_comment( $comment_id, $comment_status ) {
    485484    global $bp, $wpdb;
    486    
     485
    487486    if ( 'approve' != $comment_status )
    488487        return false;
     
    491490    $comment = get_comment($comment_id);
    492491    $comment->post = get_post( $comment->comment_post_ID );
    493    
     492
    494493    bp_blogs_delete_activity( array( 'item_id' => $comment_id, 'secondary_item_id' => $recorded_comment->blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_comment' ) );
    495494
     
    497496        /* Record in activity streams */
    498497        $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    499         $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );           
     498        $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $recorded_comment->user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );
    500499        $activity_content .= '<blockquote>' . bp_create_excerpt( $comment->comment_content ) . '</blockquote>';
    501500
     
    503502        bp_blogs_record_activity( array(
    504503            'user_id' => $recorded_comment->user_id,
    505             'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ), 
     504            'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, &$comment, &$recorded_comment, $comment_link ),
    506505            'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, &$comment, &$recorded_comment ),
    507506            'component_action' => 'new_blog_comment',
    508507            'item_id' => $comment_id,
    509508            'secondary_item_id' => $recorded_comment->blog_id,
    510             'recorded_time' =>  $recorded_comment->date_created 
     509            'recorded_time' =>  $recorded_comment->date_created
    511510        ) );
    512511    }
     
    516515function bp_blogs_unapprove_comment( $comment_id, $comment_status ) {
    517516    if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status )
    518         bp_blogs_remove_comment( $comment_id );     
     517        bp_blogs_remove_comment( $comment_id );
    519518}
    520519add_action( 'wp_set_comment_status', 'bp_blogs_unapprove_comment', 10, 2 );
     
    538537
    539538    BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    540    
     539
    541540    // Delete activity stream item
    542541    bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog' ) );
    543    
     542
    544543    do_action( 'bp_blogs_remove_blog', $blog_id );
    545544}
     
    548547function bp_blogs_remove_blog_for_user( $user_id, $blog_id ) {
    549548    global $current_user;
    550    
     549
    551550    $blog_id = (int)$blog_id;
    552551    $user_id = (int)$user_id;
     
    565564
    566565    $post_id = (int)$post_id;
    567    
     566
    568567    if ( !$blog_id )
    569568        $blog_id = (int)$current_blog->blog_id;
    570    
     569
    571570    if ( !$existing_post )
    572571        $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
     
    574573    // Delete post from the bp_blogs table
    575574    BP_Blogs_Post::delete( $post_id, $blog_id );
    576        
     575
    577576    // Delete activity stream item
    578577    bp_blogs_delete_activity( array( 'item_id' => $existing_post->id, 'component_name' => $bp->blogs->slug, 'component_action' => 'new_blog_post' ) );
     
    586585
    587586    $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
    588     BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid ); 
     587    BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
    589588
    590589    // Delete activity stream item
     
    597596function bp_blogs_remove_data_for_blog( $blog_id ) {
    598597    global $bp;
    599    
     598
    600599    /* If this is regular blog, delete all data for that blog. */
    601600    BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    602     BP_Blogs_Post::delete_posts_for_blog( $blog_id );       
     601    BP_Blogs_Post::delete_posts_for_blog( $blog_id );
    603602    BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
    604603
     
    624623function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
    625624    global $bp;
    626    
     625
    627626    if ( !is_numeric( $limit ) )
    628627        $limit = 5;
    629    
     628
    630629    return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
    631630}
     
    645644function bp_blogs_total_post_count( $blog_id ) {
    646645    return BP_Blogs_Post::total_post_count( $blog_id );
    647 } 
     646}
    648647
    649648function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
    650649    return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
    651 } 
     650}
    652651
    653652function bp_blogs_is_blog_hidden( $blog_id ) {
     
    657656function bp_blogs_redirect_to_random_blog() {
    658657    global $bp, $wpdb;
    659    
     658
    660659    if ( $bp->current_component == $bp->blogs->slug && isset( $_GET['random-blog'] ) ) {
    661660        $blog = bp_blogs_get_random_blog();
     
    676675function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false ) {
    677676    global $wpdb, $bp;
    678    
     677
    679678    if ( !is_numeric( $blog_id ) )
    680679        return false;
    681        
     680
    682681    $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    683682
    684683    if ( is_array($meta_value) || is_object($meta_value) )
    685684        $meta_value = serialize($meta_value);
    686        
     685
    687686    $meta_value = trim( $meta_value );
    688687
    689688    if ( !$meta_key ) {
    690         $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );     
     689        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d", $blog_id ) );
    691690    } else if ( $meta_value ) {
    692691        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s AND meta_value = %s", $blog_id, $meta_key, $meta_value ) );
     
    694693        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
    695694    }
    696    
     695
    697696    // TODO need to look into using this.
    698697    // wp_cache_delete($group_id, 'groups');
     
    703702function bp_blogs_get_blogmeta( $blog_id, $meta_key = '') {
    704703    global $wpdb, $bp;
    705    
     704
    706705    $blog_id = (int) $blog_id;
    707706
     
    711710    if ( !empty($meta_key) ) {
    712711        $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    713        
     712
    714713        // TODO need to look into using this.
    715714        //$user = wp_cache_get($user_id, 'users');
    716        
     715
    717716        // Check the cached user object
    718717        //if ( false !== $user && isset($user->$meta_key) )
     
    741740function bp_blogs_update_blogmeta( $blog_id, $meta_key, $meta_value ) {
    742741    global $wpdb, $bp;
    743    
     742
    744743    if ( !is_numeric( $blog_id ) )
    745744        return false;
    746    
     745
    747746    $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
    748747
    749748    if ( is_string($meta_value) )
    750749        $meta_value = stripslashes($wpdb->escape($meta_value));
    751        
     750
    752751    $meta_value = maybe_serialize($meta_value);
    753752
     
    757756
    758757    $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blogmeta} WHERE blog_id = %d AND meta_key = %s", $blog_id, $meta_key ) );
    759    
     758
    760759    if ( !$cur ) {
    761760        $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blogmeta} ( blog_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $blog_id, $meta_key, $meta_value ) );
     
    775774    /* If this is regular blog, delete all data for that blog. */
    776775    BP_Blogs_Blog::delete_blogs_for_user( $user_id );
    777     BP_Blogs_Post::delete_posts_for_user( $user_id );       
     776    BP_Blogs_Post::delete_posts_for_user( $user_id );
    778777    BP_Blogs_Comment::delete_comments_for_user( $user_id );
    779778
  • trunk/bp-core.php

    r2059 r2077  
    44define( 'BP_CORE_DB_VERSION', '1800' );
    55
    6 /*** 
    7  * Define the path and url of the BuddyPress plugins directory. 
    8  * It is important to use plugins_url() core function to obtain 
    9  * the correct scheme used (http or https). 
     6/***
     7 * Define the path and url of the BuddyPress plugins directory.
     8 * It is important to use plugins_url() core function to obtain
     9 * the correct scheme used (http or https).
    1010 */
    1111define( 'BP_PLUGIN_DIR', WP_PLUGIN_DIR . '/buddypress' );
     
    6666if ( !defined( 'BP_HOME_BLOG_SLUG' ) )
    6767    define( 'BP_HOME_BLOG_SLUG', 'blog' );
    68    
     68
     69/* Register BuddyPress themes contained within the theme folder */
     70if ( function_exists( 'register_theme_folder' ) )
     71    register_theme_folder( 'buddypress/bp-themes' );
     72
    6973/* Register BuddyPress themes contained within the theme folder */
    7074if ( function_exists( 'register_theme_folder' ) )
     
    9498    global $displayed_user_id;
    9599    global $action_variables;
    96    
     100
    97101    $current_user = wp_get_current_user();
    98102
    99     /* The domain for the root of the site where the main blog resides */   
     103    /* The domain for the root of the site where the main blog resides */
    100104    $bp->root_domain = bp_core_get_root_domain();
    101    
     105
    102106    /* The user ID of the user who is currently logged in. */
    103107    $bp->loggedin_user->id = $current_user->ID;
     
    105109    /* The domain for the user currently logged in. eg: http://domain.com/members/andy */
    106110    $bp->loggedin_user->domain = bp_core_get_user_domain($current_user->ID);
    107    
     111
    108112    /* The user id of the user currently being viewed, set in /bp-core/bp-core-catchuri.php */
    109113    $bp->displayed_user->id = $displayed_user_id;
    110    
     114
    111115    /* The domain for the user currently being displayed */
    112116    $bp->displayed_user->domain = bp_core_get_user_domain($displayed_user_id);
    113    
     117
    114118    /* The component being used eg: http://domain.com/members/andy/ [profile] */
    115119    $bp->current_component = $current_component; // type: string
    116    
     120
    117121    /* The current action for the component eg: http://domain.com/members/andy/profile/ [edit] */
    118122    $bp->current_action = $current_action; // type: string
    119    
     123
    120124    /* The action variables for the current action eg: http://domain.com/members/andy/profile/edit/ [group] / [6] */
    121125    $bp->action_variables = $action_variables; // type: array
    122    
     126
    123127    /* Only used where a component has a sub item, e.g. groups: http://domain.com/members/andy/groups/ [my-group] / home - manipulated in the actual component not in catch uri code.*/
    124128    $bp->current_item = ''; // type: string
     
    135139    /* Sets up the array container for the component navigation rendered by bp_get_nav() */
    136140    $bp->bp_nav = array();
    137    
     141
    138142    /* Sets up the array container for the component options navigation rendered by bp_get_options_nav() */
    139143    $bp->bp_options_nav = array();
    140    
     144
    141145    /* Sets up container used for the title of the current component option and rendered by bp_get_options_title() */
    142146    $bp->bp_options_title = '';
    143    
     147
    144148    /* Sets up container used for the avatar of the current component being viewed. Rendered by bp_get_options_avatar() */
    145149    $bp->bp_options_avatar = '';
    146    
     150
    147151    /* Contains an array of all the active components. The key is the slug, value the internal ID of the component */
    148152    $bp->active_components = array();
    149    
     153
    150154    /* Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar */
    151155    $bp->grav_default->user = apply_filters( 'bp_user_gravatar_default', get_site_option( 'user-avatar-default' ) );
    152156    $bp->grav_default->group = apply_filters( 'bp_group_gravatar_default', 'identicon' );
    153157    $bp->grav_default->blog = apply_filters( 'bp_blog_gravatar_default', 'identicon' );
    154    
     158
    155159    /* Fetch the full name for the logged in and current user */
    156160    $bp->loggedin_user->fullname = bp_core_get_user_displayname( $bp->loggedin_user->id );
     
    162166       'is_item_admin' would be 1 if they are a group admin, 0 if they are not. */
    163167    $bp->is_item_admin = bp_is_home();
    164    
     168
    165169    /* Used to determine if the logged in user is a moderator for the current content. */
    166170    $bp->is_item_mod = false;
     
    170174    if ( !$bp->current_component )
    171175        $bp->current_component = $bp->default_component;
    172    
     176
    173177    do_action( 'bp_core_setup_globals' );
    174178}
     
    183187 *
    184188 * For example: http://example.org/search or http://example.org/members
    185  * 
     189 *
    186190 * @package BuddyPress Core
    187191 * @uses bp_core_add_root_component() Adds a slug to the root components global variable.
     
    202206 *
    203207 * Installs the core DB tables for BuddyPress.
    204  * 
     208 *
    205209 * @package BuddyPress Core
    206210 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    211215function bp_core_install() {
    212216    global $wpdb, $bp;
    213    
     217
    214218    if ( !empty($wpdb->charset) )
    215219        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    216    
     220
    217221    $sql[] = "CREATE TABLE {$bp->core->table_name_notifications} (
    218222                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    235239    require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    236240    dbDelta( $sql );
    237    
     241
    238242    /* Add names of root components to the banned blog list to avoid conflicts */
    239243    bp_core_add_illegal_names();
    240    
     244
    241245    update_site_option( 'bp-core-db-version', BP_CORE_DB_VERSION );
    242246}
     
    246250 *
    247251 * Checks to make sure the database tables are set up for the core component.
    248  * 
     252 *
    249253 * @package BuddyPress Core
    250254 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    260264    if ( !is_site_admin() )
    261265        return false;
    262    
     266
    263267    require ( BP_PLUGIN_DIR . '/bp-core/bp-core-admin.php' );
    264268
     
    273277 *
    274278 * Adds the "BuddyPress" admin submenu item to the Site Admin tab.
    275  * 
     279 *
    276280 * @package BuddyPress Core
    277281 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    281285 */
    282286function bp_core_add_admin_menu() {
    283     global $wpdb, $bp, $menu;
    284    
    285287    if ( !is_site_admin() )
    286288        return false;
    287        
     289
    288290    /* Add the administration tab under the "Site Admin" tab for site administrators */
    289291    bp_core_add_admin_menu_page( array(
     
    294296        'position' => 2
    295297    ) );
    296    
     298
    297299    add_submenu_page( 'bp-general-settings', __( 'General Settings', 'buddypress'), __( 'General Settings', 'buddypress' ), 'manage_options', 'bp-general-settings', 'bp_core_admin_settings' );
    298300    add_submenu_page( 'bp-general-settings', __( 'Component Setup', 'buddypress'), __( 'Component Setup', 'buddypress' ), 'manage_options', 'bp-component-setup', 'bp_core_admin_component_setup' );
     
    305307 * Checks to see if a component's URL should be in the root, not under a member page:
    306308 * eg: http://domain.com/groups/the-group NOT http://domain.com/members/andy/groups/the-group
    307  * 
     309 *
    308310 * @package BuddyPress Core
    309311 * @return true if root component, else false.
     
    319321 *
    320322 * Sets up the profile navigation item if the Xprofile component is not installed.
    321  * 
     323 *
    322324 * @package BuddyPress Core
    323325 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    329331function bp_core_setup_nav() {
    330332    global $bp;
    331    
    332     /*** 
     333
     334    /***
    333335     * If the extended profiles component is disabled, we need to revert to using the
    334336     * built in WordPress profile information
     
    340342
    341343        /* Add 'Profile' to the main navigation */
    342         bp_core_new_nav_item( array( 
     344        bp_core_new_nav_item( array(
    343345            'name' => __('Profile', 'buddypress'),
    344346            'slug' => $bp->core->profile->slug,
     
    349351
    350352        $profile_link = $bp->loggedin_user->domain . '/profile/';
    351        
     353
    352354        /* Add the subnav items to the profile */
    353355        bp_core_new_subnav_item( array(
     
    358360            'screen_function' => 'bp_core_catch_profile_uri'
    359361        ) );
    360        
     362
    361363
    362364        if ( 'profile' == $bp->current_component ) {
     
    365367            } else {
    366368                $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    367                 $bp->bp_options_title = $bp->displayed_user->fullname; 
     369                $bp->bp_options_title = $bp->displayed_user->fullname;
    368370            }
    369371        }
    370     }   
     372    }
    371373}
    372374add_action( 'plugins_loaded', 'bp_core_setup_nav' );
     
    397399 * Listens to the $bp component and action variables to determine if the user is viewing the members
    398400 * directory page. If they are, it will set up the directory and load the members directory template.
    399  * 
     401 *
    400402 * @package BuddyPress Core
    401403 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    421423 * this action will fire and mark or unmark the user and their blogs as spam.
    422424 * Must be a site admin for this function to run.
    423  * 
     425 *
    424426 * @package BuddyPress Core
    425427 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    427429function bp_core_action_set_spammer_status() {
    428430    global $bp;
    429    
     431
    430432    if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
    431433        return false;
    432            
     434
    433435    if ( 'admin' == $bp->current_component && ( 'mark-spammer' == $bp->current_action || 'unmark-spammer' == $bp->current_action ) ) {
    434436        /* Check the nonce */
     
    437439        /* Get the functions file */
    438440        require( ABSPATH . 'wp-admin/includes/mu.php' );
    439        
     441
    440442        if ( 'mark-spammer' == $bp->current_action )
    441443            $is_spam = 1;
     
    445447        /* Get the blogs for the user */
    446448        $blogs = get_blogs_of_user( $bp->displayed_user->id, true );
    447    
     449
    448450        foreach ( (array) $blogs as $key => $details ) {
    449451            /* Do not mark the main or current root blog as spam */
    450             if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id ) 
    451                 continue; 
    452        
     452            if ( 1 == $details->userblog_id || BP_ROOT_BLOG == $details->userblog_id )
     453                continue;
     454
    453455            /* Update the blog status */
    454456            update_blog_status( $details->userblog_id, 'spam', $is_spam );
    455        
     457
    456458            /* Fire the standard WPMU hook */
    457459            do_action( 'make_spam_blog', $details->userblog_id );
    458460        }
    459    
     461
    460462        /* Finally, mark this user as a spammer */
    461463        update_user_status( $bp->displayed_user->id, 'spam', $is_spam, 1 );
    462        
     464
    463465        if ( $is_spam )
    464466            bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
    465467        else
    466468            bp_core_add_message( __( 'User removed as spammer.', 'buddypress' ) );
    467            
     469
    468470        do_action( 'bp_core_action_set_spammer_status' );
    469        
     471
    470472        bp_core_redirect( wp_get_referer() );
    471473    }
     
    477479 *
    478480 * Allows a site admin to delete a user from the adminbar menu.
    479  * 
     481 *
    480482 * @package BuddyPress Core
    481483 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    483485function bp_core_action_delete_user() {
    484486    global $bp;
    485    
     487
    486488    if ( !is_site_admin() || bp_is_home() || !$bp->displayed_user->id )
    487489        return false;
    488            
     490
    489491    if ( 'admin' == $bp->current_component && 'delete-user' == $bp->current_action ) {
    490492        /* Check the nonce */
     
    492494
    493495        $errors = false;
    494        
     496
    495497        if ( bp_core_delete_account( $bp->displayed_user->id ) ) {
    496498            bp_core_add_message( sprintf( __( '%s has been deleted from the system.', 'buddypress' ), $bp->displayed_user->fullname ) );
     
    499501            $errors = true;
    500502        }
    501        
     503
    502504        do_action( 'bp_core_action_set_spammer_status', $errors );
    503        
     505
    504506        if ( $errors )
    505507            bp_core_redirect( $bp->displayed_user->domain );
     
    525527 * Returns the domain for the passed user:
    526528 * e.g. http://domain.com/members/andy/
    527  * 
     529 *
    528530 * @package BuddyPress Core
    529531 * @global $current_user WordPress global variable containing current logged in user information
     
    533535function bp_core_get_user_domain( $user_id ) {
    534536    global $bp;
    535    
     537
    536538    if ( !$user_id ) return;
    537    
     539
    538540    $ud = get_userdata($user_id);
    539    
     541
    540542    if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
    541543        $username = $ud->user_login;
    542544    else
    543545        $username = $ud->user_nicename;
    544    
     546
    545547    /* If we are using a members slug, include it. */
    546548    if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) )
    547549        return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/' . $username . '/' );
    548550    else
    549         return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' );       
     551        return apply_filters( 'bp_core_get_user_domain', $bp->root_domain . '/' . $username . '/' );
    550552}
    551553
     
    555557 * Returns the domain for the root blog.
    556558 * eg: http://domain.com/ OR https://domain.com
    557  * 
     559 *
    558560 * @package BuddyPress Core
    559561 * @uses get_blog_option() WordPress function to fetch blog meta.
     
    562564function bp_core_get_root_domain() {
    563565    global $current_blog;
    564    
     566
    565567    if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
    566568        $domain = get_blog_option( $current_blog->blog_id, 'siteurl' );
     
    576578 * Returns the user id for the user that is currently being displayed.
    577579 * eg: http://andy.domain.com/ or http://domain.com/andy/
    578  * 
     580 *
    579581 * @package BuddyPress Core
    580582 * @global $current_blog WordPress global containing information and settings for the current blog being viewed.
     
    590592 *
    591593 * Adds a navigation item to the main navigation array used in BuddyPress themes.
    592  * 
     594 *
    593595 * @package BuddyPress Core
    594596 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    614616    if ( empty($name) || empty($slug) )
    615617        return false;
    616            
     618
    617619    /* If this is for site admins only and the user is not one, don't create the subnav item */
    618620    if ( $site_admin_only && !is_site_admin() )
    619621        return false;
    620    
     622
    621623    if ( empty( $item_css_id ) )
    622624        $item_css_id = $slug;
     
    637639    if ( !$show_for_displayed_user && !bp_is_home() )
    638640        return false;
    639        
     641
    640642    /***
    641643     * If we are not viewing a user, and this is a root component, don't attach the
     
    660662 *
    661663 * Modify the default subnav item to load when a top level nav item is clicked.
    662  * 
     664 *
    663665 * @package BuddyPress Core
    664666 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    666668function bp_core_new_nav_default( $args = '' ) {
    667669    global $bp;
    668    
     670
    669671    $defaults = array(
    670672        'parent_slug' => false, // Slug of the parent
     
    692694 * We can only sort nav items by their position integer at a later point in time, once all
    693695 * plugins have registered their navigation items.
    694  * 
     696 *
    695697 * @package BuddyPress Core
    696698 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    698700function bp_core_sort_nav_items() {
    699701    global $bp;
    700    
     702
    701703    if ( empty( $bp->bp_nav ) || !is_array( $bp->bp_nav ) )
    702704        return false;
    703    
     705
    704706    foreach ( $bp->bp_nav as $slug => $nav_item ) {
    705707        if ( empty( $temp[$nav_item['position']]) )
     
    710712                $nav_item['position']++;
    711713            } while ( !empty( $temp[$nav_item['position']] ) );
    712            
     714
    713715            $temp[$nav_item['position']] = $nav_item;
    714716        }
    715717    }
    716    
     718
    717719    ksort( $temp );
    718     $bp->bp_nav = &$temp; 
     720    $bp->bp_nav = &$temp;
    719721}
    720722add_action( 'wp_head', 'bp_core_sort_nav_items' );
     
    724726 *
    725727 * Removes a navigation item from the main navigation array.
    726  * 
     728 *
    727729 * @package BuddyPress Core
    728730 * @param $slug The slug of the sub navigation item.
     
    738740 *
    739741 * Adds a navigation item to the sub navigation array used in BuddyPress themes.
    740  * 
     742 *
    741743 * @package BuddyPress Core
    742744 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    756758        'screen_function' => false // The name of the function to run when clicked
    757759    );
    758    
     760
    759761    $r = wp_parse_args( $args, $defaults );
    760762    extract( $r, EXTR_SKIP );
     
    763765    if ( empty($name) || empty($slug) || empty($parent_slug) || empty($parent_url) || empty($screen_function) )
    764766        return false;
    765    
     767
    766768    /* If this is for site admins only and the user is not one, don't create the subnav item */
    767769    if ( $site_admin_only && !is_site_admin() )
    768770        return false;
    769    
     771
    770772    if ( empty( $item_css_id ) )
    771773        $item_css_id = $slug;
    772    
     774
    773775    $bp->bp_options_nav[$parent_slug][$slug] = array(
    774776        'name' => $name,
     
    779781        'user_has_access' => $user_has_access
    780782    );
    781        
     783
    782784    if ( ( $bp->current_action == $slug && $bp->current_component == $parent_slug ) && $user_has_access ) {
    783785        if ( !is_object( $screen_function[0] ) )
     
    793795    if ( empty( $bp->bp_options_nav ) || !is_array( $bp->bp_options_nav ) )
    794796        return false;
    795    
     797
    796798    foreach ( $bp->bp_options_nav as $parent_slug => $subnav_items ) {
    797799        if ( !is_array( $subnav_items ) )
    798800            continue;
    799        
     801
    800802        foreach ( $subnav_items as $subnav_item ) {
    801803            if ( empty( $temp[$subnav_item['position']]) )
     
    806808                    $subnav_item['position']++;
    807809                } while ( !empty( $temp[$subnav_item['position']] ) );
    808            
     810
    809811                $temp[$subnav_item['position']] = $subnav_item;
    810812            }
     
    821823 *
    822824 * Removes a navigation item from the sub navigation array used in BuddyPress themes.
    823  * 
     825 *
    824826 * @package BuddyPress Core
    825827 * @param $parent_id The id of the parent navigation item.
     
    828830function bp_core_remove_subnav_item( $parent_id, $slug ) {
    829831    global $bp;
    830    
     832
    831833    unset( $bp->bp_options_nav[$parent_id][$slug] );
    832834}
     
    836838 *
    837839 * Clear the subnav items for a specific nav item.
    838  * 
     840 *
    839841 * @package BuddyPress Core
    840842 * @param $parent_id The id of the parent navigation item.
     
    856858 * Loads:
    857859 *   wp-content/member-themes/[activated_theme]/profile/edit-profile.php
    858  * 
     860 *
    859861 * @package BuddyPress Core
    860862 * @param $username str Username to check.
     
    883885 *           http://community.domain.com/members/andy/friends
    884886 *           http://domain.com/wpmu/members/andy/friends
    885  * 
     887 *
    886888 * @package BuddyPress Core
    887889 * @param $slug str The slug of the component
     
    898900 *
    899901 * Returns the user_id for a user based on their username.
    900  * 
     902 *
    901903 * @package BuddyPress Core
    902904 * @param $username str Username to check.
     
    907909function bp_core_get_random_member() {
    908910    global $bp, $wpdb;
    909    
     911
    910912    if ( isset( $_GET['random-member'] ) ) {
    911913        $user = BP_Core_User::get_random_users(1);
    912        
     914
    913915        $ud = get_userdata( $user['users'][0]->user_id );
    914        
    915         bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) );     
     916
     917        bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->user_id ) );
    916918    }
    917919}
     
    922924 *
    923925 * Returns the user_id for a user based on their username.
    924  * 
     926 *
    925927 * @package BuddyPress Core
    926928 * @param $username str Username to check.
     
    931933function bp_core_get_userid( $username ) {
    932934    global $wpdb;
    933    
     935
    934936    if ( !empty( $username ) )
    935         return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) ); 
     937        return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
    936938}
    937939
     
    940942 *
    941943 * Returns the username for a user based on their user id.
    942  * 
     944 *
    943945 * @package BuddyPress Core
    944946 * @param $uid int User ID to check.
     
    950952function bp_core_get_username( $uid ) {
    951953    global $userdata;
    952    
     954
    953955    if ( $uid == $userdata->ID )
    954956        $username =  __( 'You', 'buddypress' );
    955    
     957
    956958    if ( !$ud = get_userdata($uid) )
    957959        return false;
    958        
    959     $username = $ud->user_login;   
     960
     961    $username = $ud->user_login;
    960962
    961963    return apply_filters( 'bp_core_get_username', $username );
     
    966968 *
    967969 * Returns the URL with no HTML markup for a user based on their user id.
    968  * 
     970 *
    969971 * @package BuddyPress Core
    970972 * @param $uid int User ID to check.
     
    976978function bp_core_get_userurl( $uid ) {
    977979    global $bp;
    978    
     980
    979981    if ( !is_numeric($uid) )
    980982        return false;
     
    987989 *
    988990 * Returns the email address for the user based on user ID
    989  * 
     991 *
    990992 * @package BuddyPress Core
    991993 * @param $uid int User ID to check.
     
    10051007 * eg: <a href="http://andy.domain.com/">Andy Peatling</a>
    10061008 * Optional parameters will return just the name, or just the URL, or disable "You" text when
    1007  * user matches the logged in user. 
     1009 * user matches the logged in user.
    10081010 *
    10091011 * [NOTES: This function needs to be cleaned up or split into separate functions]
    1010  * 
     1012 *
    10111013 * @package BuddyPress Core
    10121014 * @param $uid int User ID to check.
     
    10231025function bp_core_get_userlink( $user_id, $no_anchor = false, $just_link = false, $deprecated = false, $with_s = false ) {
    10241026    global $userdata;
    1025    
     1027
    10261028    $ud = get_userdata($user_id);
    1027    
     1029
    10281030    if ( !$ud )
    10291031        return false;
    10301032
    1031     if ( function_exists('bp_fetch_user_fullname') ) { 
     1033    if ( function_exists('bp_fetch_user_fullname') ) {
    10321034        $display_name = bp_core_get_user_displayname( $user_id );
    1033        
     1035
    10341036        if ( $with_s )
    10351037            $display_name = sprintf( __( "%s's", 'buddypress' ), $display_name );
    1036            
     1038
    10371039    } else {
    10381040        $display_name = $ud->display_name;
    10391041    }
    1040    
     1042
    10411043    if ( $no_anchor )
    10421044        return $display_name;
     
    10441046    if ( !$url = bp_core_get_userurl($user_id) )
    10451047        return false;
    1046        
     1048
    10471049    if ( $just_link )
    10481050        return $url;
    10491051
    1050     return '<a href="' . $url . '">' . $display_name . '</a>'; 
     1052    return '<a href="' . $url . '">' . $display_name . '</a>';
    10511053}
    10521054
     
    10571059 * Fetch the display name for a user. This will use the "Name" field in xprofile if it is installed.
    10581060 * Otherwise, it will fall back to the normal WP display_name, or user_nicename, depending on what has been set.
    1059  * 
     1061 *
    10601062 * @package BuddyPress Core
    10611063 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    10681070function bp_core_get_user_displayname( $user_id ) {
    10691071    global $bp;
    1070    
     1072
    10711073    if ( !$user_id )
    10721074        return false;
    1073        
     1075
    10741076    if ( !$fullname = wp_cache_get( 'bp_user_fullname_' . $user_id, 'bp' ) ) {
    10751077        if ( function_exists('xprofile_install') ) {
     
    10881090        } else {
    10891091            $ud = get_userdata($user_id);
    1090            
     1092
    10911093            if ( !empty( $ud->display_name ) )
    10921094                $fullname = $ud->display_name;
     
    10941096                $fullname = $ud->user_nicename;
    10951097        }
    1096        
     1098
    10971099        wp_cache_set( 'bp_user_fullname_' . $user_id, $fullname, 'bp' );
    10981100    }
    1099    
     1101
    11001102    return apply_filters( 'bp_core_get_user_displayname', $fullname );
    11011103}
     
    11091111 *
    11101112 * Returns the user link for the user based on user email address
    1111  * 
     1113 *
    11121114 * @package BuddyPress Core
    11131115 * @param $email str The email address for the user.
     
    11251127 *
    11261128 * Returns the user link for the user based on user's username
    1127  * 
     1129 *
    11281130 * @package BuddyPress Core
    11291131 * @param $username str The username for the user.
     
    11331135function bp_core_get_userlink_by_username( $username ) {
    11341136    global $wpdb;
    1135    
    1136     $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ); 
     1137
     1138    $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) );
    11371139    return apply_filters( 'bp_core_get_userlink_by_username', bp_core_get_userlink( $user_id, false, false, true ) );
    11381140}
     
    11491151function bp_core_is_user_spammer( $user_id ) {
    11501152    global $wpdb;
    1151    
    1152     return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) ); 
     1153
     1154    return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT spam FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
    11531155}
    11541156
     
    11641166function bp_core_is_user_deleted( $user_id ) {
    11651167    global $wpdb;
    1166    
    1167     return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );   
     1168
     1169    return apply_filters( 'bp_core_is_user_spammer', (int) $wpdb->get_var( $wpdb->prepare( "SELECT deleted FROM " . CUSTOM_USER_TABLE . " WHERE ID = %d", $user_id ) ) );
    11681170}
    11691171
     
    11741176    if ( !$time )
    11751177        return false;
    1176        
     1178
    11771179    $date = date( "F j, Y ", $time );
    1178    
     1180
    11791181    if ( !$just_date ) {
    11801182        $date .= __('at', 'buddypress') . date( ' g:iA', $time );
    11811183    }
    1182    
     1184
    11831185    return $date;
    11841186}
     
    11891191 *
    11901192 * Adds a feedback (error/success) message to the WP cookie so it can be displayed after the page reloads.
    1191  * 
     1193 *
    11921194 * @package BuddyPress Core
    11931195 */
    11941196function bp_core_add_message( $message, $type = false ) {
    11951197    global $bp;
    1196    
     1198
    11971199    if ( !$type )
    11981200        $type = 'success';
    1199    
     1201
    12001202    /* Send the values to the cookie for page reload display */
    12011203    @setcookie( 'bp-message', $message, time()+60*60*24, COOKIEPATH );
    12021204    @setcookie( 'bp-message-type', $type, time()+60*60*24, COOKIEPATH );
    1203    
     1205
    12041206    /***
    12051207     * Send the values to the $bp global so we can still output messages
     
    12181220 * After the message is displayed, it removes the message vars from the cookie so that the message
    12191221 * is not shown to the user multiple times.
    1220  * 
     1222 *
    12211223 * @package BuddyPress Core
    12221224 * @global $bp_message The message text
     
    12291231    if ( empty( $bp->template_message ) )
    12301232        $bp->template_message = $_COOKIE['bp-message'];
    1231    
     1233
    12321234    if ( empty( $bp->template_message_type ) )
    12331235        $bp->template_message_type = $_COOKIE['bp-message-type'];
    12341236
    12351237    add_action( 'template_notices', 'bp_core_render_message' );
    1236    
     1238
    12371239    @setcookie( 'bp-message', false, time() - 1000, COOKIEPATH );
    12381240    @setcookie( 'bp-message-type', false, time() - 1000, COOKIEPATH );
     
    12451247 * Renders a feedback message (either error or success message) to the theme template.
    12461248 * The hook action 'template_notices' is used to call this function, it is not called directly.
    1247  * 
     1249 *
    12481250 * @package BuddyPress Core
    12491251 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    12511253function bp_core_render_message() {
    12521254    global $bp;
    1253    
     1255
    12541256    if ( $bp->template_message ) {
    12551257        $type = ( 'success' == $bp->template_message_type ) ? 'updated' : 'error';
     
    12601262    <?php
    12611263        do_action( 'bp_core_render_message' );
    1262     }   
     1264    }
    12631265}
    12641266
     
    12671269 *
    12681270 * Based on function created by Dunstan Orchard - http://1976design.com
    1269  * 
     1271 *
    12701272 * This function will return an English representation of the time elapsed
    12711273 * since a given date.
     
    12731275 * eg: 4 days
    12741276 * eg: 4 weeks and 6 days
    1275  * 
     1277 *
    12761278 * @package BuddyPress Core
    12771279 * @param $older_date int Unix timestamp of date you want to calculate the time since for
     
    12911293    array( 1, __( 'second', 'buddypress' ), __( 'seconds', 'buddypress' ) )
    12921294    );
    1293    
     1295
    12941296    $older_date = strtotime( gmdate( 'Y-m-d H:i:s', $older_date ) );
    12951297
     
    12971299    /* $newer_date will have a value if we want to work out time elapsed between two known dates */
    12981300    $newer_date = ( !$newer_date ) ? ( strtotime( gmdate( 'Y-m-d H:i:s' ) ) + ( 60*60*0 ) ) : $newer_date;
    1299    
     1301
    13001302    /* Difference in seconds */
    13011303    $since = $newer_date - $older_date;
    1302    
     1304
    13031305    if ( 0 > $since )
    13041306        return __( '[Use GMT Timezone]', 'buddypress' );
     
    13271329        $seconds2 = $chunks[$i + 1][0];
    13281330        $name2 = $chunks[$i + 1][1];
    1329        
     1331
    13301332        //if ( $chunks[$i + 1][1] == __( 'second', 'buddypress' ) ) return $output;
    1331    
     1333
    13321334        if ( ( $count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 ) ) != 0 ) {
    13331335            /* Add to output var */
     
    13491351 * show the length of time since the user was last active.
    13501352 * This function will update that time as a usermeta setting for the user every 5 minutes.
    1351  * 
     1353 *
    13521354 * @package BuddyPress Core
    13531355 * @global $userdata WordPress user data for the current logged in user.
     
    13561358function bp_core_record_activity() {
    13571359    global $bp;
    1358    
     1360
    13591361    if ( !is_user_logged_in() )
    13601362        return false;
    1361    
     1363
    13621364    $activity = get_usermeta( $bp->loggedin_user->id, 'last_activity' );
    1363    
     1365
    13641366    if ( '' == $activity || time() >= strtotime( '+5 minutes', $activity ) )
    13651367        update_usermeta( $bp->loggedin_user->id, 'last_activity', time() );
     
    13721374 *
    13731375 * Formats last activity based on time since date given.
    1374  * 
     1376 *
    13751377 * @package BuddyPress Core
    13761378 * @param last_activity_date The date of last activity.
     
    13841386    } else {
    13851387        if ( strstr( $last_activity_date, '-' ) ) {
    1386             $last_active = bp_core_time_since( strtotime( $last_activity_date ) ); 
     1388            $last_active = bp_core_time_since( strtotime( $last_activity_date ) );
    13871389        } else {
    1388             $last_active = bp_core_time_since( $last_activity_date ); 
     1390            $last_active = bp_core_time_since( $last_activity_date );
    13891391        }
    1390        
     1392
    13911393        $last_active = sprintf( $string, $last_active );
    13921394    }
    1393    
     1395
    13941396    return $last_active;
    13951397}
     
    14001402 *
    14011403 * Fetch every post that is authored by the given user for the current blog.
    1402  * 
     1404 *
    14031405 * @package BuddyPress Core
    14041406 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    14081410function bp_core_get_all_posts_for_user( $user_id = null ) {
    14091411    global $bp, $wpdb;
    1410    
     1412
    14111413    if ( !$user_id )
    14121414        $user_id = $bp->displayed_user->id;
    1413    
     1415
    14141416    return $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) );
    14151417}
     
    14201422 *
    14211423 * Get the path of of the current site.
    1422  * 
     1424 *
    14231425 * @package BuddyPress Core
    14241426 * @global $comment WordPress comment global for the current comment.
     
    14271429function bp_core_get_site_path() {
    14281430    global $current_site;
    1429    
     1431
    14301432    return $current_site->path;
    14311433}
     
    14351437 *
    14361438 * Performs a status safe wp_redirect() that is compatible with bp_catch_uri()
    1437  * 
     1439 *
    14381440 * @package BuddyPress Core
    14391441 * @global $bp_no_status_set Makes sure that there are no conflicts with status_header() called in bp_core_do_catch_uri()
     
    14431445function bp_core_redirect( $location, $status = 302 ) {
    14441446    global $bp_no_status_set;
    1445    
    1446     // Make sure we don't call status_header() in bp_core_do_catch_uri() 
     1447
     1448    // Make sure we don't call status_header() in bp_core_do_catch_uri()
    14471449    // as this conflicts with wp_redirect()
    14481450    $bp_no_status_set = true;
    1449    
     1451
    14501452    wp_redirect( $location, $status );
    14511453    die;
     
    14561458 *
    14571459 * Returns the referrer URL without the http(s)://
    1458  * 
     1460 *
    14591461 * @package BuddyPress Core
    14601462 * @return The referrer URL
     
    14731475 *
    14741476 * For example, it would stop someone creating a blog with the slug "groups".
    1475  * 
     1477 *
    14761478 * @package BuddyPress Core
    14771479 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    14791481function bp_core_add_illegal_names() {
    14801482    global $bp;
    1481    
     1483
    14821484    $current = maybe_unserialize( get_site_option( 'illegal_names' ) );
    14831485    $bp_illegal_names = $bp->root_components;
    1484    
     1486
    14851487    if ( is_array( $current ) ) {
    14861488        foreach( $bp_illegal_names as $bp_illegal_name ) {
     
    15011503 *
    15021504 * Sets the "From" name in emails sent to the name of the site and not "WordPress"
    1503  * 
     1505 *
    15041506 * @package BuddyPress Core
    15051507 * @uses get_blog_option() fetches the value for a meta_key in the wp_X_options table
     
    15161518 *
    15171519 * Sets the "From" address in emails sent
    1518  * 
     1520 *
    15191521 * @package BuddyPress Core
    15201522 * @global $current_site Object containing current site metadata
     
    15321534 *
    15331535 * Allows a user to completely remove their account from the system
    1534  * 
     1536 *
    15351537 * @package BuddyPress Core
    15361538 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    15641566 *
    15651567 * A javascript free implementation of the search functions in BuddyPress
    1566  * 
     1568 *
    15671569 * @package BuddyPress Core
    15681570 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    15751577        $search_terms = $_POST['search-terms'];
    15761578        $search_which = $_POST['search-which'];
    1577        
     1579
    15781580        if ( !$slug || empty( $slug ) ) {
    15791581            switch ( $search_which ) {
     
    15961598            }
    15971599        }
    1598        
     1600
    15991601        $search_url = apply_filters( 'bp_core_search_site', site_url( $slug . $var . urlencode($search_terms) ), $search_terms );
    1600        
     1602
    16011603        bp_core_redirect( $search_url );
    16021604    }
     
    16071609/**
    16081610 * bp_core_ucfirst()
    1609  * 
     1611 *
    16101612 * Localization safe ucfirst() support.
    1611  * 
     1613 *
    16121614 * @package BuddyPress Core
    16131615 */
     
    16151617    if ( function_exists( 'mb_strtoupper' ) && function_exists( 'mb_substr' ) ) {
    16161618        $fc = mb_strtoupper( mb_substr( $str, 0, 1 ) );
    1617         return $fc.mb_substr( $str, 1 );   
     1619        return $fc.mb_substr( $str, 1 );
    16181620    } else {
    16191621        return ucfirst( $str );
     
    16241626/**
    16251627 * bp_core_strip_username_spaces()
    1626  * 
     1628 *
    16271629 * Strips spaces from usernames that are created using add_user() and wp_insert_user()
    1628  * 
     1630 *
    16291631 * @package BuddyPress Core
    16301632 */
     
    16371639/**
    16381640 * bp_core_clear_cache()
    1639  * REQUIRES WP-SUPER-CACHE 
    1640  * 
     1641 * REQUIRES WP-SUPER-CACHE
     1642 *
    16411643 * When wp-super-cache is installed this function will clear cached pages
    16421644 * so that success/error messages are not cached, or time sensitive content.
    1643  * 
     1645 *
    16441646 * @package BuddyPress Core
    16451647 */
    16461648function bp_core_clear_cache() {
    16471649    global $cache_path, $cache_filename;
    1648    
     1650
    16491651    if ( function_exists( 'prune_super_cache' ) ) {
    16501652        do_action( 'bp_core_clear_cache' );
    1651        
    1652         return prune_super_cache( $cache_path, true );     
     1653
     1654        return prune_super_cache( $cache_path, true );
    16531655    }
    16541656}
     
    16561658/**
    16571659 * bp_core_print_generation_time()
    1658  * 
     1660 *
    16591661 * Prints the generation time in the footer of the site.
    1660  * 
     1662 *
    16611663 * @package BuddyPress Core
    16621664 */
     
    16711673/**
    16721674 * bp_core_add_admin_menu_page()
    1673  * 
     1675 *
    16741676 * A better version of add_admin_menu_page() that allows positioning of menus.
    1675  * 
     1677 *
    16761678 * @package BuddyPress Core
    16771679 */
     
    16911693    $r = wp_parse_args( $args, $defaults );
    16921694    extract( $r, EXTR_SKIP );
    1693    
     1695
    16941696    $file = plugin_basename( $file );
    16951697
     
    17081710        $position++;
    17091711    } while ( !empty( $menu[$position] ) );
    1710    
     1712
    17111713    $menu[$position] = array ( $menu_title, $access_level, $file, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
    17121714
     
    17211723 * When a user logs in, check if they have been marked as a spammer. If then simply
    17221724 * redirect them to the home page and stop them from logging in.
    1723  * 
     1725 *
    17241726 * @package BuddyPress Core
    17251727 * @param $username The username of the user
     
    17281730function bp_core_boot_spammer( $auth_obj, $username ) {
    17291731    global $bp;
    1730    
     1732
    17311733    $user = get_userdatabylogin( $username );
    17321734
     
    17401742 *
    17411743 * Deletes usermeta for the user when the user is deleted.
    1742  * 
     1744 *
    17431745 * @package BuddyPress Core
    17441746 * @param $user_id The user id for the user to delete usermeta for
     
    17581760/**
    17591761 * bp_load_buddypress_textdomain()
    1760  * 
     1762 *
    17611763 * Load the buddypress translation file for current language
    1762  * 
     1764 *
    17631765 * @package BuddyPress Core
    17641766 */
     
    17661768    $locale = apply_filters( 'buddypress_locale', get_locale() );
    17671769    $mofile = BP_PLUGIN_DIR . "/bp-languages/buddypress-$locale.mo";
    1768    
     1770
    17691771    if ( file_exists( $mofile ) )
    17701772        load_textdomain( 'buddypress', $mofile );
     
    17811783/**
    17821784 * bp_core_update_message()
    1783  * 
     1785 *
    17841786 * Add an extra update message to the update plugin notification.
    1785  * 
     1787 *
    17861788 * @package BuddyPress Core
    17871789 */
     
    17931795/**
    17941796 * bp_core_clear_user_object_cache()
    1795  * 
     1797 *
    17961798 * Clears all cached objects for a user, or a user is part of.
    1797  * 
     1799 *
    17981800 * @package BuddyPress Core
    17991801 */
  • trunk/bp-core/bp-core-activation.php

    r2025 r2077  
    33function bp_core_screen_activation() {
    44    global $bp, $wpdb;
    5    
     5
    66    if ( BP_ACTIVATION_SLUG != $bp->current_component )
    77        return false;
    8        
     8
    99    /* If we are using a BuddyPress 1.0 theme ignore this. */
    1010    if ( file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    1111        return false;
    12        
     12
    1313    /* Check if an activation key has been passed */
    1414    if ( isset( $_GET['key'] ) ) {
    15        
     15
    1616        require_once( ABSPATH . WPINC . '/registration.php' );
    17        
     17
    1818        /* Activate the signup */
    1919        $signup = apply_filters( 'bp_core_activate_account', wpmu_activate_signup( $_GET['key'] ) );
    20        
     20
    2121        /* If there was errors, add a message and redirect */
    2222        if ( $signup->errors ) {
     
    2424            bp_core_redirect( $bp->root_domain . '/' . BP_ACTIVATION_SLUG );
    2525        }
    26        
     26
    2727        /* Set the password */
    2828        if ( !empty( $signup['meta']['password'] ) )
    2929            $wpdb->update( $wpdb->users, array( 'user_pass' => $signup['meta']['password'] ), array( 'ID' => $signup['user_id'] ), array( '%s' ), array( '%d' ) );
    30        
    31         /* Set any profile data */ 
     30
     31        /* Set any profile data */
    3232        if ( function_exists( 'xprofile_set_field_data' ) ) {
    33            
     33
    3434            if ( !empty( $signup['meta']['profile_field_ids'] ) ) {
    3535                $profile_field_ids = explode( ',', $signup['meta']['profile_field_ids'] );
    36            
     36
    3737                foreach( $profile_field_ids as $field_id ) {
    3838                    $current_field = $signup['meta']["field_{$field_id}"];
    39                
     39
    4040                    if ( !empty( $current_field ) )
    4141                        xprofile_set_field_data( $field_id, $signup['user_id'], $current_field );
    4242                }
    4343            }
    44            
     44
    4545        }
    46        
     46
    4747        /* Check for an uploaded avatar and move that to the correct user folder */
    4848        $hashed_key = wp_hash( $_GET['key'] );
    49        
     49
    5050        /* Check if the avatar folder exists. If it does, move rename it, move it and delete the signup avatar dir */
    5151        if ( file_exists( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key ) ) {
    5252            @rename( WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/signups/' . $hashed_key, WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/avatars/' . $signup['user_id'] );
    5353        }
    54        
     54
    5555        /* Record the new user in the activity streams */
    5656        if ( function_exists( 'bp_activity_add' ) ) {
    5757            $userlink = bp_core_get_userlink( $signup['user_id'] );
    58            
     58
    5959            bp_activity_add( array(
    6060                'user_id' => $signup['user_id'],
     
    6262                'primary_link' => apply_filters( 'bp_core_actiivty_registered_member_primary_link', $userlink ),
    6363                'component_name' => 'profile',
    64                 'component_action' => 'new_member' 
     64                'component_action' => 'new_member'
    6565            ) );
    6666        }
     
    6868        do_action( 'bp_core_account_activated', &$signup, $_GET['key'] );
    6969        bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) );
    70        
     70
    7171        $bp->activation_complete = true;
    7272    }
    73    
     73
    7474    if ( '' != locate_template( array( 'registration/activate' ), false ) )
    75         bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) );     
     75        bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) );
    7676    else
    77         bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );     
     77        bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) );
    7878}
    7979add_action( 'wp', 'bp_core_screen_activation', 3 );
     
    9191    if ( '' == locate_template( array( 'registration/register.php' ), false ) && '' == locate_template( array( 'register.php' ), false ) )
    9292        return true;
    93    
     93
    9494    return false;
    9595}
  • trunk/bp-core/bp-core-admin.php

    r2029 r2077  
    44    global $wpdb, $bp, $current_blog;
    55?>
    6    
     6
    77    <?php
    88    if ( isset( $_POST['bp-admin-submit'] ) && isset( $_POST['bp-admin'] ) ) {
    99        if ( !check_admin_referer('bp-admin') )
    1010            return false;
    11        
     11
    1212        // Settings form submitted, now save the settings.
    1313        foreach ( $_POST['bp-admin'] as $key => $value ) {
    14            
     14
    1515            if ( function_exists( 'xprofile_install' ) ) {
    1616                if ( 'bp-xprofile-base-group-name' == $key ) {
    1717                    $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s WHERE name = %s AND id = 1", $value, stripslashes( get_site_option('bp-xprofile-base-group-name') ) ) );
    1818                }
    19                
     19
    2020                if ( 'bp-xprofile-fullname-field-name' == $key ) {
    2121                    $wpdb->query( $wpdb->prepare( "UPDATE {$bp->profile->table_name_fields} SET name = %s WHERE name = %s AND group_id = 1", $value, stripslashes( get_site_option('bp-xprofile-fullname-field-name') ) ) );
    2222                }
    2323            }
    24            
     24
    2525            update_site_option( $key, $value );
    2626        }
    2727    }
    2828    ?>
    29    
     29
    3030    <div class="wrap">
    31        
     31
    3232        <h2><?php _e( 'BuddyPress Settings', 'buddypress' ) ?></h2>
    3333
     
    3939
    4040        <form action="" method="post" id="bp-admin-form">
    41        
     41
    4242            <table class="form-table">
    4343            <tbody>
     
    4747                    <td>
    4848                        <input name="bp-admin[bp-xprofile-base-group-name]" id="bp-xprofile-base-group-name" value="<?php echo get_site_option('bp-xprofile-base-group-name') ?>" />
    49                     </td>           
     49                    </td>
    5050                </tr>
    5151                <tr>
     
    6060                        <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( (int)get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    6161                        <input type="radio" name="bp-admin[bp-disable-profile-sync]"<?php if ( !(int)get_site_option( 'bp-disable-profile-sync' ) || '' == get_site_option( 'bp-disable-profile-sync' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-profile-sync" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    62                     </td>           
     62                    </td>
    6363                </tr>
    6464                <?php endif; ?>
     
    6868                        <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( (int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-yes" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    6969                        <input type="radio" name="bp-admin[hide-loggedout-adminbar]"<?php if ( !(int)get_site_option( 'hide-loggedout-adminbar' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-hide-loggedout-adminbar-no" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    70                     </td>           
     70                    </td>
    7171                </tr>
    7272                <tr>
     
    8383                        <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( (int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    8484                        <input type="radio" name="bp-admin[non-friend-wire-posting]"<?php if ( !(int)get_site_option( 'non-friend-wire-posting' ) ) : ?> checked="checked"<?php endif; ?> id="bp-admin-non-friend-wire-post" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    85                     </td>           
    86                 </tr>
    87                 <?php } ?>             
     85                    </td>
     86                </tr>
     87                <?php } ?>
    8888                <tr>
    8989                    <th scope="row"><?php _e( 'Disable user account deletion?', 'buddypress' ) ?>:</th>
     
    9191                        <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( (int)get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    9292                        <input type="radio" name="bp-admin[bp-disable-account-deletion]"<?php if ( !(int)get_site_option( 'bp-disable-account-deletion' ) || '' == get_site_option( 'bp-disable-account-deletion' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-account-deletion" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    93                     </td>           
     93                    </td>
    9494                </tr>
    9595                <?php if ( function_exists( 'bp_forums_setup') ) : ?>
     
    9999                        <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( (int)get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
    100100                        <input type="radio" name="bp-admin[bp-disable-forum-directory]"<?php if ( !(int)get_site_option( 'bp-disable-forum-directory' ) || '' == get_site_option( 'bp-disable-forum-directory' ) ) : ?> checked="checked"<?php endif; ?> id="bp-disable-forum-directory" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
    101                     </td>           
    102                 </tr>               
    103                 <?php endif; ?>
    104                
     101                    </td>
     102                </tr>
     103                <?php endif; ?>
     104
    105105                <?php $themes = bp_core_get_buddypress_themes() ?>
    106106                <?php if ( $themes ) : ?>
     
    109109                        <td>
    110110                                <select name="bp-admin[active-member-theme]" id="active-member-theme">
    111                                 <?php 
    112                                 for ( $i = 0; $i < count($themes); $i++ ) { 
     111                                <?php
     112                                for ( $i = 0; $i < count($themes); $i++ ) {
    113113                                    if ( $themes[$i]['template'] == get_site_option( 'active-member-theme' ) ) {
    114114                                        $selected = ' selected="selected"';
     
    120120                                <?php } ?>
    121121                            </select>
    122                         </td>           
     122                        </td>
    123123                    </tr>
    124124                <?php else : ?>
     
    129129                    <?php endif; ?>
    130130                <?php endif; ?>
    131                            
     131
    132132                <tr>
    133133                    <th scope="row"><?php _e( 'Default User Avatar', 'buddypress' ) ?></th>
     
    147147
    148148            <?php do_action( 'bp_core_admin_screen' ) ?>
    149            
     149
    150150            <p class="submit">
    151151                <input class="button-primary" type="submit" name="bp-admin-submit" id="bp-admin-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
     
    153153
    154154            <?php wp_nonce_field( 'bp-admin' ) ?>
    155        
     155
    156156        </form>
    157        
     157
    158158    </div>
    159    
    160 <?php 
     159
     160<?php
    161161}
    162162
     
    164164    global $wpdb, $bp;
    165165?>
    166    
     166
    167167    <?php
    168168    if ( isset( $_POST['bp-admin-component-submit'] ) && isset( $_POST['bp_components'] ) ) {
    169169        if ( !check_admin_referer('bp-admin-component-setup') )
    170170            return false;
    171        
     171
    172172        // Settings form submitted, now save the settings.
    173173        foreach ( $_POST['bp_components'] as $key => $value ) {
    174174            if ( !(int) $value )
    175                 $disabled[$key] = 1;   
     175                $disabled[$key] = 1;
    176176        }
    177177        update_site_option( 'bp-deactivated-components', $disabled );
    178178    }
    179179    ?>
    180    
     180
    181181    <div class="wrap">
    182        
     182
    183183        <h2><?php _e( 'BuddyPress Component Setup', 'buddypress' ) ?></h2>
    184        
     184
    185185        <?php if ( isset( $_POST['bp-admin-component-submit'] ) ) : ?>
    186186            <div id="message" class="updated fade">
     
    188188            </div>
    189189        <?php endif; ?>
    190    
     190
    191191        <form action="" method="post" id="bp-admin-component-form">
    192        
     192
    193193            <p>
    194             <?php _e( 
    195                 'By default, all BuddyPress components are enabled. You can selectively disable any of the 
     194            <?php _e(
     195                'By default, all BuddyPress components are enabled. You can selectively disable any of the
    196196                components by using the form below. Your BuddyPress installation will continue to function, however
    197197                the features of the disabled components will no longer be accessible to
     
    199199                ', 'buddypress' )?>
    200200            </p>
    201            
     201
    202202            <?php $disabled_components = get_site_option( 'bp-deactivated-components' ); ?>
    203            
     203
    204204            <table class="form-table" style="width: 80%">
    205205            <tbody>
     
    210210                        <input type="radio" name="bp_components[bp-activity.php]" value="1"<?php if ( !isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?> &nbsp;
    211211                        <input type="radio" name="bp_components[bp-activity.php]" value="0"<?php if ( isset( $disabled_components['bp-activity.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
    212                     </td>           
     212                    </td>
    213213                </tr>
    214214                <?php endif; ?>
     
    219219                        <input type="radio" name="bp_components[bp-blogs.php]" value="1"<?php if ( !isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
    220220                        <input type="radio" name="bp_components[bp-blogs.php]" value="0"<?php if ( isset( $disabled_components['bp-blogs.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
    221                     </td>           
     221                    </td>
    222222                </tr>
    223223                <?php endif; ?>
     
    228228                        <input type="radio" name="bp_components[bp-forums.php]" value="1"<?php if ( !isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
    229229                        <input type="radio" name="bp_components[bp-forums.php]" value="0"<?php if ( isset( $disabled_components['bp-forums.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
    230                     </td>           
     230                    </td>
    231231                </tr>
    232232                <?php endif; ?>
     
    237237                        <input type="radio" name="bp_components[bp-friends.php]" value="1"<?php if ( !isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
    238238                        <input type="radio" name="bp_components[bp-friends.php]" value="0"<?php if ( isset( $disabled_components['bp-friends.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
    239                     </td>           
     239                    </td>
    240240                </tr>
    241241                <?php endif; ?>
     
    246246                        <input type="radio" name="bp_components[bp-groups.php]" value="1"<?php if ( !isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
    247247                        <input type="radio" name="bp_components[bp-groups.php]" value="0"<?php if ( isset( $disabled_components['bp-groups.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
    248                     </td>           
     248                    </td>
    249249                </tr>
    250250                <?php endif; ?>
     
    255255                        <input type="radio" name="bp_components[bp-messages.php]" value="1"<?php if ( !isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
    256256                        <input type="radio" name="bp_components[bp-messages.php]" value="0"<?php if ( isset( $disabled_components['bp-messages.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
    257                     </td>           
     257                    </td>
    258258                </tr>
    259259                <?php endif; ?>
     
    264264                        <input type="radio" name="bp_components[bp-wire.php]" value="1"<?php if ( !isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Enabled', 'buddypress' ) ?>  &nbsp;
    265265                        <input type="radio" name="bp_components[bp-wire.php]" value="0"<?php if ( isset( $disabled_components['bp-wire.php'] ) ) : ?> checked="checked" <?php endif; ?>/> <?php _e( 'Disabled', 'buddypress' ) ?>
    266                     </td>           
     266                    </td>
    267267                </tr>
    268268                <?php endif; ?>
     
    287287            </tbody>
    288288            </table>
    289            
     289
    290290            <p class="submit">
    291291                <input class="button-primary" type="submit" name="bp-admin-component-submit" id="bp-admin-component-submit" value="<?php _e( 'Save Settings', 'buddypress' ) ?>"/>
    292292            </p>
    293            
     293
    294294            <?php wp_nonce_field( 'bp-admin-component-setup' ) ?>
    295        
     295
    296296        </form>
    297297
    298298    </div>
    299    
    300 <?php 
     299
     300<?php
    301301}
    302302
  • trunk/bp-core/bp-core-adminbar.php

    r1905 r2077  
    33function bp_core_admin_bar() {
    44    global $bp, $wpdb, $current_blog, $doing_admin_bar;
    5    
     5
    66    if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
    77        return false;
    8    
     8
    99    $doing_admin_bar = true;
    10    
     10
    1111    if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
    1212        return false;
     
    1818
    1919    echo '<ul class="main-nav">';
    20    
     20
    2121    // **** Do bp-adminbar-menus Actions ********
    2222    do_action( 'bp_adminbar_menus' );
     
    2929function bp_adminbar_logo() {
    3030    global $bp;
    31    
     31
    3232    echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname') . '</a>';
    3333}
     
    3737    global $bp;
    3838
    39     if ( !is_user_logged_in() ) {   
     39    if ( !is_user_logged_in() ) {
    4040        echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
    41        
     41
    4242        // Show "Sign Up" link if user registrations are allowed
    4343        if ( get_site_option( 'registration' ) != 'none' && get_site_option( 'registration' ) != 'blog' ) {
     
    5555
    5656    if ( is_user_logged_in() ) {
    57        
     57
    5858        echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
    59    
     59
    6060        echo __( 'My Account', 'buddypress' ) . '</a>';
    6161        echo '<ul>';
    62    
     62
    6363        /* Loop through each navigation item */
    6464        $counter = 0;
    6565        foreach( $bp->bp_nav as $nav_item ) {
    6666            $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    67            
     67
    6868            echo '<li' . $alt . '>';
    6969            echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
    70            
     70
    7171            if ( is_array( $bp->bp_options_nav[$nav_item['css_id']] ) ) {
    7272                echo '<ul>';
     
    7575                foreach( $bp->bp_options_nav[$nav_item['css_id']] as $subnav_item ) {
    7676                    $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
    77                     echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';               
     77                    echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>';
    7878                    $sub_counter++;
    7979                }
    8080                echo '</ul>';
    8181            }
    82        
     82
    8383            echo '</li>';
    84            
     84
    8585            $counter++;
    8686        }
    87    
     87
    8888        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    8989
    90         if ( function_exists('wp_logout_url') ) { 
    91             echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';                   
    92         } else { 
    93             echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 
    94         } 
    95              
     90        if ( function_exists('wp_logout_url') ) {
     91            echo '<li' . $alt . '><a id="bp-admin-logout" href="' . wp_logout_url(site_url()) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
     92        } else {
     93            echo '<li' . $alt . '><a id="bp-admin-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . site_url() . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
     94        }
     95
    9696        echo '</ul>';
    9797        echo '</li>';
     
    101101// return a string indicating user's role in that blog
    102102function get_blog_role_for_user( $user, $blog ) {
    103    
     103
    104104    // If the user is a site admin, just display admin.
    105     if ( is_site_admin() ) 
     105    if ( is_site_admin() )
    106106        return __( 'Admin', 'buddypress');
    107    
     107
    108108    $roles = get_usermeta( $user, 'wp_' . $blog . '_capabilities' );
    109109
    110110    if ( isset( $roles['subscriber'] ) )
    111         $role = __( 'Subscriber', 'buddypress' ); 
     111        $role = __( 'Subscriber', 'buddypress' );
    112112    elseif  ( isset( $roles['contributor'] ) )
    113113        $role = __( 'Contributor', 'buddypress' );
     
    120120    else
    121121        return false;
    122    
     122
    123123    return $role;
    124124}
     
    127127function bp_adminbar_blogs_menu() {
    128128    if ( is_user_logged_in() ) {
    129         global $bp; 
    130    
     129        global $bp;
     130
    131131        if ( function_exists('bp_blogs_install') ) {
    132            
     132
    133133            if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id, 'bp' ) ) {
    134134                $blogs = get_blogs_of_user( $bp->loggedin_user->id );
     
    137137
    138138            echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';
    139            
     139
    140140            _e( 'My Blogs', 'buddypress' );
    141            
     141
    142142            echo '</a>';
    143    
    144             echo '<ul>';           
     143
     144            echo '<ul>';
    145145            if ( is_array( $blogs )) {
    146        
     146
    147147                $counter = 0;
    148148                foreach( $blogs as $blog ) {
     
    157157                        echo '<li><a href="' . $blog->siteurl  . '/wp-admin/post-new.php">' . __('New Post', 'buddypress') . '</a></li>';
    158158                        echo '<li class="alt"><a href="' . $blog->siteurl  . '/wp-admin/edit.php">' . __('Manage Posts', 'buddypress') . '</a></li>';
    159                         echo '<li><a href="' . $blog->siteurl  . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';                   
    160                         if ( 'Admin' == $role ) {   
    161                             echo '<li class="alt"><a href="' . $blog->siteurl  . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>'; 
    162                         }                   
    163                         echo '</ul>';                   
     159                        echo '<li><a href="' . $blog->siteurl  . '/wp-admin/edit-comments.php">' . __('Manage Comments', 'buddypress') . '</a></li>';
     160                        if ( 'Admin' == $role ) {
     161                            echo '<li class="alt"><a href="' . $blog->siteurl  . '/wp-admin/themes.php">' . __('Switch Theme', 'buddypress') . '</a></li>';
     162                        }
     163                        echo '</ul>';
    164164                    }
    165165                    echo '</li>';
     
    167167                }
    168168            }
    169    
     169
    170170            $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    171            
     171
    172172            if ( bp_blog_signup_enabled() ) {
    173173                echo '<li' . $alt . '>';
     
    175175                echo '</li>';
    176176            }
    177            
     177
    178178            echo '</ul>';
    179179            echo '</li>';
    180180        }
    181181    }
    182 }   
     182}
    183183
    184184// **** "Notifications" Menu *********
    185 function bp_adminbar_notifications_menu() { 
     185function bp_adminbar_notifications_menu() {
    186186    if ( is_user_logged_in() ) {
    187187        global $bp;
    188        
     188
    189189        echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
    190190        _e( 'Notifications', 'buddypress' );
    191    
     191
    192192        if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    193193            <span><?php echo count($notifications) ?></span>
    194194        <?php
    195195        }
    196        
     196
    197197        echo '</a>';
    198198        echo '<ul>';
    199        
     199
    200200        if ( $notifications ) { ?>
    201201            <?php $counter = 0; ?>
     
    209209        <?php
    210210        }
    211        
     211
    212212        echo '</ul>';
    213213        echo '</li>';
     
    218218function bp_adminbar_authors_menu() {
    219219    global $current_blog;
    220    
     220
    221221    if ( $current_blog->blog_id > 1 ) {
    222         $authors = get_users_of_blog(); 
    223    
     222        $authors = get_users_of_blog();
     223
    224224        if ( is_array( $authors ) ) {
    225225            /* This is a blog, render a menu with links to all authors */
     
    227227            _e('Blog Authors', 'buddypress');
    228228            echo '</a>';
    229        
     229
    230230            echo '<ul class="author-list">';
    231231            foreach( $authors as $author ) {
     
    246246    }
    247247}
    248    
     248
    249249// **** "Random" Menu (visible when not logged in) ********
    250 function bp_adminbar_random_menu() { 
     250function bp_adminbar_random_menu() {
    251251    global $bp; ?>
    252252    <li class="align-right" id="bp-adminbar-visitrandom-menu">
     
    261261            <?php if ( function_exists('bp_blogs_install') ) : ?>
    262262            <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
    263            
     263
    264264            <?php endif; ?>
    265            
     265
    266266            <?php do_action( 'bp_adminbar_random_menu' ) ?>
    267267        </ul>
  • trunk/bp-core/bp-core-avatars.php

    r2069 r2077  
    3232if ( !defined( 'BP_AVATAR_DEFAULT_THUMB' ) )
    3333    define( 'BP_AVATAR_DEFAULT_THUMB', BP_PLUGIN_URL . '/bp-xprofile/images/none-thumbnail.gif' );
    34    
     34
    3535function bp_core_fetch_avatar( $args = '' ) {
    3636    global $bp, $current_blog;
    37    
     37
    3838    $defaults = array(
    3939        'item_id' => false,
     
    4141        'type' => 'thumb',
    4242        'avatar_dir' => false,
    43         'width' => false, 
     43        'width' => false,
    4444        'height' => false,
    4545        'class' => 'avatar',
     
    5050
    5151    $params = wp_parse_args( $args, $defaults );
    52     extract( $params, EXTR_SKIP ); 
     52    extract( $params, EXTR_SKIP );
    5353
    5454    if ( !$item_id ) {
     
    5959        else if ( 'blog' == $object )
    6060            $item_id = $current_blog->id;
    61            
     61
    6262        $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
    63    
     63
    6464        if ( !$item_id ) return false;
    6565    }
    66        
     66
    6767    if ( !$avatar_dir ) {
    6868        if ( 'user' == $object )
     
    7272        else if ( 'blog' == $object )
    7373            $avatar_dir = 'blog-avatars';
    74            
     74
    7575        $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
    76        
    77         if ( !$avatar_dir ) return false;       
    78     }
    79    
     76
     77        if ( !$avatar_dir ) return false;
     78    }
     79
    8080    if ( !$css_id )
    81         $css_id = $object . '-' . $item_id . '-avatar'; 
    82    
     81        $css_id = $object . '-' . $item_id . '-avatar';
     82
    8383    if ( $width )
    8484        $html_width = " width='{$width}'";
    8585    else
    8686        $html_width = ( 'thumb' == $type ) ? ' width="' . BP_AVATAR_THUMB_WIDTH . '"' : ' width="' . BP_AVATAR_FULL_WIDTH . '"';
    87        
     87
    8888    if ( $height )
    8989        $html_height = " height='{$height}'";
    9090    else
    9191        $html_height = ( 'thumb' == $type ) ? ' height="' . BP_AVATAR_THUMB_HEIGHT . '"' : ' height="' . BP_AVATAR_FULL_HEIGHT . '"';
    92    
    93     $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) . '/' . basename( WP_CONTENT_DIR ) . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir ); 
    94     $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );   
     92
     93    $avatar_folder_url = apply_filters( 'bp_core_avatar_folder_url', get_blog_option( BP_ROOT_BLOG, 'siteurl' ) . '/' . basename( WP_CONTENT_DIR ) . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
     94    $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
    9595
    9696    /****
     
    116116    }
    117117
    118     /* If no avatars have been uploaded for this item, display a gravatar */   
     118    /* If no avatars have been uploaded for this item, display a gravatar */
    119119    if ( !file_exists( $avatar_url ) && !$no_grav ) {
    120        
    121120        if ( empty( $bp->grav_default->{$object} ) )
    122121            $default_grav = 'wavatar';
     
    129128        else if ( 'full' == $type ) $grav_size = BP_AVATAR_FULL_WIDTH;
    130129        else if ( 'thumb' == $type ) $grav_size = BP_AVATAR_THUMB_WIDTH;
    131        
     130
    132131        if ( 'user' == $object ) {
    133132            $ud = get_userdata( $item_id );
     
    136135            $grav_email = "{$item_id}-{$object}@{$bp->root_domain}";
    137136        }
    138    
    139         $grav_email = apply_filters( 'bp_core_gravatar_email', $grav_email, $item_id, $object );   
     137
     138        $grav_email = apply_filters( 'bp_core_gravatar_email', $grav_email, $item_id, $object );
    140139        $gravatar = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' ) . md5( $grav_email ) . '?d=' . $default_grav . '&amp;s=' . $grav_size;
    141        
     140
    142141        return apply_filters( 'bp_core_fetch_avatar', "<img src='{$gravatar}' alt='{$alt}' id='{$css_id}' class='{$class}'{$html_width}{$html_height} />", $params );
    143    
    144142    } else if ( !file_exists( $avatar_url ) && $no_grav )
    145143        return false;
    146    
    147144}
    148145
    149146function bp_core_delete_existing_avatar( $args = '' ) {
    150147    global $bp;
    151    
     148
    152149    $defaults = array(
    153150        'item_id' => false,
     
    157154
    158155    $args = wp_parse_args( $args, $defaults );
    159     extract( $args, EXTR_SKIP );   
    160    
     156    extract( $args, EXTR_SKIP );
     157
    161158    if ( !$item_id ) {
    162159        if ( 'user' == $object )
     
    166163        else if ( 'blog' == $object )
    167164            $item_id = $current_blog->id;
    168            
     165
    169166        $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
    170    
     167
    171168        if ( !$item_id ) return false;
    172169    }
    173        
     170
    174171    if ( !$avatar_dir ) {
    175172        if ( 'user' == $object )
     
    179176        else if ( 'blog' == $object )
    180177            $avatar_dir = 'blog-avatars';
    181            
     178
    182179        $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
    183        
    184         if ( !$avatar_dir ) return false;       
     180
     181        if ( !$avatar_dir ) return false;
    185182    }
    186183
     
    193190    }
    194191
    195     $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );   
     192    $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
    196193
    197194    if ( !file_exists( $avatar_folder_dir ) )
     
    201198        while ( false !== ( $avatar_file = readdir($av_dir) ) ) {
    202199            if ( ( preg_match( "/-bpfull/", $avatar_file ) || preg_match( "/-bpthumb/", $avatar_file ) ) && '.' != $avatar_file && '..' != $avatar_file )
    203                 @unlink( $avatar_folder_dir . '/' . $avatar_file );             
     200                @unlink( $avatar_folder_dir . '/' . $avatar_file );
    204201        }
    205202    }
     
    215212function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
    216213    global $bp;
    217    
     214
    218215    require_once( ABSPATH . '/wp-admin/includes/image.php' );
    219216    require_once( ABSPATH . '/wp-admin/includes/file.php' );
    220    
     217
    221218    $uploadErrors = array(
    222         0 => __("There is no error, the file uploaded with success", 'buddypress'), 
    223         1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE), 
     219        0 => __("There is no error, the file uploaded with success", 'buddypress'),
     220        1 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
    224221        2 => __("Your image was bigger than the maximum allowed file size of: ", 'buddypress') . size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE),
    225222        3 => __("The uploaded file was only partially uploaded", 'buddypress'),
     
    232229        return false;
    233230    }
    234    
     231
    235232    if ( !bp_core_check_avatar_size( $file ) ) {
    236233        bp_core_add_message( sprintf( __( 'The file you uploaded is too big. Please upload a file under %s', 'buddypress'), size_format(BP_AVATAR_ORIGINAL_MAX_FILESIZE) ), 'error' );
    237234        return false;
    238235    }
    239    
     236
    240237    if ( !bp_core_check_avatar_type( $file ) ) {
    241238        bp_core_add_message( __( 'Please upload only JPG, GIF or PNG photos.', 'buddypress' ), 'error' );
    242239        return false;
    243240    }
    244    
     241
    245242    // Filter the upload location
    246243    add_filter( 'upload_dir', $upload_dir_filter, 10, 0 );
    247    
     244
    248245    $bp->avatar_admin->original = wp_handle_upload( $file['file'], array( 'action'=> 'bp_avatar_upload' ) );
    249246
     
    253250        return false;
    254251    }
    255        
     252
    256253    // Resize the image down to something manageable and then delete the original
    257254    if ( getimagesize( $bp->avatar_admin->original['file'] ) > BP_AVATAR_ORIGINAL_MAX_WIDTH ) {
    258255        $bp->avatar_admin->resized = wp_create_thumbnail( $bp->avatar_admin->original['file'], BP_AVATAR_ORIGINAL_MAX_WIDTH );
    259256    }
    260    
     257
    261258    $bp->avatar_admin->image = new stdClass;
    262    
    263     // We only want to handle one image after resize. 
     259
     260    // We only want to handle one image after resize.
    264261    if ( empty( $bp->avatar_admin->resized ) )
    265262        $bp->avatar_admin->image->dir = $bp->avatar_admin->original['file'];
     
    268265        @unlink( $bp->avatar_admin->original['file'] );
    269266    }
    270    
     267
    271268    /* Set the url value for the image */
    272269    $bp->avatar_admin->image->url = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, $bp->avatar_admin->image->dir );
     
    277274function bp_core_avatar_handle_crop( $args = '' ) {
    278275    global $bp;
    279    
     276
    280277    $defaults = array(
    281278        'object' => 'user',
     
    297294    if ( !file_exists( WP_CONTENT_DIR . '/' . $original_file ) )
    298295        return false;
    299            
     296
    300297    if ( !$item_id )
    301         $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir ); 
     298        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . dirname( $original_file ), $item_id, $object, $avatar_dir );
    302299    else
    303300        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', WP_CONTENT_DIR . '/blogs.dir/' . BP_ROOT_BLOG . '/files/' . $avatar_dir . '/' . $item_id, $item_id, $object, $avatar_dir );
     
    305302    if ( !file_exists( $avatar_folder_dir ) )
    306303        return false;
    307    
     304
    308305    require_once( ABSPATH . '/wp-admin/includes/image.php' );
    309306    require_once( ABSPATH . '/wp-admin/includes/file.php' );
     
    311308    /* Delete the existing avatar files for the object */
    312309    bp_core_delete_existing_avatar( array( 'object' => $object, 'avatar_path' => $avatar_folder_dir ) );
    313    
     310
    314311    /* Make sure we at least have a width and height for cropping */
    315312    if ( !(int)$crop_w )
    316313        $crop_w = BP_AVATAR_FULL_WIDTH;
    317    
     314
    318315    if ( !(int)$crop_h )
    319316        $crop_h = BP_AVATAR_FULL_HEIGHT;
     
    322319    $full_filename = wp_hash( $original_file . time() ) . '-bpfull.jpg';
    323320    $thumb_filename = wp_hash( $original_file . time() ) . '-bpthumb.jpg';
    324            
     321
    325322    /* Crop the image */
    326323    $full_cropped = wp_crop_image( WP_CONTENT_DIR . $original_file, (int)$crop_x, (int)$crop_y, (int)$crop_w, (int)$crop_h, BP_AVATAR_FULL_WIDTH, BP_AVATAR_FULL_HEIGHT, false, $avatar_folder_dir . '/' . $full_filename );
     
    337334    if ( is_object ( $id_or_email ) )
    338335        $id_or_email = $id_or_email->user_id;
    339    
     336
    340337    $bp_avatar = bp_core_fetch_avatar( array( 'no_grav' => true, 'item_id' => $id_or_email, 'width' => $size, 'height' => $size, 'alt' => $alt ) );
    341338
     
    347344    if ( $file['error'] )
    348345        return false;
    349    
     346
    350347    return true;
    351348}
     
    354351    if ( $file['file']['size'] > BP_AVATAR_ORIGINAL_MAX_FILESIZE )
    355352        return false;
    356    
     353
    357354    return true;
    358355}
     
    361358    if ( ( strlen($file['file']['type']) && !preg_match('/(jpe?g|gif|png)$/', $file['file']['type'] ) ) && !preg_match( '/(jpe?g|gif|png)$/', $file['file']['name'] ) )
    362359        return false;
    363    
     360
    364361    return true;
    365362}
  • trunk/bp-core/bp-core-catchuri.php

    r2027 r2077  
    1717 *   - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
    1818 *   - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
    19  * 
     19 *
    2020 *  Example:
    2121 *    - http://domain.com/members/andy/profile/edit/group/5/
     
    2323 *    - $bp->current_action: string 'edit'
    2424 *    - $bp->action_variables: array ['group', 5]
    25  * 
     25 *
    2626 * @package BuddyPress Core
    2727 */
     
    3232    global $bp_unfiltered_uri;
    3333    global $bp, $current_blog;
    34    
     34
    3535    if ( !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
    3636        /* Only catch URI's on the root blog if we are not running BP on multiple blogs */
     
    6464            array_shift( $bp_uri );
    6565    }
    66    
     66
    6767    /* Set the indexes, these are incresed by one if we are not on a VHOST install */
    6868    $component_index = 0;
    6969    $action_index = $component_index + 1;
    70    
     70
    7171    // If this is a WordPress page, return from the function.
    7272    if ( is_page( $bp_uri[$component_index] ) )
    7373        return false;
    74    
     74
    7575    /* Get site path items */
    7676    $paths = explode( '/', bp_core_get_site_path() );
     
    9393    $bp_uri = array_merge( array(), $bp_uri );
    9494    $bp_unfiltered_uri = $bp_uri;
    95    
     95
    9696    /* If we are under anything with a members slug, set the correct globals */
    9797    if ( $bp_uri[0] == BP_MEMBERS_SLUG ) {
    9898        $is_member_page = true;
    99         $is_root_component = true;     
     99        $is_root_component = true;
    100100    }
    101101
    102102    /* Catch a member page and set the current member ID */
    103     if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {     
    104         if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {   
     103    if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
     104        if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {
    105105            // We are within a member page, set up user id globals
    106106            $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
     
    108108            unset($bp_uri[0]);
    109109            unset($bp_uri[1]);
    110        
     110
    111111            /* Reset the keys by merging with an empty array */
    112112            $bp_uri = array_merge( array(), $bp_uri );
     
    116116            $is_member_page = true;
    117117            $is_root_component = true;
    118        
     118
    119119            // We are within a member page, set up user id globals
    120120            $displayed_user_id = bp_core_get_displayed_userid( $bp_uri[0] );
    121                
     121
    122122            unset($bp_uri[0]);
    123123
     
    126126        }
    127127    }
    128    
     128
    129129    if ( !isset($is_root_component) )
    130130        $is_root_component = in_array( $bp_uri[0], $bp->root_components );
     
    137137    /* Set the current component */
    138138    $current_component = $bp_uri[$component_index];
    139    
     139
    140140    /* Set the current action */
    141141    $current_action = $bp_uri[$action_index];
    142    
     142
    143143    /* Set the entire URI as the action variables, we will unset the current_component and action in a second */
    144144    $action_variables = $bp_uri;
     
    151151    if ( 'no' == VHOST && !$is_root_component )
    152152        array_shift($action_variables);
    153    
     153
    154154    /* Reset the keys by merging with an empty array */
    155155    $action_variables = array_merge( array(), $action_variables );
     
    162162 * bp_catch_uri()
    163163 *
    164  * Takes either a single page name or array of page names and 
     164 * Takes either a single page name or array of page names and
    165165 * loads the first template file that can be found.
    166166 *
    167167 * Please don't call this function directly anymore, use: bp_core_load_template()
    168  * 
     168 *
    169169 * @package BuddyPress Core
    170170 * @global $bp_path BuddyPress global containing the template file names to use.
     
    174174function bp_catch_uri( $pages, $skip_blog_check = false ) {
    175175    global $bp_path, $bp_skip_blog_check;
    176    
     176
    177177    $bp_skip_blog_check = $skip_blog_check;
    178178
     
    189189 *
    190190 * Loads the first template file found based on the $bp_path global.
    191  * 
     191 *
    192192 * @package BuddyPress Core
    193193 * @global $bp_path BuddyPress global containing the template file names to use.
     
    198198    global $bp_no_status_set;
    199199    global $wp_query;
    200    
    201     /* Can be a single template or an array of templates */ 
     200
     201    /* Can be a single template or an array of templates */
    202202    $templates = $bp_path;
    203    
     203
    204204    /* Don't hijack any URLs on blog pages */
    205205    if ( bp_is_blog_page() ) {
     
    214214        status_header( 200 );
    215215        $wp_query->is_404 = false;
    216        
     216
    217217        if ( $bp->current_component != BP_HOME_BLOG_SLUG )
    218218            $wp_query->is_page = true;
    219219    }
    220    
     220
    221221    foreach ( (array)$templates as $template )
    222222        $filtered_templates[] = $template . '.php';
    223    
     223
    224224    if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) {
    225225        load_template( apply_filters( 'bp_load_template', $located_template ) );
     
    269269 * If the extended profiles component is not installed we still need
    270270 * to catch the /profile URI's and display whatever we have installed.
    271  * 
     271 *
    272272 */
    273273function bp_core_catch_profile_uri() {
    274274    global $bp;
    275    
     275
    276276    if ( !function_exists('xprofile_install') )
    277277        bp_core_load_template( apply_filters( 'bp_core_template_display_profile', 'profile/index' ) );
  • trunk/bp-core/bp-core-classes.php

    r2055 r2077  
    33 * BP_Core_User class can be used by any component. It will fetch useful
    44 * details for any user when provided with a user_id.
    5  * 
     5 *
    66 * Example:
    77 *    $user = new BP_Core_User( $user_id );
     
    1010 *    $user_status = $user->status;
    1111 *    etc.
    12  * 
     12 *
    1313 * @package BuddyPress Core
    1414 */
     
    2020    var $fullname;
    2121    var $email;
    22    
     22
    2323    var $user_url;
    2424    var $user_link;
    25    
     25
    2626    var $last_active;
    2727    var $profile_last_updated;
     
    3131    var $total_blogs;
    3232    var $total_groups;
    33    
     33
    3434    function bp_core_user( $user_id, $populate_extras = false ) {
    3535        if ( $user_id ) {
    3636            $this->id = $user_id;
    3737            $this->populate();
    38            
     38
    3939            if ( $populate_extras )
    4040                $this->populate_extras();
    4141        }
    42     } 
    43    
     42    }
     43
    4444    /**
    4545     * populate()
    4646     *
    4747     * Populate the instantiated class with data based on the User ID provided.
    48      * 
     48     *
    4949     * @package BuddyPress Core
    5050     * @global $userdata WordPress user data for the current logged in user.
     
    5959        $this->user_url = bp_core_get_userurl( $this->id );
    6060        $this->user_link = bp_core_get_userlink( $this->id );
    61        
     61
    6262        $this->fullname = attribute_escape( bp_core_get_user_displayname( $this->id ) );
    6363        $this->email = attribute_escape( bp_core_get_user_email( $this->id ) );
     
    6868        $this->avatar_mini = bp_core_fetch_avatar( array( 'item_id' => $this->id, 'type' => 'thumb', 'width' => 30, 'height' => 30 ) );
    6969    }
    70    
     70
    7171    function populate_extras() {
    7272        global $bp;
    73        
    74         if ( function_exists('friends_install') ) { 
     73
     74        if ( function_exists('friends_install') ) {
    7575            $this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );
    7676
     
    8080                else
    8181                    $this->total_friends .= ' ' . __( 'friends', 'buddypress' );
    82            
     82
    8383                $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf( __( "%s's friend list", 'buddypress' ), $this->fullname ) . '">' . $this->total_friends . '</a>';
    8484            }
    8585        }
    8686
    87         if ( function_exists('bp_blogs_install') ) {       
     87        if ( function_exists('bp_blogs_install') ) {
    8888            if ( $this->total_blogs ) {
    8989                if ( 1 == $this->total_blogs )
    9090                    $this->total_blogs .= ' ' . __( 'blog', 'buddypress' );
    9191                else
    92                     $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' );           
    93                
     92                    $this->total_blogs .= ' ' . __( 'blogs', 'buddypress' );
     93
    9494                $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf( __( "%s's blog list", 'buddypress' ), $this->fullname ) . '">' . $this->total_blogs . '</a>';
    9595            }
    9696        }
    97        
     97
    9898        if ( function_exists('groups_install') ) {
    9999            $this->total_groups = BP_Groups_Member::total_group_count( $this->id );
    100            
     100
    101101            if ( $this->total_groups ) {
    102102                if ( 1 == $this->total_groups )
     
    109109        }
    110110    }
    111    
     111
    112112    /* Static Functions */
    113    
     113
    114114    function get_newest_users( $limit = null, $page = 1 ) {
    115115        global $wpdb;
    116        
    117         if ( $limit && $page )
    118             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    119        
     116
     117        if ( $limit && $page )
     118            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     119
    120120        $total_users_sql = apply_filters( 'bp_core_newest_users_count_sql', "SELECT DISTINCT count(ID) FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC" );
    121121        $paged_users_sql = apply_filters( 'bp_core_newest_users_sql', "SELECT DISTINCT ID as user_id, DATE_ADD( user_registered, INTERVAL " . get_option('gmt_offset') . " HOUR ) as user_registered FROM " . CUSTOM_USER_TABLE . " WHERE spam = 0 AND deleted = 0 AND user_status = 0 ORDER BY user_registered DESC{$pag_sql}", $pag_sql );
    122        
    123         $total_users = $wpdb->get_var( $total_users_sql );
    124         $paged_users = $wpdb->get_results( $paged_users_sql );
    125        
    126         return array( 'users' => $paged_users, 'total' => $total_users );
    127     }
    128    
     122
     123        $total_users = $wpdb->get_var( $total_users_sql );
     124        $paged_users = $wpdb->get_results( $paged_users_sql );
     125
     126        return array( 'users' => $paged_users, 'total' => $total_users );
     127    }
     128
    129129    function get_active_users( $limit = null, $page = 1 ) {
    130130        global $wpdb;
     
    135135        $total_users_sql = apply_filters( 'bp_core_active_users_count_sql', "SELECT DISTINCT count(um.user_id) FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC" );
    136136        $paged_users_sql = apply_filters( 'bp_core_active_users_sql', "SELECT DISTINCT user_id FROM " . CUSTOM_USER_META_TABLE . " um LEFT JOIN " . CUSTOM_USER_TABLE . " u ON u.ID = um.user_id WHERE um.meta_key = 'last_activity' AND u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 ORDER BY FROM_UNIXTIME(um.meta_value) DESC{$pag_sql}", $pag_sql );
    137        
    138         $total_users = $wpdb->get_var( $total_users_sql );
    139         $paged_users = $wpdb->get_results( $paged_users_sql );
    140        
     137
     138        $total_users = $wpdb->get_var( $total_users_sql );
     139        $paged_users = $wpdb->get_results( $paged_users_sql );
     140
    141141        return array( 'users' => $paged_users, 'total' => $total_users );
    142142    }
     
    144144    function get_popular_users( $limit = null, $page = 1 ) {
    145145        global $wpdb;
    146                
     146
    147147        if ( !function_exists('friends_install') )
    148148            return false;
    149        
     149
    150150        if ( $limit && $page )
    151151            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    156156        $total_users = $wpdb->get_var( $total_users_sql );
    157157        $paged_users = $wpdb->get_results( $paged_users_sql );
    158        
    159         return array( 'users' => $paged_users, 'total' => $total_users );
    160     }
    161    
     158
     159        return array( 'users' => $paged_users, 'total' => $total_users );
     160    }
     161
    162162    function get_random_users( $limit = null, $page = 1 ) {
    163163        global $wpdb, $bp;
    164        
     164
    165165        if ( $limit && $page )
    166166            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    171171        $total_users = $wpdb->get_var( $total_users_sql );
    172172        $paged_users = $wpdb->get_results( $paged_users_sql );
    173        
    174         return array( 'users' => $paged_users, 'total' => $total_users );
    175     }
    176    
     173
     174        return array( 'users' => $paged_users, 'total' => $total_users );
     175    }
     176
    177177    function get_online_users( $limit = null, $page = 1 ) {
    178178        global $wpdb;
    179        
     179
    180180        if ( $limit && $page )
    181181            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    189189        return array( 'users' => $paged_users, 'total' => $total_users );
    190190    }
    191    
     191
    192192    function get_alphabetical_users( $limit = null, $page = 1 ) {
    193193        global $wpdb, $bp;
     
    195195        if ( !function_exists( 'xprofile_install' ) )
    196196            return BP_Core_User::get_active_users( $limit, $page );
    197        
     197
    198198        if ( $limit && $page )
    199199            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    207207        return array( 'users' => $paged_users, 'total' => $total_users );
    208208    }
    209    
     209
    210210    function get_users_by_letter( $letter, $limit = null, $page = 1 ) {
    211211        global $wpdb, $bp;
    212        
     212
    213213        if ( !function_exists('xprofile_install') )
    214214            return BP_Core_User::get_active_users( $limit, $page );
    215        
    216         if ( $limit && $page )
    217             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    218        
     215
     216        if ( $limit && $page )
     217            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     218
    219219        if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
    220220            return false;
    221        
     221
    222222        $letter = like_escape( $wpdb->escape( $letter ) );
    223223
     
    227227        $total_users = $wpdb->get_var( $total_users_sql );
    228228        $paged_users = $wpdb->get_results( $paged_users_sql );
    229        
    230         return array( 'users' => $paged_users, 'total' => $total_users );
    231     }
    232    
     229
     230        return array( 'users' => $paged_users, 'total' => $total_users );
     231    }
     232
    233233    function search_users( $search_terms, $limit = null, $page = 1 ) {
    234234        global $wpdb, $bp;
    235        
     235
    236236        if ( !function_exists('xprofile_install') )
    237237            return BP_Core_User::get_active_users( $limit, $page );
    238        
    239         if ( $limit && $page )
    240             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    241        
    242         $search_terms = like_escape( $wpdb->escape( $search_terms ) ); 
     238
     239        if ( $limit && $page )
     240            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     241
     242        $search_terms = like_escape( $wpdb->escape( $search_terms ) );
    243243
    244244        $total_users_sql = apply_filters( 'bp_core_search_users_count_sql', "SELECT DISTINCT count(u.ID) as user_id FROM " . CUSTOM_USER_TABLE . " u LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id WHERE u.spam = 0 AND u.deleted = 0 AND u.user_status = 0 AND pd.value LIKE '%%$search_terms%%' ORDER BY pd.value ASC", $search_terms );
     
    247247        $total_users = $wpdb->get_var( $total_users_sql );
    248248        $paged_users = $wpdb->get_results( $paged_users_sql );
    249        
     249
    250250        return array( 'users' => $paged_users, 'total' => $total_users );
    251251    }
     
    256256 * BP_Core_Notification class can be used by any component.
    257257 * It will handle the fetching, saving and deleting of a user notification.
    258  * 
     258 *
    259259 * @package BuddyPress Core
    260260 */
     
    269269    var $date_notified;
    270270    var $is_new;
    271    
     271
    272272    function bp_core_notification( $id = false ) {
    273273        if ( $id ) {
     
    276276        }
    277277    }
    278    
     278
    279279    function populate() {
    280280        global $wpdb, $bp;
    281        
     281
    282282        if ( $notification = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE id = %d", $this->id ) ) ) {
    283283            $this->item_id = $notification->item_id;
     
    289289            $this->is_new = $notification->is_new;
    290290        }
    291     }   
    292    
     291    }
     292
    293293    function save() {
    294294        global $wpdb, $bp;
    295        
     295
    296296        if ( $this->id ) {
    297297            // Update
     
    310310
    311311    /* Static functions */
    312    
     312
    313313    function check_access( $user_id, $notification_id ) {
    314314        global $wpdb, $bp;
    315        
     315
    316316        return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->core->table_name_notifications} WHERE id = %d AND user_id = %d", $notification_id, $user_id ) );
    317317    }
    318    
     318
    319319    function get_all_for_user( $user_id ) {
    320320        global $wpdb, $bp;
     
    322322        return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND is_new = 1", $user_id ) );
    323323    }
    324    
     324
    325325    function delete_for_user_by_type( $user_id, $component_name, $component_action ) {
    326326        global $wpdb, $bp;
    327        
     327
    328328        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
    329329    }
    330    
     330
    331331    function delete_for_user_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ) {
    332332        global $wpdb, $bp;
    333        
     333
    334334        if ( $secondary_item_id )
    335335            $secondary_item_sql = $wpdb->prepare( " AND secondary_item_id = %d", $secondary_item_id );
    336        
     336
    337337        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE user_id = %d AND item_id = %d AND component_name = %s AND component_action = %s{$secondary_item_sql}", $user_id, $item_id, $component_name, $component_action ) );
    338338    }
    339    
     339
    340340    function delete_from_user_by_type( $user_id, $component_name, $component_action ) {
    341341        global $wpdb, $bp;
    342        
     342
    343343        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s AND component_action = %s", $user_id, $component_name, $component_action ) );
    344344    }
    345    
     345
    346346    function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
    347347        global $wpdb, $bp;
    348        
     348
    349349        if ( $component_action )
    350350            $component_action_sql = $wpdb->prepare( "AND component_action = %s", $component_action );
    351        
     351
    352352        if ( $secondary_item_id )
    353353            $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
    354        
     354
    355355        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
    356356    }
    357 }   
     357}
    358358
    359359
  • trunk/bp-core/bp-core-cssjs.php

    r2069 r2077  
    55 *
    66 * Add the CSS needed for the admin bar on blogs (other than the root) and in the admin area.
    7  * 
     7 *
    88 * @package BuddyPress Core
    99 * @uses get_option() Selects a site setting from the DB.
     
    1111function bp_core_add_admin_bar_css() {
    1212    global $current_blog;
    13    
     13
    1414    if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
    1515        return false;
     
    3232 *
    3333 * Add the minor JS needed for the admin bar.
    34  * 
     34 *
    3535 * @package BuddyPress Core
    3636 * @uses get_option() Selects a site setting from the DB.
     
    4646 *
    4747 * Add a hover-able icon to the "BuddyPress" wp-admin area menu.
    48  * 
     48 *
    4949 * @package BuddyPress Core
    5050 */
     
    6060}
    6161add_action( 'admin_head', 'bp_core_admin_menu_icon_css' );
    62    
     62
    6363function bp_core_confirmation_js() {
    6464?>
     
    7272 *
    7373 * Makes sure the jQuery jCrop library is loaded.
    74  * 
     74 *
    7575 * @package BuddyPress Core
    7676 */
    7777function bp_core_add_jquery_cropper() {
    7878    wp_enqueue_script( 'jcrop', array( 'jquery' ) );
    79     add_action( 'wp_head', 'bp_core_add_cropper_inline_js' ); 
    80     add_action( 'wp_head', 'bp_core_add_cropper_inline_css' ); 
     79    add_action( 'wp_head', 'bp_core_add_cropper_inline_js' );
     80    add_action( 'wp_head', 'bp_core_add_cropper_inline_css' );
    8181}
    8282
     
    8585 *
    8686 * Adds the inline JS needed for the cropper to work on a per-page basis.
    87  * 
     87 *
    8888 * @package BuddyPress Core
    8989 */
    9090function bp_core_add_cropper_inline_js() {
    9191    global $bp;
    92    
     92
    9393    $image = apply_filters( 'bp_inline_cropper_image', getimagesize( $bp->avatar_admin->image->dir ) );
    9494
    95     $aspect_ratio = 1; 
    96    
     95    $aspect_ratio = 1;
     96
    9797    /* Calculate Aspect Ratio */
    98     if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) ) 
     98    if ( (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) && ( (int) constant( 'BP_AVATAR_FULL_WIDTH' ) != (int) constant( 'BP_AVATAR_FULL_HEIGHT' ) ) )
    9999         $aspect_ratio = (int) constant( 'BP_AVATAR_FULL_WIDTH' ) / (int) constant( 'BP_AVATAR_FULL_HEIGHT' );
    100100?>
     
    131131                });
    132132            }
    133         }   
     133        }
    134134    </script>
    135135<?php
     
    140140 *
    141141 * Adds the inline CSS needed for the cropper to work on a per-page basis.
    142  * 
     142 *
    143143 * @package BuddyPress Core
    144144 */
     
    166166 *
    167167 * Adds AJAX target URL so themes can access the WordPress AJAX functionality.
    168  * 
     168 *
    169169 * @package BuddyPress Core
    170170 */
    171171function bp_core_add_ajax_url_js() {
    172172    global $bp;
    173    
    174     echo 
     173
     174    echo
    175175'<script type="text/javascript">var ajaxurl = "' . $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) . '";</script>
    176176';
     
    182182 *
    183183 * Overrides the theme's admin bar CSS to hide the adminbar if disabled.
    184  * 
     184 *
    185185 * @package BuddyPress Core
    186186 */
    187 function bp_core_override_adminbar_css() { 
     187function bp_core_override_adminbar_css() {
    188188    if ( defined( 'BP_DISABLE_ADMIN_BAR' ) || ( get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
    189189    ?>
  • trunk/bp-core/bp-core-notifications.php

    r1905 r2077  
    33function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false ) {
    44    global $bp;
    5    
     5
    66    if ( !$date_notified )
    77        $date_notified = time();
    8        
     8
    99    $notification = new BP_Core_Notification;
    1010    $notification->item_id = $item_id;
     
    1717    if ( $secondary_item_id )
    1818        $notification->secondary_item_id = $secondary_item_id;
    19    
     19
    2020    if ( !$notification->save() )
    2121        return false;
    22    
     22
    2323    return true;
    2424}
     
    2727    if ( !bp_core_check_notification_access( $bp->loggedin_user->id, $id ) )
    2828        return false;
    29    
     29
    3030    return BP_Core_Notification::delete( $id );
    3131}
    3232
    3333function bp_core_get_notification( $id ) {
    34     return new BP_Core_Notification( $id ); 
     34    return new BP_Core_Notification( $id );
    3535}
    3636
    3737function bp_core_get_notifications_for_user( $user_id ) {
    3838    global $bp;
    39    
     39
    4040    $notifications = BP_Core_Notification::get_all_for_user( $user_id );
    41    
     41
    4242    /* Group notifications by component and component_action and provide totals */
    4343    for ( $i = 0; $i < count($notifications); $i++ ) {
    4444        $notification = $notifications[$i];
    45        
     45
    4646        $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification;
    4747    }
    48    
     48
    4949    if ( !$grouped_notifications )
    5050        return false;
    51    
     51
    5252    /* Calculated a renderable outcome for each notification type */
    5353    foreach ( $grouped_notifications as $component_name => $action_arrays ) {
    5454        if ( !$action_arrays )
    5555            continue;
    56        
     56
    5757        foreach ( $action_arrays as $component_action_name => $component_action_items ) {
    5858            $action_item_count = count($component_action_items);
    59            
     59
    6060            if ( $action_item_count < 1 )
    6161                continue;
     
    6565            }
    6666        }
    67     }   
    68    
     67    }
     68
    6969    return $renderable;
    7070}
     
    8989    if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) )
    9090        return false;
    91    
     91
    9292    return true;
    9393}
  • trunk/bp-core/bp-core-settings.php

    r2059 r2077  
    33if ( !defined( 'BP_SETTINGS_SLUG' ) )
    44    define( 'BP_SETTINGS_SLUG', 'settings' );
    5    
     5
    66function bp_core_add_settings_nav() {
    77    global $bp;
    8    
     8
    99    /* Set up settings as a sudo-component for identification and nav selection */
    1010    $bp->settings->id = 'settings';
    1111    $bp->settings->slug = BP_SETTINGS_SLUG;
    12    
     12
    1313    /* Register this in the active components array */
    1414    $bp->active_components[$bp->settings->slug] = $bp->settings->id;
     
    1818
    1919    $settings_link = $bp->loggedin_user->domain . 'settings/';
    20    
     20
    2121    bp_core_new_subnav_item( array( 'name' => __( 'General', 'buddypress' ), 'slug' => 'general', 'parent_url' => $settings_link, 'parent_slug' => $bp->settings->slug, 'screen_function' => 'bp_core_screen_general_settings', 'position' => 10, 'user_has_access' => bp_is_home() ) );
    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_home() ) );
    23    
     23
    2424    if ( !is_site_admin() && !(int) get_site_option( '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_home() ) );
     
    3232function bp_core_screen_general_settings() {
    3333    global $current_user, $bp_settings_updated, $pass_error;
    34    
     34
    3535    $bp_settings_updated = false;
    3636    $pass_error = false;
    37    
     37
    3838    if ( isset($_POST['submit']) ) {
    3939        check_admin_referer('bp_settings_general');
    40        
     40
    4141        require_once( WPINC . '/registration.php' );
    42        
     42
    4343        // Form has been submitted and nonce checks out, lets do it.
    44        
     44
    4545        if ( $_POST['email'] != '' )
    4646            $current_user->user_email = wp_specialchars( trim( $_POST['email'] ) );
     
    5656            unset( $current_user->user_pass );
    5757        }
    58        
     58
    5959        if ( !$pass_error && wp_update_user( get_object_vars( $current_user ) ) )
    6060            $bp_settings_updated = true;
    6161    }
    62    
     62
    6363    add_action( 'bp_template_title', 'bp_core_screen_general_settings_title' );
    6464    add_action( 'bp_template_content', 'bp_core_screen_general_settings_content' );
    65    
     65
    6666    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
    6767}
     
    7979        </div>
    8080    <?php } ?>
    81    
     81
    8282    <?php if ( $pass_error && !$bp_settings_updated ) { ?>
    8383        <div id="message" class="error fade">
    8484            <p><?php _e( 'Your passwords did not match', 'buddypress' ) ?></p>
    85         </div> 
     85        </div>
    8686    <?php } ?>
    8787
     
    8989        <label for="email"><?php _e( 'Account Email', 'buddypress' ) ?></label>
    9090        <input type="text" name="email" id="email" value="<?php echo attribute_escape( $current_user->user_email ); ?>" class="settings-input" />
    91            
     91
    9292        <label for="pass1"><?php _e( 'Change Password <span>(leave blank for no change)</span>', 'buddypress' ) ?></label>
    9393        <input type="password" name="pass1" id="pass1" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'New Password', 'buddypress' ) ?><br />
    9494        <input type="password" name="pass2" id="pass2" size="16" value="" class="settings-input small" /> &nbsp;<?php _e( 'Repeat New Password', 'buddypress' ) ?>
    95    
     95
    9696        <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
    9797        <?php wp_nonce_field('bp_settings_general') ?>
     
    104104function bp_core_screen_notification_settings() {
    105105    global $current_user, $bp_settings_updated;
    106    
     106
    107107    $bp_settings_updated = false;
    108    
     108
    109109    if ( $_POST['submit'] ) {
    110110        check_admin_referer('bp_settings_notifications');
    111        
     111
    112112        if ( $_POST['notifications'] ) {
    113113            foreach ( $_POST['notifications'] as $key => $value ) {
     
    115115            }
    116116        }
    117        
     117
    118118        $bp_settings_updated = true;
    119119    }
    120        
     120
    121121    add_action( 'bp_template_title', 'bp_core_screen_notification_settings_title' );
    122122    add_action( 'bp_template_content', 'bp_core_screen_notification_settings_content' );
    123    
     123
    124124    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
    125125}
     
    137137        </div>
    138138    <?php } ?>
    139    
     139
    140140    <form action="<?php echo $bp->loggedin_user->domain . 'settings/notifications' ?>" method="post" id="settings-form">
    141141        <h3><?php _e( 'Email Notifications', 'buddypress' ) ?></h3>
    142142        <p><?php _e( 'Send a notification by email when:', 'buddypress' ) ?></p>
    143        
     143
    144144        <?php do_action( 'bp_notification_settings' ) ?>
    145        
    146         <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>     
    147        
     145
     146        <p class="submit"><input type="submit" name="submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?>" id="submit" class="auto"/></p>
     147
    148148        <?php wp_nonce_field('bp_settings_notifications') ?>
    149        
     149
    150150    </form>
    151151<?php
     
    154154/**** DELETE ACCOUNT ****/
    155155
    156 function bp_core_screen_delete_account() { 
     156function bp_core_screen_delete_account() {
    157157    if ( isset( $_POST['delete-account-understand'] ) ) {
    158158        check_admin_referer( 'delete-account' );
     
    162162            bp_core_redirect( site_url() );
    163163    }
    164    
    165164    add_action( 'bp_template_title', 'bp_core_screen_delete_account_title' );
    166165    add_action( 'bp_template_content', 'bp_core_screen_delete_account_content' );
    167    
     166
    168167    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
    169168}
     
    177176
    178177    <form action="<?php echo $bp->loggedin_user->domain . 'settings/delete-account'; ?>" name="account-delete-form" id="account-delete-form" class="standard-form" method="post">
    179        
     178
    180179        <div id="message" class="info">
    181180            <p><?php _e( 'WARNING: Deleting your account will completely remove ALL content associated with it. There is no way back, please be careful with this option.', 'buddypress' ); ?></p>
    182181        </div>
    183        
     182
    184183        <input type="checkbox" name="delete-account-understand" id="delete-account-understand" value="1" onclick="if(this.checked) { document.getElementById('delete-account-button').disabled = ''; } else { document.getElementById('delete-account-button').disabled = 'disabled'; }" /> <?php _e( 'I understand the consequences of deleting my account.', 'buddypress' ); ?>
    185184        <p><input type="submit" disabled="disabled" value="<?php _e( 'Delete My Account', 'buddypress' ) ?> &raquo;" id="delete-account-button" name="delete-account-button" /></p>
  • trunk/bp-core/bp-core-signup.php

    r2068 r2077  
    33function bp_core_screen_signup() {
    44    global $bp, $wpdb;
    5    
     5
    66    if ( $bp->current_component != BP_REGISTER_SLUG )
    77        return false;
    8        
     8
    99    /* If the user is logged in, redirect away from here */
    1010    if ( is_user_logged_in() )
    1111        bp_core_redirect( $bp->root_domain );
    12    
     12
    1313    /***
    1414     * For backwards compatibility with the old pre 1.1 two theme system, skip this screen function
     
    2121    if ( 'none' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() )
    2222        bp_core_redirect( $bp->root_domain );
    23        
     23
    2424    $bp->signup->step = 'request-details';
    25    
     25
    2626    /* If the signup page is submitted, validate and save */
    2727    if ( isset( $_POST['signup_submit'] ) ) {
    28        
     28
    2929        /* Check the nonce */
    3030        check_admin_referer( 'bp_new_signup' );
    31            
     31
    3232        require_once( ABSPATH . WPINC . '/registration.php' );
    33        
     33
    3434        /* Check the base account details for problems */
    3535        $account_details = wpmu_validate_user_signup( $_POST['signup_username'] , $_POST['signup_email'] );
    36        
     36
    3737        /* If there are errors with account details, set them for display */
    3838        if ( !empty( $account_details['errors']->errors['user_name'] ) )
    3939            $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
    40        
     40
    4141        if ( !empty( $account_details['errors']->errors['user_email'] ) )
    4242            $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
    43        
     43
    4444        /* Check that both password fields are filled in */
    4545        if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
     
    5454
    5555        /* Loop through the posted fields formatting any datebox values then validate the field */
    56         foreach ( (array) $profile_field_ids as $field_id ) {       
     56        foreach ( (array) $profile_field_ids as $field_id ) {
    5757            if ( !isset( $_POST['field_' . $field_id] ) ) {
    5858                if ( isset( $_POST['field_' . $field_id . '_day'] ) )
    5959                    $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
    6060            }
    61            
     61
    6262            if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
    6363                $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
     
    6767        if ( isset( $_POST['signup_with_blog'] ) ) {
    6868            $active_signup = get_site_option( 'registration' );
    69        
     69
    7070            if ( 'blog' == $active_signup || 'all' == $active_signup ) {
    7171                $blog_details = wpmu_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
    72                
     72
    7373                /* If there are errors with blog details, set them for display */
    7474                if ( !empty( $blog_details['errors']->errors['blogname'] ) )
     
    8888        } else {
    8989            $bp->signup->step = 'save-details';
    90            
     90
    9191            /* No errors! Let's register those deets. */
    9292            $active_signup = get_site_option( 'registration' );
    93            
     93
    9494            if ( 'none' != $active_signup ) {
    95                
     95
    9696                /* Let's compact any profile field info into usermeta */
    9797                $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    9898
    9999                /* Loop through the posted fields formatting any datebox values then add to usermeta */
    100                 foreach ( (array) $profile_field_ids as $field_id ) {       
     100                foreach ( (array) $profile_field_ids as $field_id ) {
    101101                    if ( !isset( $_POST['field_' . $field_id] ) ) {
    102102                        if ( isset( $_POST['field_' . $field_id . '_day'] ) )
    103103                            $_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
    104104                    }
    105            
     105
    106106                    if ( !empty( $_POST['field_' . $field_id] ) )
    107107                        $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
    108108                }
    109                
     109
    110110                /* Store the profile field ID's in usermeta */
    111111                $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
    112                
     112
    113113                /* Hash and store the password */
    114114                $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
    115                
     115
    116116                /* If the user decided to create a blog, save those details to usermeta */
    117117                if ( 'blog' == $active_signup || 'all' == $active_signup ) {
    118118                    $usermeta['public'] = ( 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
    119119                }
    120                
     120
    121121                $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
    122                                
     122
    123123                /* Finally, sign up the user and/or blog*/
    124124                if ( isset( $_POST['signup_with_blog'] ) )
     
    126126                else
    127127                    wpmu_signup_user( $_POST['signup_username'], $_POST['signup_email'], $usermeta );
    128                
     128
    129129                $bp->signup->step = 'completed-confirmation';
    130130            }
     
    132132            do_action( 'bp_complete_signup' );
    133133        }
    134    
     134
    135135    }
    136136
     
    139139    /* If user has uploaded a new avatar */
    140140    if ( !empty( $_FILES ) ) {
    141        
     141
    142142        /* Check the nonce */
    143143        check_admin_referer( 'bp_avatar_upload' );
    144144
    145145        $bp->signup->step = 'completed-confirmation';
    146        
     146
    147147        /* Get the activation key */
    148148        if ( !$bp->signup->key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $_POST[ 'signup_username' ], $_POST[ 'signup_email' ] ) ) ) {
     
    151151            /* Hash the key to create the upload folder (added security so people don't sniff the activation key) */
    152152            $bp->signup->avatar_dir = wp_hash( $bp->signup->key );
    153            
    154             /* Pass the file to the avatar upload handler */       
    155             if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {       
     153
     154            /* Pass the file to the avatar upload handler */
     155            if ( bp_core_avatar_handle_upload( $_FILES, 'bp_core_signup_avatar_upload_dir' ) ) {
    156156                $bp->avatar_admin->step = 'crop-image';
    157157
    158158                /* Make sure we include the jQuery jCrop file for image cropping */
    159159                add_action( 'wp', 'bp_core_add_jquery_cropper' );
    160             }           
     160            }
    161161        }
    162162    }
    163    
     163
    164164    /* If the image cropping is done, crop the image and save a full/thumb version */
    165165    if ( isset( $_POST['avatar-crop-submit'] ) ) {
    166        
     166
    167167        /* Check the nonce */
    168168        check_admin_referer( 'bp_avatar_cropstore' );
    169                        
     169
    170170        /* Reset the avatar step so we can show the upload form again if needed */
    171171        $bp->signup->step = 'completed-confirmation';
     
    178178
    179179    }
    180     bp_core_load_template( 'registration/register' );   
     180    bp_core_load_template( 'registration/register' );
    181181}
    182182add_action( 'wp', 'bp_core_screen_signup', 3 );
     
    187187    if ( !$bp->signup->avatar_dir )
    188188        return false;
    189    
     189
    190190    $path = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
    191191    $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path );
     
    193193
    194194    $newbdir = $newdir;
    195    
     195
    196196    if ( !file_exists( $newdir ) )
    197197        @wp_mkdir_p( $newdir );
     
    201201    $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir;
    202202
    203     return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );   
     203    return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
    204204}
    205205
     
    210210
    211211    if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) )
    212          wp_redirect( bp_root_domain() . BP_REGISTER_SLUG );
     212        wp_redirect( bp_root_domain() . BP_REGISTER_SLUG );
    213213}
    214214add_action( 'signup_header', 'bp_core_wpsignup_redirect' );
    215 
    216215?>
  • trunk/bp-core/bp-core-templatetags.php

    r2074 r2077  
    66 * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
    77 * Each component adds to this navigation array within its own [component_name]_setup_nav() function.
    8  * 
     8 *
    99 * This navigation array is the top level navigation, so it contains items such as:
    1010 *      [Blog, Profile, Messages, Groups, Friends] ...
     
    1818function bp_get_loggedin_user_nav() {
    1919    global $bp, $current_blog;
    20    
     20
    2121    /* Loop through each navigation item */
    2222    foreach( (array) $bp->bp_nav as $nav_item ) {
     
    2727            $selected = '';
    2828        }
    29        
     29
    3030        /* If we are viewing another person (current_userid does not equal loggedin_user->id)
    3131           then check to see if the two users are friends. if they are, add a highlight CSS class
     
    3333        if ( !bp_is_home() && $bp->displayed_user->id ) {
    3434            $selected = '';
    35            
     35
    3636            if ( function_exists('friends_install') ) {
    3737                if ( $nav_item['css_id'] == $bp->friends->id ) {
     
    4141            }
    4242        }
    43        
     43
    4444        /* echo out the final list item */
    4545        echo apply_filters( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item );
    4646    }
    47    
     47
    4848    /* Always add a log out list item to the end of the navigation */
    4949    if ( function_exists( 'wp_logout_url' ) ) {
    50         $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';       
     50        $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    5151    } else {
    5252        $logout_link = '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    5353    }
    54    
     54
    5555    echo apply_filters( 'bp_logout_nav_link', $logout_link );
    5656}
     
    7272
    7373    foreach ( $bp->bp_nav as $user_nav_item ) {
    74         if ( !$user_nav_item['show_for_displayed_user'] ) 
     74        if ( !$user_nav_item['show_for_displayed_user'] )
    7575            continue;
    76            
     76
    7777        if ( $bp->current_component == $user_nav_item['css_id'] )
    7878            $selected = ' class="current"';
    7979        else
    8080            $selected = '';
    81        
     81
    8282        if ( $bp->loggedin_user->domain )
    8383            $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] );
    8484        else
    8585            $link = $bp->displayed_user->domain . $user_nav_item['link'];
    86        
     86
    8787        echo apply_filters( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], '<li id="li-subnav-' . $user_nav_item['css_id'] . '" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item );
    88     }   
     88    }
    8989}
    9090    /* DEPRECATED - use bp_get_displayed_user_nav() */
    9191    function bp_get_user_nav() { bp_get_displayed_user_nav(); }
    92    
     92
    9393/**
    9494 * bp_get_options_nav()
     
    9797 * Uses the $bp->bp_options_nav global to render out the sub navigation for the current component.
    9898 * Each component adds to its sub navigation array within its own [component_name]_setup_nav() function.
    99  * 
     99 *
    100100 * This sub navigation array is the secondary level navigation, so for profile it contains:
    101101 *      [Public, Edit Profile, Change Avatar]
     
    103103 * The function will also analyze the current action for the current component to determine whether
    104104 * or not to highlight a particular sub nav item.
    105  * 
     105 *
    106106 * @package BuddyPress Core
    107107 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    118118        if ( count( $bp->bp_options_nav[$bp->current_component] ) < 1 )
    119119            return false;
    120    
     120
    121121        /* Loop through each navigation item */
    122122        foreach ( $bp->bp_options_nav[$bp->current_component] as $subnav_item ) {
    123123            if ( !$subnav_item['user_has_access'] )
    124124                continue;
    125            
     125
    126126            /* If the current action or an action variable matches the nav item id, then add a highlight CSS class. */
    127127            if ( $subnav_item['slug'] == $bp->current_action ) {
     
    130130                $selected = '';
    131131            }
    132            
     132
    133133            /* echo out the final list item */
    134             echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );     
     134            echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="li-subnav-' . $subnav_item['css_id'] . '" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );
    135135        }
    136136    } else {
     
    142142function bp_get_options_title() {
    143143    global $bp;
    144    
     144
    145145    if ( empty( $bp->bp_options_title ) )
    146146        $bp->bp_options_title = __( 'Options', 'buddypress' );
    147    
     147
    148148    echo apply_filters( 'bp_get_options_title', attribute_escape( $bp->bp_options_title ) );
    149149}
    150    
     150
    151151
    152152/** AVATAR TEMPLATE TAGS *******************************************************/
     
    164164function bp_has_options_avatar() {
    165165    global $bp;
    166    
     166
    167167    if ( empty( $bp->bp_options_avatar ) )
    168168        return false;
    169    
     169
    170170    return true;
    171171}
     
    179179function bp_comment_author_avatar() {
    180180    global $comment;
    181    
     181
    182182    if ( function_exists('bp_core_fetch_avatar') ) {
    183         echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) );   
     183        echo apply_filters( 'bp_comment_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $comment->user_id, 'type' => 'thumb' ) ) );
    184184    } else if ( function_exists('get_avatar') ) {
    185185        get_avatar();
     
    189189function bp_post_author_avatar() {
    190190    global $post;
    191    
     191
    192192    if ( function_exists('bp_core_fetch_avatar') ) {
    193         echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) ); 
     193        echo apply_filters( 'bp_post_author_avatar', bp_core_fetch_avatar( array( 'item_id' => $post->post_author, 'type' => 'thumb' ) ) );
    194194    } else if ( function_exists('get_avatar') ) {
    195195        get_avatar();
     
    211211        $r = wp_parse_args( $args, $defaults );
    212212        extract( $r, EXTR_SKIP );
    213        
     213
    214214        return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
    215     } 
     215    }
    216216
    217217function bp_displayed_user_avatar( $args = '' ) {
     
    229229        $r = wp_parse_args( $args, $defaults );
    230230        extract( $r, EXTR_SKIP );
    231        
     231
    232232        return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
    233     } 
     233    }
    234234
    235235function bp_avatar_admin_step() {
     
    256256    function bp_get_avatar_to_crop_src() {
    257257        global $bp;
    258    
     258
    259259        return apply_filters( 'bp_get_avatar_to_crop_src', str_replace( WP_CONTENT_DIR, '', $bp->avatar_admin->image->dir ) );
    260260    }
    261    
     261
    262262function bp_avatar_cropper() {
    263263    global $bp;
    264    
     264
    265265    echo '<img id="avatar-to-crop" class="avatar" src="' . $bp->avatar_admin->image . '" />';
    266266}
     
    272272function bp_is_home() {
    273273    global $bp;
    274    
     274
    275275    if ( is_user_logged_in() && $bp->loggedin_user->id == $bp->displayed_user->id )
    276276        return true;
    277        
     277
    278278    return false;
    279279}
     
    281281function bp_last_activity( $user_id = false, $echo = true ) {
    282282    global $bp;
    283    
     283
    284284    if ( !$user_id )
    285285        $user_id = $bp->displayed_user->id;
    286    
     286
    287287    $last_activity = bp_core_get_last_activity( get_usermeta( $user_id, 'last_activity' ), __('active %s ago', 'buddypress') );
    288288
     
    295295function bp_user_link() {
    296296    global $bp;
    297    
     297
    298298    echo apply_filters( 'bp_the_avatar_thumbnail', $bp->displayed_user->domain );
    299299}
     
    301301function bp_get_loggedin_user_link() {
    302302    global $bp;
    303    
     303
    304304    return $bp->loggedin_user->domain;
    305305}
     
    307307function bp_get_displayed_user_link() {
    308308    global $bp;
    309    
     309
    310310    return $bp->displayed_user->domain;
    311311}
     
    313313function bp_core_get_wp_profile() {
    314314    global $bp;
    315    
     315
    316316    $ud = get_userdata( $bp->displayed_user->id );
    317317?>
     
    393393    if ( function_exists($component_name . '_install') )
    394394        return true;
    395    
     395
    396396    return false;
    397397}
     
    399399function bp_format_time( $time, $just_date = false ) {
    400400    $date = date( get_option('date_format'), $time );
    401    
     401
    402402    if ( !$just_date ) {
    403403        $date .= ' ' . __( 'at', 'buddypress' ) . date( ' ' . get_option('time_format'), $time );
    404404    }
    405    
     405
    406406    return apply_filters( 'bp_format_time', $date );
    407407}
     
    409409function bp_word_or_name( $youtext, $nametext, $capitalize = true, $echo = true ) {
    410410    global $bp;
    411    
     411
    412412    if ( $capitalize )
    413413        $youtext = bp_core_ucfirst($youtext);
    414    
     414
    415415    if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
    416416        if ( $echo )
     
    429429function bp_your_or_their( $capitalize = true, $echo = true ) {
    430430    global $bp;
    431    
     431
    432432    if ( $capitalize )
    433433        $yourtext = bp_core_ucfirst($yourtext);
    434    
     434
    435435    if ( $bp->displayed_user->id == $bp->loggedin_user->id ) {
    436436        if ( $echo )
     
    448448function bp_loggedinuser_link() {
    449449    global $bp;
    450    
     450
    451451    if ( $link = bp_core_get_userlink( $bp->loggedin_user->id ) ) {
    452452        echo apply_filters( 'bp_loggedinuser_link', $link );
     
    483483            $title = __( 'Blog &#8212; ' . $post->post_title, 'buddypress' );
    484484        } else if ( is_category() ) {
    485             $title = __( 'Blog &#8212; Categories &#8212; ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' );               
     485            $title = __( 'Blog &#8212; Categories &#8212; ' . ucwords( $wp_query->query_vars['category_name'] ), 'buddypress' );
    486486        } else if ( is_tag() ) {
    487             $title = __( 'Blog &#8212; Tags &#8212; ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' );               
     487            $title = __( 'Blog &#8212; Tags &#8212; ' . ucwords( $wp_query->query_vars['tag'] ), 'buddypress' );
    488488        } else
    489489            $title = __( 'Blog', 'buddypress' );
     
    502502        $title = get_the_title($post->ID);
    503503    }
    504    
     504
    505505    if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
    506506        $blog_title = get_blog_option( $current_blog->blog_id, 'blogname' );
    507507    } else {
    508         $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' );     
    509     }
    510    
     508        $blog_title = get_blog_option( BP_ROOT_BLOG, 'blogname' );
     509    }
     510
    511511    return apply_filters( 'bp_page_title', $blog_title . ' &#8212; ' . attribute_escape( $title ), attribute_escape( $title ) );
    512512}
     
    519519function bp_is_page($page) {
    520520    global $bp;
    521    
     521
    522522    if ( $bp->displayed_user->id || $bp->is_single_item )
    523523        return false;
    524    
     524
    525525    if ( $page == $bp->current_component || ( is_home() && $page == 'home' && $bp->current_component == $bp->default_component ) || ( $page == BP_MEMBERS_SLUG && !$bp->current_component ) )
    526526        return true;
    527    
     527
    528528    return false;
    529529}
     
    535535    if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/register.php') )
    536536        return true;
    537        
     537
    538538    return false;
    539539}
     
    547547    function bp_get_signup_page() {
    548548        global $bp;
    549        
     549
    550550        if ( bp_has_custom_signup_page() ) {
    551551                return apply_filters( 'bp_get_signup_page', $bp->root_domain . '/' . BP_REGISTER_SLUG );
     
    561561    if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'template') . '/registration/activate.php') )
    562562        return true;
    563    
     563
    564564    return false;
    565565}
     
    567567function bp_activation_page( $echo = true ) {
    568568    global $bp;
    569    
     569
    570570    if ( bp_has_custom_activation_page() ) {
    571571        if ( $echo )
     
    583583function bp_search_form_action() {
    584584    global $bp;
    585    
     585
    586586    return apply_filters( 'bp_search_form_action', $bp->root_domain . '/search' );
    587587}
     
    590590    // Eventually this won't be needed and a page will be built to integrate all search results.
    591591    $selection_box = '<select name="search-which" id="search-which" style="width: auto">';
    592    
     592
    593593    if ( function_exists( 'xprofile_install' ) ) {
    594594        $selection_box .= '<option value="members">' . __( 'Members', 'buddypress' ) . '</option>';
    595595    }
    596    
     596
    597597    if ( function_exists( 'groups_install' ) ) {
    598598        $selection_box .= '<option value="groups">' . __( 'Groups', 'buddypress' ) . '</option>';
     
    602602        $selection_box .= '<option value="forums">' . __( 'Forums', 'buddypress' ) . '</option>';
    603603    }
    604    
     604
    605605    if ( function_exists( 'bp_blogs_install' ) ) {
    606606        $selection_box .= '<option value="blogs">' . __( 'Blogs', 'buddypress' ) . '</option>';
    607607    }
    608            
     608
    609609    $selection_box .= '</select>';
    610    
     610
    611611    return apply_filters( 'bp_search_form_type_select', $selection_box );
    612612}
     
    615615    $form = '
    616616        <form action="' . bp_search_form_action() . '" method="post" id="search-form">
    617             <input type="text" id="search-terms" name="search-terms" value="" /> 
     617            <input type="text" id="search-terms" name="search-terms" value="" />
    618618            ' . bp_search_form_type_select() . '
    619        
     619
    620620            <input type="submit" name="search-submit" id="search-submit" value="' . __( 'Search', 'buddypress' ) . '" />
    621621            ' . wp_nonce_field( 'bp_search_form' ) . '
    622622        </form>
    623623    ';
    624    
     624
    625625    echo apply_filters( 'bp_search_form', $form );
    626626}
     
    631631        $logout_link = '<a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
    632632    else
    633         $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';     
     633        $logout_link = '<a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
    634634
    635635    echo apply_filters( 'bp_logout_link', $logout_link );
     
    638638function bp_profile_wire_can_post() {
    639639    global $bp;
    640    
     640
    641641    if ( bp_is_home() )
    642642        return true;
    643    
     643
    644644    if ( function_exists('friends_install') ) {
    645645        if ( friends_check_friendship( $bp->loggedin_user->id, $bp->displayed_user->id ) )
     
    647647        else
    648648            return false;
    649     } 
    650    
     649    }
     650
    651651    return true;
    652652}
     
    659659    <li<?php if ( bp_is_page( BP_HOME_BLOG_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_HOME_BLOG_SLUG ?>" title="<?php _e( 'Blog', 'buddypress' ) ?>"><?php _e( 'Blog', 'buddypress' ) ?></a></li>
    660660    <li<?php if ( bp_is_page( BP_MEMBERS_SLUG ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_MEMBERS_SLUG ?>" title="<?php _e( 'Members', 'buddypress' ) ?>"><?php _e( 'Members', 'buddypress' ) ?></a></li>
    661    
     661
    662662    <?php if ( function_exists( 'groups_install' ) ) { ?>
    663663        <li<?php if ( bp_is_page( $bp->groups->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->groups->slug ?>" title="<?php _e( 'Groups', 'buddypress' ) ?>"><?php _e( 'Groups', 'buddypress' ) ?></a></li>
    664664    <?php } ?>
    665    
     665
    666666    <?php if ( function_exists( 'bp_blogs_install' ) ) { ?>
    667667        <li<?php if ( bp_is_page( $bp->blogs->slug ) ) {?> class="selected"<?php } ?>><a href="<?php echo get_option('home') ?>/<?php echo $bp->blogs->slug ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li>
     
    681681function bp_is_directory() {
    682682    global $bp;
    683    
     683
    684684    return $bp->is_directory;
    685685}
     
    689689 *
    690690 * Fakes an excerpt on any content. Will not truncate words.
    691  * 
     691 *
    692692 * @package BuddyPress Core
    693693 * @param $text str The text to create the excerpt from
     
    707707        $text = implode(' ', $words);
    708708    }
    709    
     709
    710710    return apply_filters( 'bp_create_excerpt', $text );
    711711}
     
    722722 *
    723723 * Checks to see if the data passed has been serialized.
    724  * 
     724 *
    725725 * @package BuddyPress Core
    726726 * @param $data str The data that will be checked
     
    762762        return apply_filters( 'bp_get_signup_with_blog_value', $_POST['signup_with_blog'] );
    763763    }
    764    
     764
    765765function bp_signup_blog_url_value() {
    766766    echo bp_get_signup_blog_url_value();
     
    789789    function bp_get_signup_avatar_dir_value() {
    790790        global $bp;
    791        
     791
    792792        return apply_filters( 'bp_get_signup_avatar_dir_value', $bp->signup->avatar_dir );
    793793    }
     
    798798    function bp_get_current_signup_step() {
    799799        global $bp;
    800        
     800
    801801        return $bp->signup->step;
    802802    }
     
    807807    function bp_get_signup_avatar( $args = '' ) {
    808808        global $bp;
    809        
     809
    810810        $defaults = array(
    811811            'size' => BP_AVATAR_FULL_WIDTH,
    812812            'class' => 'avatar',
    813             'alt' => __( 'Your Avatar', 'buddypress' )         
     813            'alt' => __( 'Your Avatar', 'buddypress' )
    814814        );
    815815
    816816        $r = wp_parse_args( $args, $defaults );
    817817        extract( $r, EXTR_SKIP );
    818        
     818
    819819        $signup_avatar_dir = ( !empty( $_POST['signup_avatar_dir'] ) ) ? $_POST['signup_avatar_dir'] : $bp->signup->avatar_dir;
    820820
     
    827827                $default_grav = $bp->grav_default->user;
    828828            }
    829        
     829
    830830            $gravatar_url = apply_filters( 'bp_gravatar_url', 'http://www.gravatar.com/avatar/' );
    831831            return apply_filters( 'bp_get_signup_avatar', '<img src="' . $gravatar_url . md5( $_POST['signup_email'] ) . '?d=' . $default_grav . '&amp;s=' . $size ) . '" width="' . $size . '" height="' . $size . '" alt="' . $alt . '" class="' . $class . '" />';
     
    844844function bp_account_was_activated() {
    845845    global $bp;
    846    
     846
    847847    return $bp->activation_complete;
    848848}
     
    863863    var $pag_links;
    864864    var $total_member_count;
    865    
     865
    866866    function bp_core_members_template( $type, $per_page, $max ) {
    867867        global $bp, $bp_the_member_query;
     
    869869        $this->pag_page = isset( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : 1;
    870870        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    871                
     871
    872872        if ( isset( $_REQUEST['s'] ) && '' != $_REQUEST['s'] && $type != 'random' ) {
    873873            $this->members = BP_Core_User::search_users( $_REQUEST['s'], $this->pag_num, $this->pag_page );
     
    879879                    $this->members = BP_Core_User::get_random_users( $this->pag_num, $this->pag_page );
    880880                    break;
    881                
     881
    882882                case 'newest':
    883883                    $this->members = BP_Core_User::get_newest_users( $this->pag_num, $this->pag_page );
     
    886886                case 'popular':
    887887                    $this->members = BP_Core_User::get_popular_users( $this->pag_num, $this->pag_page );
    888                     break; 
     888                    break;
    889889
    890890                case 'online':
    891891                    $this->members = BP_Core_User::get_online_users( $this->pag_num, $this->pag_page );
    892892                    break;
    893                    
     893
    894894                case 'alphabetical':
    895895                    $this->members = BP_Core_User::get_alphabetical_users( $this->pag_num, $this->pag_page );
    896896                    break;
    897                
     897
    898898                case 'active': default:
    899899                    $this->members = BP_Core_User::get_active_users( $this->pag_num, $this->pag_page );
    900                     break;                 
     900                    break;
    901901            }
    902902        }
    903        
     903
    904904        if ( !$max || $max >= (int)$this->members['total'] )
    905905            $this->total_member_count = (int)$this->members['total'];
     
    917917            $this->member_count = count($this->members);
    918918        }
    919        
    920         if ( (int) $this->total_member_count && (int) $this->pag_num ) { 
     919
     920        if ( (int) $this->total_member_count && (int) $this->pag_num ) {
    921921            $this->pag_links = paginate_links( array(
    922922                'base' => add_query_arg( 'upage', '%#%' ),
     
    927927                'next_text' => '&raquo;',
    928928                'mid_size' => 1
    929             ));     
     929            ));
    930930        }
    931931    }
    932    
     932
    933933    function has_members() {
    934934        if ( $this->member_count )
    935935            return true;
    936        
     936
    937937        return false;
    938938    }
    939    
     939
    940940    function next_member() {
    941941        $this->current_member++;
    942942        $this->member = $this->members[$this->current_member];
    943        
     943
    944944        return $this->member;
    945945    }
    946    
     946
    947947    function rewind_members() {
    948948        $this->current_member = -1;
     
    951951        }
    952952    }
    953    
    954     function site_members() { 
     953
     954    function site_members() {
    955955        if ( $this->current_member + 1 < $this->member_count ) {
    956956            return true;
     
    964964        return false;
    965965    }
    966    
     966
    967967    function the_member() {
    968968        global $member, $bp;
     
    977977            wp_cache_set( 'bp_user_' . $user_id, $this->member, 'bp' );
    978978        }
    979        
     979
    980980        if ( $user_registered )
    981981            $this->member->user_registered = $user_registered;
    982            
     982
    983983        if ( 0 == $this->current_member ) // loop has just started
    984984            do_action('loop_start');
     
    988988function bp_rewind_site_members() {
    989989    global $site_members_template;
    990    
     990
    991991    return $site_members_template->rewind_members();
    992992}
     
    10051005
    10061006    // type: active ( default ) | random | newest | popular | online | alphabetical
    1007    
     1007
    10081008    if ( $max ) {
    10091009        if ( $per_page > $max )
     
    10121012
    10131013    $site_members_template = new BP_Core_Members_Template( $type, $per_page, $max );
    1014    
     1014
    10151015    return $site_members_template->has_members();
    10161016}
     
    10281028function bp_site_members_pagination_count() {
    10291029    global $bp, $site_members_template;
    1030    
     1030
    10311031    $from_num = intval( ( $site_members_template->pag_page - 1 ) * $site_members_template->pag_num ) + 1;
    10321032    $to_num = ( $from_num + ( $site_members_template->pag_num - 1 ) > $site_members_template->total_member_count ) ? $site_members_template->total_member_count : $from_num + ( $site_members_template->pag_num - 1) ;
     
    10411041    function bp_get_site_members_pagination_links() {
    10421042        global $site_members_template;
    1043        
     1043
    10441044        return apply_filters( 'bp_get_site_members_pagination_links', $site_members_template->pag_links );
    10451045    }
    10461046
    1047 function bp_the_site_member_user_id() { 
    1048     echo bp_get_the_site_member_user_id(); 
    1049 }
    1050     function bp_get_the_site_member_user_id() { 
    1051         global $site_members_template; 
    1052 
    1053         return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id ); 
     1047function bp_the_site_member_user_id() {
     1048    echo bp_get_the_site_member_user_id();
     1049}
     1050    function bp_get_the_site_member_user_id() {
     1051        global $site_members_template;
     1052
     1053        return apply_filters( 'bp_get_the_site_member_user_id', $site_members_template->member->id );
    10541054    }
    10551055
     
    10571057    echo apply_filters( 'bp_the_site_member_avatar', bp_get_the_site_member_avatar() );
    10581058}
    1059     function bp_get_the_site_member_avatar() { 
    1060         global $site_members_template; 
     1059    function bp_get_the_site_member_avatar() {
     1060        global $site_members_template;
    10611061
    10621062        return apply_filters( 'bp_get_the_site_member_avatar', $site_members_template->member->avatar_thumb );
     
    11001100        return apply_filters( 'bp_the_site_member_last_active', strtotime( $site_members_template->member->user_registered ) );
    11011101    }
    1102    
     1102
    11031103function bp_the_site_member_add_friend_button() {
    11041104    global $site_members_template;
    1105    
     1105
    11061106    if ( function_exists( 'bp_add_friend_button' ) ) {
    11071107        echo bp_add_friend_button( $site_members_template->member->id );
     
    11111111function bp_the_site_member_total_friend_count() {
    11121112    global $site_members_template;
    1113    
     1113
    11141114    if ( !(int) $site_members_template->member->total_friends )
    11151115        return false;
    1116    
     1116
    11171117    echo bp_get_the_site_member_total_friend_count();
    11181118}
     
    11261126            return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
    11271127        else
    1128             return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) );     
    1129     }
    1130    
     1128            return apply_filters( 'bp_get_the_site_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $site_members_template->member->total_friends ) );
     1129    }
     1130
    11311131function bp_the_site_member_random_profile_data() {
    11321132    global $site_members_template;
     
    11651165function bp_home_blog_url() {
    11661166    global $bp, $current_blog;
    1167    
     1167
    11681168    if ( defined( 'BP_ENABLE_MULTIBLOG' ) ) {
    11691169        $blog_id = $current_blog->blog_id;
     
    12161216    function bp_get_loggedin_user_fullname() {
    12171217        global $bp;
    1218         return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname ); 
     1218        return apply_filters( 'bp_get_loggedin_user_fullname', $bp->loggedin_user->fullname );
    12191219    }
    12201220
    12211221function bp_current_component() {
    12221222    global $bp;
    1223     return apply_filters( 'bp_current_component', $bp->current_component );     
     1223    return apply_filters( 'bp_current_component', $bp->current_component );
    12241224}
    12251225
    12261226function bp_current_action() {
    12271227    global $bp;
    1228     return apply_filters( 'bp_current_action', $bp->current_action );       
     1228    return apply_filters( 'bp_current_action', $bp->current_action );
    12291229}
    12301230
    12311231function bp_current_item() {
    12321232    global $bp;
    1233     return apply_filters( 'bp_current_item', $bp->current_item );       
     1233    return apply_filters( 'bp_current_item', $bp->current_item );
    12341234}
    12351235
    12361236function bp_action_variables() {
    12371237    global $bp;
    1238     return apply_filters( 'bp_action_variables', $bp->action_variables );       
     1238    return apply_filters( 'bp_action_variables', $bp->action_variables );
    12391239}
    12401240
     
    12441244    function bp_get_root_domain() {
    12451245        global $bp;
    1246        
     1246
    12471247        return $bp->root_domain;
    12481248    }
     
    12521252function bp_is_profile_component() {
    12531253    global $bp;
    1254    
     1254
    12551255    if ( BP_XPROFILE_SLUG == $bp->current_component )
    12561256        return true;
    1257    
     1257
    12581258    return false;
    12591259}
     
    12611261function bp_is_activity_component() {
    12621262    global $bp;
    1263    
     1263
    12641264    if ( BP_ACTIVITY_SLUG == $bp->current_component )
    12651265        return true;
    1266    
    1267     return false;   
     1266
     1267    return false;
    12681268}
    12691269
    12701270function bp_is_blogs_component() {
    12711271    global $bp;
    1272    
     1272
    12731273    if ( BP_BLOGS_SLUG == $bp->current_component )
    12741274        return true;
    1275    
    1276     return false;   
     1275
     1276    return false;
    12771277}
    12781278
    12791279function bp_is_wire_component() {
    12801280    global $bp;
    1281    
     1281
    12821282    if ( BP_WIRE_SLUG == $bp->current_action || in_array( BP_WIRE_SLUG, (array)$bp->action_variables ) )
    12831283        return true;
    1284    
    1285     return false;   
     1284
     1285    return false;
    12861286}
    12871287
    12881288function bp_is_messages_component() {
    12891289    global $bp;
    1290    
     1290
    12911291    if ( BP_MESSAGES_SLUG == $bp->current_component )
    12921292        return true;
    1293    
    1294     return false;   
     1293
     1294    return false;
    12951295}
    12961296
    12971297function bp_is_friends_component() {
    12981298    global $bp;
    1299    
     1299
    13001300    if ( BP_FRIENDS_SLUG == $bp->current_component )
    13011301        return true;
    1302    
    1303     return false;   
     1302
     1303    return false;
    13041304}
    13051305
    13061306function bp_is_groups_component() {
    13071307    global $bp;
    1308    
     1308
    13091309    if ( BP_GROUPS_SLUG == $bp->current_component )
    13101310        return true;
    1311    
    1312     return false;   
     1311
     1312    return false;
    13131313}
    13141314
    13151315function bp_is_settings_component() {
    13161316    global $bp;
    1317    
     1317
    13181318    if ( BP_SETTINGS_SLUG == $bp->current_component )
    13191319        return true;
    1320    
    1321     return false;   
     1320
     1321    return false;
    13221322}
    13231323
    13241324function bp_is_user_activity() {
    13251325    global $bp;
    1326    
     1326
    13271327    if ( BP_ACTIVITY_SLUG == $bp->current_component && ( !$bp->current_action || 'my-activity' == $bp->current_action ) )
    13281328        return true;
    1329    
    1330     return false;
    1331 }   
     1329
     1330    return false;
     1331}
    13321332
    13331333function bp_is_user_friends_activity() {
    13341334    global $bp;
    1335    
     1335
    13361336    if ( BP_ACTIVITY_SLUG == $bp->current_component && 'my-friends' == $bp->current_action )
    13371337        return true;
    1338    
    1339     return false;   
     1338
     1339    return false;
    13401340}
    13411341
    13421342function bp_is_user_profile() {
    13431343    global $bp;
    1344    
     1344
    13451345    if ( BP_XPROFILE_SLUG == $bp->current_component )
    13461346        return true;
    1347    
    1348     return false;   
     1347
     1348    return false;
    13491349}
    13501350
    13511351function bp_is_profile_edit() {
    13521352    global $bp;
    1353    
     1353
    13541354    if ( BP_XPROFILE_SLUG == $bp->current_component && 'edit' == $bp->current_action )
    13551355        return true;
    1356    
     1356
    13571357    return false;
    13581358}
     
    13601360function bp_is_change_avatar() {
    13611361    global $bp;
    1362    
     1362
    13631363    if ( BP_XPROFILE_SLUG == $bp->current_component && 'change-avatar' == $bp->current_action )
    13641364        return true;
    1365    
    1366     return false;   
     1365
     1366    return false;
    13671367}
    13681368
    13691369function bp_is_profile_wire() {
    13701370    global $bp;
    1371    
     1371
    13721372    if ( BP_XPROFILE_SLUG == $bp->current_component && 'wire' == $bp->current_action )
    13731373        return true;
    1374    
    1375     return false;   
     1374
     1375    return false;
    13761376}
    13771377
    13781378function bp_is_user_groups() {
    13791379    global $bp;
    1380    
     1380
    13811381    if ( BP_GROUPS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-groups' == $bp->current_action ) )
    13821382        return true;
    1383    
    1384     return false;       
     1383
     1384    return false;
    13851385}
    13861386
    13871387function bp_is_group_home() {
    13881388    global $bp;
    1389    
     1389
    13901390    if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
    13911391        return true;
    1392    
    1393     return false;   
     1392
     1393    return false;
    13941394}
    13951395
    13961396function bp_is_group_create() {
    13971397    global $bp;
    1398    
     1398
    13991399    if ( BP_GROUPS_SLUG == $bp->current_component && 'create' == $bp->current_action )
    14001400        return true;
    1401    
     1401
    14021402    return false;
    14031403}
     
    14061406function bp_is_group_admin_page() {
    14071407    global $bp;
    1408    
     1408
    14091409    if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'admin' == $bp->current_action )
    14101410        return true;
    1411    
    1412     return false;   
     1411
     1412    return false;
    14131413}
    14141414
    14151415function bp_is_group_wire() {
    14161416    global $bp;
    1417    
     1417
    14181418    if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'wire' == $bp->current_action )
    14191419        return true;
    1420    
    1421     return false;       
     1420
     1421    return false;
    14221422}
    14231423
    14241424function bp_is_group_forum() {
    14251425    global $bp;
    1426    
     1426
    14271427    if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action )
    14281428        return true;
    1429    
    1430     return false;       
     1429
     1430    return false;
    14311431}
    14321432
    14331433function bp_is_group_forum_topic() {
    14341434    global $bp;
    1435    
     1435
    14361436    if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'forum' == $bp->current_action && 'topic' == $bp->action_variables[0] )
    14371437        return true;
    1438    
    1439     return false;   
     1438
     1439    return false;
    14401440}
    14411441
    14421442function bp_is_group_members() {
    14431443    global $bp;
    1444    
     1444
    14451445    if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'members' == $bp->current_action )
    14461446        return true;
    1447    
    1448     return false;   
     1447
     1448    return false;
    14491449}
    14501450
    14511451function bp_is_group_invites() {
    14521452    global $bp;
    1453    
     1453
    14541454    if ( BP_GROUPS_SLUG == $bp->current_component && 'invites' == $bp->current_action )
    14551455        return true;
    1456    
    1457     return false;       
     1456
     1457    return false;
    14581458}
    14591459
    14601460function bp_is_group_leave() {
    14611461    global $bp;
    1462    
     1462
    14631463    if ( BP_GROUPS_SLUG == $bp->current_component && $bp->is_single_item && 'leave-group' == $bp->current_action )
    14641464        return true;
    1465    
    1466     return false;   
     1465
     1466    return false;
    14671467}
    14681468
     
    14781478function bp_is_user_blogs() {
    14791479    global $bp;
    1480    
     1480
    14811481    if ( BP_BLOGS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-blogs' == $bp->current_action ) )
    14821482        return true;
    1483    
    1484     return false;       
     1483
     1484    return false;
    14851485}
    14861486
    14871487function bp_is_user_recent_posts() {
    14881488    global $bp;
    1489    
     1489
    14901490    if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-posts' == $bp->current_action )
    14911491        return true;
    1492    
    1493     return false;   
     1492
     1493    return false;
    14941494}
    14951495
    14961496function bp_is_user_recent_commments() {
    14971497    global $bp;
    1498    
     1498
    14991499    if ( BP_BLOGS_SLUG == $bp->current_component && 'recent-comments' == $bp->current_action )
    15001500        return true;
    1501    
    1502     return false;       
     1501
     1502    return false;
    15031503}
    15041504
    15051505function bp_is_create_blog() {
    15061506    global $bp;
    1507    
     1507
    15081508    if ( BP_BLOGS_SLUG == $bp->current_component && 'create-a-blog' == $bp->current_action )
    15091509        return true;
    1510    
    1511     return false;   
     1510
     1511    return false;
    15121512}
    15131513
    15141514function bp_is_user_friends() {
    15151515    global $bp;
    1516    
     1516
    15171517    if ( BP_FRIENDS_SLUG == $bp->current_component && ( !$bp->current_action || 'my-friends' == $bp->current_action ) )
    15181518        return true;
    1519    
    1520     return false;   
     1519
     1520    return false;
    15211521}
    15221522
    15231523function bp_is_friend_requests() {
    15241524    global $bp;
    1525    
     1525
    15261526    if ( BP_FRIENDS_SLUG == $bp->current_component && 'requests' == $bp->current_action )
    15271527        return true;
    1528    
    1529     return false;   
     1528
     1529    return false;
    15301530}
    15311531
    15321532function bp_is_messages_inbox() {
    15331533    global $bp;
    1534    
     1534
    15351535    if ( BP_MESSAGES_SLUG == $bp->current_component && ( !$bp->current_action || 'inbox' == $bp->current_action ) )
    15361536        return true;
    1537    
    1538     return false;   
     1537
     1538    return false;
    15391539}
    15401540
    15411541function bp_is_messages_sentbox() {
    15421542    global $bp;
    1543    
     1543
    15441544    if ( BP_MESSAGES_SLUG == $bp->current_component && 'sentbox' == $bp->current_action )
    15451545        return true;
    1546    
    1547     return false;       
     1546
     1547    return false;
    15481548}
    15491549
     
    15511551function bp_is_notices() {
    15521552    global $bp;
    1553    
     1553
    15541554    if ( BP_MESSAGES_SLUG == $bp->current_component && 'notices' == $bp->current_action )
    15551555        return true;
    1556    
    1557     return false;   
     1556
     1557    return false;
    15581558}
    15591559
     
    15611561function bp_is_messages_compose_screen() {
    15621562    global $bp;
    1563    
     1563
    15641564    if ( BP_MESSAGES_SLUG == $bp->current_component && 'compose' == $bp->current_action )
    15651565        return true;
    1566    
    1567     return false;   
     1566
     1567    return false;
    15681568}
    15691569
    15701570function bp_is_single_item() {
    15711571    global $bp;
    1572    
     1572
    15731573    if ( $bp->is_single_item )
    15741574        return true;
    1575    
     1575
    15761576    return false;
    15771577}
     
    15791579function bp_is_activation_page() {
    15801580    global $bp;
    1581    
     1581
    15821582    if ( BP_ACTIVATION_SLUG == $bp->current_component )
    15831583        return true;
    1584    
    1585     return false;   
     1584
     1585    return false;
    15861586}
    15871587
    15881588function bp_is_register_page() {
    15891589    global $bp;
    1590    
     1590
    15911591    if ( BP_REGISTER_SLUG == $bp->current_component )
    15921592        return true;
    1593    
    1594     return false;   
     1593
     1594    return false;
    15951595}
    15961596
     
    16031603        global $bp;
    16041604
    1605         if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG ) 
    1606             $bp_classes[] = 'home-page'; 
    1607        
     1605        if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG )
     1606            $bp_classes[] = 'home-page';
     1607
    16081608        if ( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() )
    16091609            $bp_classes[] = 'blog-page';
    1610        
     1610
    16111611        if ( !bp_is_blog_page() && !bp_is_register_page() && !bp_is_activation_page() )
    16121612            $bp_classes[] = 'internal-page';
    1613        
     1613
    16141614        if ( bp_is_directory() )
    16151615            $bp_classes[] = 'directory';
    1616            
     1616
    16171617        if ( bp_is_user_profile() && !bp_is_blog_page() )
    16181618            $bp_classes[] = 'profile';
    1619        
     1619
    16201620        if ( bp_is_activity_component() && !bp_is_blog_page()  )
    1621             $bp_classes[] = 'activity';     
     1621            $bp_classes[] = 'activity';
    16221622
    16231623        if ( bp_is_blogs_component() && !bp_is_blog_page()  )
     
    16281628
    16291629        if ( bp_is_messages_component() && !bp_is_blog_page()  )
    1630             $bp_classes[] = 'messages';                 
    1631        
     1630            $bp_classes[] = 'messages';
     1631
    16321632        if ( bp_is_friends_component() && !bp_is_blog_page()  )
    16331633            $bp_classes[] = 'friends';
    1634            
     1634
    16351635        if ( bp_is_groups_component() && !bp_is_blog_page()  )
    16361636            $bp_classes[] = 'groups';
     
    16381638        if ( bp_is_settings_component() && !bp_is_blog_page()  )
    16391639            $bp_classes[] = 'settings';
    1640            
     1640
    16411641        if ( bp_is_single_item() )
    16421642            $bp_classes[] = 'single-item';
    1643            
     1643
    16441644        if ( bp_is_messages_inbox() )
    16451645            $bp_classes[] = 'inbox';
     
    16531653        if ( bp_is_notices() )
    16541654            $bp_classes[] = 'notices';
    1655                        
     1655
    16561656        if ( bp_is_friend_requests() )
    16571657            $bp_classes[] = 'friend-requests';
     
    16591659        if ( bp_is_user_friends() )
    16601660            $bp_classes[] = 'my-friends';
    1661            
     1661
    16621662        if ( bp_is_create_blog() )
    16631663            $bp_classes[] = 'create-blog';
    1664            
     1664
    16651665        if ( bp_is_user_recent_commments() )
    16661666            $bp_classes[] = 'recent-comments';
    1667            
     1667
    16681668        if ( bp_is_user_recent_posts() )
    16691669            $bp_classes[] = 'recent-posts';
    1670            
     1670
    16711671        if ( bp_is_user_blogs() && !bp_is_directory() )
    16721672            $bp_classes[] = 'my-blogs';
    1673            
     1673
    16741674        if ( bp_is_user_groups() && !bp_is_directory() )
    16751675            $bp_classes[] = 'my-groups';
    1676            
     1676
    16771677        if ( bp_is_group_leave() )
    16781678            $bp_classes[] = 'leave-group';
    1679            
     1679
    16801680        if ( bp_is_group_invites() )
    16811681            $bp_classes[] = 'group-invites';
    1682            
     1682
    16831683        if ( bp_is_group_members() )
    16841684            $bp_classes[] = 'group-members';
    1685            
     1685
    16861686        if ( bp_is_group_forum_topic() )
    16871687            $bp_classes[] = 'group-forum-topic';
    1688            
     1688
    16891689        if ( bp_is_group_forum() )
    16901690            $bp_classes[] = 'group-forum';
    1691            
     1691
    16921692        if ( bp_is_group_wire() )
    16931693            $bp_classes[] = 'group-wire';
    1694        
     1694
    16951695        if ( bp_is_group_admin_page() )
    16961696            $bp_classes[] = 'group-admin';
    1697            
     1697
    16981698        if ( bp_is_group_create() )
    16991699            $bp_classes[] = 'group-create';
    1700        
     1700
    17011701        if ( bp_is_group_home() )
    17021702            $bp_classes[] = 'group-home';
    1703            
     1703
    17041704        if ( bp_is_profile_wire() )
    17051705            $bp_classes[] = 'profile-wire';
    1706            
     1706
    17071707        if ( bp_is_change_avatar() )
    17081708            $bp_classes[] = 'change-avatar';
    1709            
     1709
    17101710        if ( bp_is_profile_edit() )
    17111711            $bp_classes[] = 'profile-edit';
    1712            
     1712
    17131713        if ( bp_is_user_friends_activity() )
    17141714            $bp_classes[] = 'friends-activity';
    1715            
     1715
    17161716        if ( bp_is_user_activity() )
    17171717            $bp_classes[] = 'my-activity';
    1718        
     1718
    17191719        if ( bp_is_register_page() )
    17201720            $bp_classes[] = 'registration';
    1721        
     1721
    17221722        if ( bp_is_activation_page() )
    17231723            $bp_classes[] = 'activation';
    1724            
     1724
    17251725        if ( is_user_logged_in() )
    17261726            $bp_classes[] = 'logged-in';
     
    17301730            if ( !empty( $bp->current_component ) )
    17311731                $bp_classes[] = $bp->current_component;
    1732        
     1732
    17331733            if ( !empty( $bp->current_action ) )
    17341734                $bp_classes[] = $bp->current_action;
    17351735        }
    1736        
     1736
    17371737        /* We don't want WordPress blog classes to appear on non-blog pages. */
    17381738        if ( !bp_is_blog_page() || is_home() ) {
     
    17431743                $wp_classes = array();
    17441744        }
    1745  
     1745
    17461746        /* Merge WP classes with BP classes */
    17471747        $classes = array_merge( (array) $bp_classes, (array) $wp_classes );
    1748        
     1748
    17491749        /* Remove any duplicates */
    17501750        $classes = array_unique( $classes );
    1751        
     1751
    17521752        return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
    17531753    }
  • trunk/bp-core/bp-core-widgets.php

    r1926 r2077  
    3131        <div class="create-account"><div class="visit generic-button"><a href="<?php bp_signup_page() ?>" title="<?php _e('Create Account', 'buddypress') ?>"><?php _e('Create Account', 'buddypress') ?></a></div></div>
    3232        <?php } ?>
    33    
     33
    3434        <?php echo $after_widget; ?>
    3535    <?php
     
    7474
    7575        if ( is_active_widget( false, false, $this->id_base ) )
    76             wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') );       
     76            wp_enqueue_script( 'bp_core_widget_members-js', BP_PLUGIN_URL . '/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') );
    7777    }
    7878
    7979    function widget($args, $instance) {
    8080        global $bp;
    81        
     81
    8282        extract( $args );
    83        
     83
    8484        echo $before_widget;
    8585        echo $before_title
    86            . $widget_name 
     86           . $widget_name
    8787           . $after_title; ?>
    8888
     
    9090            <div class="item-options" id="members-list-options">
    9191                <span class="ajax-loader" id="ajax-loader-members"></span>
    92                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> | 
    93                 <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> | 
     92                <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="newest-members" class="selected"><?php _e( 'Newest', 'buddypress' ) ?></a> |
     93                <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="recently-active-members"><?php _e( 'Active', 'buddypress' ) ?></a> |
    9494                <a href="<?php echo site_url() . '/' . BP_MEMBERS_SLUG ?>" id="popular-members"><?php _e( 'Popular', 'buddypress' ) ?></a>
    9595            </div>
    96            
     96
    9797            <ul id="members-list" class="item-list">
    9898                <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
     
    109109
    110110                <?php endwhile; ?>
    111             </ul>       
     111            </ul>
    112112            <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' ); ?>
    113113            <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo attribute_escape( $instance['max_members'] ); ?>" />
    114            
     114
    115115        <?php else: ?>
    116116
     
    120120
    121121        <?php endif; ?>
    122            
     122
    123123        <?php echo $after_widget; ?>
    124124    <?php
     
    151151    function widget($args, $instance) {
    152152        global $bp;
    153        
     153
    154154        extract( $args );
    155        
     155
    156156        echo $before_widget;
    157157        echo $before_title
    158            . $widget_name 
     158           . $widget_name
    159159           . $after_title; ?>
    160        
    161         <?php if ( bp_has_site_members( 'type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>           
     160
     161        <?php if ( bp_has_site_members( 'type=online&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>
    162162            <div class="avatar-block">
    163163                <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
     
    166166                    </div>
    167167                <?php endwhile; ?>
    168             </div>                 
     168            </div>
    169169        <?php else: ?>
    170170
     
    174174
    175175        <?php endif; ?>
    176            
     176
    177177        <?php echo $after_widget; ?>
    178178    <?php
     
    205205    function widget($args, $instance) {
    206206        global $bp;
    207        
     207
    208208        extract( $args );
    209        
     209
    210210        echo $before_widget;
    211211        echo $before_title
    212            . $widget_name 
     212           . $widget_name
    213213           . $after_title; ?>
    214            
    215         <?php if ( bp_has_site_members( 'type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>           
     214
     215        <?php if ( bp_has_site_members( 'type=active&per_page=' . $instance['max_members'] . '&max=' . $instance['max_members'] ) ) : ?>
    216216            <div class="avatar-block">
    217217                <?php while ( bp_site_members() ) : bp_the_site_member(); ?>
     
    220220                    </div>
    221221                <?php endwhile; ?>
    222             </div>                 
     222            </div>
    223223        <?php else: ?>
    224224
     
    228228
    229229        <?php endif; ?>
    230            
     230
    231231        <?php echo $after_widget; ?>
    232232    <?php
     
    256256
    257257    check_ajax_referer('bp_core_widget_members');
    258    
     258
    259259    switch ( $_POST['filter'] ) {
    260260        case 'newest-members':
     
    277277        break;
    278278    }
    279    
     279
    280280    if ( $users['users'] ) {
    281281        echo '0[[SPLIT]]'; // return valid result.
    282    
     282
    283283        foreach ( (array) $users['users'] as $user ) {
    284284        ?>
     
    292292                    <div class="item-meta">
    293293                        <span class="activity">
    294                             <?php 
     294                            <?php
    295295                            if ( 'newest-members' == $_POST['filter'] ) {
    296296                                echo bp_core_get_last_activity( $user->user_registered, __( 'registered %s ago', 'buddypress' ) );
     
    308308                </div>
    309309            </li>
    310             <?php   
     310            <?php
    311311        }
    312312    } else {
  • trunk/bp-core/deprecated/bp-core-deprecated.php

    r2070 r2077  
    44 *
    55 * This file contains functions that are deprecated.
    6  * You should not under any circumstance use these functions as they are 
     6 * You should not under any circumstance use these functions as they are
    77 * either no longer valid, or have been replaced with something much more awesome.
    88 *
     
    1313 * Of course, things will still work if you use these functions but you will
    1414 * be the laughing stock of the BuddyPress community. We will all point and laugh at
    15  * you. You'll also be making things harder for yourself in the long run, 
     15 * you. You'll also be making things harder for yourself in the long run,
    1616 * and you will miss out on lovely performance and functionality improvements.
    17  * 
     17 *
    1818 * If you've checked you are not using any deprecated functions and finished your little
    1919 * dance, you can add the following line to your wp-config.php file to prevent any of
     
    2525function bp_core_deprecated_globals() {
    2626    global $bp;
    27    
     27
    2828    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    2929    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     
    6565function bp_core_signup_show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
    6666    global $current_site;
    67    
     67
    6868    ?>
    6969    <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3>
     
    7171        <?php _e( "To register your first blog, just fill in the details below and your registration is complete.", 'buddypress' ) ?>
    7272    </p>
    73    
     73
    7474    <div id="blog-details-fields">
    7575        <?php
    76    
     76
    7777        // Blog name
    7878        if ( 'no' == constant( "VHOST" ) )
     
    9090            echo '<input name="blogname" type="text" id="blogname" value="'.$blogname.'" maxlength="50" /><span class="suffix_address">.' . $current_site->domain . $current_site->path . '</span><br />';
    9191        }
    92        
     92
    9393        if ( !is_user_logged_in() ) {
    9494            echo '<p class="help-text">';
     
    105105        // Blog Title
    106106        ?>
    107         <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label> 
     107        <label for="blog_title"><?php _e( 'Blog Title:', 'buddypress' ) ?></label>
    108108        <?php if ( $errmsg = $errors->get_error_message('blog_title') ) { ?>
    109109            <p class="error"><?php echo $errmsg ?></p>
     
    114114        <p>
    115115            <label for="blog_public_on"><?php _e( 'Privacy:', 'buddypress' ) ?></label>
    116             <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?> 
     116            <?php _e( 'I would like my blog to appear in search engines like Google and Technorati, and in public listings around this site.', 'buddypress' ); ?>
    117117            <label class="checkbox" for="blog_public_on">
    118118                <input type="radio" id="blog_public_on" name="blog_public" value="1" <?php if( !isset( $_POST['blog_public'] ) || '1' == $_POST['blog_public'] ) { ?>checked="checked"<?php } ?> />
     
    153153    <?php if ( $errmsg = $errors->get_error_message('user_email') ) { ?>
    154154        <p class="error"><?php echo $errmsg ?></p>
    155     <?php } ?>     
     155    <?php } ?>
    156156    <input name="user_email" type="text" id="user_email" value="<?php  echo wp_specialchars($user_email, 1) ?>" maxlength="200" /><p class="help-text"><?php _e( '(We&#8217;ll send your password to this address, so <strong>triple-check it</strong>.)', 'buddypress' ) ?></p>
    157157    <?php
     
    160160    }
    161161    echo '</div>';
    162    
     162
    163163    echo '<div id="extra-fields">';
    164164    do_action( 'signup_extra_fields', $errors );
     
    172172function bp_core_signup_signup_another_blog($blogname = '', $blog_title = '', $errors = '') {
    173173    global $current_user, $current_site;
    174    
     174
    175175    if ( ! is_wp_error($errors) ) {
    176176        $errors = new WP_Error();
     
    186186    <h3><?php _e( "You're already registered!", 'buddypress' )?></h3>
    187187    <p><?php _e( 'You can still create another blog however. Fill in the form below to add another blog to your account.', 'buddypress' ) ?>
    188      
     188
    189189
    190190    <p><?php _e( "There is no limit to the number of blogs you can have, so create to your heart's content, but blog responsibly. If you&#8217;re not going to use a great blog domain, leave it for a new user. Now have at it!", 'buddypress' ) ?></p>
    191    
     191
    192192    <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
    193193        <input type="hidden" name="stage" value="gimmeanotherblog" />
     
    254254
    255255    ?>
    256    
     256
    257257    <form id="setupform" method="post" action="<?php echo site_url(BP_REGISTER_SLUG) ?>">
    258258        <p id="intro-text"><?php _e( 'Registering for a new account is easy, just fill in the form below and you\'ll be a new member in no time at all.', 'buddypress' ) ?></p>
    259259        <input type="hidden" name="stage" value="validate-user-signup" />
    260260        <?php do_action( "signup_hidden_fields" ); ?>
    261        
     261
    262262        <?php bp_core_signup_show_user_form($user_name, $user_email, $errors); ?>
    263        
     263
    264264        <?php if( 'blog' == $active_signup ) { ?>
    265265            <input id="signupblog" type="hidden" name="signup_for" value="blog" />
     
    270270                <h3><?php _e( 'Create a Blog?', 'buddypress' ) ?></h3>
    271271                <p id="blog-help-text"><?php _e( 'If you want to create your first blog, select the option below and you\'ll be asked for a few more details.', 'buddypress' ) ?></p>
    272                
     272
    273273                <div id="blog-or-username-fields">
    274274                    <p>
    275275                        <input id="signupblog" type="radio" name="signup_for" value="blog" <?php echo $signup['blog'] ?> />
    276                         <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label>           
     276                        <label class="checkbox" for="signupblog"><?php _e( 'Gimme a blog!', 'buddypress' ) ?></label>
    277277                    </p>
    278                
     278
    279279                    <p>
    280                         <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />         
     280                        <input id="signupuser" type="radio" name="signup_for" value="user" <?php echo $signup['user'] ?> />
    281281                        <label class="checkbox" for="signupuser"><?php _e( 'Just a username, please.', 'buddypress' ) ?></label>
    282282                    </p>
     
    378378    ?>
    379379    <h3><?php _e('Congratulations, You are now registered!', 'buddypress' ) ?></h3>
    380    
     380
    381381    <p><?php printf( __('But, before you can start using your blog, <strong>you must activate it</strong>. Check your inbox at <strong>%s</strong> and click the link given. It should arrive within 30 minutes.', 'buddypress' ),  $user_email) ?></p>
    382382    <p>&nbsp;</p>
    383    
     383
    384384    <h3><?php _e( 'Still waiting for your email?', 'buddypress' ); ?></h3>
    385385    <p>
     
    465465function bp_core_activation_set_headers() {
    466466    global $wp_object_cache;
    467    
     467
    468468    define( "WP_INSTALLING", true );
    469    
     469
    470470    require_once( ABSPATH . WPINC . '/registration.php');
    471    
     471
    472472    if( is_object( $wp_object_cache ) )
    473473        $wp_object_cache->cache_enabled = false;
    474        
     474
    475475    do_action("activate_header");
    476476}
     
    478478function bp_core_activation_do_activation() {
    479479    global $current_site, $blog_id, $user_id; ?>
    480    
     480
    481481    <?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
    482482
    483483        <h3><?php _e( 'Activation Key Required', 'buddypress' ) ?></h3>
    484        
     484
    485485        <p id="intro-text"><?php _e( 'This is the key contained in the email you were sent after registering for this site.', 'buddypress' ) ?></p>
    486            
     486
    487487        <div class="field-box">
    488488            <form name="activateform" id="activateform" method="post" action="<?php echo 'http://' . $current_site->domain . $current_site->path ?>wp-activate.php">
     
    496496            </form>
    497497        </div>
    498        
     498
    499499    <?php } else {
    500500
    501501        $key = !empty($_GET['key']) ? $_GET['key'] : $_POST['key'];
    502502        $result = wpmu_activate_signup($key);
    503                
     503
    504504        if ( is_wp_error($result) ) {
    505505            if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
    506506                $signup = $result->get_error_data();
    507507                ?>
    508                
     508
    509509                <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
    510                
     510
    511511                <?php
    512512                _e( 'Your account has already been activated. You can now log in with the account details that were emailed to you.' );
    513            
     513
    514514            } else {
    515515                ?>
     
    522522
    523523            $user = new WP_User( (int) $user_id);
    524            
     524
    525525            ?>
    526            
     526
    527527            <h3><?php _e('Your account is now active!', 'buddypress' ); ?></h3>
    528            
     528
    529529            <p class="view"><?php printf( __( 'Your account is now activated. <a href="%1$s">Login</a> or go back to the <a href="%2$s">homepage</a>.', 'buddypress' ), site_url( 'wp-login.php?redirect_to=' . site_url() ), site_url() ); ?></p>
    530            
     530
    531531            <div class="field-box" id="signup-welcome">
    532532                <p><span class="label"><?php _e( 'Username:', 'buddypress' ); ?></span> <?php echo $user->user_login ?></p>
    533533                <p><span class="label"><?php _e( 'Password:', 'buddypress' ); ?></span> <?php echo $password; ?></p>
    534534            </div>
    535            
    536             <?php 
     535
     536            <?php
    537537            do_action( 'bp_activation_extras', $user_id, $meta );
    538538        }
     
    550550        $activate_url = bp_activation_page( false ) ."?key=$key";
    551551    }
    552    
     552
    553553    $activate_url = clean_url($activate_url);
    554554    $admin_email = get_site_option( "admin_email" );
    555    
     555
    556556    if ( empty( $admin_email ) )
    557557        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    558    
     558
    559559    $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    560560    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    561561    $message = sprintf(__("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) );
    562562    $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path));
    563    
     563
    564564    wp_mail($user_email, $subject, $message, $message_headers);
    565    
     565
    566566    // Return false to stop the original WPMU function from continuing
    567567    return false;
     
    574574    // Send email with activation link.
    575575    $admin_email = get_site_option( "admin_email" );
    576    
     576
    577577    if ( empty( $admin_email ) )
    578578        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    579    
     579
    580580    $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    581581    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    582582    $message = apply_filters( 'wpmu_signup_user_notification_email', sprintf( __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\n", 'buddypress' ), clean_url( bp_activation_page( false ) . "?key=$key" ) ) );
    583     $subject = apply_filters( 'wpmu_signup_user_notification_subject', sprintf( __(  'Activate %s', 'buddypress' ), $user ) ); 
     583    $subject = apply_filters( 'wpmu_signup_user_notification_subject', sprintf( __(  'Activate %s', 'buddypress' ), $user ) );
    584584
    585585    wp_mail( $user_email, $subject, $message, $message_headers );
    586    
     586
    587587    // Return false to stop the original WPMU function from continuing
    588588    return false;
     
    632632function bp_loggedinuser_avatar( $width = false, $height = false ) {
    633633    global $bp;
    634    
     634
    635635    echo apply_filters( 'bp_loggedinuser_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
    636636}
     
    639639function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) {
    640640    global $bp;
    641    
     641
    642642    echo apply_filters( 'bp_get_options_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb', 'width' => $width, 'height' => $height ) ) );
    643643}
     
    667667    <p><?php _e('Your avatar will be used on your profile and throughout the site.', 'buddypress') ?></p>
    668668    <p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Photo\' to proceed.', 'buddypress' ) ?></p>
    669    
    670     <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">   
     669
     670    <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">
    671671
    672672    <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?>
    673    
     673
    674674        <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3>
    675675
    676676        <?php bp_displayed_user_avatar( 'type=full') ?>
    677677        <?php bp_displayed_user_avatar( 'type=thumb' ) ?>
    678    
     678
    679679        <p>
    680             <input type="file" name="file" id="file" /> 
     680            <input type="file" name="file" id="file" />
    681681            <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
    682682            <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
     
    684684
    685685        <?php wp_nonce_field( 'bp_avatar_upload' ) ?>
    686        
     686
    687687    <?php endif; ?>
    688    
     688
    689689    <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
    690    
     690
    691691        <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3>
    692        
     692
    693693        <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
    694        
     694
    695695        <div id="avatar-crop-pane" style="width:100px;height:100px;overflow:hidden;">
    696696            <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" />
     
    698698
    699699        <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
    700        
     700
    701701        <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
    702702        <input type="hidden" id="x" name="x" />
     
    706706
    707707        <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?>
    708        
     708
    709709    <?php endif; ?>
    710    
     710
    711711    </form> <?php
    712712}
     
    714714function bp_core_handle_avatar_upload($file) {
    715715    global $wp_upload_error;
    716    
     716
    717717    require_once( ABSPATH . '/wp-admin/includes/file.php' );
    718    
     718
    719719    // Change the upload file location to /avatars/user_id
    720720    add_filter( 'upload_dir', 'xprofile_avatar_upload_dir' );
     
    757757function bp_core_get_buddypress_themes() {
    758758    global $wp_themes;
    759    
     759
    760760    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    761761    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    762762        return false;
    763    
     763
    764764    /* Remove the cached WP themes first */
    765765    $wp_existing_themes = &$wp_themes;
    766766    $wp_themes = null;
    767    
     767
    768768    add_filter( 'theme_root', 'bp_core_filter_buddypress_theme_root' );
    769769    $themes = get_themes();
    770    
     770
    771771    if ( $themes ) {
    772772        foreach ( $themes as $name => $values ) {
    773773            if ( $name == 'BuddyPress Default Home Theme' )
    774774                continue;
    775            
     775
    776776            $member_themes[] = array(
    777777                'name' => $name,
     
    781781        }
    782782    }
    783    
     783
    784784    /* Restore the cached WP themes */
    785785    $wp_themes = $wp_existing_themes;
    786    
     786
    787787    return $member_themes;
    788788}
     
    807807function bp_core_force_buddypress_theme( $template ) {
    808808    global $is_member_page, $bp;
    809    
     809
    810810    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    811811    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    812812        return $template;
    813        
     813
    814814    if ( $is_member_page ) {
    815815        $member_theme = get_site_option( 'active-member-theme' );
    816    
     816
    817817        if ( empty( $member_theme ) )
    818818            $member_theme = 'bpmember';
     
    830830function bp_core_force_buddypress_stylesheet( $stylesheet ) {
    831831    global $is_member_page;
    832    
     832
    833833    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    834834    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     
    836836
    837837    $member_theme = get_site_option( 'active-member-theme' );
    838    
     838
    839839    if ( empty( $member_theme ) )
    840840        $member_theme = 'bpmember';
     
    859859
    860860    /* Enqueue the structure CSS file to give basic positional formatting for components */
    861     wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/deprecated/css/structure.css' );   
     861    wp_enqueue_style( 'bp-core-structure', BP_PLUGIN_URL . '/bp-core/deprecated/css/structure.css' );
    862862}
    863863add_action( 'bp_styles', 'bp_core_add_structure_css' );
     
    868868    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    869869        return false;
    870    
     870
    871871    // Enable a sitewide CSS file that will apply styles to both the home blog theme
    872872    // and the member theme.
    873873    if ( file_exists( WP_CONTENT_DIR . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' ) )
    874874        wp_enqueue_style( 'site-wide-styles', WP_CONTENT_URL . '/themes/' . get_blog_option( BP_ROOT_BLOG, 'stylesheet' ) . '/css/site-wide.css' );
    875    
     875
    876876    wp_print_styles();
    877877}
     
    886886    if ( defined( 'BP_DISABLE_ADMIN_BAR') )
    887887        return false;
    888        
     888
    889889    if ( is_user_logged_in() || ( !(int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() ) ) {
    890890        wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar.css' ) );
    891        
     891
    892892        if ( 'rtl' == get_bloginfo('text_direction') && file_exists( BP_PLUGIN_DIR . '/bp-core/deprecated/css/admin-bar-rtl.css' ) )
    893             wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar-rtl.css' );   
     893            wp_enqueue_style( 'bp-admin-bar-rtl', BP_PLUGIN_URL . '/bp-core/deprecated/css/admin-bar-rtl.css' );
    894894    }
    895895}
     
    902902    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    903903        return $template;
    904    
     904
    905905    wp_enqueue_script( 'jquery' );
    906906    wp_enqueue_script( 'jquery-livequery-pack', BP_PLUGIN_URL . '/bp-core/deprecated/js/jquery/jquery.livequery.pack.js', 'jquery' );
     
    914914    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    915915        return $template;
    916            
     916
    917917    wp_enqueue_script( 'bp-core-directory-members', BP_PLUGIN_URL . '/bp-core/deprecated/js/directory-members.js', array( 'jquery', 'jquery-livequery-pack' ) );
    918918}
    919 add_action( 'bp_core_action_directory_members', 'bp_core_directory_members_js' ); 
     919add_action( 'bp_core_action_directory_members', 'bp_core_directory_members_js' );
    920920
    921921/*** END DEPRECATED OLD BUDDYPRESS THEME SUPPORT ************/
     
    925925    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    926926        return false;
    927        
     927
    928928    check_ajax_referer('directory_members');
    929    
     929
    930930    locate_template( array( 'directories/members/members-loop.php' ), true );
    931931}
     
    935935function bp_login_bar() {
    936936    global $bp;
    937    
     937
    938938    if ( !is_user_logged_in() ) : ?>
    939        
     939
    940940        <form name="login-form" id="login-form" action="<?php echo $bp->root_domain . '/wp-login.php' ?>" method="post">
    941941            <input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" />
    942942            <input type="password" name="pwd" id="user_pass" class="input" value="" />
    943            
     943
    944944            <input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" />
    945            
    946             <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>               
     945
     946            <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>
    947947            <input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" />
    948948
    949949            <input type="hidden" name="redirect_to" value="http://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ?>" />
    950950            <input type="hidden" name="testcookie" value="1" />
    951                        
     951
    952952            <?php do_action( 'bp_login_bar_logged_out' ) ?>
    953953        </form>
    954    
     954
    955955    <?php else : ?>
    956        
     956
    957957        <div id="logout-link">
    958958            <?php bp_loggedinuser_avatar_thumbnail( 20, 20 ) ?> &nbsp;
    959959            <?php bp_loggedinuser_link() ?>
    960             <?php 
     960            <?php
    961961                if ( function_exists('wp_logout_url') ) {
    962962                    $logout_link = '/ <a href="' . wp_logout_url( $bp->root_domain ) . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
    963963                } else {
    964                     $logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';                   
    965                 }           
    966                
     964                    $logout_link = '/ <a href="' . $bp->root_domain . '/wp-login.php?action=logout&amp;redirect_to=' . $bp->root_domain . '">' . __( 'Log Out', 'buddypress' ) . '</a>';
     965                }
     966
    967967                echo apply_filters( 'bp_logout_link', $logout_link );
    968968            ?>
    969            
     969
    970970            <?php do_action( 'bp_login_bar_logged_in' ) ?>
    971971        </div>
    972        
     972
    973973    <?php endif;
    974974}
     
    977977function bp_core_add_nav_default( $parent_id, $function, $slug = false, $user_has_access = true, $admin_only = false ) {
    978978    global $bp;
    979    
     979
    980980    if ( !$user_has_access && !bp_is_home() )
    981981        return false;
    982        
     982
    983983    if ( $admin_only && !is_site_admin() )
    984984        return false;
     
    988988            add_action( 'wp', $function, 3 );
    989989        }
    990        
     990
    991991        if ( $slug )
    992992            $bp->current_action = $slug;
     
    997997function bp_get_userbar( $hide_on_directory = true ) {
    998998    global $bp;
    999    
     999
    10001000    if ( $hide_on_directory && $bp->is_directory )
    10011001        return false;
    1002    
     1002
    10031003    load_template( TEMPLATEPATH . '/userbar.php' );
    10041004}
     
    10071007function bp_get_optionsbar( $hide_on_directory = true ) {
    10081008    global $bp;
    1009    
     1009
    10101010    if ( $hide_on_directory && $bp->is_directory )
    10111011        return false;
    1012        
     1012
    10131013    load_template( TEMPLATEPATH . '/optionsbar.php' );
    10141014}
  • trunk/bp-forums.php

    r2033 r2077  
    44if ( !defined( 'BP_FORUMS_PARENT_FORUM_ID' ) )
    55    define( 'BP_FORUMS_PARENT_FORUM_ID', 1 );
    6    
     6
    77if ( !defined( 'BP_FORUMS_SLUG' ) )
    88    define( 'BP_FORUMS_SLUG', 'forums' );
     
    1919    /* For internal identification */
    2020    $bp->forums->id = 'forums';
    21        
     21
    2222    $bp->forums->image_base = BP_PLUGIN_URL . '/bp-forums/images';
    2323    $bp->forums->bbconfig = get_site_option( 'bb-config-location' );
    2424    $bp->forums->slug = BP_FORUMS_SLUG;
    25    
     25
    2626    /* Register this in the active components array */
    2727    $bp->active_components[$bp->forums->slug] = $bp->forums->id;
     
    3434function bp_forums_is_installed_correctly() {
    3535    global $bp;
    36    
     36
    3737    if ( file_exists( $bp->forums->bbconfig ) )
    3838        return true;
    39    
     39
    4040    return false;
    4141}
     
    5353        if ( (int) get_site_option( 'bp-disable-forum-directory' ) || !function_exists( 'groups_install' ) )
    5454            return false;
    55            
     55
    5656        if ( !bp_forums_is_installed_correctly() ) {
    5757            bp_core_add_message( __( 'The forums component has not been set up yet.', 'buddypress' ), 'error' );
    5858            bp_core_redirect( $bp->root_domain );
    5959        }
    60        
     60
    6161        $bp->is_directory = true;
    62        
    63         do_action( 'bbpress_init' ); 
     62
     63        do_action( 'bbpress_init' );
    6464        do_action( 'bp_forums_directory_forums_setup' );
    6565        bp_core_load_template( apply_filters( 'bp_forums_template_directory_forums_setup', 'directories/forums/index' ) );
     
    7070function bp_forums_add_admin_menu() {
    7171    global $bp;
    72    
     72
    7373    if ( !is_site_admin() )
    7474        return false;
    7575
    7676    require ( BP_PLUGIN_DIR . '/bp-forums/bp-forums-admin.php' );
    77    
     77
    7878    /* Add the administration tab under the "Site Admin" tab for site administrators */
    7979    add_submenu_page( 'bp-general-settings', __( 'Forums Setup', 'buddypress' ), __( 'Forums Setup', 'buddypress' ), 'manage_options', 'bb-forums-setup', "bp_forums_bbpress_admin" );
     
    9090function bp_forums_new_forum( $args = '' ) {
    9191    do_action( 'bbpress_init' );
    92    
    93     $defaults = array( 
    94         'forum_name' => '', 
    95         'forum_desc' => '', 
    96         'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID, 
    97         'forum_order' => false, 
     92
     93    $defaults = array(
     94        'forum_name' => '',
     95        'forum_desc' => '',
     96        'forum_parent_id' => BP_FORUMS_PARENT_FORUM_ID,
     97        'forum_order' => false,
    9898        'forum_is_category' => 0
    9999    );
     
    101101    $r = wp_parse_args( $args, $defaults );
    102102    extract( $r, EXTR_SKIP );
    103    
     103
    104104    return bb_new_forum( array( 'forum_name' => stripslashes( $forum_name ), 'forum_desc' => stripslashes( $forum_desc ), 'forum_parent' => $forum_parent_id, 'forum_order' => $forum_order, 'forum_is_category' => $forum_is_category ) );
    105105}
     
    107107function bp_forums_get_forum_topicpost_count( $forum_id ) {
    108108    global $wpdb, $bbdb;
    109    
     109
    110110    do_action( 'bbpress_init' );
    111111
     
    118118function bp_forums_get_forum_topics( $args = '' ) {
    119119    global $bp;
    120    
    121     do_action( 'bbpress_init' );
    122    
     120
     121    do_action( 'bbpress_init' );
     122
    123123    $defaults = array(
    124124        'type' => 'newest',
    125         'forum_id' => false, 
    126         'page' => 1, 
    127         'per_page' => 15, 
     125        'forum_id' => false,
     126        'page' => 1,
     127        'per_page' => 15,
    128128        'exclude' => false,
    129129        'show_stickies' => 'all',
    130130        'filter' => false // if $type = tag then filter is the tag name, otherwise it's terms to search on.
    131131    );
    132    
     132
    133133    $r = wp_parse_args( $args, $defaults );
    134134    extract( $r, EXTR_SKIP );
     
    139139            $topics = $query->results;
    140140        break;
    141        
     141
    142142        case 'popular':
    143143            $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_posts', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
    144144            $topics =& $query->results;
    145145        break;
    146        
     146
    147147        case 'unreplied':
    148148            $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'post_count' => 1, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ) );
    149149            $topics =& $query->results;
    150         break; 
    151        
     150        break;
     151
    152152        case 'personal':
    153153            $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'per_page' => $per_page, 'page' => $page, 'topic_author_id' => $bp->loggedin_user->id, 'order_by' => 't.topic_time', 'topic_title' => $filter, 'sticky' => $show_stickies ), 'get_recent_user_threads' );
    154154            $topics =& $query->results;
    155155        break;
    156        
     156
    157157        case 'tag':
    158158            $query = new BB_Query( 'topic', array( 'forum_id' => $forum_id, 'tag' => $filter, 'per_page' => $per_page, 'page' => $page, 'order_by' => 't.topic_time', 'sticky' => $show_stickies ) );
     
    167167    do_action( 'bbpress_init' );
    168168
    169     $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ ); 
     169    $query = new BB_Query( 'topic', 'topic_id=' . $topic_id . '&page=1' /* Page override so bbPress doesn't use the URI */ );
    170170
    171171    return $query->results[0];
     
    179179function bp_forums_new_topic( $args = '' ) {
    180180    global $bp;
    181    
    182     do_action( 'bbpress_init' );
    183    
     181
     182    do_action( 'bbpress_init' );
     183
    184184    $defaults = array(
    185185        'topic_title' => '',
     
    198198    $r = wp_parse_args( $args, $defaults );
    199199    extract( $r, EXTR_SKIP );
    200    
     200
    201201    if ( empty( $topic_slug ) )
    202202        $topic_slug = sanitize_title( $topic_title );
    203        
     203
    204204    if ( !$topic_id = bb_insert_topic( array( 'topic_title' => stripslashes( $topic_title ), 'topic_slug' => $topic_slug, 'topic_poster' => $topic_poster, 'topic_poster_name' => $topic_poster_name, 'topic_last_poster' => $topic_last_poster, 'topic_last_poster_name' => $topic_last_poster_name, 'topic_start_time' => $topic_start_time, 'topic_time' => $topic_time, 'topic_open' => $topic_open, 'forum_id' => (int)$forum_id, 'tags' => $topic_tags ) ) )
    205205        return false;
     
    208208    if ( !bp_forums_insert_post( array( 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $topic_time, 'poster_id' => $topic_poster ) ) )
    209209        return false;
    210    
     210
    211211    return $topic_id;
    212212}
     
    214214function bp_forums_update_topic( $args = '' ) {
    215215    global $bp;
    216    
    217     do_action( 'bbpress_init' );
    218    
     216
     217    do_action( 'bbpress_init' );
     218
    219219    $defaults = array(
    220220        'topic_id' => false,
     
    225225    $r = wp_parse_args( $args, $defaults );
    226226    extract( $r, EXTR_SKIP );
    227    
     227
    228228    if ( !$topic_id = bb_insert_topic( array( 'topic_id' => $topic_id, 'topic_title' => stripslashes( $topic_title ) ) ) )
    229229        return false;
    230    
     230
    231231    if ( !$post = bb_get_first_post( $topic_id ) )
    232232        return false;
     
    235235    if ( !$post = bb_insert_post( array( 'post_id' => $post->post_id, 'topic_id' => $topic_id, 'post_text' => $topic_text, 'post_time' => $post->post_time, 'poster_id' => $post->poster_id, 'poster_ip' => $post->poster_ip, 'post_status' => $post->post_status, 'post_position' => $post->post_position ) ) )
    236236        return false;
    237    
     237
    238238    return bp_forums_get_topic_details( $topic_id );
    239239}
     
    241241function bp_forums_sticky_topic( $args = '' ) {
    242242    global $bp;
    243    
    244     do_action( 'bbpress_init' );
    245    
     243
     244    do_action( 'bbpress_init' );
     245
    246246    $defaults = array(
    247247        'topic_id' => false,
     
    251251    $r = wp_parse_args( $args, $defaults );
    252252    extract( $r, EXTR_SKIP );
    253    
     253
    254254    if ( 'stick' == $mode )
    255255        return bb_stick_topic( $topic_id );
     
    262262function bp_forums_openclose_topic( $args = '' ) {
    263263    global $bp;
    264    
    265     do_action( 'bbpress_init' );
    266    
     264
     265    do_action( 'bbpress_init' );
     266
    267267    $defaults = array(
    268268        'topic_id' => false,
     
    272272    $r = wp_parse_args( $args, $defaults );
    273273    extract( $r, EXTR_SKIP );
    274    
     274
    275275    if ( 'close' == $mode )
    276276        return bb_close_topic( $topic_id );
     
    283283function bp_forums_delete_topic( $args = '' ) {
    284284    global $bp;
    285    
    286     do_action( 'bbpress_init' );
    287    
     285
     286    do_action( 'bbpress_init' );
     287
    288288    $defaults = array(
    289289        'topic_id' => false
     
    296296}
    297297
    298 /* Post Functions */ 
     298/* Post Functions */
    299299
    300300function bp_forums_get_topic_posts( $args = '' ) {
    301301    do_action( 'bbpress_init' );
    302    
    303     $defaults = array( 
    304         'topic_id' => false, 
     302
     303    $defaults = array(
     304        'topic_id' => false,
    305305        'page' => 1,
    306306        'per_page' => 15,
     
    321321function bp_forums_delete_post( $args = '' ) {
    322322    global $bp;
    323    
    324     do_action( 'bbpress_init' );
    325    
     323
     324    do_action( 'bbpress_init' );
     325
    326326    $defaults = array(
    327327        'post_id' => false
     
    331331    extract( $r, EXTR_SKIP );
    332332
    333     return bb_delete_post( $post_id, 1 );   
     333    return bb_delete_post( $post_id, 1 );
    334334}
    335335
    336336function bp_forums_insert_post( $args = '' ) {
    337337    global $bp;
    338    
    339     do_action( 'bbpress_init' );
    340 
    341     $defaults = array(
    342         'post_id' => false, 
     338
     339    do_action( 'bbpress_init' );
     340
     341    $defaults = array(
     342        'post_id' => false,
    343343        'topic_id' => false,
    344344        'post_text' => '',
     
    352352    $r = wp_parse_args( $args, $defaults );
    353353    extract( $r, EXTR_SKIP );
    354    
     354
    355355    if ( !$post = bp_forums_get_post( $post_id ) )
    356356        $post_id = false;
     
    358358    if ( !isset( $topic_id ) )
    359359        $topic_id = $post->topic_id;
    360    
     360
    361361    if ( empty( $post_text ) )
    362362        $post_text = $post->post_text;
    363    
     363
    364364    if ( !isset( $post_time ) )
    365365        $post_time = $post->post_time;
     
    378378function bp_forums_filter_caps( $allcaps ) {
    379379    global $bp, $wp_roles, $bb_table_prefix;
    380    
     380
    381381    $bb_cap = get_usermeta( $bp->loggedin_user->id, $bb_table_prefix . 'capabilities' );
    382382
    383383    if ( empty( $bb_cap ) )
    384384        return $allcaps;
    385    
     385
    386386    $bb_cap = array_keys($bb_cap);
    387387    $bb_cap = $wp_roles->get_role( $bb_cap[0] );
    388388    $bb_cap = $bb_cap->capabilities;
    389    
     389
    390390    return array_merge( (array) $allcaps, (array) $bb_cap );
    391391}
  • trunk/bp-forums/bp-forums-admin.php

    r1960 r2077  
    11<?php
    22
    3 function bp_forums_bbpress_admin() { 
     3function bp_forums_bbpress_admin() {
    44    global $bp;
    55?>
     
    77
    88        <h2><?php _e( 'Forums Setup', 'buddypress' ) ?></h2>
    9        
     9
    1010        <?php if ( isset( $_POST['submit'] ) ) : ?>
    1111            <div id="message" class="updated fade">
     
    1515
    1616        <?php
    17        
     17
    1818        if ( isset( $_REQUEST['reinstall'] ) || !bp_forums_is_installed_correctly() ) {
    1919            update_site_option( 'bb-config-location', false );
     
    2222            <p><?php printf( __( 'bbPress forum integration in BuddyPress has been set up correctly. If you are having problems you can <a href="%s" title="Reinstall bbPress">re-install</a>', 'buddypress' ), site_url( 'wp-admin/admin.php?page=bb-forums-setup&reinstall=1' ) ); ?>
    2323            <p><?php _e( 'NOTE: The forums directory will only work if your bbPress tables are in the same database as your WordPress tables. If you are not using an existing bbPress install you can ignore this message.', 'buddypress' ) ?></p>
    24         <?php   
     24        <?php
    2525        }
    2626        ?>
     
    2929}
    3030
    31 function bp_forums_bbpress_install_wizard() { 
     31function bp_forums_bbpress_install_wizard() {
    3232    $post_url = site_url( 'wp-admin/admin.php?page=bb-forums-setup' );
    3333
    34     switch( $_REQUEST['step'] ) {       
     34    switch( $_REQUEST['step'] ) {
    3535        case 'existing':
    3636            if ( 1 == (int)$_REQUEST['doinstall'] ) {
     
    5353                        <?php wp_nonce_field( 'bp_forums_existing_install_init' ) ?>
    5454                    </form>
    55                 <?php   
     55                <?php
    5656            }
    5757        break;
    58        
     58
    5959        case 'new':
    6060            if ( 1 == (int)$_REQUEST['doinstall'] ) {
    6161                $result = bp_forums_bbpress_install();
    62            
     62
    6363                switch ( $result ) {
    6464                    case 1:
     
    8080            }
    8181        break;
    82    
    83         default: 
     82
     83        default:
    8484            if ( !file_exists( BP_PLUGIN_DIR . '/bp-forums/bbpress/' ) ) { ?>
    8585                <div id="message" class="error">
     
    8787                </div>
    8888            <?php } else { ?>
    89            
     89
    9090                <p><?php _e( 'Forums in BuddyPress make use of a bbPress installation to function. You can choose to either let BuddyPress set up a new bbPress install, or use an already existing bbPress install. Please choose one of the options below.', 'buddypress' ) ?></p>
    91            
     91
    9292                <a class="button" href="<?php echo $post_url . '&step=new' ?>"><?php _e( 'Set up a new bbPress installation', 'buddypress' ) ?></a> &nbsp;
    9393                <a class="button" href="<?php echo $post_url . '&step=existing' ?>"><?php _e( 'Use an existing bbPress installation', 'buddypress' ) ?></a>
    9494
    95             <?php } 
     95            <?php }
    9696        break;
    9797    }
     
    100100function bp_forums_configure_existing_install() {
    101101    global $wpdb, $bbdb;
    102    
     102
    103103    check_admin_referer( 'bp_forums_existing_install_init' );
    104    
     104
    105105    /* Sanitize $_REQUEST['bbconfigloc'] */
    106106    $_REQUEST['bbconfigloc'] = apply_filters( 'bp_forums_bbconfig_location', $_REQUEST['bbconfigloc'] );
    107    
     107
    108108    if ( false === strpos( $_REQUEST['bbconfigloc'], 'bb-config.php' ) ) {
    109109        if ( '/' != substr( $_REQUEST['bbconfigloc'], -1, 1 ) )
    110110            $_REQUEST['bbconfigloc'] .= '/';
    111        
     111
    112112        $_REQUEST['bbconfigloc'] .= 'bb-config.php';
    113113    }
     
    117117
    118118    update_site_option( 'bb-config-location', $_REQUEST['bbconfigloc'] );
    119    
     119
    120120    return true;
    121121}
     
    123123function bp_forums_bbpress_install() {
    124124    global $wpdb, $bbdb;
    125    
     125
    126126    check_admin_referer( 'bp_forums_new_install_init' );
    127127
     
    145145        )
    146146    );
    147    
     147
    148148    /* Add the custom user and usermeta entries to the config file */
    149149    if ( $initial_write == 1 ) {
     
    154154
    155155    $file = substr( $file, 0, -2 );
    156     $file .= "\n" .   '$bb->custom_user_table = "' . $wpdb->users . '";'; 
     156    $file .= "\n" .   '$bb->custom_user_table = "' . $wpdb->users . '";';
    157157    $file .= "\n" .   '$bb->custom_user_meta_table = "' . $wpdb->usermeta . '";';
    158158    $file .= "\n\n" . '$bb->uri = "' . BP_PLUGIN_URL . '/bp-forums/bbpress/";';
    159159    $file .= "\n" .   '$bb->name = "' . get_blog_option( BP_ROOT_BLOG, 'name' ) . ' ' . __( 'Forums', 'buddypress' ) . '";';
    160160    $file .= "\n" .   '$bb->wordpress_mu_primary_blog_id = ' . BP_ROOT_BLOG . ';';
    161     $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . AUTH_SALT . '");'; 
    162     $file .= "\n" .   'define(\'BB_LOGGED_IN_SALT\', "' . LOGGED_IN_SALT . '");';   
    163     $file .= "\n" .   'define(\'BB_SECURE_AUTH_SALT\', "' . SECURE_AUTH_SALT . '");';   
    164     $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; 
     161    $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', "' . AUTH_SALT . '");';
     162    $file .= "\n" .   'define(\'BB_LOGGED_IN_SALT\', "' . LOGGED_IN_SALT . '");';
     163    $file .= "\n" .   'define(\'BB_SECURE_AUTH_SALT\', "' . SECURE_AUTH_SALT . '");';
     164    $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
    165165    $file .= "\n\n" . '?>';
    166    
     166
    167167    if ( $initial_write == 1 ) {
    168168        $file_handle = fopen( ABSPATH . 'bb-config.php', 'w' );
     
    189189        return -2;
    190190    }
    191    
     191
    192192    // Get the existing lines in the file
    193193    $lines = file( $file_source );
     
    205205        }
    206206    }
    207    
     207
    208208    $writable = true;
    209209    if ( file_exists( $file_target ) ) {
  • trunk/bp-forums/bp-forums-bbpress.php

    r1905 r2077  
    55    global $bb, $bbdb, $bb_table_prefix, $bb_current_user;
    66    global $bb_roles, $wp_taxonomy_object;
    7    
     7
    88    /* Return if we've already run this function. */
    99    if ( is_object( $bbdb ) && is_object( $bb_roles ) )
    1010        return;
    11    
     11
    1212    if ( !bp_forums_is_installed_correctly() )
    1313        return false;
    14    
     14
    1515    define( 'BB_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/' );
    1616    define( 'BACKPRESS_PATH', BP_PLUGIN_DIR . '/bp-forums/bbpress/bb-includes/backpress/' );
     
    2020    require_once( BB_PATH . BB_INC . 'class.bb-query.php' );
    2121    require_once( BB_PATH . BB_INC . 'class.bb-walker.php' );
    22    
     22
    2323    require_once( BB_PATH . BB_INC . 'functions.bb-core.php' );
    2424    require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' );
     
    3131    require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' );
    3232    require_once( BB_PATH . BB_INC . 'functions.bb-template.php' );
    33    
     33
    3434    require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' );
    3535    require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' );
    36    
     36
    3737    $bb = new stdClass();
    3838    require_once( $bp->forums->bbconfig );
     
    4040    // Setup the global database connection
    4141    $bbdb = new BPDB ( BBDB_USER, BBDB_PASSWORD, BBDB_NAME, BBDB_HOST );
    42    
     42
    4343    /* Set the table names */
    4444    $bbdb->forums = $bb_table_prefix . 'forums';
     
    4949    $bbdb->term_taxonomy = $bb_table_prefix . 'term_taxonomy';
    5050    $bbdb->topics = $bb_table_prefix . 'topics';
    51    
     51
    5252    if ( isset( $bb->custom_user_table ) )
    5353        $bbdb->users = $bb->custom_user_table;
    5454    else
    5555        $bbdb->users = $wpdb->users;
    56    
     56
    5757    if ( isset( $bb->custom_user_meta_table ) )
    5858        $bbdb->usermeta = $bb->custom_user_meta_table;
    5959    else
    6060        $bbdb->usermeta = $wpdb->usermeta;
    61        
     61
    6262    $bbdb->prefix = $bb_table_prefix;
    6363
     
    6767    if ( !$tables_installed = (boolean) $bbdb->get_results( 'DESCRIBE `' . $bbdb->forums . '`;', ARRAY_A ) )
    6868        require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    69    
     69
    7070    require_once( BB_PATH . 'bb-admin/includes/functions.bb-admin.php' );
    71    
     71
    7272    if ( is_object( $wp_roles ) ) {
    7373        $bb_roles =& $wp_roles;
     
    8484    if ( !isset( $wp_taxonomy_object ) )
    8585        $wp_taxonomy_object = new BB_Taxonomy( $bbdb );
    86    
     86
    8787    $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );
    8888
     
    9696
    9797        dbDelta( $bb_queries );
    98        
     98
    9999        require_once( BB_PATH . 'bb-admin/includes/functions.bb-upgrade.php' );
    100100        bb_update_db_version();
    101        
     101
    102102        /* Set the site admins as the keymasters */
    103103        $site_admins = get_site_option( 'site_admins', array('admin') );
     
    107107        // Create the first forum.
    108108        bb_new_forum( array( 'forum_name' => 'Default Forum' ) );
    109        
     109
    110110        // Set the site URI
    111111        bb_update_option( 'uri', BB_URL );
     
    129129        $args = wp_parse_args( $args, $defaults );
    130130        extract( $args, EXTR_SKIP );
    131        
     131
    132132        return update_usermeta( $id, $meta_key, $meta_value );
    133133    }
  • trunk/bp-forums/bp-forums-filters.php

    r2019 r2077  
    3838    $allowedtags['p'] = array();
    3939    $allowedtags['br'] = array();
    40    
     40
    4141    return $allowedtags;
    4242}
     
    4545function bp_forums_filter_tag_link( $link, $tag, $page, $context ) {
    4646    global $bp;
    47    
     47
    4848    return apply_filters( 'bp_forums_filter_tag_link', $bp->root_domain . '/' . $bp->forums->slug . '/tag/' . $tag . '/' );
    4949}
  • trunk/bp-forums/bp-forums-templatetags.php

    r2012 r2077  
    66    var $topics;
    77    var $topic;
    8    
     8
    99    var $in_the_loop;
    10    
     10
    1111    var $pag_page;
    1212    var $pag_num;
    1313    var $pag_links;
    1414    var $total_topic_count;
    15    
     15
    1616    var $single_topic = false;
    17    
     17
    1818    var $sort_by;
    1919    var $order;
    20    
     20
    2121    function BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter ) {
    2222        global $bp;
     
    2424        $this->pag_page = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 1;
    2525        $this->pag_num = isset( $_REQUEST['n'] ) ? intval( $_REQUEST['n'] ) : $per_page;
    26        
     26
    2727        /* Only show stickies if we are viewing a single group forum, otherwise we could end up with hundreds globally */
    2828        if ( $no_stickies )
     
    3333                $this->topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id, 'filter' => $filter, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
    3434                break;
    35            
     35
    3636            case 'popular':
    3737                $this->topics = bp_forums_get_forum_topics( array( 'type' => 'popular', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
    3838                break;
    39            
     39
    4040            case 'unreplied':
    4141                $this->topics = bp_forums_get_forum_topics( array( 'type' => 'unreplied', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
    4242                break;
    43                
     43
    4444            case 'personal':
    4545                $this->topics = bp_forums_get_forum_topics( array( 'type' => 'personal', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
    4646                break;
    47                
     47
    4848            case 'tag':
    4949                $this->topics = bp_forums_get_forum_topics( array( 'type' => 'tag', 'filter' => $filter, 'forum_id' => $forum_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'show_stickies' => $show_stickies ) );
    50                 break; 
     50                break;
    5151        }
    5252
    5353        $this->topics = apply_filters( 'bp_forums_template_topics', $this->topics, $type, $forum_id, $per_page, $max, $no_stickies );
    54        
     54
    5555        if ( !(int)$this->topics ) {
    5656            $this->topic_count = 0;
     
    6363                $topic_count = (int)groups_total_public_forum_topic_count( $type );
    6464            } else {
    65                 $topic_count = count( $this->topics );             
     65                $topic_count = count( $this->topics );
    6666            }
    67            
     67
    6868            if ( !$max || $max >= $topic_count )
    6969                $this->total_topic_count = $topic_count;
     
    7878            } else {
    7979                $this->topic_count = count( $this->topics );
    80             }       
     80            }
    8181        }
    8282
     
    9090                    $stickies[] = $topic;
    9191                else
    92                     $standard[] = $topic; 
     92                    $standard[] = $topic;
    9393            }
    9494            $this->topics = array_merge( (array)$stickies, (array)$standard );
     
    105105        ));
    106106    }
    107    
     107
    108108    function has_topics() {
    109109        if ( $this->topic_count )
    110110            return true;
    111        
     111
    112112        return false;
    113113    }
    114    
     114
    115115    function next_topic() {
    116116        $this->current_topic++;
    117117        $this->topic = $this->topics[$this->current_topic];
    118            
     118
    119119        return $this->topic;
    120120    }
    121    
     121
    122122    function rewind_topics() {
    123123        $this->current_topic = -1;
     
    126126        }
    127127    }
    128    
    129     function user_topics() { 
     128
     129    function user_topics() {
    130130        if ( $this->current_topic + 1 < $this->topic_count ) {
    131131            return true;
     
    139139        return false;
    140140    }
    141    
     141
    142142    function the_topic() {
    143143        global $topic;
     
    146146        $this->topic = $this->next_topic();
    147147        $this->topic = (object)$this->topic;
    148        
     148
    149149        if ( $this->current_topic == 0 ) // loop has just started
    150150            do_action('loop_start');
     
    154154function bp_has_forum_topics( $args = '' ) {
    155155    global $forum_template, $bp;
    156    
     156
    157157    $defaults = array(
    158158        'type' => 'newest',
     
    175175            return false;
    176176    }
    177    
     177
    178178    /* If we're viewing a tag in the directory, let's auto set the filter to the tag name */
    179179    if ( $bp->is_directory && 'tag' == $type && !empty( $bp->action_variables[0] ) )
     
    183183    if ( $bp->is_directory && !empty( $_GET['fs'] ) )
    184184        $filter = $_GET['fs'];
    185        
     185
    186186    $forum_template = new BP_Forums_Template_Forum( $type, $forum_id, $per_page, $max, $no_stickies, $filter );
    187187
    188     return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template );   
     188    return apply_filters( 'bp_has_topics', $forum_template->has_topics(), &$forum_template );
    189189}
    190190    /* DEPRECATED use bp_has_forum_topics() */
     
    213213        return apply_filters( 'bp_get_the_topic_id', $forum_template->topic->topic_id );
    214214    }
    215    
     215
    216216function bp_the_topic_title() {
    217217    echo bp_get_the_topic_title();
     
    256256    function bp_get_the_topic_poster_avatar( $args = '' ) {
    257257        global $forum_template;
    258    
     258
    259259        $defaults = array(
    260260            'type' => 'thumb',
     
    266266        extract( $r, EXTR_SKIP );
    267267
    268         return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 
     268        return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
    269269    }
    270270
     
    277277        return apply_filters( 'bp_get_the_topic_poster_name', bp_core_get_userlink( $forum_template->topic->topic_poster ) );
    278278    }
    279    
     279
    280280function bp_the_topic_object_id() {
    281281    echo bp_get_the_topic_object_id();
     
    286286        return apply_filters( 'bp_get_the_topic_object_id', $forum_template->topic->object_id );
    287287    }
    288    
     288
    289289function bp_the_topic_object_name() {
    290290    echo bp_get_the_topic_object_name();
     
    295295        return apply_filters( 'bp_get_the_topic_object_name', $forum_template->topic->object_name );
    296296    }
    297    
     297
    298298function bp_the_topic_object_slug() {
    299299    echo bp_get_the_topic_object_slug();
     
    304304        return apply_filters( 'bp_get_the_topic_object_slug', $forum_template->topic->object_slug );
    305305    }
    306    
     306
    307307function bp_the_topic_object_permalink() {
    308308    echo bp_get_the_topic_object_permalink();
     
    310310    function bp_get_the_topic_object_permalink() {
    311311        global $bp, $forum_template;
    312        
     312
    313313        /* Currently this will only work with group forums, extended support in the future */
    314314        return apply_filters( 'bp_get_the_topic_object_permalink', $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/forum/' );
    315315    }
    316    
     316
    317317function bp_the_topic_last_poster_name() {
    318318    echo bp_get_the_topic_last_poster_name();
     
    323323        return apply_filters( 'bp_get_the_topic_last_poster_name', bp_core_get_userlink( $forum_template->topic->topic_last_poster ) );
    324324    }
    325    
     325
    326326function bp_the_topic_object_avatar( $args = '' ) {
    327327    echo bp_get_the_topic_object_avatar( $args );
     
    339339        extract( $r, EXTR_SKIP );
    340340
    341         return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) );       
    342     }
    343    
     341        return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) );
     342    }
     343
    344344function bp_the_topic_last_poster_avatar( $args = '' ) {
    345345    echo bp_get_the_topic_last_poster_avatar( $args );
     
    357357        extract( $r, EXTR_SKIP );
    358358
    359         return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 
     359        return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
    360360    }
    361361
     
    368368        return apply_filters( 'bp_get_the_topic_start_time', $forum_template->topic->topic_start_time );
    369369    }
    370    
     370
    371371function bp_the_topic_time() {
    372372    echo bp_get_the_topic_time();
     
    432432            return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d post', 'buddypress' ), $forum_template->topic->topic_posts ) );
    433433        else
    434             return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) );       
    435     }
    436    
     434            return apply_filters( 'bp_get_the_topic_total_post_count', sprintf( __( '%d posts', 'buddypress' ), $forum_template->topic->topic_posts ) );
     435    }
     436
    437437function bp_the_topic_total_posts() {
    438438    echo bp_get_the_topic_total_posts();
     
    440440    function bp_get_the_topic_total_posts() {
    441441        global $forum_template;
    442        
     442
    443443        return $forum_template->topic->topic_posts;
    444444    }
    445    
     445
    446446function bp_the_topic_tag_count() {
    447447    echo bp_get_the_topic_tag_count();
     
    458458    function bp_get_the_topic_permalink() {
    459459        global $forum_template, $bp;
    460        
     460
    461461        if ( $forum_template->topic->object_slug )
    462462            $permalink = $bp->root_domain . '/' . BP_GROUPS_SLUG . '/' . $forum_template->topic->object_slug . '/';
     
    465465        else
    466466            $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_action . '/';
    467            
     467
    468468        return apply_filters( 'bp_get_the_topic_permalink', $permalink . 'forum/topic/' . $forum_template->topic->topic_slug . '/' );
    469469    }
     
    477477        return apply_filters( 'bp_get_the_topic_time_since_created', bp_core_time_since( strtotime( $forum_template->topic->topic_start_time ) ) );
    478478    }
    479    
     479
    480480function bp_the_topic_latest_post_excerpt( $args = '' ) {
    481481    echo bp_get_the_topic_latest_post_excerpt( $args );
     
    498498function bp_the_topic_time_since_last_post( $deprecated = true ) {
    499499    global $forum_template;
    500    
     500
    501501    if ( !$deprecated )
    502502        return bp_get_the_topic_time_since_last_post();
     
    515515    function bp_get_the_topic_is_mine() {
    516516        global $bp, $forum_template;
    517    
     517
    518518        return $bp->loggedin_user->id == $forum_template->topic->topic_poster;
    519519    }
     
    523523}
    524524    function bp_get_the_topic_admin_links( $args = '' ) {
    525         global $bp, $forum_template;   
    526        
     525        global $bp, $forum_template;
     526
    527527        $defaults = array(
    528528            'seperator' => '|'
     
    533533
    534534        $links[] = '<a href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'edit', 'bp_forums_edit_topic' ) . '">' . __( 'Edit', 'buddypress' ) . '</a>';
    535        
     535
    536536        if ( $bp->is_item_admin || $bp->is_item_mod || is_site_admin() ) {
    537537            if ( 0 == (int)$forum_template->topic->topic_sticky )
     
    547547            $links[] = '<a class="confirm" id="topic-delete-link" href="' . wp_nonce_url( bp_get_the_topic_permalink() . 'delete', 'bp_forums_delete_topic' ) . '">' . __( 'Delete', 'buddypress' ) . '</a>';
    548548        }
    549        
     549
    550550        return implode( ' ' . $seperator . ' ', (array) $links );
    551551    }
     
    557557    function bp_get_the_topic_css_class() {
    558558        global $forum_template;
    559    
     559
    560560        $class = false;
    561    
     561
    562562        if ( $forum_template->current_topic % 2 == 1 )
    563563            $class .= 'alt';
    564        
     564
    565565        if ( 1 == (int)$forum_template->topic->topic_sticky )
    566566            $class .= ' sticky';
    567    
     567
    568568        if ( 0 == (int)$forum_template->topic->topic_open )
    569569            $class .= ' closed';
    570    
     570
    571571        return trim( $class );
    572572    }
     
    577577    function bp_get_my_forum_topics_link() {
    578578        global $bp;
    579        
     579
    580580        return apply_filters( 'bp_get_my_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/personal/' );
    581581    }
     
    586586    function bp_get_unreplied_forum_topics_link() {
    587587        global $bp;
    588        
     588
    589589        return apply_filters( 'bp_get_unreplied_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/unreplied/' );
    590590    }
     
    596596    function bp_get_popular_forum_topics_link() {
    597597        global $bp;
    598        
     598
    599599        return apply_filters( 'bp_get_popular_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/popular/' );
    600600    }
     
    605605    function bp_get_newest_forum_topics_link() {
    606606        global $bp;
    607        
     607
    608608        return apply_filters( 'bp_get_newest_forum_topics_link', $bp->root_domain . '/' . $bp->forums->slug . '/' );
    609609    }
     
    614614    function bp_get_forum_topic_type() {
    615615        global $bp;
    616        
     616
    617617        if ( !$bp->is_directory || !$bp->current_action )
    618618            return 'newest';
    619        
     619
    620620
    621621        return apply_filters( 'bp_get_forum_topic_type', $bp->current_action );
    622622    }
    623    
     623
    624624function bp_forums_tag_name() {
    625625    echo bp_get_forums_tag_name();
     
    627627    function bp_get_forums_tag_name() {
    628628        global $bp;
    629        
     629
    630630        if ( $bp->is_directory && $bp->forums->slug == $bp->current_component )
    631             return apply_filters( 'bp_get_forums_tag_name', $bp->action_variables[0] ); 
     631            return apply_filters( 'bp_get_forums_tag_name', $bp->action_variables[0] );
    632632    }
    633633
     
    643643function bp_forum_pagination_count() {
    644644    global $bp, $forum_template;
    645    
     645
    646646    $from_num = intval( ( $forum_template->pag_page - 1 ) * $forum_template->pag_num ) + 1;
    647     $to_num = ( $from_num + ( $forum_template->pag_num - 1  ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 ); 
    648    
     647    $to_num = ( $from_num + ( $forum_template->pag_num - 1  ) > $forum_template->total_topic_count ) ? $forum_template->total_topic_count : $from_num + ( $forum_template->pag_num - 1 );
     648
    649649    echo apply_filters( 'bp_forum_pagination_count', sprintf( __( 'Viewing topic %d to %d (%d total topics)', 'buddypress' ), $from_num, $to_num, $forum_template->total_topic_count ) );
    650650?>
     
    655655function bp_is_edit_topic() {
    656656    global $bp;
    657    
     657
    658658    if ( in_array( 'post', (array)$bp->action_variables ) && in_array( 'edit', (array)$bp->action_variables ) )
    659659        return false;
    660    
     660
    661661    return true;
    662662}
     
    668668    var $posts;
    669669    var $post;
    670    
     670
    671671    var $topic_id;
    672672    var $topic;
    673    
     673
    674674    var $in_the_loop;
    675    
     675
    676676    var $pag_page;
    677677    var $pag_num;
    678678    var $pag_links;
    679679    var $total_post_count;
    680    
     680
    681681    var $single_post = false;
    682    
     682
    683683    var $sort_by;
    684684    var $order;
    685    
     685
    686686    function BP_Forums_Template_Topic( $topic_id, $per_page, $max ) {
    687687        global $bp, $current_user, $forum_template;
    688        
     688
    689689        $this->pag_page = isset( $_REQUEST['topic_page'] ) ? intval( $_REQUEST['topic_page'] ) : 1;
    690690        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    691    
     691
    692692        $this->topic_id = $topic_id;
    693693        $forum_template->topic = (object) bp_forums_get_topic_details( $this->topic_id );
    694694
    695695        $this->posts = bp_forums_get_topic_posts( array( 'topic_id' => $this->topic_id, 'page' => $this->pag_page, 'per_page' => $this->pag_num ) );
    696        
     696
    697697        if ( !$this->posts ) {
    698698            $this->post_count = 0;
     
    724724        ));
    725725    }
    726    
     726
    727727    function has_posts() {
    728728        if ( $this->post_count )
    729729            return true;
    730        
     730
    731731        return false;
    732732    }
    733    
     733
    734734    function next_post() {
    735735        $this->current_post++;
    736736        $this->post = $this->posts[$this->current_post];
    737            
     737
    738738        return $this->post;
    739739    }
    740    
     740
    741741    function rewind_posts() {
    742742        $this->current_post = -1;
     
    745745        }
    746746    }
    747    
    748     function user_posts() { 
     747
     748    function user_posts() {
    749749        if ( $this->current_post + 1 < $this->post_count ) {
    750750            return true;
     
    758758        return false;
    759759    }
    760    
     760
    761761    function the_post() {
    762762        global $post;
     
    765765        $this->post = $this->next_post();
    766766        $this->post = (object)$this->post;
    767        
     767
    768768        if ( $this->current_post == 0 ) // loop has just started
    769769            do_action('loop_start');
     
    773773function bp_has_forum_topic_posts( $args = '' ) {
    774774    global $topic_template, $bp;
    775    
     775
    776776    $defaults = array(
    777777        'topic_id' => false,
     
    815815    function bp_get_the_topic_post_id() {
    816816        global $topic_template;
    817        
     817
    818818        return apply_filters( 'bp_get_the_topic_post_id', $topic_template->post->post_id );
    819819    }
     
    843843        extract( $r, EXTR_SKIP );
    844844
    845         return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) ); 
     845        return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
    846846    }
    847847
     
    855855        global $topic_template;
    856856
    857         return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_userlink( $topic_template->post->poster_id ) );     
     857        return apply_filters( 'bp_get_the_topic_post_poster_name', bp_core_get_userlink( $topic_template->post->poster_id ) );
    858858    }
    859859
     
    875875    function bp_get_the_topic_post_is_mine() {
    876876        global $bp, $topic_template;
    877        
     877
    878878        return $bp->loggedin_user->id == $topic_template->post->poster_id;
    879879    }
     
    883883}
    884884    function bp_get_the_topic_post_admin_links( $args = '' ) {
    885         global $topic_template; 
    886        
     885        global $topic_template;
     886
    887887        /* Never show for the first post in a topic. */
    888888        if ( 0 == $topic_template->current_post )
    889889            return;
    890        
     890
    891891        $defaults = array(
    892892            'seperator' => '|'
     
    907907    function bp_get_the_topic_post_edit_text() {
    908908        global $bp;
    909        
     909
    910910        $post = bp_forums_get_post( $bp->action_variables[4] );
    911911        return attribute_escape( $post->post_text );
     
    923923function bp_the_topic_pagination_count() {
    924924    global $bp, $topic_template;
    925    
     925
    926926    $from_num = intval( ( $topic_template->pag_page - 1 ) * $topic_template->pag_num ) + 1;
    927     $to_num = ( $from_num + ( $topic_template->pag_num - 1  ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $from_num + ( $topic_template->pag_num - 1 ); 
    928    
     927    $to_num = ( $from_num + ( $topic_template->pag_num - 1  ) > $topic_template->total_post_count ) ? $topic_template->total_post_count : $from_num + ( $topic_template->pag_num - 1 );
     928
    929929    echo apply_filters( 'bp_the_topic_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $topic_template->total_post_count ) );
    930930?>
     
    947947    function bp_get_forum_permalink() {
    948948        global $bp;
    949        
     949
    950950        if ( $bp->is_single_item )
    951951            $permalink = $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/';
     
    961961    function bp_get_forum_directory_permalink() {
    962962        global $bp;
    963        
     963
    964964        return apply_filters( 'bp_get_forum_directory_permalink', $bp->root_domain . '/' . $bp->forums->slug );
    965965    }
    966966
    967 function bp_forums_tag_heat_map( $args = '' ) { 
     967function bp_forums_tag_heat_map( $args = '' ) {
    968968    $defaults = array(
    969969        'smallest' => '10',
     
    985985        global $topic_template;
    986986
    987         return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) ); 
     987        return apply_filters( 'bp_get_forum_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
    988988    }
    989989
     
    993993    function bp_get_forum_topic_action() {
    994994        global $bp;
    995        
    996         return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );   
     995
     996        return apply_filters( 'bp_get_forum_topic_action', $bp->root_domain . attribute_escape( $_SERVER['REQUEST_URI'] ) );
    997997    }
    998998
  • trunk/bp-friends.php

    r1995 r2077  
    1616function friends_install() {
    1717    global $wpdb, $bp;
    18    
     18
    1919    if ( !empty($wpdb->charset) )
    2020        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    21        
     21
    2222    $sql[] = "CREATE TABLE {$bp->friends->table_name} (
    2323                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    3333    require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    3434    dbDelta($sql);
    35    
     35
    3636    update_site_option( 'bp-friends-db-version', BP_FRIENDS_DB_VERSION );
    3737}
     
    4242    /* For internal identification */
    4343    $bp->friends->id = 'friends';
    44        
     44
    4545    $bp->friends->table_name = $wpdb->base_prefix . 'bp_friends';
    4646    $bp->friends->format_notification_function = 'friends_format_notifications';
    4747    $bp->friends->slug = BP_FRIENDS_SLUG;
    48    
     48
    4949    /* Register this in the active components array */
    5050    $bp->active_components[$bp->friends->slug] = $bp->friends->id;
     
    5252    do_action( 'friends_setup_globals' );
    5353}
    54 add_action( 'plugins_loaded', 'friends_setup_globals', 5 ); 
     54add_action( 'plugins_loaded', 'friends_setup_globals', 5 );
    5555add_action( 'admin_menu', 'friends_setup_globals', 2 );
    5656
    57 function friends_check_installed() {   
     57function friends_check_installed() {
    5858    global $wpdb, $bp;
    5959
    6060    if ( !is_site_admin() )
    6161        return false;
    62    
     62
    6363    /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    6464    if ( get_site_option('bp-friends-db-version') < BP_FRIENDS_DB_VERSION )
     
    6969function friends_setup_nav() {
    7070    global $bp;
    71    
     71
    7272    /* Add 'Friends' to the main navigation */
    7373    bp_core_new_nav_item( array( 'name' => __('Friends', 'buddypress'), 'slug' => $bp->friends->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id ) );
    74    
     74
    7575    $friends_link = $bp->loggedin_user->domain . $bp->friends->slug . '/';
    76    
     76
    7777    /* Add the subnav items to the friends nav item */
    7878    bp_core_new_subnav_item( array( 'name' => __( 'My Friends', 'buddypress' ), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends' ) );
    7979    bp_core_new_subnav_item( array( 'name' => __( 'Requests', 'buddypress' ), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $bp->friends->slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_home() ) );
    80    
     80
    8181    if ( $bp->current_component == $bp->friends->slug ) {
    8282        if ( bp_is_home() ) {
     
    8484        } else {
    8585            $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    86             $bp->bp_options_title = $bp->displayed_user->fullname; 
     86            $bp->bp_options_title = $bp->displayed_user->fullname;
    8787        }
    8888    }
    89    
     89
    9090    do_action( 'friends_setup_nav' );
    9191}
     
    109109
    110110    do_action( 'friends_screen_my_friends' );
    111    
    112     bp_core_load_template( apply_filters( 'friends_template_my_friends', 'friends/index' ) );   
     111
     112    bp_core_load_template( apply_filters( 'friends_template_my_friends', 'friends/index' ) );
    113113}
    114114
    115115function friends_screen_requests() {
    116116    global $bp;
    117            
     117
    118118    if ( isset($bp->action_variables) && 'accept' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
    119119        /* Check the nonce */
    120         if ( !check_admin_referer( 'friends_accept_friendship' ) ) 
     120        if ( !check_admin_referer( 'friends_accept_friendship' ) )
    121121            return false;
    122                
     122
    123123        if ( friends_accept_friendship( $bp->action_variables[1] ) ) {
    124124            bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
     
    127127        }
    128128        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
    129        
     129
    130130    } else if ( isset($bp->action_variables) && 'reject' == $bp->action_variables[0] && is_numeric($bp->action_variables[1]) ) {
    131131        /* Check the nonce */
    132         if ( !check_admin_referer( 'friends_reject_friendship' ) ) 
    133             return false;       
    134        
     132        if ( !check_admin_referer( 'friends_reject_friendship' ) )
     133            return false;
     134
    135135        if ( friends_reject_friendship( $bp->action_variables[1] ) ) {
    136136            bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
    137137        } else {
    138138            bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
    139         }   
     139        }
    140140        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
    141141    }
    142    
     142
    143143    do_action( 'friends_screen_requests' );
    144    
     144
    145145    bp_core_load_template( apply_filters( 'friends_template_requests', 'friends/requests' ) );
    146146}
     
    151151}
    152152
    153 function friends_screen_notification_settings() { 
     153function friends_screen_notification_settings() {
    154154    global $current_user; ?>
    155155    <table class="notification-settings" id="friends-notification-settings">
     
    172172            <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>
    173173        </tr>
    174        
     174
    175175        <?php do_action( 'friends_screen_notification_settings' ); ?>
    176176    </table>
    177 <?php   
     177<?php
    178178}
    179179add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
     
    193193    if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'add-friend' )
    194194        return false;
    195    
     195
    196196    $potential_friend_id = $bp->action_variables[0];
    197197
     
    201201    if ( $potential_friend_id == $bp->loggedin_user->id )
    202202        return false;
    203    
     203
    204204    $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
    205205
    206206    if ( 'not_friends' == $friendship_status ) {
    207        
     207
    208208        if ( !check_admin_referer( 'friends_add_friend' ) )
    209209            return false;
    210            
     210
    211211        if ( !friends_add_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
    212212            bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' );
     
    215215        }
    216216    } else if ( 'is_friend' == $friendship_status ) {
    217         bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );       
     217        bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
    218218    } else {
    219         bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );     
    220     }
    221    
     219        bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
     220    }
     221
    222222    bp_core_redirect( wp_get_referer() );
    223    
     223
    224224    return false;
    225225}
     
    228228function friends_action_remove_friend() {
    229229    global $bp;
    230    
     230
    231231    if ( $bp->current_component != $bp->friends->slug || $bp->current_action != 'remove-friend' )
    232232        return false;
    233    
     233
    234234    $potential_friend_id = $bp->action_variables[0];
    235235
     
    239239    if ( $potential_friend_id == $bp->loggedin_user->id )
    240240        return false;
    241        
     241
    242242    $friendship_status = BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $potential_friend_id );
    243    
     243
    244244    if ( 'is_friend' == $friendship_status ) {
    245        
     245
    246246        if ( !check_admin_referer( 'friends_remove_friend' ) )
    247247            return false;
    248        
     248
    249249        if ( !friends_remove_friend( $bp->loggedin_user->id, $potential_friend_id ) ) {
    250250            bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
     
    253253        }
    254254    } else if ( 'is_friends' == $friendship_status ) {
    255         bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );       
     255        bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
    256256    } else {
    257         bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );     
    258     }
    259    
     257        bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
     258    }
     259
    260260    bp_core_redirect( wp_get_referer() );
    261    
     261
    262262    return false;
    263263}
     
    274274function friends_record_activity( $args = '' ) {
    275275    global $bp;
    276    
     276
    277277    if ( !function_exists( 'bp_activity_add' ) )
    278278        return false;
     
    291291
    292292    $r = wp_parse_args( $args, $defaults );
    293     extract( $r, EXTR_SKIP );   
     293    extract( $r, EXTR_SKIP );
    294294
    295295    return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
     
    305305function friends_register_activity_actions() {
    306306    global $bp;
    307    
     307
    308308    if ( !function_exists( 'bp_activity_set_action' ) )
    309309        return false;
     
    317317function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
    318318    global $bp;
    319    
     319
    320320    switch ( $action ) {
    321321        case 'friendship_accepted':
    322322            if ( (int)$total_items > 1 ) {
    323                 return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items );     
     323                return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest" title="' . __( 'My Friends', 'buddypress' ) . '">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items );
    324324            } else {
    325325                $user_fullname = bp_core_get_user_displayname( $item_id );
    326326                $user_url = bp_core_get_userurl( $item_id );
    327327                return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $user_url . '?new" title="' . $user_fullname .'\'s profile">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
    328             }   
     328            }
    329329        break;
    330        
     330
    331331        case 'friendship_request':
    332332            if ( (int)$total_items > 1 ) {
    333                 return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );     
     333                return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    334334            } else {
    335335                $user_fullname = bp_core_get_user_displayname( $item_id );
    336336                $user_url = bp_core_get_userurl( $item_id );
    337337                return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
    338             }   
     338            }
    339339        break;
    340340    }
    341341
    342342    do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    343    
     343
    344344    return false;
    345345}
     
    360360    if ( empty( $friend_count ) )
    361361        return false;
    362    
     362
    363363    if ( !(int)$friend_count )
    364364        return false;
    365    
     365
    366366    return true;
    367367}
     
    381381function friends_get_friendship_requests( $user_id ) {
    382382    $fship_ids = friends_get_friendship_ids( $user_id, true );
    383    
     383
    384384    return array( 'requests' => $fship_ids, 'total' => count($fship_ids) );
    385385}
     
    390390    else
    391391        $friend_ids = friends_get_friend_user_ids( $user_id );
    392    
     392
    393393    if ( !$friend_ids )
    394394        return false;
    395    
     395
    396396    if ( $filter )
    397397        $friend_ids = $friend_ids['friends'];
    398398
    399399    $ids_and_activity = friends_get_bulk_last_active( implode( ',', (array)$friend_ids ) );
    400    
     400
    401401    if ( !$ids_and_activity )
    402402        return false;
    403    
     403
    404404    $total_friends = count( $ids_and_activity );
    405    
     405
    406406    if ( $pag_num && $pag_page )
    407407        return array( 'friends' => array_slice( $ids_and_activity, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
     
    415415    else
    416416        $friend_ids = friends_get_friend_user_ids( $user_id );
    417    
     417
    418418    if ( !$friend_ids )
    419419        return false;
    420    
     420
    421421    if ( $filter )
    422422        $friend_ids = $friend_ids['friends'];
    423        
     423
    424424    $sorted_ids = BP_Friends_Friendship::sort_by_name( implode( ',', $friend_ids ) );
    425    
     425
    426426    if ( !$sorted_ids )
    427427        return false;
    428    
     428
    429429    $total_friends = count( $sorted_ids );
    430    
     430
    431431    if ( $pag_num && $pag_page )
    432432        return array( 'friends' => array_slice( $sorted_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
     
    440440    else
    441441        $friend_ids = friends_get_friend_user_ids( $user_id );
    442    
     442
    443443    if ( !$friend_ids )
    444         return false;   
     444        return false;
    445445
    446446    if ( $filter )
     
    448448
    449449    $total_friends = count( $friend_ids );
    450    
     450
    451451    if ( $pag_num && $pag_page )
    452         return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends ); 
     452        return array( 'friends' => array_slice( $friend_ids, intval( ( $pag_page - 1 ) * $pag_num), intval( $pag_num ) ), 'total' => $total_friends );
    453453    else
    454         return array( 'friends' => $friend_ids, 'total' => $total_friends );   
    455 }
    456    
     454        return array( 'friends' => $friend_ids, 'total' => $total_friends );
     455}
     456
    457457function friends_get_bulk_last_active( $friend_ids ) {
    458458    return BP_Friends_Friendship::get_bulk_last_active( $friend_ids );
     
    461461function friends_get_friends_list( $user_id ) {
    462462    global $bp;
    463    
     463
    464464    $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
    465465
     
    470470        if ( function_exists('bp_user_fullname') )
    471471            $display_name = bp_core_get_user_displayname( $friend_ids[$i] );
    472        
     472
    473473        if ( $display_name != ' ' ) {
    474474            $friends[] = array(
     
    478478        }
    479479    }
    480    
     480
    481481    if ( $friends && is_array($friends) )
    482482        usort($friends, 'friends_sort_by_name');
     
    488488}
    489489
    490     function friends_sort_by_name($a, $b) { 
     490    function friends_sort_by_name($a, $b) {
    491491        return strcasecmp($a['full_name'], $b['full_name']);
    492492    }
     
    494494function friends_get_friends_invite_list( $user_id = false, $group_id ) {
    495495    global $bp;
    496    
     496
    497497    if ( !$user_id )
    498498        $user_id = $bp->loggedin_user->id;
    499    
     499
    500500    $friend_ids = friends_get_alphabetically( $user_id );
    501501
     
    506506        if ( groups_check_user_has_invite( $friend_ids['friends'][$i]->user_id, $group_id ) || groups_is_user_member( $friend_ids['friends'][$i]->user_id, $group_id ) )
    507507            continue;
    508            
     508
    509509        $display_name = bp_core_get_user_displayname( $friend_ids['friends'][$i]->user_id );
    510        
     510
    511511        if ( $display_name != ' ' ) {
    512512            $friends[] = array(
     
    535535
    536536    $user_ids = BP_Friends_Friendship::search_users( $search_terms, $user_id, $pag_num, $pag_page );
    537    
     537
    538538    if ( !$user_ids )
    539539        return false;
     
    542542        $users[] = new BP_Core_User($user_ids[$i]);
    543543    }
    544    
     544
    545545    return array( 'users' => $users, 'count' => BP_Friends_Friendship::search_users_count($search_terms) );
    546546}
     
    551551    if ( 'is_friend' == BP_Friends_Friendship::check_is_friend( $user_id, $possible_friend_id ) )
    552552        return true;
    553    
     553
    554554    return false;
    555555}
     
    557557function friends_add_friend( $initiator_userid, $friend_userid, $force_accept = false ) {
    558558    global $bp;
    559    
     559
    560560    $friendship = new BP_Friends_Friendship;
    561    
     561
    562562    if ( (int)$friendship->is_confirmed )
    563563        return true;
    564        
     564
    565565    $friendship->initiator_user_id = $initiator_userid;
    566566    $friendship->friend_user_id = $friend_userid;
     
    568568    $friendship->is_limited = 0;
    569569    $friendship->date_created = time();
    570    
     570
    571571    if ( $force_accept )
    572572        $friendship->is_confirmed = 1;
    573    
     573
    574574    if ( $friendship->save() ) {
    575        
     575
    576576        if ( !$force_accept ) {
    577577            // Add the on screen notification
    578             bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' );   
     578            bp_core_add_notification( $friendship->initiator_user_id, $friendship->friend_user_id, 'friends', 'friendship_request' );
    579579
    580580            // Send the email notification
    581581            require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
    582582            friends_notification_new_request( $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    583            
    584             do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id ); 
     583
     584            do_action( 'friends_friendship_requested', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    585585        } else {
    586586            do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    587587        }
    588            
     588
    589589        return true;
    590590    }
    591    
     591
    592592    return false;
    593593}
     
    595595function friends_remove_friend( $initiator_userid, $friend_userid ) {
    596596    global $bp;
    597        
     597
    598598    $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid );
    599599    $friendship = new BP_Friends_Friendship( $friendship_id );
    600    
     600
    601601    // Remove the activity stream item for the user who canceled the friendship
    602602    friends_delete_activity( array( 'item_id' => $friendship_id, 'component_action' => 'friendship_accepted', 'user_id' => $bp->displayed_user->id ) );
    603    
     603
    604604    do_action( 'friends_friendship_deleted', $friendship_id, $initiator_userid, $friend_userid );
    605    
     605
    606606    if ( $friendship->delete() ) {
    607607        friends_update_friend_totals( $initiator_userid, $friend_userid, 'remove' );
    608        
     608
    609609        return true;
    610610    }
    611    
     611
    612612    return false;
    613613}
     
    615615function friends_accept_friendship( $friendship_id ) {
    616616    global $bp;
    617        
     617
    618618    $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
    619619
    620620    if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) {
    621621        friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id );
    622        
     622
    623623        /* Remove the friend request notice */
    624         bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );   
    625        
     624        bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
     625
    626626        /* Add a friend accepted notice for the initiating user */
    627627        bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_accepted' );
    628        
     628
    629629        $initiator_link = bp_core_get_userlink( $friendship->initiator_user_id );
    630630        $friend_link = bp_core_get_userlink( $friendship->friend_user_id );
    631        
     631
    632632        $primary_link = apply_filters( 'friends_activity_friendship_accepted_primary_link', bp_core_get_userlink( $friendship->initiator_user_id ), &$friendship );
    633        
     633
    634634        /* Record in activity streams for the initiator */
    635         friends_record_activity( array( 
     635        friends_record_activity( array(
    636636            'user_id' => $friendship->initiator_user_id,
    637637            'component_action' => 'friendship_created',
     
    642642
    643643        /* Record in activity streams for the friend */
    644         friends_record_activity( array( 
     644        friends_record_activity( array(
    645645            'user_id' => $friendship->friend_user_id,
    646646            'component_action' => 'friendship_created',
     
    650650            'hide_sitewide' => true /* We've already got the first entry site wide */
    651651        ) );
    652        
     652
    653653        /* Send the email notification */
    654654        require_once( BP_PLUGIN_DIR . '/bp-friends/bp-friends-notifications.php' );
     
    656656
    657657        do_action( 'friends_friendship_accepted', $friendship->id, $friendship->initiator_user_id, $friendship->friend_user_id );
    658        
     658
    659659        return true;
    660660    }
    661    
     661
    662662    return false;
    663663}
    664664
    665 function friends_reject_friendship( $friendship_id ) {     
     665function friends_reject_friendship( $friendship_id ) {
    666666    $friendship = new BP_Friends_Friendship( $friendship_id, true, false );
    667667
    668668    if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
    669669        // Remove the friend request notice
    670         bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );   
    671        
     670        bp_core_delete_notifications_for_user_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, 'friends', 'friendship_request' );
     671
    672672        do_action( 'friends_friendship_rejected', $friendship_id, &$friendship );
    673673        return true;
    674674    }
    675    
     675
    676676    return false;
    677677}
     
    688688    } else {
    689689        update_usermeta( $initiator_user_id, 'total_friend_count', (int)get_usermeta( $initiator_user_id, 'total_friend_count' ) - 1 );
    690         update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );       
     690        update_usermeta( $friend_user_id, 'total_friend_count', (int)get_usermeta( $friend_user_id, 'total_friend_count' ) - 1 );
    691691    }
    692692}
     
    694694function friends_remove_data( $user_id ) {
    695695    BP_Friends_Friendship::delete_all_for_user($user_id);
    696    
     696
    697697    /* Remove usermeta */
    698698    delete_usermeta( $user_id, 'total_friend_count' );
    699    
     699
    700700    /* Remove friendship requests FROM user */
    701701    bp_core_delete_notifications_from_user( $user_id, $bp->friends->slug, 'friendship_request' );
  • trunk/bp-friends/bp-friends-classes.php

    r2055 r2077  
    88    var $is_limited;
    99    var $date_created;
    10    
     10
    1111    var $is_request;
    1212    var $populate_friend_details;
    13    
     13
    1414    var $friend;
    15    
     15
    1616    function bp_friends_friendship( $id = null, $is_request = false, $populate_friend_details = true ) {
    1717        $this->is_request = $is_request;
    18        
     18
    1919        if ( $id ) {
    2020            $this->id = $id;
     
    2626    function populate() {
    2727        global $wpdb, $bp, $creds;
    28        
     28
    2929        if ( $friendship = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) ) ) {
    3030            $this->initiator_user_id = $friendship->initiator_user_id;
     
    3434            $this->date_created = $friendship->date_created;
    3535        }
    36        
     36
    3737        // if running from ajax.
    3838        if ( !$bp->displayed_user->id )
    3939            $bp->displayed_user->id = $creds['current_userid'];
    40        
     40
    4141        if ( $this->populate_friend_details ) {
    4242            if ( $this->friend_user_id == $bp->displayed_user->id ) {
     
    4747        }
    4848    }
    49    
     49
    5050    function save() {
    5151        global $wpdb, $bp;
     
    5757        $this->date_created = apply_filters( 'friends_friendship_date_created_before_save', $this->date_created, $this->id );
    5858
    59         do_action( 'friends_friendship_before_save', $this );       
    60        
     59        do_action( 'friends_friendship_before_save', $this );
     60
    6161        if ( $this->id ) {
    6262            // Update
     
    6868        }
    6969
    70         do_action( 'friends_friendship_after_save', $this );       
    71        
     70        do_action( 'friends_friendship_after_save', $this );
     71
    7272        return $result;
    7373    }
    74    
     74
    7575    function delete() {
    7676        global $wpdb, $bp;
    77        
     77
    7878        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d", $this->id ) );
    7979    }
    80    
     80
    8181    /* Static Functions */
    82    
     82
    8383    function get_friend_user_ids( $user_id, $friend_requests_only = false, $assoc_arr = false ) {
    8484        global $wpdb, $bp;
    85        
     85
    8686        if ( $friend_requests_only ) {
    8787            $oc_sql = $wpdb->prepare( "AND is_confirmed = 0" );
     
    9393
    9494        $friends = $wpdb->get_results( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} $friend_sql $oc_sql ORDER BY date_created DESC" ) );
    95        
     95
    9696        for ( $i = 0; $i < count($friends); $i++ ) {
    9797            if ( $assoc_arr )
     
    100100                $fids[] = ( $friends[$i]->friend_user_id == $user_id ) ? $friends[$i]->initiator_user_id : $friends[$i]->friend_user_id;
    101101        }
    102        
     102
    103103        return $fids;
    104104    }
    105    
     105
    106106    function get_friendship_ids( $user_id, $friend_requests_only = false ) {
    107107        global $wpdb, $bp;
     
    114114            $friend_sql = $wpdb->prepare ( " WHERE (initiator_user_id = %d OR friend_user_id = %d)", $user_id, $user_id );
    115115        }
    116        
     116
    117117        return $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} $friend_sql $oc_sql" ) );
    118118    }
    119    
     119
    120120    function get_friendship_id( $user_id, $friend_id ) {
    121121        global $wpdb, $bp;
    122        
     122
    123123        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->friends->table_name} WHERE ( initiator_user_id = %d AND friend_user_id = %d ) OR ( initiator_user_id = %d AND friend_user_id = %d ) AND is_confirmed = 1", $user_id, $friend_id, $friend_id, $user_id ) );
    124124    }
    125    
     125
    126126    function total_friend_count( $user_id = false) {
    127127        global $wpdb, $bp;
    128        
     128
    129129        if ( !$user_id )
    130130            $user_id = $bp->displayed_user->id;
    131            
    132         /* This is stored in 'total_friend_count' usermeta. 
     131
     132        /* This is stored in 'total_friend_count' usermeta.
    133133           This function will recalculate, update and return. */
    134        
     134
    135135        $count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d OR friend_user_id = %d) AND is_confirmed = 1", $user_id, $user_id ) );
    136136
    137137        if ( !$count )
    138138            return 0;
    139        
     139
    140140        update_usermeta( $user_id, 'total_friend_count', $count );
    141141        return $count;
    142142    }
    143    
     143
    144144    function search_friends( $filter, $user_id, $limit = null, $page = null ) {
    145145        global $wpdb, $bp;
    146        
     146
    147147        // TODO: Optimize this function.
    148        
     148
    149149        if ( !$user_id )
    150150            $user_id = $bp->loggedin_user->id;
    151        
     151
    152152        $filter = like_escape( $wpdb->escape( $filter ) );
    153        
     153
    154154        if ( $limit && $page )
    155155            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    156        
     156
    157157        if ( !$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id ) )
    158158            return false;
     
    160160        // Get all the user ids for the current user's friends.
    161161        $fids = implode( ',', $friend_ids );
    162        
     162
    163163        if ( empty($fids) )
    164164            return false;
     
    173173        }
    174174
    175         $filtered_friend_ids = $wpdb->get_col($sql);   
    176         $total_friend_ids = $wpdb->get_var($total_sql); 
    177        
     175        $filtered_friend_ids = $wpdb->get_col($sql);
     176        $total_friend_ids = $wpdb->get_var($total_sql);
     177
    178178        if ( !$filtered_friend_ids )
    179179            return false;
     
    181181        return array( 'friends' => $filtered_friend_ids, 'total' => (int)$total_friend_ids );
    182182    }
    183            
     183
    184184    function check_is_friend( $loggedin_userid, $possible_friend_userid ) {
    185185        global $wpdb, $bp;
    186        
     186
    187187        if ( !$loggedin_userid || !$possible_friend_userid )
    188188            return false;
    189            
     189
    190190        $result = $wpdb->get_results( $wpdb->prepare( "SELECT id, is_confirmed FROM {$bp->friends->table_name} WHERE (initiator_user_id = %d AND friend_user_id = %d) OR (initiator_user_id = %d AND friend_user_id = %d)", $loggedin_userid, $possible_friend_userid, $possible_friend_userid, $loggedin_userid ) );
    191        
     191
    192192        if ( $result ) {
    193193            if ( 0 == (int)$result[0]->is_confirmed ) {
     
    200200        }
    201201    }
    202    
     202
    203203    function get_bulk_last_active( $user_ids ) {
    204204        global $wpdb, $bp;
     
    206206        return $wpdb->get_results( $wpdb->prepare( "SELECT meta_value as last_activity, user_id FROM " . CUSTOM_USER_META_TABLE . " WHERE meta_key = 'last_activity' AND user_id IN ( {$user_ids} ) ORDER BY meta_value DESC" ) );
    207207    }
    208    
     208
    209209    function accept($friendship_id) {
    210210        global $wpdb, $bp;
     
    212212        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 ) );
    213213    }
    214    
     214
    215215    function reject($friendship_id) {
    216216        global $wpdb, $bp;
    217        
     217
    218218        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE id = %d AND friend_user_id = %d", $friendship_id, $bp->loggedin_user->id ) );
    219219    }
    220    
     220
    221221    function search_users( $filter, $user_id, $limit = null, $page = null ) {
    222222        global $wpdb, $bp;
    223        
     223
    224224        $filter = like_escape( $wpdb->escape( $filter ) );
     225
    225226        $usermeta_table = $wpdb->base_prefix . 'usermeta';
    226227        $users_table = $wpdb->base_prefix . 'users';
     
    228229        if ( $limit && $page )
    229230            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    230        
     231
    231232        // filter the user_ids based on the search criteria.
    232233        if ( function_exists('xprofile_install') ) {
     
    235236            $sql = $wpdb->prepare( "SELECT DISTINCT user_id as id FROM $usermeta_table WHERE meta_value LIKE '$filter%%' ORDER BY d.value DESC $pag_sql" );
    236237        }
    237        
    238         $filtered_fids = $wpdb->get_col($sql); 
    239        
     238
     239        $filtered_fids = $wpdb->get_col($sql);
     240
    240241        if ( !$filtered_fids )
    241242            return false;
     
    243244        return $filtered_fids;
    244245    }
    245    
     246
    246247    function search_users_count( $filter ) {
    247248        global $wpdb, $bp;
    248        
     249
    249250        $filter = like_escape( $wpdb->escape( $filter ) );
     251
    250252        $usermeta_table = $wpdb->prefix . 'usermeta';
    251253        $users_table = $wpdb->base_prefix . 'users';
    252        
     254
    253255        // filter the user_ids based on the search criteria.
    254256        if ( function_exists('xprofile_install') ) {
     
    258260        }
    259261
    260         $user_count = $wpdb->get_col($sql); 
    261        
     262        $user_count = $wpdb->get_col($sql);
     263
    262264        if ( !$user_count )
    263265            return false;
     
    265267        return $user_count[0];
    266268    }
    267    
     269
    268270    function sort_by_name( $user_ids ) {
    269271        global $wpdb, $bp;
    270        
     272
    271273        if ( !function_exists( 'xprofile_install') )
    272274            return false;
    273    
     275
    274276        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->profile->table_name_data} pd, {$bp->profile->table_name_fields} pf WHERE pf.id = pd.field_id AND pf.name = %s AND pd.user_id IN ( {$user_ids} ) ORDER BY pd.value ASC", BP_XPROFILE_FULLNAME_FIELD_NAME ) );
    275277    }
    276    
     278
    277279    function get_random_friends( $user_id, $total_friends = 5 ) {
    278280        global $wpdb, $bp;
     
    284286            $fids[] = ( $results[$i]->friend_user_id == $user_id ) ? $results[$i]->initiator_user_id : $results[$i]->friend_user_id;
    285287        }
    286        
     288
    287289        // remove duplicates
    288290        if ( count($fids) > 0 )
     
    291293            return false;
    292294    }
    293    
     295
    294296    function get_invitable_friend_count( $user_id, $group_id ) {
    295297        global $wpdb, $bp;
    296298
    297299        $friend_ids = BP_Friends_Friendship::get_friend_user_ids( $user_id );
    298        
     300
    299301        $invitable_count = 0;
    300302        for ( $i = 0; $i < count($friend_ids); $i++ ) {
    301            
     303
    302304            if ( BP_Groups_Member::check_is_member( (int)$friend_ids[$i], $group_id ) )
    303305                continue;
    304            
     306
    305307            if ( BP_Groups_Member::check_has_invite( (int)$friend_ids[$i], $group_id )  )
    306308                continue;
    307                
     309
    308310            $invitable_count++;
    309311        }
     
    311313        return $invitable_count;
    312314    }
    313    
     315
    314316    function get_user_ids_for_friendship( $friendship_id ) {
    315317        global $wpdb, $bp;
     
    317319        return $wpdb->get_row( $wpdb->prepare( "SELECT friend_user_id, initiator_user_id FROM {$bp->friends->table_name} WHERE id = %d", $friendship_id ) );
    318320    }
    319    
     321
    320322    function delete_all_for_user( $user_id ) {
    321323        global $wpdb, $bp;
    322324
    323         $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) ); 
    324        
    325         // Delete friend request notifications for members who have a notification from this user.     
     325        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id ) );
     326
     327        // Delete friend request notifications for members who have a notification from this user.
    326328        $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id ) );
    327329    }
    328330}
    329    
     331
    330332
    331333
  • trunk/bp-friends/bp-friends-notifications.php

    r1905 r2077  
    33function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
    44    global $bp;
    5    
     5
    66    $initiator_name = bp_core_get_user_displayname( $initiator_id );
    77
    88    if ( 'no' == get_usermeta( (int)$friend_id, 'notification_friends_friendship_request' ) )
    99        return false;
    10    
     10
    1111    $ud = get_userdata( $friend_id );
    1212    $initiator_ud = get_userdata( $initiator_id );
    13    
     13
    1414    $all_requests_link = bp_core_get_user_domain( $friend_id ) . 'friends/requests/';
    1515    $settings_link = bp_core_get_user_domain( $friend_id ) . 'settings/notifications';
    16    
     16
    1717    $initiator_link = bp_core_get_user_domain( $initiator_id );
    1818
     
    2121    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name );
    2222
    23     $message = sprintf( __( 
     23    $message = sprintf( __(
    2424"%s wants to add you as a friend.
    2525
     
    4040function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
    4141    global $bp;
    42    
     42
    4343    $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
    44    
     44
    4545    $friend_name = bp_core_get_user_displayname( $friend_id );
    4646
    4747    if ( 'no' == get_usermeta( (int)$initiator_id, 'notification_friends_friendship_accepted' ) )
    4848        return false;
    49    
     49
    5050    $ud = get_userdata( $initiator_id );
    51    
     51
    5252    $friend_link = bp_core_get_user_domain( $friend_id );
    53     $settings_link = bp_core_get_user_domain( $initiator_id ) . 'settings/notifications'; 
    54        
     53    $settings_link = bp_core_get_user_domain( $initiator_id ) . 'settings/notifications';
     54
    5555    // Set up and send the message
    5656    $to = $ud->user_email;
    5757    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );
    5858
    59     $message = sprintf( __( 
     59    $message = sprintf( __(
    6060'%s accepted your friend request.
    6161
  • trunk/bp-friends/bp-friends-templatetags.php

    r2032 r2077  
    66    var $friendships;
    77    var $friendship;
    8    
     8
    99    var $in_the_loop;
    10    
     10
    1111    var $pag_page;
    1212    var $pag_num;
    1313    var $pag_links;
    1414    var $total_friend_count;
    15    
     15
    1616    function bp_friendship_template( $user_id, $type, $per_page, $max, $filter ) {
    1717        global $bp;
     
    1919        if ( !$user_id )
    2020            $user_id = $bp->displayed_user->id;
    21                    
     21
    2222        $this->pag_page = isset( $_REQUEST['frpage'] ) ? intval( $_REQUEST['frpage'] ) : 1;
    2323        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     
    2828                $this->friendships = friends_get_newest( $user_id, $this->pag_num, $this->pag_page, $filter );
    2929                break;
    30            
     30
    3131            case 'alphabetical':
    32                 $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter );             
     32                $this->friendships = friends_get_alphabetically( $user_id, $this->pag_num, $this->pag_page, $filter );
    3333                break;
    3434
     
    3838
    3939            case 'active': default:
    40                 $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter ); 
     40                $this->friendships = friends_get_recently_active( $user_id, $this->pag_num, $this->pag_page, $filter );
    4141                break;
    4242        }
     
    7474        ));
    7575    }
    76    
     76
    7777    function has_friendships() {
    7878        if ( $this->friendship_count )
    7979            return true;
    80        
     80
    8181        return false;
    8282    }
    83    
     83
    8484    function next_friendship() {
    8585        $this->current_friendship++;
    8686        $this->friendship = $this->friendships[$this->current_friendship];
    87        
     87
    8888        return $this->friendship;
    8989    }
    90    
     90
    9191    function rewind_friendships() {
    9292        $this->current_friendship = -1;
     
    9595        }
    9696    }
    97    
    98     function user_friendships() { 
     97
     98    function user_friendships() {
    9999        if ( $this->current_friendship + 1 < $this->friendship_count ) {
    100100            return true;
     
    108108        return false;
    109109    }
    110    
     110
    111111    function the_friendship() {
    112112        global $friendship, $bp;
     
    123123            else
    124124                $user_id = $this->friendship->user_id;
    125            
     125
    126126            $this->friendship = new stdClass;
    127                
     127
    128128            if ( !$this->friendship->friend = wp_cache_get( 'bp_user_' . $user_id, 'bp' ) ) {
    129129                $this->friendship->friend = new BP_Core_User( $user_id );
    130130                wp_cache_set( 'bp_user_' . $user_id, $this->friendship->friend, 'bp' );
    131131            }
    132            
     132
    133133            /* Make sure the user_id is available in the friend object. */
    134134            $this->friendship->friend->user_id = $user_id;
     
    153153    $r = wp_parse_args( $args, $defaults );
    154154    extract( $r, EXTR_SKIP );
    155    
     155
    156156    /* The following code will auto set parameters based on the page being viewed.
    157157     * for example on example.com/members/andy/friends/my-friends/newest/
     
    167167        $type = 'requests';
    168168    }
    169    
     169
    170170    if ( isset( $_REQUEST['friend-search-box'] ) )
    171171        $filter = $_REQUEST['friend-search-box'];
     
    190190    function bp_get_friend_id() {
    191191        global $friends_template;
    192        
    193         return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id ); 
     192
     193        return apply_filters( 'bp_get_friend_id', $friends_template->friendship->friend->user_id );
    194194    }
    195195
     
    208208    function bp_get_friend_name() {
    209209        global $friends_template;
    210        
    211         return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) );   
    212     }
    213    
     210
     211        return apply_filters( 'bp_get_friend_name', strip_tags( $friends_template->friendship->friend->user_link ) );
     212    }
     213
    214214function bp_friend_link() {
    215215    echo bp_get_friend_link();
     
    238238        return apply_filters( 'bp_get_friend_last_active', $friends_template->friendship->friend->last_active );
    239239    }
    240    
     240
    241241function bp_friend_time_since_requested() {
    242242    echo bp_get_friend_time_since_requested();
     
    248248            return apply_filters( 'bp_friend_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $friends_template->friendship->date_created ) ) ) );
    249249        }
    250        
     250
    251251        return false;
    252252    }
     
    267267        global $friends_template, $bp;
    268268
    269         return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) );   
     269        return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->friends->slug . '/requests/reject/' . $friends_template->friendship->id, 'friends_reject_friendship' ) );
    270270    }
    271271
     
    275275    function bp_get_friend_pagination() {
    276276        global $friends_template;
    277        
     277
    278278        return apply_filters( 'bp_friend_pagination', $friends_template->pag_links );
    279279    }
     
    286286
    287287    echo sprintf( __( 'Viewing friend %d to %d (of %d friends)', 'buddypress' ), $from_num, $to_num, $friends_template->total_friend_count ); ?> &nbsp;
    288     <span class="ajax-loader"></span><?php 
     288    <span class="ajax-loader"></span><?php
    289289}
    290290
     
    295295        return apply_filters( 'bp_get_friend_total_for_member', BP_Friends_Friendship::total_friend_count() );
    296296    }
    297    
     297
    298298function bp_friend_search_form() {
    299299    global $friends_template, $bp;
     
    306306        <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label>
    307307        <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> />
    308        
     308
    309309        <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?>
    310310        <input type="hidden" name="initiator" id="initiator" value="<?php echo attribute_escape( $bp->displayed_user->id ) ?>" />
    311    
     311
    312312    </form>
    313313<?php
     
    317317    if ( isset( $_POST['friend-search-box'] ) )
    318318        return true;
    319    
     319
    320320    return false;
    321321}
     
    328328function bp_friend_latest_update_link() {
    329329    global $bp;
    330     echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' ); 
     330    echo apply_filters( 'bp_friend_latest_update_link', $bp->displayed_user->domain . 'my-friends/last-updated' );
    331331}
    332332
    333333function bp_friend_recent_activity_link() {
    334334    global $bp;
    335     echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' ); 
     335    echo apply_filters( 'bp_friend_recent_activity_link', $bp->displayed_user->domain . 'my-friends/recently-active' );
    336336}
    337337
    338338function bp_friend_recent_status_link() {
    339339    global $bp;
    340     echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' );   
     340    echo apply_filters( 'bp_friend_recent_status_link', $bp->displayed_user->domain . 'my-friends/status-updates' );
    341341}
    342342
     
    346346    function bp_get_add_friend_button( $potential_friend_id = false ) {
    347347        global $bp, $friends_template;
    348    
     348
    349349        $button = false;
    350        
     350
    351351        if ( is_user_logged_in() ) {
    352        
     352
    353353            if ( !$potential_friend_id && $friends_template->friendship->friend )
    354354                $potential_friend_id = $friends_template->friendship->friend->id;
     
    371371            $button .= '</div>';
    372372        }
    373        
     373
    374374        return apply_filters( 'bp_get_add_friend_button', $button );
    375375    }
     
    387387function bp_friends_filter_title() {
    388388    global $bp;
    389    
     389
    390390    $current_filter = $bp->action_variables[0];
    391    
     391
    392392    switch ( $current_filter ) {
    393393        case 'recently-active': default:
     
    405405function bp_friends_random_friends() {
    406406    global $bp;
    407    
     407
    408408    if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) {
    409409        $friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
    410410        wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' );
    411411    }
    412 ?> 
     412?>
    413413    <div class="info-group">
    414414        <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?>  (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></span></h4>
    415        
     415
    416416        <?php if ( $friend_ids ) { ?>
    417417            <ul class="horiz-gallery">
     
    435435function bp_friends_random_members( $total_members = 5 ) {
    436436    global $bp;
    437    
     437
    438438    if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) {
    439439        $user_ids = BP_Core_User::get_random_users( $total_members );
    440440        wp_cache_set( 'friends_random_users', $user_ids, 'bp' );
    441441    }
    442 ?> 
     442?>
    443443    <?php if ( $user_ids['users'] ) { ?>
    444444        <ul class="item-list" id="random-members-list">
     
    454454                    </div>
    455455                <?php } ?>
    456                
     456
    457457                <div class="action">
    458458                    <?php if ( function_exists( 'bp_add_friend_button' ) ) { ?>
     
    466466        <div id="message" class="info">
    467467            <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ) ?></p>
    468         </div>     
     468        </div>
    469469    <?php } ?>
    470470<?php
  • trunk/bp-groups.php

    r2070 r2077  
    1414/* Include deprecated functions if settings allow */
    1515if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    16     require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' );   
     16    require ( BP_PLUGIN_DIR . '/bp-groups/deprecated/bp-groups-deprecated.php' );
    1717
    1818function groups_install() {
    1919    global $wpdb, $bp;
    20    
     20
    2121    if ( !empty($wpdb->charset) )
    2222        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    23    
     23
    2424    $sql[] = "CREATE TABLE {$bp->groups->table_name} (
    2525            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    3636            KEY status (status)
    3737           ) {$charset_collate};";
    38    
     38
    3939    $sql[] = "CREATE TABLE {$bp->groups->table_name_members} (
    4040            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    6666            KEY meta_key (meta_key)
    6767           ) {$charset_collate};";
    68    
     68
    6969    require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
    7070    dbDelta($sql);
    71    
     71
    7272    /* On upgrade, handle moving of old group avatars */
    7373    $groups = groups_get_all();
    74    
     74
    7575    foreach ( $groups as $group ) {
    7676        /* Don't fetch and move gravs, default images or empties */
     
    8686            if ( !file_exists( $avatar_thumb ) || !file_exists( $avatar_full ) )
    8787                continue;
    88            
     88
    8989            $upload_dir = groups_avatar_upload_dir( $group->id );
    9090
     
    9393        }
    9494    }
    95    
     95
    9696    if ( function_exists('bp_wire_install') )
    9797        groups_wire_install();
    98    
     98
    9999    update_site_option( 'bp-groups-db-version', BP_GROUPS_DB_VERSION );
    100100}
     
    102102function groups_wire_install() {
    103103    global $wpdb, $bp;
    104    
     104
    105105    if ( !empty($wpdb->charset) )
    106106        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    107    
     107
    108108    $sql[] = "CREATE TABLE {$bp->groups->table_name_wire} (
    109109            id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    125125    /* For internal identification */
    126126    $bp->groups->id = 'groups';
    127        
     127
    128128    $bp->groups->table_name = $wpdb->base_prefix . 'bp_groups';
    129129    $bp->groups->table_name_members = $wpdb->base_prefix . 'bp_groups_members';
     
    134134    /* Register this in the active components array */
    135135    $bp->active_components[$bp->groups->slug] = $bp->groups->id;
    136        
     136
    137137    if ( function_exists('bp_wire_install') )
    138138        $bp->groups->table_name_wire = $wpdb->base_prefix . 'bp_groups_wire';
    139    
     139
    140140    $bp->groups->forbidden_names = apply_filters( 'groups_forbidden_names', array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add', 'admin', 'request-membership' ) );
    141    
    142     $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array( 
    143         'group-details' => array( 'name' => __( 'Group Details', 'buddypress' ), 'position' => 0 ), 
     141
     142    $bp->groups->group_creation_steps = apply_filters( 'groups_create_group_steps', array(
     143        'group-details' => array( 'name' => __( 'Group Details', 'buddypress' ), 'position' => 0 ),
    144144        'group-settings' => array( 'name' => __( 'Group Settings', 'buddypress' ), 'position' => 10 ),
    145145        'group-avatar' => array( 'name' => __( 'Group Avatar', 'buddypress' ), 'position' => 20 ),
    146146        'group-invites' => array( 'name' => __( 'Group Invites', 'buddypress' ), 'position' => 30 )
    147147    ) );
    148    
     148
    149149    $bp->groups->valid_status = apply_filters( 'groups_valid_status', array( 'public', 'private', 'hidden' ) );
    150150
    151151    do_action( 'groups_setup_globals' );
    152152}
    153 add_action( 'plugins_loaded', 'groups_setup_globals', 5 ); 
     153add_action( 'plugins_loaded', 'groups_setup_globals', 5 );
    154154add_action( 'admin_menu', 'groups_setup_globals', 2 );
    155155
     
    160160add_action( 'plugins_loaded', 'groups_setup_root_component', 2 );
    161161
    162 function groups_check_installed() { 
     162function groups_check_installed() {
    163163    global $wpdb, $bp;
    164    
     164
    165165    require ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-admin.php' );
    166166
     
    173173function groups_add_admin_menu() {
    174174    global $wpdb, $bp;
    175    
     175
    176176    if ( !is_site_admin() )
    177177        return false;
    178        
     178
    179179    /* Add the administration tab under the "Site Admin" tab for site administrators */
    180180    add_submenu_page( 'wpmu-admin.php', __("Groups", 'buddypress'), __("Groups", 'buddypress'), 1, "groups_admin_settings", "groups_admin_settings" );
     
    184184function groups_setup_nav() {
    185185    global $bp, $current_blog, $group_obj;
    186    
     186
    187187    if ( $group_id = BP_Groups_Group::group_exists($bp->current_action) ) {
    188        
     188
    189189        /* This is a single group page. */
    190190        $bp->is_single_item = true;
    191191        $bp->groups->current_group = &new BP_Groups_Group( $group_id );
    192    
     192
    193193        /* Using "item" not "group" for generic support in other components. */
    194194        if ( is_site_admin() )
     
    196196        else
    197197            $bp->is_item_admin = groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id );
    198        
     198
    199199        /* If the user is not an admin, check if they are a moderator */
    200200        if ( !$bp->is_item_admin )
    201201            $bp->is_item_mod = groups_is_user_mod( $bp->loggedin_user->id, $bp->groups->current_group->id );
    202        
     202
    203203        /* Is the logged in user a member of the group? */
    204204        $bp->groups->current_group->is_user_member = ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) ? true : false;
    205    
     205
    206206        /* Should this group be visible to the logged in user? */
    207207        $bp->groups->current_group->is_group_visible_to_member = ( 'public' == $bp->groups->current_group->status || $is_member ) ? true : false;
    208        
     208
    209209        /* Pre 1.1 backwards compatibility - use $bp->groups->current_group instead */
    210210        $group_obj = &$bp->groups->current_group;
     
    213213    /* Add 'Groups' to the main navigation */
    214214    bp_core_new_nav_item( array( 'name' => __('Groups', 'buddypress'), 'slug' => $bp->groups->slug, 'position' => 70, 'screen_function' => 'groups_screen_my_groups', 'default_subnav_slug' => 'my-groups', 'item_css_id' => $bp->groups->id ) );
    215    
     215
    216216    $groups_link = $bp->loggedin_user->domain . $bp->groups->slug . '/';
    217    
     217
    218218    /* Add the subnav items to the groups nav item */
    219219    bp_core_new_subnav_item( array( 'name' => __( 'My Groups', 'buddypress' ), 'slug' => 'my-groups', 'parent_url' => $groups_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_my_groups', 'position' => 10, 'item_css_id' => 'groups-my-groups' ) );
     
    222222
    223223    if ( $bp->current_component == $bp->groups->slug ) {
    224        
     224
    225225        if ( bp_is_home() && !$bp->is_single_item ) {
    226            
     226
    227227            $bp->bp_options_title = __( 'My Groups', 'buddypress' );
    228            
     228
    229229        } else if ( !bp_is_home() && !$bp->is_single_item ) {
    230230
    231231            $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    232232            $bp->bp_options_title = $bp->displayed_user->fullname;
    233            
     233
    234234        } else if ( $bp->is_single_item ) {
    235235            // We are viewing a single group, so set up the
    236236            // group navigation menu using the $bp->groups->current_group global.
    237            
     237
    238238            /* When in a single group, the first action is bumped down one because of the
    239239               group name, so we need to adjust this and set the group name to current_item. */
     
    241241            $bp->current_action = $bp->action_variables[0];
    242242            array_shift($bp->action_variables);
    243                                    
     243
    244244            $bp->bp_options_title = $bp->groups->current_group->name;
    245            
     245
    246246            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' ) ) ) )
    247247                $bp->bp_options_avatar = '<img src="' . attribute_escape( $group->avatar_full ) . '" class="avatar" alt="' . attribute_escape( $group->name ) . '" />';
    248            
     248
    249249            $group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
    250            
     250
    251251            // If this is a private or hidden group, does the user have access?
    252252            if ( 'private' == $bp->groups->current_group->status || 'hidden' == $bp->groups->current_group->status ) {
     
    261261            /* Reset the existing subnav items */
    262262            bp_core_reset_subnav_items($bp->groups->slug);
    263            
     263
    264264            /* Add a new default subnav item for when the groups nav is selected. */
    265265            bp_core_new_nav_default( array( 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'subnav_slug' => 'home' ) );
    266            
     266
    267267            /* Add the "Home" subnav item, as this will always be present */
    268268            bp_core_new_subnav_item( array( 'name' => __( 'Home', 'buddypress' ), 'slug' => 'home', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_home', 'position' => 10, 'item_css_id' => 'group-home' ) );
    269            
     269
    270270            /* If the user is a group mod or more, then show the group admin nav item */
    271271            if ( $bp->is_item_mod || $bp->is_item_admin )
     
    283283
    284284            bp_core_new_subnav_item( array( 'name' => __( 'Members', 'buddypress' ), 'slug' => 'members', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'groups_screen_group_members', 'position' => 60, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'group-members'  ) );
    285            
     285
    286286            if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    287287                if ( function_exists('friends_install') )
     
    292292        }
    293293    }
    294    
     294
    295295    do_action( 'groups_setup_nav', $bp->groups->current_group->user_has_access );
    296296}
     
    312312function groups_setup_adminbar_menu() {
    313313    global $bp;
    314    
     314
    315315    if ( !$bp->groups->current_group )
    316316        return false;
     
    322322    <li id="bp-adminbar-adminoptions-menu">
    323323        <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
    324        
     324
    325325        <ul>
    326326            <li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/delete-group/', 'groups_delete_group' ) ?>&amp;delete-group-button=1&amp;delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
    327            
     327
    328328            <?php do_action( 'groups_adminbar_menu_items' ) ?>
    329329        </ul>
     
    344344function groups_screen_my_groups() {
    345345    global $bp;
    346    
     346
    347347    bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
    348348    bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
    349349
    350350    do_action( 'groups_screen_my_groups' );
    351    
     351
    352352    bp_core_load_template( apply_filters( 'groups_template_my_groups', 'groups/index' ) );
    353353}
     
    355355function groups_screen_group_invites() {
    356356    global $bp;
    357    
     357
    358358    $group_id = $bp->action_variables[1];
    359    
     359
    360360    if ( isset($bp->action_variables) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric($group_id) ) {
    361361        /* Check the nonce */
    362362        if ( !check_admin_referer( 'groups_accept_invite' ) )
    363363            return false;
    364        
     364
    365365        if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) {
    366             bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );             
     366            bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' );
    367367        } else {
    368368            bp_core_add_message( __('Group invite accepted', 'buddypress') );
    369            
     369
    370370            /* Record this in activity streams */
    371371            $group = new BP_Groups_Group( $group_id, false, false );
    372372
    373373            groups_record_activity( array(
    374                 'content' => apply_filters( 'groups_activity_accepted_invite', 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 ), 
     374                'content' => apply_filters( 'groups_activity_accepted_invite', 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 ),
    375375                'primary_link' => apply_filters( 'groups_activity_accepted_invite_primary_link', bp_get_group_permalink( $group ), &$group ),
    376376                'component_action' => 'joined_group',
     
    380380
    381381        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
    382        
     382
    383383    } else if ( isset($bp->action_variables) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric($group_id) ) {
    384384        /* Check the nonce */
    385385        if ( !check_admin_referer( 'groups_reject_invite' ) )
    386386            return false;
    387                    
     387
    388388        if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) {
    389             bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );                         
    390         } else {           
    391             bp_core_add_message( __('Group invite rejected', 'buddypress') );           
     389            bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );
     390        } else {
     391            bp_core_add_message( __('Group invite rejected', 'buddypress') );
    392392        }
    393393
    394394        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action );
    395395    }
    396    
     396
    397397    // Remove notifications
    398398    bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'group_invite' );
    399399
    400400    do_action( 'groups_screen_group_invites', $group_id );
    401    
     401
    402402    if ( '' != locate_template( array( 'groups/invites.php' ), false ) )
    403403        bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/invites' ) );
    404404    else
    405         bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) );       
     405        bp_core_load_template( apply_filters( 'groups_template_group_invites', 'groups/list-invites' ) );
    406406}
    407407
     
    414414        unset( $bp->groups->current_create_step );
    415415        unset( $bp->groups->completed_create_steps );
    416        
     416
    417417        setcookie( 'bp_new_group_id', false, time() - 1000, COOKIEPATH );
    418418        setcookie( 'bp_completed_create_steps', false, time() - 1000, COOKIEPATH );
    419        
     419
    420420        $reset_steps = true;
    421421        bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . array_shift( array_keys( $bp->groups->group_creation_steps )  ) );
    422422    }
    423    
     423
    424424    /* If this is a creation step that is not recognized, just redirect them back to the first screen */
    425425    if ( $bp->action_variables[1] && !$bp->groups->group_creation_steps[$bp->action_variables[1]] ) {
     
    440440    /* If the save, upload or skip button is hit, lets calculate what we need to save */
    441441    if ( isset( $_POST['save'] ) ) {
    442        
     442
    443443        /* Check the nonce */
    444444        check_admin_referer( 'groups_create_save_' . $bp->groups->current_create_step );
    445        
     445
    446446        if ( 'group-details' == $bp->groups->current_create_step ) {
    447447            if ( empty( $_POST['group-name'] ) || empty( $_POST['group-desc'] ) ) {
     
    449449                bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
    450450            }
    451            
     451
    452452            if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'name' => $_POST['group-name'], 'description' => $_POST['group-desc'], 'news' => $_POST['group-news'], 'slug' => groups_check_slug( sanitize_title($_POST['group-name']) ), 'date_created' => time() ) ) ) {
    453453                bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
    454                 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );               
    455             }
    456            
     454                bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
     455            }
     456
    457457            groups_update_groupmeta( $bp->groups->new_group_id, 'total_member_count', 1 );
    458458            groups_update_groupmeta( $bp->groups->new_group_id, 'last_activity', time() );
     
    460460            groups_update_groupmeta( $bp->groups->new_group_id, 'stylesheet', 'buddypress' );
    461461        }
    462        
     462
    463463        if ( 'group-settings' == $bp->groups->current_create_step ) {
    464464            $group_status = 'public';
    465465            $group_enable_wire = 1;
    466466            $group_enable_forum = 1;
    467            
     467
    468468            if ( !isset($_POST['group-show-wire']) )
    469469                $group_enable_wire = 0;
    470            
     470
    471471            if ( !isset($_POST['group-show-forum']) ) {
    472472                $group_enable_forum = 0;
     
    477477                }
    478478            }
    479            
     479
    480480            if ( 'private' == $_POST['group-status'] )
    481481                $group_status = 'private';
    482482            else if ( 'hidden' == $_POST['group-status'] )
    483483                $group_status = 'hidden';
    484        
     484
    485485            if ( !$bp->groups->new_group_id = groups_create_group( array( 'group_id' => $bp->groups->new_group_id, 'status' => $group_status, 'enable_wire' => $group_enable_wire, 'enable_forum' => $group_enable_forum ) ) ) {
    486486                bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
    487                 bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );               
     487                bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->groups->current_create_step );
    488488            }
    489489        }
     
    495495        do_action( 'groups_create_group_step_save_' . $bp->groups->current_create_step );
    496496        do_action( 'groups_create_group_step_complete' ); // Mostly for clearing cache on a generic action name
    497        
     497
    498498        /**
    499499         * Once we have successfully saved the details for this step of the creation process
     
    503503        if ( !in_array( $bp->groups->current_create_step, (array)$bp->groups->completed_create_steps ) )
    504504            $bp->groups->completed_create_steps[] = $bp->groups->current_create_step;
    505        
     505
    506506        /* Reset cookie info */
    507507        setcookie( 'bp_new_group_id', $bp->groups->new_group_id, time()+60*60*24, COOKIEPATH );
    508         setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );   
     508        setcookie( 'bp_completed_create_steps', serialize( $bp->groups->completed_create_steps ), time()+60*60*24, COOKIEPATH );
    509509
    510510        /* If we have completed all steps and hit done on the final step we can redirect to the completed group */
     
    512512            unset( $bp->groups->current_create_step );
    513513            unset( $bp->groups->completed_create_steps );
    514            
     514
    515515            /* Once we compelete all steps, record the group creation in the activity stream. */
    516516            groups_record_activity( array(
    517                 'content' => apply_filters( 'groups_activity_created_group', 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>' ) ), 
     517                'content' => apply_filters( 'groups_activity_created_group', 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>' ) ),
    518518                'primary_link' => apply_filters( 'groups_activity_created_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    519519                'component_action' => 'created_group',
    520520                'item_id' => $bp->groups->new_group_id
    521521            ) );
    522            
     522
    523523            do_action( 'groups_group_create_complete', $bp->groups->new_group_id );
    524            
     524
    525525            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    526526        } else {
     
    531531            foreach ( $bp->groups->group_creation_steps as $key => $value ) {
    532532                if ( $key == $bp->groups->current_create_step ) {
    533                     $next = 1; 
     533                    $next = 1;
    534534                    continue;
    535535                }
    536                
     536
    537537                if ( $next ) {
    538                     $next_step = $key; 
     538                    $next_step = $key;
    539539                    break;
    540540                }
     
    544544        }
    545545    }
    546    
     546
    547547    /* Group avatar is handled separately */
    548548    if ( 'group-avatar' == $bp->groups->current_create_step && isset( $_POST['upload'] ) ) {
     
    551551
    552552            /* Pass the file to the avatar upload handler */
    553             if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {       
     553            if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
    554554                $bp->avatar_admin->step = 'crop-image';
    555555
     
    562562        if ( isset( $_POST['avatar-crop-submit'] ) && isset( $_POST['upload'] ) ) {
    563563            /* Normally we would check a nonce here, but the group save nonce is used instead */
    564            
     564
    565565            if ( !bp_core_avatar_handle_crop( array( 'object' => 'group', 'avatar_dir' => 'group-avatars', 'item_id' => $bp->groups->current_group->id, 'original_file' => $_POST['image_src'], 'crop_x' => $_POST['x'], 'crop_y' => $_POST['y'], 'crop_w' => $_POST['w'], 'crop_h' => $_POST['h'] ) ) )
    566566                bp_core_add_message( __( 'There was an error saving the group avatar, please try uploading again.', 'buddypress' ), 'error' );
     
    576576function groups_screen_group_home() {
    577577    global $bp;
    578    
     578
    579579    if ( $bp->is_single_item ) {
    580        
     580
    581581        if ( isset($_GET['new']) ) {
    582582            // Delete group request notifications for the user
     
    585585            bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_mod' );
    586586            bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'member_promoted_to_admin' );
    587         }   
    588 
    589         do_action( 'groups_screen_group_home' );   
    590        
     587        }
     588
     589        do_action( 'groups_screen_group_home' );
     590
    591591        if ( '' != locate_template( array( 'groups/single/home.php' ), false ) )
    592592            bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
     
    598598function groups_screen_group_forum() {
    599599    global $bp;
    600    
     600
    601601    if ( $bp->is_single_item && $bp->groups->current_group->user_has_access ) {
    602        
     602
    603603        /* Fetch the details we need */
    604604        $topic_slug = $bp->action_variables[1];
     
    612612                /* Check the nonce */
    613613                check_admin_referer( 'bp_forums_new_reply' );
    614                
     614
    615615                /* Auto join this user if they are not yet a member of this group */
    616616                if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
    617617                    groups_join_group( $bp->groups->current_group->id, $bp->loggedin_user->id );
    618                
     618
    619619                if ( !groups_new_group_forum_post( $_POST['reply_text'], $topic_id ) )
    620620                    bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
    621621                else
    622622                    bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );
    623                
     623
    624624                if ( $_SERVER['QUERY_STRING'] )
    625                     $query_vars = '?' . $_SERVER['QUERY_STRING'];           
    626                
     625                    $query_vars = '?' . $_SERVER['QUERY_STRING'];
     626
    627627                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' . $query_vars );
    628628            }
    629            
     629
    630630            /* Sticky a topic */
    631631            else if ( 'stick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
     
    637637                else
    638638                    bp_core_add_message( __( 'The topic was made sticky successfully', 'buddypress' ) );
    639            
     639
    640640                do_action( 'groups_stick_forum_topic', $topic_id );
    641641                bp_core_redirect( wp_get_referer() );
    642642            }
    643            
     643
    644644            /* Un-Sticky a topic */
    645645            else if ( 'unstick' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
    646646                /* Check the nonce */
    647647                check_admin_referer( 'bp_forums_unstick_topic' );
    648    
     648
    649649                if ( !bp_forums_sticky_topic( array( 'topic_id' => $topic_id, 'mode' => 'unstick' ) ) )
    650650                    bp_core_add_message( __( 'There was an error when unsticking that topic', 'buddypress'), 'error' );
    651651                else
    652652                    bp_core_add_message( __( 'The topic was unstuck successfully', 'buddypress') );
    653            
     653
    654654                do_action( 'groups_unstick_forum_topic', $topic_id );
    655655                bp_core_redirect( wp_get_referer() );
    656656            }
    657            
     657
    658658            /* Close a topic */
    659659            else if ( 'close' == $bp->action_variables[2] && ( $bp->is_item_admin || $bp->is_item_mod ) ) {
    660660                /* Check the nonce */
    661661                check_admin_referer( 'bp_forums_close_topic' );
    662    
     662
    663663                if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id ) ) )
    664664                    bp_core_add_message( __( 'There was an error when closing that topic', 'buddypress'), 'error' );
    665665                else
    666666                    bp_core_add_message( __( 'The topic was closed successfully', 'buddypress') );
    667            
     667
    668668                do_action( 'groups_close_forum_topic', $topic_id );
    669669                bp_core_redirect( wp_get_referer() );
     
    674674                /* Check the nonce */
    675675                check_admin_referer( 'bp_forums_open_topic' );
    676    
     676
    677677                if ( !bp_forums_openclose_topic( array( 'topic_id' => $topic_id, 'mode' => 'open' ) ) )
    678678                    bp_core_add_message( __( 'There was an error when opening that topic', 'buddypress'), 'error' );
    679679                else
    680680                    bp_core_add_message( __( 'The topic was opened successfully', 'buddypress') );
    681            
     681
    682682                do_action( 'groups_open_forum_topic', $topic_id );
    683683                bp_core_redirect( wp_get_referer() );
     
    692692                if ( !$bp->is_item_admin && !$bp->is_item_mod && (int)$bp->loggedin_user->id != (int)$topic->topic_poster )
    693693                    bp_core_redirect( wp_get_referer() );
    694                
     694
    695695                /* Check the nonce */
    696696                check_admin_referer( 'bp_forums_delete_topic' );
    697    
     697
    698698                if ( !groups_delete_group_forum_topic( $topic_id ) )
    699699                    bp_core_add_message( __( 'There was an error deleting the topic', 'buddypress'), 'error' );
    700700                else
    701701                    bp_core_add_message( __( 'The topic was deleted successfully', 'buddypress') );
    702                
     702
    703703                do_action( 'groups_delete_forum_topic', $topic_id );
    704704                bp_core_redirect( wp_get_referer() );
    705705            }
    706            
     706
    707707            /* Editing a topic */
    708708            else if ( 'edit' == $bp->action_variables[2] && empty( $bp->action_variables[3] ) ) {
     
    717717                    /* Check the nonce */
    718718                    check_admin_referer( 'bp_forums_edit_topic' );
    719        
     719
    720720                    if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'], $_POST['topic_text'] ) )
    721721                        bp_core_add_message( __( 'There was an error when editing that topic', 'buddypress'), 'error' );
    722722                    else
    723723                        bp_core_add_message( __( 'The topic was edited successfully', 'buddypress') );
    724                
     724
    725725                    do_action( 'groups_edit_forum_topic', $topic_id );
    726726                    bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' );
    727727                }
    728                
     728
    729729                bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) );
    730730            }
    731            
     731
    732732            /* Delete a post */
    733733            else if ( 'delete' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
     
    746746                else
    747747                    bp_core_add_message( __( 'The post was deleted successfully', 'buddypress') );
    748                
     748
    749749                do_action( 'groups_delete_forum_post', $post_id );
    750750                bp_core_redirect( wp_get_referer() );
    751751            }
    752                
     752
    753753            /* Editing a post */
    754754            else if ( 'edit' == $bp->action_variables[2] && $post_id = $bp->action_variables[4] ) {
     
    763763                    /* Check the nonce */
    764764                    check_admin_referer( 'bp_forums_edit_post' );
    765                            
     765
    766766                    if ( !groups_update_group_forum_post( $post_id, $_POST['post_text'], $topic_id ) )
    767767                        bp_core_add_message( __( 'There was an error when editing that post', 'buddypress'), 'error' );
    768768                    else
    769769                        bp_core_add_message( __( 'The post was edited successfully', 'buddypress') );
    770                    
     770
    771771                    do_action( 'groups_edit_forum_post', $post_id );
    772772                    bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic_slug . '/' );
    773773                }
    774                
     774
    775775                bp_core_load_template( apply_filters( 'groups_template_group_forum_topic_edit', 'groups/single/forum/edit' ) );
    776776            }
     
    783783                    bp_core_load_template( apply_filters( 'groups_template_group_forum_topic', 'groups/forum/topic' ) );
    784784            }
    785            
     785
    786786        } else {
    787787
    788788            /* Posting a topic */
    789789            if ( isset( $_POST['submit_topic'] ) && function_exists( 'bp_forums_new_topic') ) {
    790                 /* Check the nonce */   
     790                /* Check the nonce */
    791791                check_admin_referer( 'bp_forums_new_topic' );
    792                
     792
    793793                /* Auto join this user if they are not yet a member of this group */
    794794                if ( !is_site_admin() && 'public' == $bp->groups->current_group->status && !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) )
     
    799799                else
    800800                    bp_core_add_message( __( 'The topic was created successfully', 'buddypress') );
    801                    
     801
    802802                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/forum/topic/' . $topic->topic_slug . '/' );
    803803            }
    804            
     804
    805805            do_action( 'groups_screen_group_forum', $topic_id, $forum_id );
    806            
     806
    807807            if ( '' != locate_template( array( 'groups/single/forum/index.php' ), false ) )
    808808                bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/forum/index' ) );
    809809            else
    810                 bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) );             
     810                bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/forum/index' ) );
    811811        }
    812812    }
     
    815815function groups_screen_group_wire() {
    816816    global $bp;
    817    
     817
    818818    $wire_action = $bp->action_variables[0];
    819        
     819
    820820    if ( $bp->is_single_item ) {
    821821        if ( 'post' == $wire_action && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    822822            /* Check the nonce first. */
    823             if ( !check_admin_referer( 'bp_wire_post' ) ) 
     823            if ( !check_admin_referer( 'bp_wire_post' ) )
    824824                return false;
    825        
     825
    826826            if ( !groups_new_wire_post( $bp->groups->current_group->id, $_POST['wire-post-textarea'] ) )
    827827                bp_core_add_message( __('Wire message could not be posted.', 'buddypress'), 'error' );
     
    833833            else
    834834                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
    835    
     835
    836836        } else if ( 'delete' == $wire_action && groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    837837            $wire_message_id = $bp->action_variables[1];
     
    840840            if ( !check_admin_referer( 'bp_wire_delete_link' ) )
    841841                return false;
    842        
     842
    843843            if ( !groups_delete_wire_post( $wire_message_id, $bp->groups->table_name_wire ) )
    844844                bp_core_add_message( __('There was an error deleting the wire message.', 'buddypress'), 'error' );
    845845            else
    846846                bp_core_add_message( __('Wire message successfully deleted.', 'buddypress') );
    847            
     847
    848848            if ( !strpos( wp_get_referer(), $bp->wire->slug ) )
    849849                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    850850            else
    851851                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/' . $bp->wire->slug );
    852        
     852
    853853        } else if ( ( !$wire_action || 'latest' == $bp->action_variables[1] ) ) {
    854854            if ( '' != locate_template( array( 'groups/single/wire.php' ), false ) )
    855855                bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/single/wire' ) );
    856             else   
     856            else
    857857                bp_core_load_template( apply_filters( 'groups_template_group_wire', 'groups/wire' ) );
    858858        } else {
    859859            if ( '' != locate_template( array( 'groups/single/home.php' ), false ) )
    860860                bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
    861             else   
     861            else
    862862                bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
    863863        }
     
    867867function groups_screen_group_members() {
    868868    global $bp;
    869    
     869
    870870    if ( $bp->is_single_item ) {
    871871        do_action( 'groups_screen_group_members', $bp->groups->current_group->id );
     
    874874            bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/single/members' ) );
    875875        else
    876             bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/list-members' ) );     
     876            bp_core_load_template( apply_filters( 'groups_template_group_forum', 'groups/list-members' ) );
    877877    }
    878878}
     
    880880function groups_screen_group_invite() {
    881881    global $bp;
    882    
     882
    883883    if ( $bp->is_single_item ) {
    884884        if ( isset($bp->action_variables) && 'send' == $bp->action_variables[0] ) {
    885            
     885
    886886            if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) )
    887887                return false;
    888        
     888
    889889            // Send the invites.
    890890            groups_send_invites( $bp->loggedin_user->id, $bp->groups->current_group->id );
    891            
     891
    892892            bp_core_add_message( __('Group invites sent.', 'buddypress') );
    893893
     
    898898            // Show send invite page
    899899            if ( '' != locate_template( array( 'groups/single/send-invite.php' ), false ) )
    900                 bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/send-invite' ) ); 
     900                bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/single/send-invite' ) );
    901901            else
    902                 bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) ); 
     902                bp_core_load_template( apply_filters( 'groups_template_group_invite', 'groups/send-invite' ) );
    903903        }
    904904    }
     
    907907function groups_screen_group_leave() {
    908908    global $bp;
    909    
     909
    910910    if ( $bp->is_single_item ) {
    911911        if ( isset($bp->action_variables) && 'yes' == $bp->action_variables[0] ) {
    912            
     912
    913913            // Check if the user is the group admin first.
    914914            if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     
    916916                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    917917            }
    918            
     918
    919919            // remove the user from the group.
    920920            if ( !groups_leave_group( $bp->groups->current_group->id ) ) {
     
    925925                bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug );
    926926            }
    927            
     927
    928928        } else if ( isset($bp->action_variables) && 'no' == $bp->action_variables[0] ) {
    929            
     929
    930930            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    931        
     931
    932932        } else {
    933        
     933
    934934            do_action( 'groups_screen_group_leave', $bp->groups->current_group->id );
    935            
     935
    936936            // Show leave group page
    937937            if ( '' != locate_template( array( 'groups/single/leave-confirm.php' ), false ) )
    938938                bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/single/leave-confirm' ) );
    939939            else
    940                 bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) );             
     940                bp_core_load_template( apply_filters( 'groups_template_group_leave', 'groups/leave-group-confirm' ) );
    941941        }
    942942    }
     
    945945function groups_screen_group_request_membership() {
    946946    global $bp;
    947    
     947
    948948    if ( !is_user_logged_in() )
    949949        return false;
    950    
     950
    951951    if ( 'private' == $bp->groups->current_group->status ) {
    952952        // If the user has submitted a request, send it.
     
    955955            if ( !check_admin_referer( 'groups_request_membership' ) )
    956956                return false;
    957        
     957
    958958            if ( !groups_send_membership_request( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    959959                bp_core_add_message( __( 'There was an error sending your group membership request, please try again.', 'buddypress' ), 'error' );
     
    963963            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    964964        }
    965        
     965
    966966        do_action( 'groups_screen_group_request_membership', $bp->groups->current_group->id );
    967        
     967
    968968        if ( '' != locate_template( array( 'groups/single/request-membership.php' ), false ) )
    969969            bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/single/request-membership' ) );
    970970        else
    971             bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) );         
     971            bp_core_load_template( apply_filters( 'groups_template_group_request_membership', 'groups/request-membership' ) );
    972972    }
    973973}
     
    975975function groups_screen_group_admin() {
    976976    global $bp;
    977    
     977
    978978    if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
    979979        return false;
    980    
     980
    981981    if ( !empty( $bp->action_variables[0] ) )
    982982        return false;
    983    
     983
    984984    bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' );
    985985}
     
    987987function groups_screen_group_admin_edit_details() {
    988988    global $bp;
    989    
     989
    990990    if ( $bp->current_component == $bp->groups->slug && 'edit-details' == $bp->action_variables[0] ) {
    991    
     991
    992992        if ( $bp->is_item_admin || $bp->is_item_mod  ) {
    993        
     993
    994994            // If the edit form has been submitted, save the edited details
    995995            if ( isset( $_POST['save'] ) ) {
     
    997997                if ( !check_admin_referer( 'groups_edit_group_details' ) )
    998998                    return false;
    999        
     999
    10001000                if ( !groups_edit_base_group_details( $_POST['group-id'], $_POST['group-name'], $_POST['group-desc'], $_POST['group-news'], (int)$_POST['group-notify-members'] ) ) {
    10011001                    bp_core_add_message( __( 'There was an error updating group details, please try again.', 'buddypress' ), 'error' );
     
    10031003                    bp_core_add_message( __( 'Group details were successfully updated.', 'buddypress' ) );
    10041004                }
    1005                
     1005
    10061006                do_action( 'groups_group_details_edited', $bp->groups->current_group->id );
    1007                
     1007
    10081008                bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/edit-details' );
    10091009            }
     
    10121012
    10131013            if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
    1014                 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );     
     1014                bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );
    10151015            else
    1016                 bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) );           
     1016                bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/admin/edit-details' ) );
    10171017        }
    10181018    }
     
    10221022function groups_screen_group_admin_settings() {
    10231023    global $bp;
    1024    
     1024
    10251025    if ( $bp->current_component == $bp->groups->slug && 'group-settings' == $bp->action_variables[0] ) {
    1026        
     1026
    10271027        if ( !$bp->is_item_admin )
    10281028            return false;
    1029        
     1029
    10301030        // If the edit form has been submitted, save the edited details
    10311031        if ( isset( $_POST['save'] ) ) {
     
    10341034            $enable_photos = ( isset($_POST['group-show-photos'] ) ) ? 1 : 0;
    10351035            $photos_admin_only = ( $_POST['group-photos-status'] != 'all' ) ? 1 : 0;
    1036            
     1036
    10371037            $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) );
    10381038            $status = ( in_array( $_POST['group-status'], (array)$allowed_status ) ) ? $_POST['group-status'] : 'public';
    1039            
     1039
    10401040            /* Check the nonce first. */
    10411041            if ( !check_admin_referer( 'groups_edit_group_settings' ) )
    10421042                return false;
    1043            
     1043
    10441044            if ( !groups_edit_group_settings( $_POST['group-id'], $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) ) {
    10451045                bp_core_add_message( __( 'There was an error updating group settings, please try again.', 'buddypress' ), 'error' );
     
    10491049
    10501050            do_action( 'groups_group_settings_edited', $bp->groups->current_group->id );
    1051            
     1051
    10521052            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-settings' );
    10531053        }
    10541054
    10551055        do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id );
    1056        
     1056
    10571057        if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
    1058             bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/admin' ) );       
     1058            bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/admin' ) );
    10591059        else
    10601060            bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/admin/group-settings' ) );
     
    10651065function groups_screen_group_admin_avatar() {
    10661066    global $bp;
    1067    
     1067
    10681068    if ( $bp->current_component == $bp->groups->slug && 'group-avatar' == $bp->action_variables[0] ) {
    1069        
     1069
    10701070        if ( !$bp->is_item_admin )
    10711071            return false;
    1072            
     1072
    10731073        /* If the group admin has deleted the admin avatar */
    10741074        if ( 'delete' == $bp->action_variables[1] ) {
    1075            
     1075
    10761076            /* Check the nonce */
    10771077            check_admin_referer( 'bp_group_avatar_delete' );
    1078            
     1078
    10791079            if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group' ) ) )
    10801080                bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) );
    10811081            else
    10821082                bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' );
    1083        
    1084         }   
    1085        
     1083
     1084        }
     1085
    10861086        $bp->avatar_admin->step = 'upload-image';
    10871087
     
    10921092
    10931093            /* Pass the file to the avatar upload handler */
    1094             if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {       
     1094            if ( bp_core_avatar_handle_upload( $_FILES, 'groups_avatar_upload_dir' ) ) {
    10951095                $bp->avatar_admin->step = 'crop-image';
    10961096
     
    11141114        }
    11151115
    1116         do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id );   
    1117        
     1116        do_action( 'groups_screen_group_admin_avatar', $bp->groups->current_group->id );
     1117
    11181118        if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
    1119             bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/admin' ) );     
     1119            bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/single/admin' ) );
    11201120        else
    1121             bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) );       
     1121            bp_core_load_template( apply_filters( 'groups_template_group_admin_avatar', 'groups/admin/group-avatar' ) );
    11221122    }
    11231123}
     
    11281128
    11291129    if ( $bp->current_component == $bp->groups->slug && 'manage-members' == $bp->action_variables[0] ) {
    1130        
     1130
    11311131        if ( !$bp->is_item_admin )
    11321132            return false;
    1133        
     1133
    11341134        if ( 'promote' == $bp->action_variables[1] && ( 'mod' == $bp->action_variables[2] || 'admin' == $bp->action_variables[2] ) && is_numeric( $bp->action_variables[3] ) ) {
    11351135            $user_id = $bp->action_variables[3];
    11361136            $status = $bp->action_variables[2];
    1137            
     1137
    11381138            /* Check the nonce first. */
    11391139            if ( !check_admin_referer( 'groups_promote_member' ) )
    11401140                return false;
    1141        
     1141
    11421142            // Promote a user.
    11431143            if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) {
     
    11461146                bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
    11471147            }
    1148            
     1148
    11491149            do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
    11501150
    11511151            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
    11521152        }
    1153        
     1153
    11541154        if ( 'demote' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
    11551155            $user_id = $bp->action_variables[2];
     
    11571157            /* Check if the user is the group admin first. */
    11581158            if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    1159                 bp_core_add_message(  __('As the only group administrator, you cannot demote yourself.', 'buddypress'), 'error' );
    1160                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     1159                    bp_core_add_message(  __('As the only group administrator, you cannot demote yourself.', 'buddypress'), 'error' );
     1160                    bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    11611161            }
    11621162
     
    11641164            if ( !check_admin_referer( 'groups_demote_member' ) )
    11651165                return false;
    1166                    
     1166
    11671167            // Demote a user.
    11681168            if ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) ) {
     
    11761176            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
    11771177        }
    1178        
     1178
    11791179        if ( 'ban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
    11801180            $user_id = $bp->action_variables[2];
     
    11821182            /* Check if the user is the group admin first. */
    11831183            if ( groups_is_user_admin( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
    1184                 bp_core_add_message(  __('As the only group administrator, you cannot ban yourself.', 'buddypress'), 'error' );
    1185                 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
     1184                    bp_core_add_message(  __('As the only group administrator, you cannot ban yourself.', 'buddypress'), 'error' );
     1185                    bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) );
    11861186            }
    11871187
     
    11891189            if ( !check_admin_referer( 'groups_ban_member' ) )
    11901190                return false;
    1191                    
     1191
    11921192            // Ban a user.
    11931193            if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) ) {
     
    12011201            bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/manage-members' );
    12021202        }
    1203        
     1203
    12041204        if ( 'unban' == $bp->action_variables[1] && is_numeric( $bp->action_variables[2] ) ) {
    12051205            $user_id = $bp->action_variables[2];
     
    12081208            if ( !check_admin_referer( 'groups_unban_member' ) )
    12091209                return false;
    1210                    
     1210
    12111211            // Remove a ban for user.
    12121212            if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) ) {
     
    12221222
    12231223        do_action( 'groups_screen_group_admin_manage_members', $bp->groups->current_group->id );
    1224        
     1224
    12251225        if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
    1226             bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/admin' ) );     
     1226            bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/single/admin' ) );
    12271227        else
    12281228            bp_core_load_template( apply_filters( 'groups_template_group_admin_manage_members', 'groups/admin/manage-members' ) );
     
    12331233function groups_screen_group_admin_requests() {
    12341234    global $bp;
    1235    
     1235
    12361236    if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {
    1237        
     1237
    12381238        if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status )
    12391239            return false;
    1240        
     1240
    12411241        // Remove any screen notifications
    12421242        bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request' );
    1243        
     1243
    12441244        $request_action = $bp->action_variables[1];
    12451245        $membership_id = $bp->action_variables[2];
     
    12511251                if ( !check_admin_referer( 'groups_accept_membership_request' ) )
    12521252                    return false;
    1253        
     1253
    12541254                // Accept the membership request
    12551255                if ( !groups_accept_membership_request( $membership_id ) ) {
     
    12631263                if ( !check_admin_referer( 'groups_reject_membership_request' ) )
    12641264                    return false;
    1265        
     1265
    12661266                // Reject the membership request
    12671267                if ( !groups_reject_membership_request( $membership_id ) ) {
     
    12691269                } else {
    12701270                    bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
    1271                 }   
    1272 
    1273             }
    1274            
     1271                }
     1272
     1273            }
     1274
    12751275            do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id );
    12761276
     
    12811281
    12821282        if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
    1283             bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/admin' ) );       
     1283            bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/admin' ) );
    12841284        else
    1285             bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) );       
     1285            bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/admin/membership-requests' ) );
    12861286    }
    12871287}
     
    12901290function groups_screen_group_admin_delete_group() {
    12911291    global $bp;
    1292    
     1292
    12931293    if ( $bp->current_component == $bp->groups->slug && 'delete-group' == $bp->action_variables[0] ) {
    1294        
     1294
    12951295        if ( !$bp->is_item_admin && !is_site_admin() )
    12961296            return false;
    1297        
     1297
    12981298        if ( isset( $_REQUEST['delete-group-button'] ) && isset( $_REQUEST['delete-group-understand'] ) ) {
    12991299            /* Check the nonce first. */
    13001300            if ( !check_admin_referer( 'groups_delete_group' ) )
    13011301                return false;
    1302        
     1302
    13031303            // Group admin has deleted the group, now do it.
    13041304            if ( !groups_delete_group( $bp->groups->current_group->id ) ) {
     
    13181318
    13191319        if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
    1320             bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/admin' ) );       
     1320            bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/single/admin' ) );
    13211321        else
    1322             bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) );     
     1322            bp_core_load_template( apply_filters( 'groups_template_group_admin_delete_group', 'groups/admin/delete-group' ) );
    13231323    }
    13241324}
    13251325add_action( 'wp', 'groups_screen_group_admin_delete_group', 4 );
    13261326
    1327 function groups_screen_notification_settings() { 
     1327function groups_screen_notification_settings() {
    13281328    global $current_user; ?>
    13291329    <table class="notification-settings" id="groups-notification-settings">
     
    13661366            <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>
    13671367        </tr>
    1368        
     1368
    13691369        <?php do_action( 'groups_screen_notification_settings' ); ?>
    13701370    </table>
    1371 <?php   
     1371<?php
    13721372}
    13731373add_action( 'bp_notification_settings', 'groups_screen_notification_settings' );
     
    13841384function groups_action_join_group() {
    13851385    global $bp;
    1386        
     1386
    13871387    if ( !$bp->is_single_item || $bp->current_component != $bp->groups->slug || $bp->current_action != 'join' )
    13881388        return false;
    1389        
     1389
    13901390    // user wants to join a group
    13911391    if ( !groups_is_user_member( $bp->loggedin_user->id, $bp->groups->current_group->id ) && !groups_is_user_banned( $bp->loggedin_user->id, $bp->groups->current_group->id ) ) {
     
    13991399
    14001400    if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) )
    1401         bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );       
     1401        bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
    14021402    else
    14031403        bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/group-home' ) );
     
    14071407function groups_action_sort_creation_steps() {
    14081408    global $bp;
    1409    
     1409
    14101410    if ( $bp->current_component != BP_GROUPS_SLUG && $bp->current_action != 'create' )
    14111411        return false;
     
    14131413    if ( !is_array( $bp->groups->group_creation_steps ) )
    14141414        return false;
    1415        
     1415
    14161416    foreach ( $bp->groups->group_creation_steps as $slug => $step )
    14171417        $temp[$step['position']] = array( 'name' => $step['name'], 'slug' => $slug );
     
    14201420    ksort($temp);
    14211421    unset($bp->groups->group_creation_steps);
    1422    
     1422
    14231423    foreach( $temp as $position => $step )
    14241424        $bp->groups->group_creation_steps[$step['slug']] = array( 'name' => $step['name'], 'position' => $position );
     
    14281428function groups_aciton_redirect_to_random_group() {
    14291429    global $bp, $wpdb;
    1430    
     1430
    14311431    if ( $bp->current_component == $bp->groups->slug && isset( $_GET['random-group'] ) ) {
    14321432        $group = groups_get_random_groups( 1, 1 );
     
    14471447function groups_register_activity_actions() {
    14481448    global $bp;
    1449    
     1449
    14501450    if ( !function_exists( 'bp_activity_set_action' ) )
    14511451        return false;
     
    14631463function groups_record_activity( $args = '' ) {
    14641464    global $bp;
    1465    
     1465
    14661466    if ( !function_exists( 'bp_activity_add' ) )
    14671467        return false;
    1468    
     1468
    14691469    /* If the group is not public, no recording of activity please. */
    1470     if ( 'public' != $bp->groups->current_group->status )   
    1471         return false;
    1472        
     1470    if ( 'public' != $bp->groups->current_group->status )
     1471        return false;
     1472
    14731473    $defaults = array(
    14741474        'user_id' => $bp->loggedin_user->id,
     
    14841484
    14851485    $r = wp_parse_args( $args, $defaults );
    1486     extract( $r, EXTR_SKIP );   
     1486    extract( $r, EXTR_SKIP );
    14871487
    14881488    return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
     
    15021502function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
    15031503    global $bp;
    1504    
     1504
    15051505    switch ( $action ) {
    15061506        case 'new_membership_request':
     
    15091509
    15101510            $group = new BP_Groups_Group( $group_id, false, false );
    1511            
     1511
    15121512            $group_link = bp_get_group_permalink( $group );
    15131513
    15141514            if ( (int)$total_items > 1 ) {
    1515                 return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%d new membership requests for the group "%s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );     
     1515                return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __('%d new membership requests for the group "%s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );
    15161516            } else {
    15171517                $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
    15181518                return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . '/admin/membership-requests/" title="' . $user_fullname .' requests group membership">' . sprintf( __('%s requests membership for the group "%s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
    1519             }   
     1519            }
    15201520        break;
    1521        
     1521
    15221522        case 'membership_request_accepted':
    15231523            $group_id = $item_id;
    1524            
     1524
    15251525            $group = new BP_Groups_Group( $group_id, false, false );
    15261526            $group_link = bp_get_group_permalink( $group )  . '/?new';
    1527            
     1527
    15281528            if ( (int)$total_items > 1 ) {
    1529                 return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );       
     1529                return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group_name );
    15301530            } else {
    15311531                return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>', $group_link, $group->name );
    1532             }   
     1532            }
    15331533        break;
    1534        
     1534
    15351535        case 'membership_request_rejected':
    15361536            $group_id = $item_id;
    1537            
     1537
    15381538            $group = new BP_Groups_Group( $group_id, false, false );
    15391539            $group_link = bp_get_group_permalink( $group )  . '/?new';
    1540            
     1540
    15411541            if ( (int)$total_items > 1 ) {
    1542                 return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );       
     1542                return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . site_url() . '/' . BP_MEMBERS_SLUG . '/' . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
    15431543            } else {
    15441544                return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '">' . sprintf( __('Membership for group "%s" rejected'), $group->name ) . '</a>', $group_link, $group->name );
    1545             }   
    1546        
     1545            }
     1546
    15471547        break;
    1548        
     1548
    15491549        case 'member_promoted_to_admin':
    15501550            $group_id = $item_id;
    1551        
     1551
    15521552            $group = new BP_Groups_Group( $group_id, false, false );
    15531553            $group_link = bp_get_group_permalink( $group )  . '/?new';
    1554            
     1554
    15551555            if ( (int)$total_items > 1 ) {
    1556                 return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );       
     1556                return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    15571557            } else {
    15581558                return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
    1559             }   
     1559            }
    15601560        break;
    1561        
     1561
    15621562        case 'member_promoted_to_mod':
    15631563            $group_id = $item_id;
    1564    
     1564
    15651565            $group = new BP_Groups_Group( $group_id, false, false );
    15661566            $group_link = bp_get_group_permalink( $group )  . '/?new';
    1567            
     1567
    15681568            if ( (int)$total_items > 1 ) {
    1569                 return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );     
     1569                return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    15701570            } else {
    15711571                return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>', $group_link, $group->name );
    1572             }   
     1572            }
    15731573        break;
    1574        
     1574
    15751575        case 'group_invite':
    15761576            $group_id = $item_id;
     
    15781578            $group = new BP_Groups_Group( $group_id, false, false );
    15791579            $user_url = bp_core_get_userurl( $user_id );
    1580            
     1580
    15811581            if ( (int)$total_items > 1 ) {
    1582                 return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );     
     1582                return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    15831583            } else {
    15841584                return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
    1585             }   
     1585            }
    15861586        break;
    15871587    }
    15881588
    15891589    do_action( 'groups_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    1590    
     1590
    15911591    return false;
    15921592}
     
    16061606function groups_create_group( $args = '' ) {
    16071607    global $bp;
    1608    
     1608
    16091609    extract( $args );
    1610    
     1610
    16111611    /**
    16121612     * Possible parameters (pass as assoc array):
     
    16271627    else
    16281628        $group = new BP_Groups_Group;
    1629    
     1629
    16301630    if ( $creator_id ) {
    16311631        $group->creator_id = $creator_id;
     
    16331633        $group->creator_id = $bp->loggedin_user->id;
    16341634    }
    1635    
     1635
    16361636    if ( isset( $name ) )
    16371637        $group->name = $name;
    1638    
     1638
    16391639    if ( isset( $description ) )
    16401640        $group->description = $description;
    1641    
     1641
    16421642    if ( isset( $news ) )
    16431643        $group->news = $news;
    1644    
     1644
    16451645    if ( isset( $slug ) && groups_check_slug( $slug ) )
    16461646        $group->slug = $slug;
    1647    
     1647
    16481648    if ( isset( $status ) ) {
    16491649        if ( groups_is_valid_status( $status ) )
    16501650            $group->status = $status;
    16511651    }
    1652    
     1652
    16531653    if ( isset( $enable_wire ) )
    16541654        $group->enable_wire = $enable_wire;
    16551655    else if ( !$group_id && !isset( $enable_wire ) )
    16561656        $group->enable_wire = 1;
    1657    
     1657
    16581658    if ( isset( $enable_forum ) )
    16591659        $group->enable_forum = $enable_forum;
    16601660    else if ( !$group_id && !isset( $enable_forum ) )
    16611661        $group->enable_forum = 1;
    1662            
     1662
    16631663    if ( isset( $date_created ) )
    16641664        $group->date_created = $date_created;
    1665    
     1665
    16661666    if ( !$group->save() )
    16671667        return false;
     
    16751675        $member->user_title = __( 'Group Admin', 'buddypress' );
    16761676        $member->is_confirmed = 1;
    1677        
     1677
    16781678        $member->save();
    16791679    }
     
    16871687    if ( empty( $group_name ) || empty( $group_desc ) )
    16881688        return false;
    1689    
     1689
    16901690    $group = new BP_Groups_Group( $group_id, false, false );
    16911691    $group->name = $group_name;
     
    17001700        groups_notification_group_updated( $group->id );
    17011701    }
    1702        
     1702
    17031703    do_action( 'groups_details_updated', $group->id );
    1704    
     1704
    17051705    return true;
    17061706}
     
    17081708function groups_edit_group_settings( $group_id, $enable_wire, $enable_forum, $enable_photos, $photos_admin_only, $status ) {
    17091709    global $bp;
    1710    
     1710
    17111711    $group = new BP_Groups_Group( $group_id, false, false );
    17121712    $group->enable_wire = $enable_wire;
     
    17141714    $group->enable_photos = $enable_photos;
    17151715    $group->photos_admin_only = $photos_admin_only;
    1716    
    1717     /*** 
     1716
     1717    /***
    17181718     * Before we potentially switch the group status, if it has been changed to public
    17191719     * from private and there are outstanding membership requests, auto-accept those requests.
     
    17211721    if ( 'private' == $group->status && 'public' == $status )
    17221722        groups_accept_all_pending_membership_requests( $group->id );
    1723    
     1723
    17241724    /* Now update the status */
    17251725    $group->status = $status;
    1726    
     1726
    17271727    if ( !$group->save() )
    17281728        return false;
    1729    
     1729
    17301730    /* If forums have been enabled, and a forum does not yet exist, we need to create one. */
    17311731    if ( $group->enable_forum ) {
     
    17341734        }
    17351735    }
    1736    
     1736
    17371737    do_action( 'groups_settings_updated', $group->id );
    1738    
     1738
    17391739    return true;
    17401740}
     
    17421742function groups_delete_group( $group_id ) {
    17431743    global $bp;
    1744    
     1744
    17451745    // Check the user is the group admin.
    17461746    if ( !$bp->is_item_admin )
    17471747        return false;
    1748    
     1748
    17491749    // Get the group object
    17501750    $group = new BP_Groups_Group( $group_id );
    1751    
     1751
    17521752    if ( !$group->delete() )
    17531753        return false;
     
    17571757        bp_activity_delete_by_item_id( array( 'item_id' => $group_id, 'component_name' => $bp->groups->id ) );
    17581758    }
    1759  
     1759
    17601760    // Remove all outstanding invites for this group
    17611761    groups_delete_all_group_invites( $group_id );
     
    17631763    // Remove all notifications for any user belonging to this group
    17641764    bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
    1765    
     1765
    17661766    do_action( 'groups_delete_group', $group_id );
    1767    
     1767
    17681768    return true;
    17691769}
     
    17711771function groups_is_valid_status( $status ) {
    17721772    global $bp;
    1773    
     1773
    17741774    return in_array( $status, (array)$bp->groups->valid_status );
    17751775}
     
    17801780    if ( 'wp' == substr( $slug, 0, 2 ) )
    17811781        $slug = substr( $slug, 2, strlen( $slug ) - 2 );
    1782            
     1782
    17831783    if ( in_array( $slug, (array)$bp->groups->forbidden_names ) ) {
    17841784        $slug = $slug . '-' . rand();
    17851785    }
    1786    
     1786
    17871787    if ( BP_Groups_Group::check_slug( $slug ) ) {
    17881788        do {
     
    17911791        while ( BP_Groups_Group::check_slug( $slug ) );
    17921792    }
    1793    
     1793
    17941794    return $slug;
    17951795}
     
    18071807    if ( !$user_id )
    18081808        $user_id = $bp->loggedin_user->id;
    1809    
     1809
    18101810    // Admins cannot leave a group, that is until promotion to admin support is implemented.
    18111811    if ( groups_is_user_admin( $user_id, $group_id ) )
    18121812        return false;
    1813        
     1813
    18141814    // This is exactly the same as deleting and invite, just is_confirmed = 1 NOT 0.
    18151815    if ( !groups_uninvite_user( $user_id, $group_id, true ) )
     
    18201820    /* Modify group member count */
    18211821    groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
    1822    
     1822
    18231823    return true;
    18241824}
     
    18261826function groups_join_group( $group_id, $user_id = false ) {
    18271827    global $bp;
    1828        
     1828
    18291829    if ( !$user_id )
    18301830        $user_id = $bp->loggedin_user->id;
     
    18321832    if ( groups_check_user_has_invite( $user_id, $group_id ) )
    18331833        groups_delete_invite( $user_id, $group_id );
    1834    
     1834
    18351835    $new_member = new BP_Groups_Member;
    18361836    $new_member->group_id = $group_id;
     
    18411841    $new_member->date_modified = time();
    18421842    $new_member->is_confirmed = 1;
    1843    
     1843
    18441844    if ( !$new_member->save() )
    18451845        return false;
     
    18471847    /* Record this in activity streams */
    18481848    groups_record_activity( array(
    1849         'content' => 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>' ) ), 
     1849        'content' => 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>' ) ),
    18501850        'primary_link' => apply_filters( 'groups_activity_joined_group_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    18511851        'component_action' => 'joined_group',
     
    19031903
    19041904function groups_get_alphabetically( $limit = null, $page = 1 ) {
    1905     return BP_Groups_Group::get_alphabetically( $limit, $page );   
     1905    return BP_Groups_Group::get_alphabetically( $limit, $page );
    19061906}
    19071907
     
    19161916function groups_get_user_groups( $user_id = false, $pag_num = false, $pag_page = false ) {
    19171917    global $bp;
    1918    
     1918
    19191919    if ( !$user_id )
    19201920        $user_id = $bp->displayed_user->id;
    1921    
     1921
    19221922    return BP_Groups_Member::get_group_ids( $user_id, $pag_num, $pag_page );
    19231923}
     
    19271927function groups_get_recently_joined_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
    19281928    global $bp;
    1929    
     1929
    19301930    if ( !$user_id )
    19311931        $user_id = $bp->displayed_user->id;
     
    19361936function groups_get_most_popular_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
    19371937    global $bp;
    1938    
     1938
    19391939    if ( !$user_id )
    19401940        $user_id = $bp->displayed_user->id;
    19411941
    1942     return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter );   
     1942    return BP_Groups_Member::get_most_popular( $user_id, $pag_num, $pag_page, $filter );
    19431943}
    19441944
    19451945function groups_get_recently_active_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
    19461946    global $bp;
    1947    
     1947
    19481948    if ( !$user_id )
    19491949        $user_id = $bp->displayed_user->id;
    1950        
     1950
    19511951    return BP_Groups_Member::get_recently_active( $user_id, $pag_num, $pag_page, $filter );
    19521952}
     
    19541954function groups_get_alphabetically_for_user( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
    19551955    global $bp;
    1956    
     1956
    19571957    if ( !$user_id )
    19581958        $user_id = $bp->displayed_user->id;
    19591959
    1960     return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter ); 
     1960    return BP_Groups_Member::get_alphabetically( $user_id, $pag_num, $pag_page, $filter );
    19611961}
    19621962
    19631963function groups_get_user_is_admin_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
    19641964    global $bp;
    1965    
     1965
    19661966    if ( !$user_id )
    19671967        $user_id = $bp->displayed_user->id;
    1968        
    1969     return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter ); 
     1968
     1969    return BP_Groups_Member::get_is_admin_of( $user_id, $pag_num, $pag_page, $filter );
    19701970}
    19711971
    19721972function groups_get_user_is_mod_of( $user_id = false, $pag_num = false, $pag_page = false, $filter = false ) {
    19731973    global $bp;
    1974    
     1974
    19751975    if ( !$user_id )
    19761976        $user_id = $bp->displayed_user->id;
    1977        
    1978     return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter );   
     1977
     1978    return BP_Groups_Member::get_is_mod_of( $user_id, $pag_num, $pag_page, $filter );
    19791979}
    19801980
    19811981function groups_total_groups_for_user( $user_id = false ) {
    19821982    global $bp;
    1983    
     1983
    19841984    if ( !$user_id )
    19851985        $user_id = $bp->displayed_user->id;
    1986        
     1986
    19871987    return BP_Groups_Member::total_group_count( $user_id );
    19881988}
     
    19901990function groups_get_random_groups_for_user( $user_id = false, $total_groups = 5 ) {
    19911991    global $bp;
    1992    
     1992
    19931993    if ( !$user_id )
    19941994        $user_id = $bp->displayed_user->id;
    1995        
     1995
    19961996    return BP_Groups_Member::get_random_groups( $user_id, $total_groups );
    19971997}
     
    20122012    if ( !$group_id )
    20132013        $group_id = $bp->groups->current_group->id;
    2014        
     2014
    20152015    $path  = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
    20162016    $newdir = WP_CONTENT_DIR . str_replace( 'wp-content', '', $path );
     
    20182018
    20192019    $newbdir = $newdir;
    2020    
     2020
    20212021    if ( !file_exists( $newdir ) )
    20222022        @wp_mkdir_p( $newdir );
     
    20262026    $newsubdir = '/group-avatars/' . $group_id;
    20272027
    2028     return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );   
     2028    return apply_filters( 'groups_avatar_upload_dir', array( 'path' => $newdir, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) );
    20292029}
    20302030
     
    20512051function groups_new_wire_post( $group_id, $content ) {
    20522052    global $bp;
    2053    
     2053
    20542054    if ( !function_exists( 'bp_wire_new_post' ) )
    20552055        return false;
    2056    
     2056
    20572057    if ( $wire_post = bp_wire_new_post( $group_id, $content, 'groups' ) ) {
    2058        
     2058
    20592059        /* Post an email notification if settings allow */
    20602060        require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    20612061        groups_notification_new_wire_post( $group_id, $wire_post->id );
    2062        
     2062
    20632063        /* Record this in activity streams */
    20642064        $activity_content = sprintf( __( '%s wrote on the wire of 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>' );
    20652065        $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $content ) ) . '</blockquote>';
    2066        
     2066
    20672067        groups_record_activity( array(
    2068             'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ), 
     2068            'content' => apply_filters( 'groups_activity_new_wire_post', $activity_content ),
    20692069            'primary_link' => apply_filters( 'groups_activity_new_wire_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    20702070            'component_action' => 'new_wire_post',
     
    20742074
    20752075        do_action( 'groups_new_wire_post', $group_id, $wire_post->id );
    2076        
     2076
    20772077        return true;
    20782078    }
    2079    
     2079
    20802080    return false;
    20812081}
     
    20872087            bp_activity_delete_by_item_id( array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post' ) );
    20882088        }
    2089            
     2089
    20902090        do_action( 'groups_deleted_wire_post', $wire_post_id );
    20912091        return true;
    20922092    }
    2093    
     2093
    20942094    return false;
    20952095}
     
    21022102    if ( !$group_id )
    21032103        $group_id = $bp->groups->current_group->id;
    2104    
     2104
    21052105    if ( !$group_name )
    21062106        $group_name = $bp->groups->current_group->name;
    2107    
     2107
    21082108    if ( !$group_desc )
    21092109        $group_desc = $bp->groups->current_group->description;
    2110    
     2110
    21112111    $forum_id = bp_forums_new_forum( array( 'forum_name' => $group_name, 'forum_desc' => $group_desc ) );
    21122112
    21132113    groups_update_groupmeta( $group_id, 'forum_id', $forum_id );
    2114    
     2114
    21152115    do_action( 'groups_new_group_forum', $forum, $group_id );
    21162116}
     
    21182118function groups_new_group_forum_post( $post_text, $topic_id ) {
    21192119    global $bp;
    2120    
     2120
    21212121    if ( empty( $post_text ) )
    21222122        return false;
    2123    
     2123
    21242124    if ( $forum_post = bp_forums_insert_post( array( 'post_text' => $post_text, 'topic_id' => $topic_id ) ) ) {
    21252125        $topic = bp_forums_get_topic_details( $topic_id );
    2126        
     2126
    21272127        $activity_content = 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>' );
    21282128        $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>';
    2129        
     2129
    21302130        /* Record this in activity streams */
    21312131        groups_record_activity( array(
    2132             'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ), 
     2132            'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
    21332133            'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    21342134            'component_action' => 'new_forum_post',
     
    21382138
    21392139        do_action( 'groups_new_forum_topic_post', $bp->groups->current_group->id, $forum_post );
    2140        
     2140
    21412141        return $forum_post;
    21422142    }
    2143    
     2143
    21442144    return false;
    21452145}
     
    21472147function groups_new_group_forum_topic( $topic_title, $topic_text, $topic_tags, $forum_id ) {
    21482148    global $bp;
    2149    
     2149
    21502150    if ( empty( $topic_title ) || empty( $topic_text ) )
    21512151        return false;
    2152        
     2152
    21532153    if ( $topic_id = bp_forums_new_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_tags' => $topic_tags, 'forum_id' => $forum_id ) ) ) {
    21542154        $topic = bp_forums_get_topic_details( $topic_id );
     
    21562156        $activity_content = 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>' );
    21572157        $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>';
    2158        
     2158
    21592159        /* Record this in activity streams */
    21602160        groups_record_activity( array(
    2161             'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ), 
     2161            'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
    21622162            'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    21632163            'component_action' => 'new_forum_topic',
     
    21652165            'secondary_item_id' => $topic->topic_id
    21662166        ) );
    2167        
     2167
    21682168        do_action( 'groups_new_forum_topic', $bp->groups->current_group->id, &$topic );
    21692169
    21702170        return $topic;
    21712171    }
    2172                    
     2172
    21732173    return false;
    21742174}
     
    21762176function groups_update_group_forum_topic( $topic_id, $topic_title, $topic_text ) {
    21772177    global $bp;
    2178    
     2178
    21792179    if ( $topic = bp_forums_update_topic( array( 'topic_title' => $topic_title, 'topic_text' => $topic_text, 'topic_id' => $topic_id ) ) ) {
    21802180        /* Update the activity stream item */
    21812181        if ( function_exists( 'bp_activity_delete_by_item_id' ) )
    21822182            bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $topic_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_topic' ) );
    2183        
     2183
    21842184        $activity_content = 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>' );
    21852185        $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $topic_text ) ) . '</blockquote>';
     
    21872187        /* Record this in activity streams */
    21882188        groups_record_activity( array(
    2189             'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ), 
     2189            'content' => apply_filters( 'groups_activity_new_forum_topic', $activity_content, $topic_text, &$topic ),
    21902190            'primary_link' => apply_filters( 'groups_activity_new_forum_topic_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    21912191            'component_action' => 'new_forum_topic',
     
    21972197
    21982198        do_action( 'groups_update_group_forum_topic', &$topic );
    2199        
     2199
    22002200        return true;
    22012201    }
    2202    
     2202
    22032203    return false;
    22042204}
     
    22062206function groups_update_group_forum_post( $post_id, $post_text, $topic_id ) {
    22072207    global $bp;
    2208    
     2208
    22092209    $post = bp_forums_get_post( $post_id );
    2210        
     2210
    22112211    if ( $post_id = bp_forums_insert_post( array( 'post_id' => $post_id, 'post_text' => $post_text, 'post_time' => $post->post_time, 'topic_id' => $topic_id, 'poster_id' => $post->poster_id ) ) ) {
    22122212        $topic = bp_forums_get_topic_details( $topic_id );
     
    22152215        if ( function_exists( 'bp_activity_delete_by_item_id' ) )
    22162216            bp_activity_delete_by_item_id( array( 'item_id' => $bp->groups->current_group->id, 'secondary_item_id' => $post_id, 'component_name' => $bp->groups->id, 'component_action' => 'new_forum_post' ) );
    2217            
     2217
    22182218        $activity_content = 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>' );
    22192219        $activity_content .= '<blockquote>' . bp_create_excerpt( attribute_escape( $post_text ) ) . '</blockquote>';
    2220        
     2220
    22212221        /* Record this in activity streams */
    22222222        groups_record_activity( array(
    2223             'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ), 
     2223            'content' => apply_filters( 'groups_activity_new_forum_post', $activity_content, $post_text, &$topic, &$forum_post ),
    22242224            'primary_link' => apply_filters( 'groups_activity_new_forum_post_primary_link', bp_get_group_permalink( $bp->groups->current_group ) ),
    22252225            'component_action' => 'new_forum_post',
     
    22312231
    22322232        do_action( 'groups_update_group_forum_post', &$post, &$topic );
    2233        
     2233
    22342234        return true;
    22352235    }
    2236    
     2236
    22372237    return false;
    22382238}
     
    22402240function groups_delete_group_forum_topic( $topic_id ) {
    22412241    global $bp;
    2242    
     2242
    22432243    if ( bp_forums_delete_topic( array( 'topic_id' => $topic_id ) ) ) {
    22442244        /* Delete the activity stream item */
     
    22492249
    22502250        do_action( 'groups_delete_group_forum_topic', $topic_id );
    2251        
     2251
    22522252        return true;
    22532253    }
    2254    
     2254
    22552255    return false;
    22562256}
     
    22582258function groups_delete_group_forum_post( $post_id, $topic_id ) {
    22592259    global $bp;
    2260    
     2260
    22612261    if ( bp_forums_delete_post( array( 'post_id' => $post_id ) ) ) {
    22622262        /* Delete the activity stream item */
     
    22662266
    22672267        do_action( 'groups_delete_group_forum_post', $post_id, $topic_id );
    2268        
     2268
    22692269        return true;
    22702270    }
    2271    
     2271
    22722272    return false;
    22732273}
     
    22822282function groups_get_invites_for_user( $user_id = false ) {
    22832283    global $bp;
    2284    
     2284
    22852285    if ( !$user_id )
    22862286        $user_id = $bp->loggedin_user->id;
    2287    
     2287
    22882288    return BP_Groups_Member::get_invites( $user_id );
    22892289}
     
    22912291function groups_invite_user( $args = '' ) {
    22922292    global $bp;
    2293    
     2293
    22942294    $defaults = array(
    22952295        'user_id' => false,
     
    23012301
    23022302    $args = wp_parse_args( $args, $defaults );
    2303     extract( $args, EXTR_SKIP );   
     2303    extract( $args, EXTR_SKIP );
    23042304
    23052305    if ( !$user_id || !$group_id )
    23062306        return false;
    2307    
     2307
    23082308    if ( groups_is_user_member( $user_id, $group_id ) )
    23092309        return false;
    2310    
     2310
    23112311    $invite = new BP_Groups_Member;
    23122312    $invite->group_id = $group_id;
     
    23152315    $invite->inviter_id = $inviter_id;
    23162316    $invite->is_confirmed = $is_confirmed;
    2317    
     2317
    23182318    if ( !$invite->save() )
    23192319        return false;
    2320    
     2320
    23212321    do_action( 'groups_invite_user', $args );
    2322        
     2322
    23232323    return true;
    23242324}
     
    23262326function groups_uninvite_user( $user_id, $group_id ) {
    23272327    global $bp;
    2328    
     2328
    23292329    if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
    23302330        return false;
     
    23382338    if ( groups_is_user_member( $user_id, $group_id ) )
    23392339        return false;
    2340    
     2340
    23412341    $member = new BP_Groups_Member( $user_id, $group_id );
    23422342    $member->accept_invite();
    23432343
    2344     if ( !$member->save() ) 
    2345         return false;
    2346    
     2344    if ( !$member->save() )
     2345        return false;
     2346
    23472347    do_action( 'groups_accept_invite', $user_id, $group_id );
    23482348    return true;
     
    23522352    if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
    23532353        return false;
    2354    
     2354
    23552355    do_action( 'groups_reject_invite', $user_id, $group_id );
    2356    
     2356
    23572357    return true;
    23582358}
     
    23602360function groups_delete_invite( $user_id, $group_id ) {
    23612361    global $bp;
    2362    
     2362
    23632363    $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
    2364    
     2364
    23652365    if ( $delete )
    23662366        bp_core_delete_notifications_for_user_by_item_id( $user_id, $group_id, $bp->groups->slug, 'group_invite' );
    2367    
     2367
    23682368    return $delete;
    23692369}
     
    23712371function groups_send_invites( $user_id, $group_id ) {
    23722372    global $bp;
    2373    
     2373
    23742374    require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    2375    
     2375
    23762376    if ( !$user_id )
    23772377        $user_id = $bp->loggedin_user->id;
     
    23862386        // Send the actual invite
    23872387        groups_notification_group_invites( $group, $member, $user_id );
    2388        
     2388
    23892389        $member->invite_sent = 1;
    23902390        $member->save();
    23912391    }
    2392    
     2392
    23932393    do_action( 'groups_send_invites', $bp->groups->current_group->id, $invited_users );
    23942394}
     
    24102410function groups_promote_member( $user_id, $group_id, $status ) {
    24112411    global $bp;
    2412    
     2412
    24132413    if ( !$bp->is_item_admin )
    24142414        return false;
    2415        
     2415
    24162416    $member = new BP_Groups_Member( $user_id, $group_id );
    24172417
    24182418    do_action( 'groups_premote_member', $user_id, $group_id, $status );
    2419    
     2419
    24202420    return $member->promote( $status );
    24212421}
     
    24252425
    24262426    $member = new BP_Groups_Member( $user_id, $group_id );
    2427    
     2427
    24282428    do_action( 'groups_demote_member', $user_id, $group_id );
    24292429
     
    24362436    if ( !$bp->is_item_admin )
    24372437        return false;
    2438        
     2438
    24392439    $member = new BP_Groups_Member( $user_id, $group_id );
    24402440
    24412441    do_action( 'groups_ban_member', $user_id, $group_id );
    2442    
     2442
    24432443    return $member->ban();
    24442444}
     
    24462446function groups_unban_member( $user_id, $group_id ) {
    24472447    global $bp;
    2448    
     2448
    24492449    if ( !$bp->is_item_admin )
    24502450        return false;
    2451        
     2451
    24522452    $member = new BP_Groups_Member( $user_id, $group_id );
    2453    
     2453
    24542454    do_action( 'groups_unban_member', $user_id, $group_id );
    2455    
     2455
    24562456    return $member->unban();
    24572457}
     
    24712471    $requesting_user->is_confirmed = 0;
    24722472    $requesting_user->comments = $_POST['group-request-membership-comments'];
    2473    
     2473
    24742474    if ( $requesting_user->save() ) {
    24752475        $admins = groups_get_group_admins( $group_id );
     
    24812481            groups_notification_new_membership_request( $requesting_user_id, $admins[$i]->user_id, $group_id, $requesting_user->id );
    24822482        }
    2483        
     2483
    24842484        do_action( 'groups_membership_requested', $requesting_user_id, $admins, $group_id, $requesting_user->id );
    2485    
     2485
    24862486        return true;
    24872487    }
    2488    
     2488
    24892489    return false;
    24902490}
     
    24922492function groups_accept_membership_request( $membership_id, $user_id = false, $group_id = false ) {
    24932493    global $bp;
    2494    
     2494
    24952495    if ( $user_id && $group_id )
    24962496        $membership = new BP_Groups_Member( $user_id, $group_id );
     
    24992499
    25002500    $membership->accept_request();
    2501    
     2501
    25022502    if ( !$membership->save() )
    25032503        return false;
    2504        
     2504
    25052505    /* Modify group member count */
    25062506    groups_update_groupmeta( $membership->group_id, 'total_member_count', (int) groups_get_groupmeta( $membership->group_id, 'total_member_count') + 1 );
    2507    
     2507
    25082508    /* Record this in activity streams */
    25092509    $group = new BP_Groups_Group( $group_id, false, false );
    25102510
    25112511    groups_record_activity( array(
    2512         'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ), 
     2512        'content' => apply_filters( 'groups_activity_membership_accepted', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $user_id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . attribute_escape( $group->name ) . '</a>' ), $user_id, &$group ),
    25132513        'primary_link' => apply_filters( 'groups_activity_membership_accepted_primary_link', bp_get_group_permalink( $group ), &$group ),
    25142514        'component_action' => 'joined_group',
     
    25202520    require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    25212521    groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, true );
    2522    
     2522
    25232523    do_action( 'groups_membership_accepted', $membership->user_id, $membership->group_id );
    2524    
     2524
    25252525    return true;
    25262526}
    25272527
    2528 function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {     
     2528function groups_reject_membership_request( $membership_id, $user_id = false, $group_id = false ) {
    25292529    if ( $user_id && $group_id )
    25302530        $membership = new BP_Groups_Member( $user_id, $group_id );
    25312531    else
    25322532        $membership = new BP_Groups_Member( false, false, $membership_id );
    2533    
     2533
    25342534    if ( !BP_Groups_Member::delete( $membership->user_id, $membership->group_id ) )
    25352535        return false;
    2536    
     2536
    25372537    // Send a notification to the user.
    25382538    require_once ( BP_PLUGIN_DIR . '/bp-groups/bp-groups-notifications.php' );
    25392539    groups_notification_membership_request_completed( $membership->user_id, $membership->group_id, false );
    2540    
     2540
    25412541    do_action( 'groups_membership_rejected', $membership->user_id, $membership->group_id );
    2542    
     2542
    25432543    return true;
    25442544}
     
    25532553    if ( !$user_ids )
    25542554        return false;
    2555    
     2555
    25562556    foreach ( (array) $user_ids as $user_id ) {
    25572557        groups_accept_membership_request( false, $user_id, $group_id );
    25582558    }
    2559    
     2559
    25602560    do_action( 'groups_accept_all_pending_membership_requests', $group_id );
    2561    
     2561
    25622562    return true;
    25632563}
     
    25672567function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false ) {
    25682568    global $wpdb, $bp;
    2569    
     2569
    25702570    if ( !is_numeric( $group_id ) )
    25712571        return false;
    2572        
     2572
    25732573    $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    25742574
    25752575    if ( is_array($meta_value) || is_object($meta_value) )
    25762576        $meta_value = serialize($meta_value);
    2577        
     2577
    25782578    $meta_value = trim( $meta_value );
    25792579
    25802580    if ( !$meta_key ) {
    2581         $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) );       
     2581        $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d", $group_id ) );
    25822582    } else if ( $meta_value ) {
    25832583        $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value ) );
     
    25852585        $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp->groups->table_name_groupmeta . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
    25862586    }
    2587    
     2587
    25882588    // TODO need to look into using this.
    25892589    // wp_cache_delete($group_id, 'groups');
     
    25942594function groups_get_groupmeta( $group_id, $meta_key = '') {
    25952595    global $wpdb, $bp;
    2596    
     2596
    25972597    $group_id = (int) $group_id;
    25982598
     
    26022602    if ( !empty($meta_key) ) {
    26032603        $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    2604        
     2604
    26052605        // TODO need to look into using this.
    26062606        //$user = wp_cache_get($user_id, 'users');
    2607        
     2607
    26082608        // Check the cached user object
    26092609        //if ( false !== $user && isset($user->$meta_key) )
     
    26322632function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
    26332633    global $wpdb, $bp;
    2634    
     2634
    26352635    if ( !is_numeric( $group_id ) )
    26362636        return false;
    2637    
     2637
    26382638    $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
    26392639
    26402640    if ( is_string($meta_value) )
    26412641        $meta_value = stripslashes($wpdb->escape($meta_value));
    2642    
     2642
    26432643    $meta_value = maybe_serialize($meta_value);
    2644    
     2644
    26452645    if (empty($meta_value)) {
    26462646        return groups_delete_groupmeta( $group_id, $meta_key );
     
    26672667function groups_remove_data_for_user( $user_id ) {
    26682668    BP_Groups_Member::delete_all_for_user($user_id);
    2669    
     2669
    26702670    do_action( 'groups_remove_data_for_user', $user_id );
    26712671}
  • trunk/bp-groups/bp-groups-admin.php

    r1905 r2077  
    11<?php
    22
    3 function groups_admin_settings() { 
    4    
     3function groups_admin_settings() {
     4
    55    if ( isset( $_POST['groups_admin_delete']) && isset( $_POST['allgroups'] ) ) {
    66        if ( !check_admin_referer('bp-groups-admin') )
    77            return false;
    8        
     8
    99        $errors = false;
    1010        foreach ( $_POST['allgroups'] as $group_id ) {
     
    1414            }
    1515        }
    16        
     16
    1717        if ( $errors ) {
    1818            $message = __( 'There were errors when deleting groups, please try again', 'buddypress' );
     
    3232    <div class="wrap" style="position: relative">
    3333        <h2><?php _e( 'Groups', 'buddypress' ) ?></h2>
    34    
     34
    3535        <form id="wpmu-search" method="post" action="">
    3636            <input type="text" size="17" value="<?php echo attribute_escape( stripslashes( $_REQUEST['s'] ) ); ?>" name="s" />
    3737            <input id="post-query-submit" class="button" type="submit" value="<?php _e( 'Search Groups', 'buddypress' ) ?>" />
    3838        </form>
    39        
     39
    4040        <?php if ( bp_has_site_groups( 'type=active&per_page=10' ) ) : ?>
    4141            <form id="bp-group-admin-list" method="post" action="">
     
    5050                    </div>
    5151                </div>
    52                
     52
    5353                <br class="clear"/>
    54                
     54
    5555                <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] != '' ) { ?>
    5656                    <p><?php echo sprintf( __( 'Groups matching: "%s"', 'buddypress' ), $_REQUEST['s'] ) ?></p>
     
    111111                    <?php endwhile; ?>
    112112                    </tbody>
    113                 </table>   
     113                </table>
    114114
    115115        <?php else: ?>
     
    124124        </form>
    125125    </div>
    126 <?php 
     126<?php
    127127}
    128128
  • trunk/bp-groups/bp-groups-classes.php

    r2055 r2077  
    1414
    1515    var $user_dataset;
    16    
     16
    1717    var $admins;
    1818    var $total_member_count;
    1919    var $random_members;
    2020    var $latest_wire_posts;
    21    
     21
    2222    function bp_groups_group( $id = null, $single = false, $get_user_dataset = true ) {
    2323        if ( $id ) {
     
    2525            $this->populate( $get_user_dataset );
    2626        }
    27        
     27
    2828        if ( $single ) {
    2929            $this->populate_meta();
    3030        }
    3131    }
    32    
     32
    3333    function populate( $get_user_dataset ) {
    3434        global $wpdb, $bp;
     
    3636        $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} WHERE id = %d", $this->id );
    3737        $group = $wpdb->get_row($sql);
    38        
     38
    3939        if ( $group ) {
    4040            $this->id = $group->id;
     
    4949            $this->date_created = strtotime($group->date_created);
    5050            $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
    51            
     51
    5252            if ( $get_user_dataset ) {
    5353                $this->user_dataset = $this->get_user_dataset();
    54                
     54
    5555                //if ( !$this->total_member_count ) {
    5656                $this->total_member_count = count( $this->user_dataset );
     
    5858                //}
    5959            }
    60         }   
    61     }
    62    
     60        }
     61    }
     62
    6363    function populate_meta() {
    6464        if ( $this->id ) {
     
    6767        }
    6868    }
    69    
     69
    7070    function save() {
    7171        global $wpdb, $bp;
    72        
     72
    7373        $this->creator_id = apply_filters( 'groups_group_creator_id_before_save', $this->creator_id, $this->id );
    7474        $this->name = apply_filters( 'groups_group_name_before_save', $this->name, $this->id );
     
    8282
    8383        do_action( 'groups_group_before_save', $this );
    84        
     84
    8585        if ( $this->id ) {
    86             $sql = $wpdb->prepare( 
    87                 "UPDATE {$bp->groups->table_name} SET 
    88                     creator_id = %d, 
    89                     name = %s, 
    90                     slug = %s, 
    91                     description = %s, 
    92                     news = %s, 
    93                     status = %s, 
    94                     enable_wire = %d, 
    95                     enable_forum = %d, 
     86            $sql = $wpdb->prepare(
     87                "UPDATE {$bp->groups->table_name} SET
     88                    creator_id = %d,
     89                    name = %s,
     90                    slug = %s,
     91                    description = %s,
     92                    news = %s,
     93                    status = %s,
     94                    enable_wire = %d,
     95                    enable_forum = %d,
    9696                    date_created = FROM_UNIXTIME(%d)
    9797                WHERE
    9898                    id = %d
    9999                ",
    100                     $this->creator_id, 
    101                     $this->name, 
    102                     $this->slug, 
    103                     $this->description, 
    104                     $this->news, 
    105                     $this->status, 
    106                     $this->enable_wire, 
    107                     $this->enable_forum, 
     100                    $this->creator_id,
     101                    $this->name,
     102                    $this->slug,
     103                    $this->description,
     104                    $this->news,
     105                    $this->status,
     106                    $this->enable_wire,
     107                    $this->enable_forum,
    108108                    $this->date_created,
    109109                    $this->id
    110110            );
    111111        } else {
    112             $sql = $wpdb->prepare( 
    113                 "INSERT INTO {$bp->groups->table_name} ( 
     112            $sql = $wpdb->prepare(
     113                "INSERT INTO {$bp->groups->table_name} (
    114114                    creator_id,
    115115                    name,
     
    124124                    %d, %s, %s, %s, %s, %s, %d, %d, FROM_UNIXTIME(%d)
    125125                )",
    126                     $this->creator_id, 
    127                     $this->name, 
    128                     $this->slug, 
    129                     $this->description, 
    130                     $this->news, 
    131                     $this->status, 
    132                     $this->enable_wire, 
     126                    $this->creator_id,
     127                    $this->name,
     128                    $this->slug,
     129                    $this->description,
     130                    $this->news,
     131                    $this->status,
     132                    $this->enable_wire,
    133133                    $this->enable_forum,
    134134                    $this->date_created
    135135            );
    136136        }
    137        
     137
    138138        if ( false === $wpdb->query($sql) )
    139139            return false;
    140        
     140
    141141        if ( !$this->id ) {
    142142            $this->id = $wpdb->insert_id;
     
    144144
    145145        do_action( 'groups_group_after_save', $this );
    146        
     146
    147147        return true;
    148148    }
    149    
     149
    150150    function get_user_dataset() {
    151151        global $wpdb, $bp;
    152        
     152
    153153        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, is_admin, inviter_id, user_title, is_mod FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand()", $this->id ) );
    154154    }
    155        
     155
    156156    function get_administrators() {
    157157        for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
    158158            if ( $this->user_dataset[$i]->is_admin )
    159159                $admins[] = new BP_Groups_Member( $this->user_dataset[$i]->user_id, $this->id );
    160         }   
    161        
     160        }
     161
    162162        return $admins;
    163163    }
     
    165165    function get_random_members() {
    166166        $total_randoms = ( $this->total_member_count > 5 ) ? 5 : $this->total_member_count;
    167        
     167
    168168        for ( $i = 0; $i < $total_randoms; $i++ ) {
    169169            if ( !(int)$this->user_dataset[$i]->is_banned )
     
    172172        return $users;
    173173    }
    174    
     174
    175175    function is_member() {
    176176        global $bp;
    177        
     177
    178178        for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
    179179            if ( $this->user_dataset[$i]->user_id == $bp->loggedin_user->id ) {
    180180                return true;
    181181            }
    182         }   
    183        
     182        }
     183
    184184        return false;
    185185    }
    186    
     186
    187187    function delete() {
    188188        global $wpdb, $bp;
    189        
     189
    190190        // Delete groupmeta for the group
    191191        groups_delete_groupmeta( $this->id );
     
    194194        for ( $i = 0; $i < count($this->user_dataset); $i++ ) {
    195195            $user = $this->user_dataset[$i];
    196            
     196
    197197            $total_count = get_usermeta( $user->user_id, 'total_group_count' );
    198            
     198
    199199            if ( $total_count != '' ) {
    200200                update_usermeta( $user->user_id, 'total_group_count', (int)$total_count - 1 );
    201201            }
    202            
     202
    203203            // Now delete the group member record
    204204            BP_Groups_Member::delete( $user->user_id, $this->id, false );
    205205        }
    206        
     206
    207207        // Delete the wire posts for this group if the wire is installed
    208208        if ( function_exists('bp_wire_install') ) {
    209209            BP_Wire_Post::delete_all_for_item( $this->id, $bp->groups->table_name_wire );
    210210        }
    211                
     211
    212212        // Finally remove the group entry from the DB
    213213        if ( !$wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name} WHERE id = %d", $this->id ) ) )
     
    216216        return true;
    217217    }
    218    
     218
    219219
    220220    /* Static Functions */
    221        
     221
    222222    function group_exists( $slug, $table_name = false ) {
    223223        global $wpdb, $bp;
    224        
     224
    225225        if ( !$table_name )
    226226            $table_name = $bp->groups->table_name;
    227        
     227
    228228        if ( !$slug )
    229229            return false;
    230            
     230
    231231        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$table_name} WHERE slug = %s", $slug ) );
    232232    }
     
    240240        return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d and is_confirmed = 0 AND inviter_id = %d", $group_id, $user_id ) );
    241241    }
    242    
     242
    243243    function filter_user_groups( $filter, $user_id = false, $order = false, $limit = null, $page = null ) {
    244244        global $wpdb, $bp;
    245        
     245
    246246        if ( !$user_id )
    247247            $user_id = $bp->displayed_user->id;
    248        
     248
    249249        $filter = like_escape( $wpdb->escape( $filter ) );
    250        
    251         if ( $limit && $page )
    252             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    253        
     250
     251        if ( $limit && $page )
     252            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     253
    254254        // Get all the group ids for the current user's groups.
    255255        $gids = BP_Groups_Member::get_group_ids( $user_id );
    256        
     256
    257257        if ( !$gids['groups'] )
    258258            return false;
    259            
     259
    260260        $gids = implode( ',', $gids['groups'] );
    261        
     261
    262262        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids}) {$pag_sql}" ) );
    263263        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '{$filter}%%' OR description LIKE '{$filter}%%' ) AND id IN ({$gids})" ) );
    264        
    265         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    266     }
    267    
     264
     265        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     266    }
     267
    268268    function search_groups( $filter, $limit = null, $page = null, $sort_by = false, $order = false ) {
    269269        global $wpdb, $bp;
    270        
     270
    271271        $filter = like_escape( $wpdb->escape( $filter ) );
    272        
     272
    273273        if ( $limit && $page )
    274274            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    279279            $order_sql = "ORDER BY $sort_by $order";
    280280        }
    281        
     281
    282282        if ( !is_site_admin() )
    283283            $hidden_sql = "AND status != 'hidden'";
     
    285285        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sql} {$order_sql} {$pag_sql}" ) );
    286286        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE ( name LIKE '%%$filter%%' OR description LIKE '%%$filter%%' ) {$hidden_sq}" ) );
    287        
    288         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    289     }
    290    
     287
     288        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     289    }
     290
    291291    function check_slug( $slug ) {
    292292        global $wpdb, $bp;
    293        
    294         return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) );     
    295     }
    296    
     293
     294        return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE slug = %s", $slug ) );
     295    }
     296
    297297    function get_slug( $group_id ) {
    298298        global $wpdb, $bp;
    299        
    300         return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) );       
    301     }
    302    
     299
     300        return $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM {$bp->groups->table_name} WHERE id = %d", $group_id ) );
     301    }
     302
    303303    function has_members( $group_id ) {
    304304        global $wpdb, $bp;
    305        
    306         $members = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );                       
     305
     306        $members = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d", $group_id ) );
    307307
    308308        if ( !$members )
    309309            return false;
    310        
     310
    311311        return true;
    312312    }
    313    
     313
    314314    function has_membership_requests( $group_id ) {
    315315        global $wpdb, $bp;
    316        
    317         return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) );                       
    318     }
    319    
     316
     317        return $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0", $group_id ) );
     318    }
     319
    320320    function get_membership_requests( $group_id, $limit = null, $page = null ) {
    321321        global $wpdb, $bp;
    322        
     322
    323323        if ( $limit && $page ) {
    324324            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    325325        }
    326        
     326
    327327        $paged_requests = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0{$pag_sql}", $group_id ) );
    328328        $total_requests = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
     
    330330        return array( 'requests' => $paged_requests, 'total' => $total_requests );
    331331    }
    332    
     332
    333333    function get_newest( $limit = null, $page = null ) {
    334334        global $wpdb, $bp;
    335                
    336         if ( $limit && $page )
    337             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    338        
     335
     336        if ( $limit && $page )
     337            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     338
    339339        if ( !is_site_admin() )
    340340            $hidden_sql = "WHERE status != 'hidden'";
    341        
     341
    342342        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC {$pag_sql}" ) );
    343343        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY date_created DESC", $limit ) );
     
    345345        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    346346    }
    347    
     347
    348348    function get_active( $limit = null, $page = null ) {
    349349        global $wpdb, $bp;
    350        
     350
    351351        if ( $limit && $page )
    352352            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    354354        if ( !is_site_admin() )
    355355            $hidden_sql = "AND g.status != 'hidden'";
    356        
     356
    357357        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) );
    358358        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'last_activity' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) );
     
    360360        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    361361    }
    362    
     362
    363363    function get_popular( $limit = null, $page = null ) {
    364364        global $wpdb, $bp;
    365        
     365
    366366        if ( $limit && $page ) {
    367367            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    370370        if ( !is_site_admin() )
    371371            $hidden_sql = "AND g.status != 'hidden'";
    372            
     372
    373373        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT gm.group_id FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC {$pag_sql}" ) );
    374374        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(gm.group_id) FROM {$bp->groups->table_name_groupmeta} gm, {$bp->groups->table_name} g WHERE g.id = gm.group_id {$hidden_sql} AND gm.meta_key = 'total_member_count' ORDER BY CONVERT(gm.meta_value, SIGNED) DESC" ) );
     
    376376        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    377377    }
    378    
     378
    379379    function get_alphabetically( $limit = null, $page = null ) {
    380380        global $wpdb, $bp;
    381                
    382         if ( $limit && $page )
    383             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    384        
     381
     382        if ( $limit && $page )
     383            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     384
    385385        if ( !is_site_admin() )
    386386            $hidden_sql = "WHERE status != 'hidden'";
    387        
     387
    388388        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) );
    389389        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(id) FROM {$bp->groups->table_name} {$hidden_sql} ORDER BY name ASC", $limit ) );
     
    391391        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    392392    }
    393    
     393
    394394    function get_by_most_forum_topics( $limit = null, $page = null ) {
    395395        global $wpdb, $bp, $bbdb;
    396        
     396
    397397        if ( $limit && $page ) {
    398398            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    402402        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.topics DESC" ) );
    403403
    404         return array( 'groups' => $paged_groups, 'total' => $total_groups );       
     404        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    405405    }
    406406
    407407    function get_by_most_forum_posts( $limit = null, $page = null ) {
    408408        global $wpdb, $bp, $bbdb;
    409        
     409
    410410        if ( $limit && $page ) {
    411411            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    412412        }
    413            
     413
    414414        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT gm.group_id FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC {$pag_sql}" ) );
    415415        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT COUNT(gm.group_id) FROM {$bbdb->forums} AS f, {$bp->groups->table_name} AS g LEFT JOIN {$bp->groups->table_name_groupmeta} AS gm ON g.id = gm.group_id WHERE (gm.meta_key = 'forum_id' AND gm.meta_value = f.forum_id) AND g.status = 'public' ORDER BY f.posts DESC" ) );
    416416
    417         return array( 'groups' => $paged_groups, 'total' => $total_groups );       
    418     }
    419 
    420    
     417        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     418    }
     419
     420
    421421    function get_all( $limit = null, $page = null, $only_public = true, $sort_by = false, $order = false ) {
    422422        global $wpdb, $bp;
    423        
     423
    424424        if ( $only_public )
    425425            $public_sql = $wpdb->prepare( " WHERE g.status = 'public'" );
    426        
     426
    427427        if ( !is_site_admin() )
    428428            $hidden_sql = $wpdb->prepare( " AND g.status != 'hidden'");
    429        
    430         if ( $limit && $page )
    431             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    432        
     429
     430        if ( $limit && $page )
     431            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     432
    433433        if ( $sort_by && $order ) {
    434434            $sort_by = $wpdb->escape( $sort_by );
    435435            $order = $wpdb->escape( $order );
    436436            $order_sql = "ORDER BY g.$sort_by $order";
    437            
     437
    438438            switch ( $sort_by ) {
    439439                default:
    440                     $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );   
     440                    $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
    441441                    break;
    442442                case 'members':
    443                     $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); 
     443                    $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'total_member_count' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
    444444                    break;
    445445                case 'last_active':
    446                     $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" ); 
     446                    $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g, {$bp->groups->table_name_groupmeta} gm WHERE g.id = gm.group_id AND gm.meta_key = 'last_activity' {$hidden_sql} {$public_sql} ORDER BY CONVERT(gm.meta_value, SIGNED) {$order} {$pag_sql}" );
    447447                    break;
    448448            }
    449449        } else {
    450             $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );   
    451         }
    452        
     450            $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name} g {$public_sql} {$hidden_sql} {$order_sql} {$pag_sql}" );
     451        }
     452
    453453        return $wpdb->get_results($sql);
    454454    }
    455    
     455
    456456    function get_by_letter( $letter, $limit = null, $page = null ) {
    457457        global $wpdb, $bp;
    458        
     458
    459459        if ( strlen($letter) > 1 || is_numeric($letter) || !$letter )
    460460            return false;
    461        
     461
    462462        if ( !is_site_admin() )
    463463            $hidden_sql = $wpdb->prepare( " AND status != 'hidden'");
    464        
     464
    465465        $letter = like_escape( $wpdb->escape( $letter ) );
    466466
     
    469469            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC" ) );
    470470        }
    471                
     471
    472472        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM {$bp->groups->table_name} WHERE name LIKE '$letter%%' {$hidden_sql} ORDER BY name ASC {$pag_sql}" ) );
    473        
    474         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    475     }
    476    
     473
     474        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     475    }
     476
    477477    function get_random( $limit = null, $page = null ) {
    478478        global $wpdb, $bp;
     
    485485            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand()" ) );
    486486        }
    487        
    488         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand() {$pag_sql}" ) );     
    489        
    490         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    491     }
    492    
     487
     488        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id, slug FROM {$bp->groups->table_name} WHERE status = 'public' {$hidden_sql} ORDER BY rand() {$pag_sql}" ) );
     489
     490        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     491    }
     492
    493493    function delete_all_invites( $group_id ) {
    494494        global $wpdb, $bp;
    495        
     495
    496496        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
    497497    }
    498    
     498
    499499    function get_global_forum_topic_count( $type ) {
    500500        global $bbdb, $wpdb, $bp;
    501        
     501
    502502        if ( 'unreplied' == $type )
    503503            $bp->groups->filter_sql = ' AND t.topic_posts = 1';
    504        
     504
    505505        $extra_sql = apply_filters( 'groups_total_public_forum_topic_count', $bp->groups->filter_sql, $type );
    506506
     
    522522    var $comments;
    523523    var $invite_sent;
    524    
     524
    525525    var $user;
    526    
     526
    527527    function bp_groups_member( $user_id = false, $group_id = false, $id = false, $populate = true ) {
    528528        if ( $user_id && $group_id && !$id ) {
    529529            $this->user_id = $user_id;
    530530            $this->group_id = $group_id;
    531            
     531
    532532            if ( $populate )
    533533                $this->populate();
    534534        }
    535        
     535
    536536        if ( $id ) {
    537537            $this->id = $id;
    538            
     538
    539539            if ( $populate )
    540540                $this->populate();
    541         }       
    542     }
    543    
     541        }
     542    }
     543
    544544    function populate() {
    545545        global $wpdb, $bp;
    546        
     546
    547547        if ( $this->user_id && $this->group_id && !$this->id )
    548548            $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );
    549        
     549
    550550        if ( $this->id )
    551551            $sql = $wpdb->prepare( "SELECT * FROM {$bp->groups->table_name_members} WHERE id = %d", $this->id );
    552            
     552
    553553        $member = $wpdb->get_row($sql);
    554        
     554
    555555        if ( $member ) {
    556556            $this->id = $member->id;
     
    566566            $this->comments = $member->comments;
    567567            $this->invite_sent = $member->invite_sent;
    568            
     568
    569569            $this->user = new BP_Core_User( $this->user_id );
    570570        }
    571571    }
    572    
     572
    573573    function save() {
    574574        global $wpdb, $bp;
    575        
     575
    576576        $this->user_id = apply_filters( 'groups_member_user_id_before_save', $this->user_id, $this->id );
    577577        $this->group_id = apply_filters( 'groups_member_group_id_before_save', $this->group_id, $this->id );
     
    585585        $this->comments = apply_filters( 'groups_member_comments_before_save', $this->comments, $this->id );
    586586        $this->invite_sent = apply_filters( 'groups_member_invite_sent_before_save', $this->invite_sent, $this->id );
    587        
     587
    588588        do_action( 'groups_member_before_save', $this );
    589        
     589
    590590        if ( $this->id ) {
    591591            $sql = $wpdb->prepare( "UPDATE {$bp->groups->table_name_members} SET inviter_id = %d, is_admin = %d, is_mod = %d, is_banned = %d, user_title = %s, date_modified = FROM_UNIXTIME(%d), is_confirmed = %d, comments = %s, invite_sent = %d WHERE id = %d", $this->inviter_id, $this->is_admin, $this->is_mod, $this->is_banned, $this->user_title, $this->date_modified, $this->is_confirmed, $this->comments, $this->invite_sent, $this->id );
     
    596596        if ( !$wpdb->query($sql) )
    597597            return false;
    598        
     598
    599599        $this->id = $wpdb->insert_id;
    600        
     600
    601601        do_action( 'groups_member_after_save', $this );
    602        
     602
    603603        return true;
    604604    }
    605    
     605
    606606    function promote( $status = 'mod' ) {
    607607        if ( 'mod' == $status ) {
     
    610610            $this->user_title = __( 'Group Mod', 'buddypress' );
    611611        }
    612        
     612
    613613        if ( 'admin' == $status ) {
    614614            $this->is_admin = 1;
     
    616616            $this->user_title = __( 'Group Admin', 'buddypress' );
    617617        }
    618        
     618
    619619        return $this->save();
    620620    }
    621    
    622     function demote() {     
     621
     622    function demote() {
    623623        $this->is_mod = 0;
    624624        $this->is_admin = 0;
    625625        $this->user_title = false;
    626        
    627         return $this->save();       
    628     }
    629    
     626
     627        return $this->save();
     628    }
     629
    630630    function ban() {
    631         if ( $this->is_admin ) 
    632             return false;
    633        
     631        if ( $this->is_admin )
     632            return false;
     633
    634634        $this->is_mod = 0;
    635635        $this->is_banned = 1;
    636        
     636
    637637        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) - 1 ) );
    638        
    639         return $this->save();       
    640     }
    641    
     638
     639        return $this->save();
     640    }
     641
    642642    function unban() {
    643         if ( $this->is_admin ) 
    644             return false;
    645        
     643        if ( $this->is_admin )
     644            return false;
     645
    646646        $this->is_banned = 0;
    647647
    648648        groups_update_groupmeta( $this->group_id, 'total_member_count', ( (int) groups_get_groupmeta( $this->group_id, 'total_member_count' ) + 1 ) );
    649        
    650         return $this->save();       
    651     }
    652    
     649
     650        return $this->save();
     651    }
     652
    653653    function accept_invite() {
    654654        $this->inviter_id = 0;
     
    656656        $this->date_modified = time();
    657657    }
    658    
     658
    659659    function accept_request() {
    660660        $this->is_confirmed = 1;
    661         $this->date_modified = time();     
    662     }
    663        
     661        $this->date_modified = time();
     662    }
     663
    664664    /* Static Functions */
    665665
     
    668668
    669669        $delete_result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
    670        
     670
    671671        return $delete_result;
    672672    }
    673    
     673
    674674    function get_group_ids( $user_id, $limit = false, $page = false ) {
    675675        global $wpdb, $bp;
     
    677677        if ( $limit && $page )
    678678            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    679        
     679
    680680        // If the user is logged in and viewing their own groups, we can show hidden and private groupss
    681681        if ( bp_is_home() ) {
    682             $group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id );   
    683             $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) ); 
     682            $group_sql = $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0{$pag_sql}", $user_id );
     683            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
    684684        } else {
    685             $group_sql = $wpdb->prepare( "SELECT 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.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id ); 
     685            $group_sql = $wpdb->prepare( "SELECT 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.inviter_id = 0 AND m.is_banned = 0{$pag_sql}", $user_id );
    686686            $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(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.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
    687687        }
    688        
     688
    689689        $groups = $wpdb->get_col( $group_sql );
    690690
    691691        return array( 'groups' => $groups, 'total' => (int) $total_groups );
    692692    }
    693    
     693
    694694    function get_recently_joined( $user_id, $limit = false, $page = false, $filter = false ) {
    695695        global $wpdb, $bp;
     
    700700        if ( $filter ) {
    701701            $filter = like_escape( $wpdb->escape( $filter ) );
    702             $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";         
     702            $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
    703703        }
    704704
    705705        if ( !bp_is_home() )
    706706            $hidden_sql = " AND g.status != 'hidden'";
    707        
    708         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) ); 
    709         $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) ); 
    710 
    711         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    712     }
    713    
     707
     708        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC {$pag_sql}", $user_id ) );
     709        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 ORDER BY m.date_modified DESC", $user_id ) );
     710
     711        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     712    }
     713
    714714    function get_most_popular( $user_id, $limit = false, $page = false, $filter = false ) {
    715715        global $wpdb, $bp;
     
    720720        if ( $filter ) {
    721721            like_escape( $wpdb->escape( $filter ) );
    722             $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";         
     722            $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
    723723        }
    724724
     
    726726            $hidden_sql = " AND g.status != 'hidden'";
    727727
    728         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) ); 
    729         $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) ); 
    730        
    731         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    732     }
    733    
     728        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC {$pag_sql}", $user_id ) );
     729        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_confirmed = 1 LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id AND gm.meta_key = 'total_member_count' ORDER BY CONVERT( gm.meta_value, SIGNED ) DESC", $user_id ) );
     730
     731        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     732    }
     733
    734734    function get_recently_active( $user_id, $limit = false, $page = false, $filter = false ) {
    735735        global $wpdb, $bp;
    736    
    737         if ( $limit && $page )
    738             $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    739            
     736
     737        if ( $limit && $page )
     738            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     739
    740740        if ( $filter ) {
    741741            $filter = like_escape( $wpdb->escape( $filter ) );
    742             $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";         
     742            $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
    743743        }
    744744
    745745        if ( !bp_is_home() )
    746746            $hidden_sql = " AND g.status != 'hidden'";
    747        
    748         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC {$pag_sql}", $user_id ) ); 
    749         $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) ); 
    750 
    751         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    752     }
    753    
     747
     748        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC {$pag_sql}", $user_id ) );
     749        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = 'last_activity'{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY gm.meta_value DESC", $user_id ) );
     750
     751        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     752    }
     753
    754754    function get_alphabetically( $user_id, $limit = false, $page = false, $filter = false ) {
    755755        global $wpdb, $bp;
    756    
     756
    757757        if ( $limit && $page )
    758758            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    760760        if ( $filter ) {
    761761            $filter = like_escape( $wpdb->escape( $filter ) );
    762             $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";         
     762            $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
    763763        }
    764764
    765765        if ( !bp_is_home() )
    766             $hidden_sql = " AND g.status != 'hidden'"; 
    767 
    768         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) ); 
    769         $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC", $user_id ) ); 
    770        
    771         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    772     }
    773    
     766            $hidden_sql = " AND g.status != 'hidden'";
     767
     768        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC {$pag_sql}", $user_id ) );
     769        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 ORDER BY g.name ASC", $user_id ) );
     770
     771        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     772    }
     773
    774774    function get_is_admin_of( $user_id, $limit = false, $page = false, $filter = false ) {
    775775        global $wpdb, $bp;
    776    
     776
    777777        if ( $limit && $page )
    778778            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    780780        if ( $filter ) {
    781781            $filter = like_escape( $wpdb->escape( $filter ) );
    782             $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";         
     782            $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
    783783        }
    784784
    785785        if ( !bp_is_home() )
    786             $hidden_sql = " AND g.status != 'hidden'"; 
    787        
    788         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) );   
    789         $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) );   
    790        
    791         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    792     }
    793    
     786            $hidden_sql = " AND g.status != 'hidden'";
     787
     788        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) );
     789        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_admin = 1 ORDER BY date_modified ASC", $user_id ) );
     790
     791        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     792    }
     793
    794794    function get_is_mod_of( $user_id, $limit = false, $page = false, $filter = false ) {
    795795        global $wpdb, $bp;
    796    
     796
    797797        if ( $limit && $page )
    798798            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
     
    800800        if ( $filter ) {
    801801            $filter = like_escape( $wpdb->escape( $filter ) );
    802             $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";         
     802            $filter_sql = " AND ( g.name LIKE '{$filter}%%' OR g.description LIKE '{$filter}%%' )";
    803803        }
    804804
    805805        if ( !bp_is_home() )
    806             $hidden_sql = " AND g.status != 'hidden'";         
    807 
    808         $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) ); 
    809         $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) ); 
    810        
    811         return array( 'groups' => $paged_groups, 'total' => $total_groups );
    812     }
    813    
     806            $hidden_sql = " AND g.status != 'hidden'";
     807
     808        $paged_groups = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT m.group_id FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC {$pag_sql}", $user_id ) );
     809        $total_groups = $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id{$hidden_sql}{$filter_sql} AND m.user_id = %d AND m.inviter_id = 0 AND m.is_banned = 0 AND m.is_mod = 1 ORDER BY date_modified ASC", $user_id ) );
     810
     811        return array( 'groups' => $paged_groups, 'total' => $total_groups );
     812    }
     813
    814814    function total_group_count( $user_id = false ) {
    815815        global $bp, $wpdb;
    816        
     816
    817817        if ( !$user_id )
    818818            $user_id = $bp->displayed_user->id;
    819            
     819
    820820        if ( bp_is_home() ) {
    821             return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );         
     821            return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(group_id) FROM {$bp->groups->table_name_members} WHERE user_id = %d AND inviter_id = 0 AND is_banned = 0", $user_id ) );
    822822        } else {
    823             return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(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.inviter_id = 0 AND m.is_banned = 0", $user_id ) );           
    824         }
    825     }
    826    
     823            return $wpdb->get_var( $wpdb->prepare( "SELECT DISTINCT count(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.inviter_id = 0 AND m.is_banned = 0", $user_id ) );
     824        }
     825    }
     826
    827827    function get_invites( $user_id ) {
    828828        global $wpdb, $bp;
    829        
     829
    830830        $group_ids = $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d and is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id ) );
    831        
     831
    832832        return $group_ids;
    833833    }
    834    
     834
    835835    function check_has_invite( $user_id, $group_id ) {
    836836        global $wpdb, $bp;
    837        
     837
    838838        if ( !$user_id )
    839839            return false;
    840            
    841         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );       
    842     }
    843    
     840
     841        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
     842    }
     843
    844844    function delete_invite( $user_id, $group_id ) {
    845845        global $wpdb, $bp;
    846        
     846
    847847        if ( !$user_id )
    848848            return false;
    849        
    850         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );               
    851     }
    852    
     849
     850        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
     851    }
     852
    853853    function check_is_admin( $user_id, $group_id ) {
    854854        global $wpdb, $bp;
    855        
     855
    856856        if ( !$user_id )
    857857            return false;
    858        
     858
    859859        return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_admin = 1 AND is_banned = 0", $user_id, $group_id ) );
    860860    }
    861    
     861
    862862    function check_is_mod( $user_id, $group_id ) {
    863863        global $wpdb, $bp;
    864        
     864
    865865        if ( !$user_id )
    866866            return false;
    867                
     867
    868868        return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_mod = 1 AND is_banned = 0", $user_id, $group_id ) );
    869869    }
    870    
     870
    871871    function check_is_member( $user_id, $group_id ) {
    872872        global $wpdb, $bp;
    873        
     873
    874874        if ( !$user_id )
    875875            return false;
    876        
    877         return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) );   
    878     }
    879    
     876
     877        return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 1 AND is_banned = 0", $user_id, $group_id ) );
     878    }
     879
    880880    function check_is_banned( $user_id, $group_id ) {
    881881        global $wpdb, $bp;
    882        
     882
    883883        if ( !$user_id )
    884884            return false;
    885        
     885
    886886        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 ) );
    887887    }
    888    
     888
    889889    function check_for_membership_request( $user_id, $group_id ) {
    890890        global $wpdb, $bp;
    891        
     891
    892892        if ( !$user_id )
    893893            return false;
    894        
    895         return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) );   
    896     }
    897    
     894
     895        return $wpdb->query( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND is_banned = 0 AND inviter_id = 0", $user_id, $group_id ) );
     896    }
     897
    898898    function get_random_groups( $user_id, $total_groups = 5 ) {
    899899        global $wpdb, $bp;
    900        
     900
    901901        // If the user is logged in and viewing their random groups, we can show hidden and private groups
    902902        if ( bp_is_home() ) {
    903903            return $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 1 AND is_banned = 0 ORDER BY rand() LIMIT $total_groups", $user_id ) );
    904904        } else {
    905             return $wpdb->get_col( $wpdb->prepare( "SELECT 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 ORDER BY rand() LIMIT $total_groups", $user_id ) );         
    906         }
    907     }
    908    
     905            return $wpdb->get_col( $wpdb->prepare( "SELECT 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 ORDER BY rand() LIMIT $total_groups", $user_id ) );
     906        }
     907    }
     908
    909909    function get_group_administrator_ids( $group_id ) {
    910910        global $bp, $wpdb;
    911        
     911
    912912        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_admin = 1 AND is_banned = 0", $group_id ) );
    913913    }
    914    
     914
    915915    function get_group_moderator_ids( $group_id ) {
    916916        global $bp, $wpdb;
     
    918918        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_mod = 1 AND is_banned = 0", $group_id ) );
    919919    }
    920    
     920
    921921    function get_all_membership_request_user_ids( $group_id ) {
    922922        global $bp, $wpdb;
    923923
    924         return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );     
    925     }
    926    
     924        return $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 0 AND inviter_id = 0", $group_id ) );
     925    }
     926
    927927    function get_all_for_group( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true ) {
    928928        global $bp, $wpdb;
    929        
     929
    930930        if ( $limit && $page )
    931931            $pag_sql = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    932        
     932
    933933        if ( $exclude_admins_mods )
    934934            $exclude_sql = $wpdb->prepare( "AND is_admin = 0 AND is_mod = 0" );
    935        
     935
    936936        if ( $exclude_banned )
    937937            $banned_sql = $wpdb->prepare( " AND is_banned = 0" );
    938        
     938
    939939        $members = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql} {$pag_sql}", $group_id ) );
    940940
    941941        if ( !$members )
    942942            return false;
    943        
    944         if ( !isset($pag_sql) ) 
     943
     944        if ( !isset($pag_sql) )
    945945            $total_member_count = count($members);
    946946        else
    947947            $total_member_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(user_id) FROM {$bp->groups->table_name_members} WHERE group_id = %d AND is_confirmed = 1 {$banned_sql} {$exclude_sql}", $group_id ) );
    948    
     948
    949949        return array( 'members' => $members, 'count' => $total_member_count );
    950950    }
    951    
     951
    952952    function delete_all_for_user( $user_id ) {
    953953        global $wpdb, $bp;
    954        
    955         return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) );     
     954
     955        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) );
    956956    }
    957957}
     
    959959/**
    960960 * API for creating group extensions without having to hardcode the content into
    961  * the theme. 
     961 * the theme.
    962962 *
    963963 * This class must be extended for each group extension and the following methods overridden:
    964  * 
     964 *
    965965 * BP_Group_Extension::widget_display(), BP_Group_Extension::display(),
    966966 * BP_Group_Extension::edit_screen_save(), BP_Group_Extension::edit_screen(),
     
    974974    var $name = false;
    975975    var $slug = false;
    976    
     976
    977977    /* Will this extension be visible to non-members of a group? Options: public/private */
    978978    var $visibility = 'public';
    979    
     979
    980980    var $create_step_position = 81;
    981981    var $nav_item_position = 81;
    982    
     982
    983983    var $enable_create_step = true;
    984984    var $enable_nav_item = true;
    985985    var $enable_edit_item = true;
    986    
     986
    987987    var $nav_item_name = false;
    988    
     988
    989989    var $display_hook = 'groups_custom_group_boxes';
    990990    var $template_file = 'plugin-template';
    991    
     991
    992992    // Methods you should override
    993    
     993
    994994    function display() {
    995995        die( 'function BP_Group_Extension::display() must be over-ridden in a sub-class.' );
    996996    }
    997    
     997
    998998    function widget_display() {
    999999        die( 'function BP_Group_Extension::widget_display() must be over-ridden in a sub-class.' );
    10001000    }
    1001    
     1001
    10021002    function edit_screen() {
    10031003        die( 'function BP_Group_Extension::edit_screen() must be over-ridden in a sub-class.' );
    10041004    }
    1005    
     1005
    10061006    function edit_screen_save() {
    10071007        die( 'function BP_Group_Extension::edit_screen_save() must be over-ridden in a sub-class.' );
    10081008    }
    1009    
     1009
    10101010    function create_screen() {
    10111011        die( 'function BP_Group_Extension::create_screen() must be over-ridden in a sub-class.' );
    10121012    }
    1013    
     1013
    10141014    function create_screen_save() {
    1015         die( 'function BP_Group_Extension::create_screen_save() must be over-ridden in a sub-class.' ); 
    1016     }
    1017    
     1015        die( 'function BP_Group_Extension::create_screen_save() must be over-ridden in a sub-class.' );
     1016    }
     1017
    10181018    // Private Methods
    1019    
     1019
    10201020    function _register() {
    10211021        global $bp;
     
    10271027            /* Attach the group creation step display content action */
    10281028            add_action( 'groups_custom_create_steps', array( &$this, 'create_screen' ) );
    1029    
     1029
    10301030            /* Attach the group creation step save content action */
    10311031            add_action( 'groups_create_group_step_save_' . $this->slug, array( &$this, 'create_screen_save' ) );
    10321032        }
    1033    
     1033
    10341034        /* Construct the admin edit tab for the new group extension */
    10351035        if ( $this->enable_edit_item ) {
    1036             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 ); 
     1036            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 );
    10371037
    10381038            /* Catch the edit screen and forward it to the plugin template */
     
    10421042
    10431043                if ( '' != locate_template( array( 'groups/single/admin.php' ), false ) ) {
    1044                     bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );     
     1044                    bp_core_load_template( apply_filters( 'groups_template_group_admin', 'groups/single/admin' ) );
    10451045                } else {
    10461046                    add_action( 'bp_template_content_header', create_function( '', 'echo "<ul class=\"content-header-nav\">"; bp_group_admin_tabs(); echo "</ul>";' ) );
    10471047                    add_action( 'bp_template_content', array( &$this, 'edit_screen' ) );
    1048                     bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) ); 
     1048                    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'plugin-template' ) );
    10491049                }
    10501050            }
     
    10551055            if ( $this->enable_nav_item ) {
    10561056                if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item )
    1057                     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 ) );           
     1057                    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 ) );
    10581058
    10591059                /* When we are viewing the extension display page, set the title and options title */
     
    10631063                }
    10641064            }
    1065            
     1065
    10661066            /* Hook the group home widget */
    10671067            if ( $bp->current_component == $bp->groups->slug && $bp->is_single_item && ( !$bp->current_action || 'home' == $bp->current_action ) )
     
    10691069        }
    10701070    }
    1071    
     1071
    10721072    function _display_hook() {
    10731073        add_action( 'bp_template_content', array( &$this, 'display' ) );
     
    10781078function bp_register_group_extension( $group_extension_class ) {
    10791079    global $bp;
    1080    
     1080
    10811081    if ( !class_exists( $group_extension_class ) )
    10821082        return false;
    1083    
     1083
    10841084    /* Register the group extension on the plugins_loaded action so we have access to all plugins */
    10851085    add_action( 'plugins_loaded', create_function( '', '$extension = new ' . $group_extension_class . '; add_action( "wp", array( &$extension, "_register" ), 2 );' ) );
  • trunk/bp-groups/bp-groups-filters.php

    r2026 r2077  
    6161function groups_add_forum_privacy_sql() {
    6262    global $bp;
    63    
     63
    6464    /* Only filter the forum SQL on group pages or on the forums directory */
    6565    if ( ( $bp->groups->current_group && 'public' == $bp->groups->current_group->status ) || bp_is_directory() ) {
     
    8282function groups_add_forum_where_sql( $sql ) {
    8383    global $bp;
    84    
     84
    8585    $bp->groups->filter_sql = ' AND ' . $sql;
    8686    return "(gm.meta_key = 'forum_id' AND gm.meta_value = t.forum_id) AND g.status = 'public' AND " . $sql;
     
    9292    if ( is_site_admin() )
    9393        return true;
    94    
     94
    9595    if ( 'add_tag_to' == $cap )
    9696        if ( $bp->groups->current_group->user_has_access ) return true;
    97    
     97
    9898    if ( 'manage_forums' == $cap && is_user_logged_in() )
    9999        return true;
    100    
     100
    101101    return $value;
    102102}
  • trunk/bp-groups/bp-groups-notifications.php

    r1905 r2077  
    33function groups_notification_new_wire_post( $group_id, $wire_post_id ) {
    44    global $bp;
    5    
     5
    66    if ( !isset( $_POST['wire-post-email-notify'] ) )
    77        return false;
    8    
     8
    99    $wire_post = new BP_Wire_Post( $bp->groups->table_name_wire, $wire_post_id );
    1010    $group = new BP_Groups_Group( $group_id, false, true );
    11    
     11
    1212    $poster_name = bp_core_get_user_displayname( $wire_post->user_id );
    13     $poster_profile_link = bp_core_get_user_domain( $wire_post->user_id ); 
     13    $poster_profile_link = bp_core_get_user_domain( $wire_post->user_id );
    1414
    1515    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New wire post on group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
     
    1717    foreach ( $group->user_dataset as $user ) {
    1818        if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_wire_post' ) ) continue;
    19        
     19
    2020        $ud = get_userdata( $user->user_id );
    21        
     21
    2222        // Set up and send the message
    2323        $to = $ud->user_email;
     
    2525        $wire_link = site_url( $bp->groups->slug . '/' . $group->slug . '/wire/' );
    2626        $group_link = site_url( $bp->groups->slug . '/' . $group->slug . '/' );
    27         $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/'; 
    28 
    29         $message = sprintf( __( 
     27        $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/';
     28
     29        $message = sprintf( __(
    3030'%s posted on the wire of the group "%s":
    3131
     
    4545        // Send it
    4646        wp_mail( $to, $subject, $message );
    47        
     47
    4848        unset( $message, $to );
    4949    }
     
    5252function groups_notification_group_updated( $group_id ) {
    5353    global $bp;
    54    
     54
    5555    $group = new BP_Groups_Group( $group_id, false, true );
    5656    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' );
     
    5858    foreach ( $group->user_dataset as $user ) {
    5959        if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_group_updated' ) ) continue;
    60        
     60
    6161        $ud = get_userdata( $user->user_id );
    62        
     62
    6363        // Set up and send the message
    6464        $to = $ud->user_email;
     
    6767        $settings_link = bp_core_get_user_domain( $user->user_id ) . 'settings/notifications/';
    6868
    69         $message = sprintf( __( 
     69        $message = sprintf( __(
    7070'Group details for the group "%s" were updated:
    7171
     
    9191    if ( 'no' == get_usermeta( $admin_id, 'notification_groups_membership_request' ) )
    9292        return false;
    93        
     93
    9494    $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
    9595    $group = new BP_Groups_Group( $group_id, false, false );
    96    
     96
    9797    $ud = get_userdata($admin_id);
    9898    $requesting_ud = get_userdata($requesting_user_id);
     
    106106    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
    107107
    108 $message = sprintf( __( 
     108$message = sprintf( __(
    109109'%s wants to join the group "%s".
    110110
     
    122122
    123123    // Send it
    124     wp_mail( $to, $subject, $message ); 
     124    wp_mail( $to, $subject, $message );
    125125}
    126126
    127127function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) {
    128128    global $bp;
    129    
     129
    130130    // Post a screen notification first.
    131131    if ( $accepted )
     
    133133    else
    134134        bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
    135    
     135
    136136    if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) )
    137137        return false;
    138        
     138
    139139    $group = new BP_Groups_Group( $group_id, false, false );
    140    
     140
    141141    $ud = get_userdata($requesting_user_id);
    142142
     
    146146    // Set up and send the message
    147147    $to = $ud->user_email;
    148    
     148
    149149    if ( $accepted ) {
    150150        $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
    151         $message = sprintf( __( 
     151        $message = sprintf( __(
    152152'Your membership request for the group "%s" has been accepted.
    153153
     
    156156---------------------
    157157', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link );
    158        
     158
    159159    } else {
    160160        $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
    161         $message = sprintf( __( 
     161        $message = sprintf( __(
    162162'Your membership request for the group "%s" has been rejected.
    163163
     
    167167', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ), $group_link );
    168168    }
    169    
     169
    170170    $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    171171
    172172    // Send it
    173     wp_mail( $to, $subject, $message ); 
     173    wp_mail( $to, $subject, $message );
    174174}
    175175
     
    184184        $type = 'member_promoted_to_mod';
    185185    }
    186    
     186
    187187    // Post a screen notification first.
    188188    bp_core_add_notification( $group_id, $user_id, 'groups', $type );
     
    202202    $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
    203203
    204     $message = sprintf( __( 
     204    $message = sprintf( __(
    205205'You have been promoted to %s for the group: "%s".
    206206
     
    219219function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
    220220    global $bp;
    221    
     221
    222222    $inviter_ud = get_userdata( $inviter_user_id );
    223223    $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
    224224    $inviter_link = bp_core_get_user_domain( $inviter_user_id );
    225    
     225
    226226    $group_link = bp_get_group_permalink( $group );
    227    
     227
    228228    if ( !$member->invite_sent ) {
    229229        $invited_user_id = $member->user_id;
     
    236236
    237237        $invited_ud = get_userdata($invited_user_id);
    238        
     238
    239239        $settings_link = bp_core_get_user_domain( $invited_user_id ) . 'settings/notifications/';
    240240        $invited_link = bp_core_get_user_domain( $invited_user_id );
     
    246246        $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), stripslashes( attribute_escape( $group->name ) ) );
    247247
    248         $message = sprintf( __( 
     248        $message = sprintf( __(
    249249'One of your friends %s has invited you to the group: "%s".
    250250
  • trunk/bp-groups/bp-groups-templatetags.php

    r2055 r2077  
    99    <li<?php if ( 'admin-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/admin-of""><?php _e( 'Administrator Of', 'buddypress' ) ?></a></li>
    1010    <li<?php if ( 'mod-of' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/mod-of""><?php _e( 'Moderator Of', 'buddypress' ) ?></a></li>
    11     <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>   
     11    <li<?php if ( 'alphabetically' == $bp->action_variables[0] ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>/my-groups/alphabetically""><?php _e( 'Alphabetically', 'buddypress' ) ?></a></li>
    1212<?php
    1313    do_action( 'groups_header_tabs' );
     
    1616function bp_groups_filter_title() {
    1717    global $bp;
    18    
     18
    1919    $current_filter = $bp->action_variables[0];
    20    
     20
    2121    switch ( $current_filter ) {
    2222        case 'recently-active': default:
     
    4444function bp_is_group_admin_screen( $slug ) {
    4545    global $bp;
    46    
     46
    4747    if ( $bp->current_component != BP_GROUPS_SLUG || 'admin' != $bp->current_action )
    4848        return false;
    49    
     49
    5050    if ( $bp->action_variables[0] == $slug )
    5151        return true;
    52    
     52
    5353    return false;
    5454}
     
    5656function bp_group_current_avatar() {
    5757    global $bp;
    58    
     58
    5959    if ( $bp->groups->current_group->avatar_full ) { ?>
    6060        <img src="<?php echo attribute_escape( $bp->groups->current_group->avatar_full ) ?>" alt="<?php _e( 'Group Avatar', 'buddypress' ) ?>" class="avatar" />
     
    7070    if ( !empty( $_FILES ) || !bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'no_grav' => true ) ) )
    7171        return false;
    72    
     72
    7373    return true;
    7474}
     
    7979    function bp_get_group_avatar_delete_link() {
    8080        global $bp;
    81        
     81
    8282        return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/group-avatar/delete', 'bp_group_avatar_delete' ) );
    8383    }
     
    113113    var $groups;
    114114    var $group;
    115    
     115
    116116    var $in_the_loop;
    117    
     117
    118118    var $pag_page;
    119119    var $pag_num;
    120120    var $pag_links;
    121121    var $total_group_count;
    122    
     122
    123123    var $single_group = false;
    124    
     124
    125125    var $sort_by;
    126126    var $order;
    127    
     127
    128128    function bp_groups_user_groups_template( $user_id, $type, $per_page, $max, $slug, $filter ) {
    129129        global $bp;
    130        
     130
    131131        if ( !$user_id )
    132132            $user_id = $bp->displayed_user->id;
    133        
     133
    134134        $this->pag_page = isset( $_REQUEST['grpage'] ) ? intval( $_REQUEST['grpage'] ) : 1;
    135135        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     
    141141
    142142            case 'popular':
    143                 $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );             
     143                $this->groups = groups_get_most_popular_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
    144144                break;
    145145
    146146            case 'admin-of':
    147                 $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter );             
    148                 break; 
     147                $this->groups = groups_get_user_is_admin_of( $user_id, $this->pag_num, $this->pag_page, $filter );
     148                break;
    149149
    150150            case 'mod-of':
    151                 $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );               
     151                $this->groups = groups_get_user_is_mod_of( $user_id, $this->pag_num, $this->pag_page, $filter );
    152152                break;
    153153
    154154            case 'alphabetical':
    155                 $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );   
     155                $this->groups = groups_get_alphabetically_for_user( $user_id, $this->pag_num, $this->pag_page, $filter );
    156156                break;
    157157
     
    162162            case 'single-group':
    163163                $group = new stdClass;
    164                 $group->group_id = BP_Groups_Group::get_id_from_slug($slug);           
     164                $group->group_id = BP_Groups_Group::get_id_from_slug($slug);
    165165                $this->groups = array( $group );
    166166                break;
     
    170170                break;
    171171        }
    172        
     172
    173173        if ( 'invites' == $type ) {
    174174            $this->total_group_count = count($this->groups);
     
    210210        if ( $this->group_count )
    211211            return true;
    212        
     212
    213213        return false;
    214214    }
    215    
     215
    216216    function next_group() {
    217217        $this->current_group++;
    218218        $this->group = $this->groups[$this->current_group];
    219            
     219
    220220        return $this->group;
    221221    }
    222    
     222
    223223    function rewind_groups() {
    224224        $this->current_group = -1;
     
    227227        }
    228228    }
    229    
    230     function user_groups() { 
     229
     230    function user_groups() {
    231231        if ( $this->current_group + 1 < $this->group_count ) {
    232232            return true;
     
    240240        return false;
    241241    }
    242    
     242
    243243    function the_group() {
    244244        global $group;
     
    246246        $this->in_the_loop = true;
    247247        $this->group = $this->next_group();
    248        
     248
    249249        // If this is a single group then instantiate group meta when creating the object.
    250250        if ( $this->single_group ) {
     
    259259            }
    260260        }
    261        
     261
    262262        $this->group = $group;
    263        
     263
    264264        if ( 0 == $this->current_group ) // loop has just started
    265265            do_action('loop_start');
     
    269269function bp_has_groups( $args = '' ) {
    270270    global $groups_template, $bp;
    271    
     271
    272272    $defaults = array(
    273273        'type' => 'active',
     
    281281    $r = wp_parse_args( $args, $defaults );
    282282    extract( $r, EXTR_SKIP );
    283    
     283
    284284    /* The following code will auto set parameters based on the page being viewed.
    285285     * for example on example.com/members/andy/groups/my-groups/most-popular/
     
    304304        $slug = $bp->groups->current_group->slug;
    305305    }
    306    
     306
    307307    if ( isset( $_REQUEST['group-filter-box'] ) )
    308308        $filter = $_REQUEST['group-filter-box'];
    309    
     309
    310310    $groups_template = new BP_Groups_User_Groups_Template( $user_id, $type, $per_page, $max, $slug, $filter );
    311311    return apply_filters( 'bp_has_groups', $groups_template->has_groups(), &$groups_template );
     
    324324function bp_group_is_visible( $group = false ) {
    325325    global $bp, $groups_template;
    326    
     326
    327327    if ( !$group )
    328328        $group =& $groups_template->group;
    329        
     329
    330330    if ( 'public' == $group->status ) {
    331331        return true;
     
    335335        }
    336336    }
    337    
     337
    338338    return false;
    339339}
     
    341341function bp_group_has_news( $group = false ) {
    342342    global $groups_template;
    343    
     343
    344344    if ( !$group )
    345345        $group =& $groups_template->group;
    346    
     346
    347347    if ( empty( $group->news ) )
    348348        return false;
    349    
     349
    350350    return true;
    351351}
     
    367367        return apply_filters( 'bp_get_group_id', $group->id );
    368368    }
    369    
     369
    370370function bp_group_name( $deprecated = true, $deprecated2 = false ) {
    371371    global $groups_template;
     
    396396        if ( 'public' == $group->status ) {
    397397            $type = __( "Public Group", "buddypress" );
    398         } else if ( 'hidden' == $group->status ) { 
     398        } else if ( 'hidden' == $group->status ) {
    399399            $type = __( "Hidden Group", "buddypress" );
    400400        } else if ( 'private' == $group->status ) {
     
    404404        }
    405405
    406         return apply_filters( 'bp_get_group_type', $type ); 
     406        return apply_filters( 'bp_get_group_type', $type );
    407407    }
    408408
     
    416416            $group =& $groups_template->group;
    417417
    418         return apply_filters( 'bp_get_group_status', $group->status ); 
     418        return apply_filters( 'bp_get_group_status', $group->status );
    419419    }
    420420
     
    431431            'class' => 'avatar',
    432432            'id' => false,
    433             'alt' => __( 'Group avatar', 'buddypress' ) 
     433            'alt' => __( 'Group avatar', 'buddypress' )
    434434        );
    435435
    436436        $r = wp_parse_args( $args, $defaults );
    437437        extract( $r, EXTR_SKIP );
    438    
     438
    439439        /* Fetch the avatar from the folder, if not provide backwards compat. */
    440440        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 ) ) )
     
    462462        return bp_get_group_last_active();
    463463    else
    464         echo bp_get_group_last_active();           
     464        echo bp_get_group_last_active();
    465465}
    466466    function bp_get_group_last_active( $group = false ) {
     
    475475            return __( 'not yet active', 'buddypress' );
    476476        } else {
    477             return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) );         
    478         }
    479     }
    480    
     477            return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ) );
     478        }
     479    }
     480
    481481function bp_group_permalink( $deprecated = false, $deprecated2 = true ) {
    482482    if ( !$deprecated2 )
     
    506506            $group =& $groups_template->group;
    507507
    508         return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' ); 
     508        return apply_filters( 'bp_get_group_admin_permalink', $bp->root_domain . '/' . $bp->groups->slug . '/' . $group->slug . '/admin' );
    509509    }
    510510
     
    557557            $group =& $groups_template->group;
    558558
    559         return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );   
     559        return apply_filters( 'bp_get_group_description_excerpt', bp_create_excerpt( $group->description, 20 ) );
    560560    }
    561561
     
    599599        }
    600600    }
    601    
     601
    602602function bp_group_is_public( $deprecated = false ) {
    603603    echo bp_get_group_is_public();
     
    626626function bp_group_is_admin() {
    627627    global $bp;
    628    
     628
    629629    return $bp->is_item_admin;
    630630}
     
    632632function bp_group_is_mod() {
    633633    global $bp;
    634    
     634
    635635    return $bp->is_item_mod;
    636636}
     
    638638function bp_group_list_admins( $full_list = true, $group = false ) {
    639639    global $groups_template;
    640    
     640
    641641    if ( !$group )
    642642        $group =& $groups_template->group;
    643    
     643
    644644    if ( !$admins = &$group->admins )
    645645        $admins = $group->get_administrators();
     
    665665        <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span>
    666666    <?php } ?>
    667    
     667
    668668<?php
    669669}
     
    671671function bp_group_list_mods( $full_list = true, $group = false ) {
    672672    global $groups_template;
    673    
     673
    674674    if ( !$group )
    675675        $group =& $groups_template->group;
    676    
     676
    677677    $group_mods = groups_get_group_mods( $group->id );
    678    
     678
    679679    if ( $group_mods ) {
    680680        if ( $full_list ) { ?>
     
    697697        <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span>
    698698    <?php } ?>
    699    
     699
    700700<?php
    701701}
     
    706706    if ( !$group )
    707707        $group =& $groups_template->group;
    708    
     708
    709709    if ( !$deprecated )
    710710        return bp_get_group_all_members_permalink();
     
    731731        <label for="<?php echo $name ?>" id="<?php echo $name ?>-label"><?php echo $label ?></label>
    732732        <input type="search" name="<?php echo $name ?>" id="<?php echo $name ?>" value="<?php echo $value ?>"<?php echo $disabled ?> />
    733    
     733
    734734        <?php wp_nonce_field( 'group-filter-box', '_wpnonce_group_filter' ) ?>
    735735    </form>
     
    739739function bp_group_show_no_groups_message() {
    740740    global $bp;
    741    
     741
    742742    if ( !groups_total_groups_for_user( $bp->displayed_user->id ) )
    743743        return true;
    744        
     744
    745745    return false;
    746746}
     
    751751    function bp_get_group_pagination() {
    752752        global $groups_template;
    753        
     753
    754754        return apply_filters( 'bp_get_group_pagination', $groups_template->pag_links );
    755755    }
     
    762762
    763763    echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $groups_template->total_group_count ); ?> &nbsp;
    764     <span class="ajax-loader"></span><?php 
     764    <span class="ajax-loader"></span><?php
    765765}
    766766
     
    804804    if ( !$group )
    805805        $group =& $groups_template->group;
    806    
     806
    807807    if ( $group->enable_wire )
    808808        return true;
    809    
     809
    810810    return false;
    811811}
     
    833833            if ( $group->enable_forum )
    834834                return true;
    835            
     835
    836836            return false;
    837837        } else {
     
    839839        }
    840840    }
    841    
    842     return false;   
     841
     842    return false;
    843843}
    844844
     
    848848    if ( !$group )
    849849        $group =& $groups_template->group;
    850    
     850
    851851    if ( $group->enable_forum )
    852852        echo ' checked="checked"';
     
    858858    if ( !$group )
    859859        $group =& $groups_template->group;
    860    
     860
    861861    if ( $setting == $group->status )
    862862        echo ' checked="checked"';
     
    865865function bp_group_admin_memberlist( $admin_list = false, $group = false ) {
    866866    global $groups_template;
    867    
     867
    868868    if ( !$group )
    869869        $group =& $groups_template->group;
    870    
     870
    871871    $admins = groups_get_group_admins( $group->id );
    872872?>
     
    884884                <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5>
    885885                <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
    886                
     886
    887887                <?php if ( function_exists( 'friends_install' ) ) : ?>
    888888                    <div class="action">
     
    890890                    </div>
    891891                <?php endif; ?>
    892             </li>       
     892            </li>
    893893            <?php } ?>
    894894        <?php } ?>
     
    902902
    903903function bp_group_mod_memberlist( $admin_list = false, $group = false ) {
    904     global $groups_template, $group_mods;   
     904    global $groups_template, $group_mods;
    905905
    906906    if ( !$group )
    907907        $group =& $groups_template->group;
    908    
     908
    909909    $group_mods = groups_get_group_mods( $group->id );
    910910    ?>
     
    922922                    <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5>
    923923                    <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
    924                    
     924
    925925                    <?php if ( function_exists( 'friends_install' ) ) : ?>
    926926                        <div class="action">
     
    928928                        </div>
    929929                    <?php endif; ?>
    930                 </li>       
    931                 <?php } ?>         
     930                </li>
     931                <?php } ?>
    932932            <?php } ?>
    933933            </ul>
     
    10011001        return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/admin/manage-members/demote/' . $user_id, 'groups_demote_member' ) );
    10021002    }
    1003    
     1003
    10041004function bp_group_member_ban_link( $user_id = false, $deprecated = false ) {
    10051005    global $members_template;
     
    10241024    if ( !$user_id )
    10251025        $user_id = $members_template->member->user_id;
    1026    
    1027     echo bp_get_group_member_unban_link( $user_id );   
     1026
     1027    echo bp_get_group_member_unban_link( $user_id );
    10281028}
    10291029    function bp_get_group_member_unban_link( $user_id = false, $group = false ) {
     
    10321032        if ( !$user_id )
    10331033            $user_id = $members_template->member->user_id;
    1034        
    1035         if ( !$group )
    1036             $group =& $groups_template->group;
    1037 
    1038         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' ) ); 
     1034
     1035        if ( !$group )
     1036            $group =& $groups_template->group;
     1037
     1038        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' ) );
    10391039    }
    10401040
     
    10441044    if ( !$group )
    10451045        $group = ( $groups_template->group ) ? $groups_template->group : $bp->groups->current_group;
    1046    
     1046
    10471047    $current_tab = $bp->action_variables[0];
    10481048?>
     
    10501050        <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/edit-details"><?php _e('Edit Details', 'buddypress') ?></a></li>
    10511051    <?php } ?>
    1052    
     1052
    10531053    <?php
    10541054        if ( !$bp->is_item_admin )
     
    10621062        <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/membership-requests"><?php _e('Membership Requests', 'buddypress') ?></a></li>
    10631063    <?php endif; ?>
    1064    
     1064
    10651065    <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
    1066    
     1066
    10671067    <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug ?>/<?php echo $group->slug ?>/admin/delete-group"><?php _e('Delete Group', 'buddypress') ?></a></li>
    10681068<?php
     
    10871087        return apply_filters( 'bp_group_form_action', bp_get_group_permalink( $group ) . '/' . $page );
    10881088    }
    1089    
     1089
    10901090function bp_group_admin_form_action( $page = false, $deprecated = false ) {
    10911091    echo bp_get_group_admin_form_action( $page );
     
    11051105function bp_group_has_requested_membership( $group = false ) {
    11061106    global $bp, $groups_template;
    1107    
     1107
    11081108    if ( !$group )
    11091109        $group =& $groups_template->group;
    1110    
     1110
    11111111    if ( groups_check_for_membership_request( $bp->loggedin_user->id, $group->id ) )
    11121112        return true;
    1113    
     1113
    11141114    return false;
    11151115}
     
    11201120    if ( !$group )
    11211121        $group =& $groups_template->group;
    1122    
     1122
    11231123    if ( groups_is_user_member( $bp->loggedin_user->id, $group->id ) )
    11241124        return true;
    1125    
     1125
    11261126    return false;
    11271127}
     
    11361136            $group =& $groups_template->group;
    11371137
    1138         return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) );   
     1138        return apply_filters( 'bp_get_group_accept_invite_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/invites/accept/' . $group->id, 'groups_accept_invite' ) );
    11391139    }
    11401140
     
    11601160            $group =& $groups_template->group;
    11611161
    1162         return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) ); 
     1162        return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group/yes', 'groups_leave_group' ) );
    11631163    }
    11641164
     
    11891189function bp_has_friends_to_invite( $group = false ) {
    11901190    global $groups_template, $bp;
    1191    
     1191
    11921192    if ( !function_exists('friends_install') )
    11931193        return false;
     
    11951195    if ( !$group )
    11961196        $group =& $groups_template->group;
    1197    
     1197
    11981198    if ( !friends_check_user_has_friends( $bp->loggedin_user->id ) || !friends_count_invitable_friends( $bp->loggedin_user->id, $group->id ) )
    11991199        return false;
    1200    
     1200
    12011201    return true;
    12021202}
     
    12041204function bp_group_join_button( $group = false ) {
    12051205    global $bp, $groups_template;
    1206    
     1206
    12071207    if ( !$group )
    12081208        $group =& $groups_template->group;
    1209    
     1209
    12101210    // If they're not logged in or are banned from the group, no join button.
    12111211    if ( !is_user_logged_in() || groups_is_user_banned( $bp->loggedin_user->id, $group->id ) )
     
    12141214    if ( !$group->status )
    12151215        return false;
    1216    
     1216
    12171217    echo '<div class="generic-button group-button ' . $group->status . '" id="groupbutton-' . $group->id . '">';
    1218    
     1218
    12191219    switch ( $group->status ) {
    12201220        case 'public':
    12211221            if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) )
    1222                 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';                                 
     1222                echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    12231223            else
    1224                 echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';                   
     1224                echo '<a class="join-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
    12251225        break;
    1226        
     1226
    12271227        case 'private':
    12281228            if ( BP_Groups_Member::check_is_member( $bp->loggedin_user->id, $group->id ) ) {
    1229                 echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';                                     
     1229                echo '<a class="leave-group" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    12301230            } else {
    12311231                if ( !bp_group_has_requested_membership( $group ) )
    1232                     echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';       
     1232                    echo '<a class="request-membership" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_request_membership' ) . '">' . __('Request Membership', 'buddypress') . '</a>';
    12331233                else
    1234                     echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';             
     1234                    echo '<a class="membership-requested" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Request Sent', 'buddypress' ) . '</a>';
    12351235            }
    12361236        break;
    12371237    }
    1238    
     1238
    12391239    echo '</div>';
    12401240}
     
    12421242function bp_group_status_message( $group = false ) {
    12431243    global $groups_template;
    1244    
     1244
    12451245    if ( !$group )
    12461246        $group =& $groups_template->group;
    1247    
     1247
    12481248    if ( 'private' == $group->status ) {
    12491249        if ( !bp_group_has_requested_membership() )
     
    12521252            else
    12531253                _e( 'This is a private group. To join you must be a registered site member and request group membership.', 'buddypress' );
    1254         else 
    1255             _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );         
     1254        else
     1255            _e( 'This is a private group. Your membership request is awaiting approval from the group administrator.', 'buddypress' );
    12561256    } else {
    12571257        _e( 'This is a hidden group and only invited members can join.', 'buddypress' );
     
    12691269    var $members;
    12701270    var $member;
    1271    
     1271
    12721272    var $in_the_loop;
    1273    
     1273
    12741274    var $pag_page;
    12751275    var $pag_num;
    12761276    var $pag_links;
    12771277    var $total_group_count;
    1278    
     1278
    12791279    function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned ) {
    12801280        global $bp;
    1281        
     1281
    12821282        $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1;
    12831283        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    1284        
     1284
    12851285        $this->members = BP_Groups_Member::get_all_for_group( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned );
    1286        
     1286
    12871287        if ( !$max || $max >= (int)$this->members['count'] )
    12881288            $this->total_member_count = (int)$this->members['count'];
     
    12911291
    12921292        $this->members = $this->members['members'];
    1293        
     1293
    12941294        if ( $max ) {
    12951295            if ( $max >= count($this->members) )
     
    13111311        ));
    13121312    }
    1313    
     1313
    13141314    function has_members() {
    13151315        if ( $this->member_count )
     
    13181318        return false;
    13191319    }
    1320    
     1320
    13211321    function next_member() {
    13221322        $this->current_member++;
    13231323        $this->member = $this->members[$this->current_member];
    1324        
     1324
    13251325        return $this->member;
    13261326    }
    1327    
     1327
    13281328    function rewind_members() {
    13291329        $this->current_member = -1;
     
    13321332        }
    13331333    }
    1334    
    1335     function members() { 
     1334
     1335    function members() {
    13361336        if ( $this->current_member + 1 < $this->member_count ) {
    13371337            return true;
     
    13451345        return false;
    13461346    }
    1347    
     1347
    13481348    function the_member() {
    13491349        global $member;
     
    13591359function bp_group_has_members( $args = '' ) {
    13601360    global $bp, $members_template;
    1361    
     1361
    13621362    $defaults = array(
    13631363        'group_id' => $bp->groups->current_group->id,
     
    13771377function bp_group_members() {
    13781378    global $members_template;
    1379    
     1379
    13801380    return $members_template->members();
    13811381}
     
    13831383function bp_group_the_member() {
    13841384    global $members_template;
    1385    
     1385
    13861386    return $members_template->the_member();
    13871387}
     
    14401440        return apply_filters( 'bp_get_group_member_link', bp_core_get_userlink( $members_template->member->user_id ) );
    14411441    }
    1442    
     1442
    14431443function bp_group_member_is_banned() {
    14441444    echo bp_get_group_member_is_banned();
     
    14581458        return apply_filters( 'bp_get_group_member_joined_since', bp_core_get_last_activity( strtotime( $members_template->member->date_modified ), __( 'joined %s ago', 'buddypress') ) );
    14591459    }
    1460    
     1460
    14611461function bp_group_member_id() {
    14621462    echo bp_get_group_member_id();
     
    14731473    if ( $members_template->total_member_count > $members_template->pag_num )
    14741474        return true;
    1475    
     1475
    14761476    return false;
    14771477}
     
    15021502
    15031503        $from_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
    1504         $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 ); 
    1505 
    1506         return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) ); 
     1504        $to_num = ( $from_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $from_num + ( $members_template->pag_num - 1 );
     1505
     1506        return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %d to %d (of %d members)', 'buddypress' ), $from_num, $to_num, $members_template->total_member_count ) );
    15071507    }
    15081508
     
    15131513    function bp_get_group_member_admin_pagination() {
    15141514        global $members_template;
    1515        
     1515
    15161516        return $members_template->pag_links;
    15171517    }
     
    15241524function bp_group_creation_tabs() {
    15251525    global $bp;
    1526    
     1526
    15271527    if ( !is_array( $bp->groups->group_creation_steps ) )
    15281528        return false;
    1529    
     1529
    15301530    if ( !$bp->groups->current_create_step )
    15311531        $bp->groups->current_create_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
     
    15341534    foreach ( $bp->groups->group_creation_steps as $slug => $step ) {
    15351535        $is_enabled = bp_are_previous_group_creation_steps_complete( $slug ); ?>
    1536        
     1536
    15371537        <li<?php if ( $bp->groups->current_create_step == $slug ) : ?> class="current"<?php endif; ?>><?php if ( $is_enabled ) : ?><a href="<?php echo $bp->loggedin_user->domain . $bp->groups->slug ?>/create/step/<?php echo $slug ?>"><?php endif; ?><?php echo $counter ?>. <?php echo $step['name'] ?><?php if ( $is_enabled ) : ?></a><?php endif; ?></li><?php
    15381538        $counter++;
    15391539    }
    1540    
     1540
    15411541    unset( $is_enabled );
    1542    
     1542
    15431543    do_action( 'groups_creation_tabs' );
    15441544}
     
    15461546function bp_group_creation_stage_title() {
    15471547    global $bp;
    1548    
     1548
    15491549    echo apply_filters( 'bp_group_creation_stage_title', '<span>&mdash; ' . $bp->groups->group_creation_steps[$bp->groups->current_create_step]['name'] . '</span>' );
    15501550}
     
    15551555    function bp_get_group_creation_form_action() {
    15561556        global $bp;
    1557        
     1557
    15581558        if ( empty( $bp->action_variables[1] ) )
    15591559            $bp->action_variables[1] = array_shift( array_keys( $bp->groups->group_creation_steps ) );
    1560        
     1560
    15611561        return apply_filters( 'bp_get_group_creation_form_action', $bp->loggedin_user->domain . $bp->groups->slug . '/create/step/' . $bp->action_variables[1] );
    15621562    }
     
    15641564function bp_is_group_creation_step( $step_slug ) {
    15651565    global $bp;
    1566    
     1566
    15671567    /* Make sure we are in the groups component */
    15681568    if ( $bp->current_component != BP_GROUPS_SLUG || 'create' != $bp->current_action )
    15691569        return false;
    1570    
     1570
    15711571    /* If this the first step, we can just accept and return true */
    15721572    if ( !$bp->action_variables[1] && array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
    15731573        return true;
    1574    
     1574
    15751575    /* Before allowing a user to see a group creation step we must make sure previous steps are completed */
    15761576    if ( !bp_is_first_group_creation_step() ) {
     
    15781578            return false;
    15791579    }
    1580    
     1580
    15811581    /* Check the current step against the step parameter */
    15821582    if ( $bp->action_variables[1] == $step_slug )
    15831583        return true;
    1584    
     1584
    15851585    return false;
    15861586}
     
    15881588function bp_is_group_creation_step_complete( $step_slugs ) {
    15891589    global $bp;
    1590    
     1590
    15911591    if ( !$bp->groups->completed_create_steps )
    15921592        return false;
     
    15941594    if ( is_array( $step_slugs ) ) {
    15951595        $found = true;
    1596        
     1596
    15971597        foreach ( $step_slugs as $step_slug ) {
    15981598            if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) )
    15991599                $found = false;
    16001600        }
    1601        
     1601
    16021602        return $found;
    16031603    } else {
    1604         return in_array( $step_slugs, $bp->groups->completed_create_steps );   
     1604        return in_array( $step_slugs, $bp->groups->completed_create_steps );
    16051605    }
    16061606
     
    16101610function bp_are_previous_group_creation_steps_complete( $step_slug ) {
    16111611    global $bp;
    1612    
     1612
    16131613    /* If this is the first group creation step, return true */
    16141614    if ( array_shift( array_keys( $bp->groups->group_creation_steps ) ) == $step_slug )
    16151615        return true;
    1616    
     1616
    16171617    reset( $bp->groups->group_creation_steps );
    16181618    unset( $previous_steps );
    1619        
     1619
    16201620    /* Get previous steps */
    16211621    foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
    16221622        if ( $slug == $step_slug )
    16231623            break;
    1624    
     1624
    16251625        $previous_steps[] = $slug;
    16261626    }
    1627    
     1627
    16281628    return bp_is_group_creation_step_complete( $previous_steps );
    16291629}
     
    16361636        return apply_filters( 'bp_get_new_group_id', $bp->groups->new_group_id );
    16371637    }
    1638    
     1638
    16391639function bp_new_group_name() {
    16401640    echo bp_get_new_group_name();
     
    16901690    function bp_get_new_group_avatar( $args = '' ) {
    16911691        global $bp;
    1692            
     1692
    16931693        $defaults = array(
    16941694            'type' => 'full',
     
    16971697            'class' => 'avatar',
    16981698            'id' => 'avatar-crop-preview',
    1699             'alt' => __( 'Group avatar', 'buddypress' ) 
     1699            'alt' => __( 'Group avatar', 'buddypress' )
    17001700        );
    17011701
    17021702        $r = wp_parse_args( $args, $defaults );
    17031703        extract( $r, EXTR_SKIP );
    1704    
     1704
    17051705        return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class ) ) );
    17061706    }
     
    17111711    function bp_get_group_creation_previous_link() {
    17121712        global $bp;
    1713        
     1713
    17141714        foreach ( $bp->groups->group_creation_steps as $slug => $name ) {
    17151715            if ( $slug == $bp->action_variables[1] )
    17161716                break;
    1717    
     1717
    17181718            $previous_steps[] = $slug;
    17191719        }
     
    17241724function bp_is_last_group_creation_step() {
    17251725    global $bp;
    1726    
     1726
    17271727    $last_step = array_pop( array_keys( $bp->groups->group_creation_steps ) );
    17281728
    17291729    if ( $last_step == $bp->groups->current_create_step )
    17301730        return true;
    1731    
     1731
    17321732    return false;
    17331733}
     
    17351735function bp_is_first_group_creation_step() {
    17361736    global $bp;
    1737    
     1737
    17381738    $first_step = array_shift( array_keys( $bp->groups->group_creation_steps ) );
    17391739
    17401740    if ( $first_step == $bp->groups->current_create_step )
    17411741        return true;
    1742    
     1742
    17431743    return false;
    17441744}
     
    17521752        if ( !function_exists('friends_install') )
    17531753            return false;
    1754        
     1754
    17551755        $defaults = array(
    17561756            'group_id' => false,
     
    17601760        $r = wp_parse_args( $args, $defaults );
    17611761        extract( $r, EXTR_SKIP );
    1762    
     1762
    17631763        if ( !$group_id )
    17641764            $group_id = ( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id;
    1765            
     1765
    17661766        $friends = friends_get_friends_invite_list( $bp->loggedin_user->id, $group_id );
    1767            
     1767
    17681768        if ( $friends ) {
    17691769            $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group_id );
     
    17751775                    } else {
    17761776                        $checked = '';
    1777                     } 
     1777                    }
    17781778                }
    1779                
     1779
    17801780                $items[] = '<' . $separator . '><input' . $checked . ' type="checkbox" name="friends[]" id="f-' . $friends[$i]['id'] . '" value="' . attribute_escape( $friends[$i]['id'] ) . '" /> ' . $friends[$i]['full_name'] . '</' . $separator . '>';
    17811781            }
    17821782        }
    1783        
     1783
    17841784        return implode( "\n", (array)$items );
    17851785    }
     
    17941794    var $groups;
    17951795    var $group;
    1796    
     1796
    17971797    var $in_the_loop;
    1798    
     1798
    17991799    var $pag_page;
    18001800    var $pag_num;
    18011801    var $pag_links;
    18021802    var $total_group_count;
    1803    
     1803
    18041804    function bp_groups_site_groups_template( $type, $per_page, $max ) {
    18051805        global $bp;
    1806        
     1806
    18071807        /* TODO: Move $_REQUEST vars out of here */
    1808        
     1808
    18091809        $this->pag_page = isset( $_REQUEST['gpage'] ) ? intval( $_REQUEST['gpage'] ) : 1;
    18101810        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     
    18141814        } else if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) {
    18151815            $this->groups = BP_Groups_Group::get_by_letter( $_REQUEST['letter'], $this->pag_num, $this->pag_page );
    1816        
     1816
    18171817        } else {
    18181818            switch ( $type ) {
    18191819                case 'active': default:
    18201820                    $this->groups = groups_get_active( $this->pag_num, $this->pag_page );
    1821                     break; 
     1821                    break;
    18221822
    18231823                case 'alphabetical': default:
    18241824                    $this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page );
    1825                     break; 
    1826                
    1827                 case 'random':     
     1825                    break;
     1826
     1827                case 'random':
    18281828                    $this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page );
    18291829                    break;
    1830                
     1830
    18311831                case 'newest':
    18321832                    $this->groups = groups_get_newest( $this->pag_num, $this->pag_page );
     
    18351835                case 'popular':
    18361836                    $this->groups = groups_get_popular( $this->pag_num, $this->pag_page );
    1837                     break; 
     1837                    break;
    18381838
    18391839                case 'most-forum-topics':
    18401840                    $this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page );
    18411841                    break;
    1842                
     1842
    18431843                case 'most-forum-posts':
    18441844                    $this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page );
     
    18461846            }
    18471847        }
    1848        
     1848
    18491849        if ( !$max || $max >= (int)$this->groups['total'] )
    18501850            $this->total_group_count = (int)$this->groups['total'];
     
    18531853
    18541854        $this->groups = $this->groups['groups'];
    1855        
     1855
    18561856        if ( $max ) {
    18571857            if ( $max >= count($this->groups) )
     
    18621862            $this->group_count = count($this->groups);
    18631863        }
    1864        
     1864
    18651865        if ( (int) $this->total_group_count && (int) $this->pag_num ) {
    18661866            $this->pag_links = paginate_links( array(
     
    18721872                'next_text' => '&raquo;',
    18731873                'mid_size' => 1
    1874             ));     
    1875     }
    1876     }
    1877    
     1874            ));
     1875    }
     1876    }
     1877
    18781878    function has_groups() {
    18791879        if ( $this->group_count )
    18801880            return true;
    1881        
     1881
    18821882        return false;
    18831883    }
    1884    
     1884
    18851885    function next_group() {
    18861886        $this->current_group++;
    18871887        $this->group = $this->groups[$this->current_group];
    1888        
     1888
    18891889        return $this->group;
    18901890    }
    1891    
     1891
    18921892    function rewind_groups() {
    18931893        $this->current_group = -1;
     
    18961896        }
    18971897    }
    1898    
    1899     function groups() { 
     1898
     1899    function groups() {
    19001900        if ( $this->current_group + 1 < $this->group_count ) {
    19011901            return true;
     
    19091909        return false;
    19101910    }
    1911    
     1911
    19121912    function the_group() {
    19131913        global $group;
     
    19151915        $this->in_the_loop = true;
    19161916        $this->group = $this->next_group();
    1917        
     1917
    19181918        if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $this->group->group_id, 'bp' ) ) {
    19191919            $group = new BP_Groups_Group( $this->group->group_id, false, false );
    19201920            wp_cache_set( 'groups_group_nouserdata_' . $this->group->group_id, $group, 'bp' );
    19211921        }
    1922        
     1922
    19231923        $this->group = $group;
    1924        
     1924
    19251925        if ( 0 == $this->current_group ) // loop has just started
    19261926            do_action('loop_start');
     
    19301930function bp_rewind_site_groups() {
    19311931    global $site_groups_template;
    1932    
    1933     $site_groups_template->rewind_groups(); 
     1932
     1933    $site_groups_template->rewind_groups();
    19341934}
    19351935
     
    19451945    $r = wp_parse_args( $args, $defaults );
    19461946    extract( $r, EXTR_SKIP );
    1947    
     1947
    19481948    // type: active ( default ) | random | newest | popular
    1949    
     1949
    19501950    if ( $max ) {
    19511951        if ( $per_page > $max )
    19521952            $per_page = $max;
    19531953    }
    1954        
     1954
    19551955    $site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
    19561956    return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template );
     
    19591959function bp_site_groups() {
    19601960    global $site_groups_template;
    1961    
     1961
    19621962    return $site_groups_template->groups();
    19631963}
     
    19651965function bp_the_site_group() {
    19661966    global $site_groups_template;
    1967    
     1967
    19681968    return $site_groups_template->the_group();
    19691969}
     
    19711971function bp_site_groups_pagination_count() {
    19721972    global $bp, $site_groups_template;
    1973    
     1973
    19741974    $from_num = intval( ( $site_groups_template->pag_page - 1 ) * $site_groups_template->pag_num ) + 1;
    19751975    $to_num = ( $from_num + ( $site_groups_template->pag_num - 1 ) > $site_groups_template->total_group_count ) ? $site_groups_template->total_group_count : $from_num + ( $site_groups_template->pag_num - 1) ;
    19761976
    19771977    echo sprintf( __( 'Viewing group %d to %d (of %d groups)', 'buddypress' ), $from_num, $to_num, $site_groups_template->total_group_count ); ?> &nbsp;
    1978     <span class="ajax-loader"></span><?php 
     1978    <span class="ajax-loader"></span><?php
    19791979}
    19801980
     
    19841984    function bp_get_site_groups_pagination_links() {
    19851985        global $site_groups_template;
    1986        
     1986
    19871987        return apply_filters( 'bp_get_site_groups_pagination_links', $site_groups_template->pag_links );
    19881988    }
     
    19931993    function bp_get_the_site_group_id() {
    19941994        global $site_groups_template;
    1995        
     1995
    19961996        return apply_filters( 'bp_get_the_site_group_id', $site_groups_template->group->id );
    19971997    }
     
    20112011    function bp_get_the_site_group_avatar_thumb() {
    20122012        global $site_groups_template;
    2013        
     2013
    20142014        return apply_filters( 'bp_get_the_site_group_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $site_groups_template->group->id, 'object' => 'group', 'type' => 'thumb', 'avatar_dir' => 'group-avatars', 'alt' => __( 'Group Avatar', 'buddypress' ) ) ) );
    20152015    }
     
    20292029    function bp_get_the_site_group_link() {
    20302030        global $site_groups_template;
    2031        
     2031
    20322032        return apply_filters( 'bp_get_the_site_group_link', bp_get_group_permalink( $site_groups_template->group ) );
    20332033    }
     
    20412041        return apply_filters( 'bp_get_the_site_group_name', bp_get_group_name( $site_groups_template->group ) );
    20422042    }
    2043    
     2043
    20442044
    20452045function bp_the_site_group_last_active() {
     
    20542054function bp_the_site_group_join_button() {
    20552055    global $site_groups_template;
    2056    
     2056
    20572057    echo bp_group_join_button( $site_groups_template->group );
    20582058}
     
    20642064        global $site_groups_template;
    20652065
    2066         return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) ); 
     2066        return apply_filters( 'bp_get_the_site_group_description', bp_get_group_description( $site_groups_template->group ) );
    20672067    }
    20682068
     
    20732073        global $site_groups_template;
    20742074
    2075         return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) ); 
     2075        return apply_filters( 'bp_get_the_site_group_description_excerpt', bp_create_excerpt( bp_get_group_description( $site_groups_template->group, false ), 25 ) );
    20762076    }
    20772077
    20782078function bp_the_site_group_date_created() {
    2079     echo bp_get_the_site_group_date_created(); 
     2079    echo bp_get_the_site_group_date_created();
    20802080}
    20812081    function bp_get_the_site_group_date_created() {
    20822082        global $site_groups_template;
    20832083
    2084         return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) ); 
     2084        return apply_filters( 'bp_get_the_site_group_date_created', bp_core_time_since( $site_groups_template->group->date_created ) );
    20852085    }
    20862086
     
    20942094            return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d member', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
    20952095        else
    2096             return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );     
     2096            return apply_filters( 'bp_get_the_site_group_member_count', sprintf( __( '%d members', 'buddypress' ), (int) $site_groups_template->group->total_member_count ) );
    20972097    }
    20982098
     
    21242124        if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
    21252125            return false;
    2126            
     2126
    21272127        if ( !$site_groups_template->group->forum_counts )
    21282128            $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
     
    21322132                $total_topics = sprintf( __( '%d topic', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
    21332133            else
    2134                 $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );   
     2134                $total_topics = sprintf( __( '%d topics', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->topics );
    21352135        } else {
    21362136            $total_topics = (int) $site_groups_template->group->forum_counts[0]->topics;
    21372137        }
    2138        
     2138
    21392139        return apply_filters( 'bp_get_the_site_group_forum_topic_count', $total_topics, (bool)$showtext );
    21402140    }
     
    21452145    function bp_get_the_site_group_forum_post_count( $args = '' ) {
    21462146        global $site_groups_template;
    2147        
     2147
    21482148        $defaults = array(
    21492149            'showtext' => false
     
    21522152        $r = wp_parse_args( $args, $defaults );
    21532153        extract( $r, EXTR_SKIP );
    2154        
     2154
    21552155        if ( !$forum_id = groups_get_groupmeta( $site_groups_template->group->id, 'forum_id' ) )
    21562156            return false;
     
    21582158        if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) )
    21592159            return false;
    2160            
     2160
    21612161        if ( !$site_groups_template->group->forum_counts )
    21622162            $site_groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int)$forum_id );
     
    21662166                $total_posts = sprintf( __( '%d post', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
    21672167            else
    2168                 $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );   
     2168                $total_posts = sprintf( __( '%d posts', 'buddypress' ), (int) $site_groups_template->group->forum_counts[0]->posts );
    21692169        } else {
    21702170            $total_posts = (int) $site_groups_template->group->forum_counts[0]->posts;
    21712171        }
    2172        
     2172
    21732173        return apply_filters( 'bp_get_the_site_group_forum_post_count', $total_posts, (bool)$showtext );
    21742174    }
     
    21782178        echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['s'] ) . '" name="search_terms" />';
    21792179    }
    2180    
     2180
    21812181    if ( isset( $_REQUEST['letter'] ) ) {
    21822182        echo '<input type="hidden" id="selected_letter" value="' . attribute_escape( $_REQUEST['letter'] ) . '" name="selected_letter" />';
    21832183    }
    2184    
     2184
    21852185    if ( isset( $_REQUEST['groups_search'] ) ) {
    21862186        echo '<input type="hidden" id="search_terms" value="' . attribute_escape( $_REQUEST['groups_search'] ) . '" name="search_terms" />';
     
    22062206    var $requests;
    22072207    var $request;
    2208    
     2208
    22092209    var $in_the_loop;
    2210    
     2210
    22112211    var $pag_page;
    22122212    var $pag_num;
    22132213    var $pag_links;
    22142214    var $total_request_count;
    2215    
     2215
    22162216    function bp_groups_membership_requests_template( $group_id, $per_page, $max ) {
    22172217        global $bp;
    2218        
     2218
    22192219        $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1;
    22202220        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    2221        
    2222         $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page );       
     2221
     2222        $this->requests = BP_Groups_Group::get_membership_requests( $group_id, $this->pag_num, $this->pag_page );
    22232223
    22242224        if ( !$max || $max >= (int)$this->requests['total'] )
     
    22282228
    22292229        $this->requests = $this->requests['requests'];
    2230        
     2230
    22312231        if ( $max ) {
    22322232            if ( $max >= count($this->requests) )
     
    22482248        ));
    22492249    }
    2250    
     2250
    22512251    function has_requests() {
    22522252        if ( $this->request_count )
    22532253            return true;
    2254        
     2254
    22552255        return false;
    22562256    }
    2257    
     2257
    22582258    function next_request() {
    22592259        $this->current_request++;
    22602260        $this->request = $this->requests[$this->current_request];
    2261        
     2261
    22622262        return $this->request;
    22632263    }
    2264    
     2264
    22652265    function rewind_requests() {
    22662266        $this->current_request = -1;
     
    22692269        }
    22702270    }
    2271    
    2272     function requests() { 
     2271
     2272    function requests() {
    22732273        if ( $this->current_request + 1 < $this->request_count ) {
    22742274            return true;
     
    22822282        return false;
    22832283    }
    2284    
     2284
    22852285    function the_request() {
    22862286        global $request;
     
    23122312function bp_group_membership_requests() {
    23132313    global $requests_template;
    2314    
     2314
    23152315    return $requests_template->requests();
    23162316}
     
    23182318function bp_group_the_membership_request() {
    23192319    global $requests_template;
    2320    
     2320
    23212321    return $requests_template->the_request();
    23222322}
     
    23242324function bp_group_request_user_avatar_thumb() {
    23252325    global $requests_template;
    2326    
     2326
    23272327    echo apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $requests_template->request->user_id, 'type' => 'thumb' ) ) );
    23282328}
    23292329
    23302330function bp_group_request_reject_link() {
    2331     global $requests_template, $groups_template;   
     2331    global $requests_template, $groups_template;
    23322332
    23332333    echo apply_filters( 'bp_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) );
     
    23352335
    23362336function bp_group_request_accept_link() {
    2337     global $requests_template, $groups_template;   
     2337    global $requests_template, $groups_template;
    23382338
    23392339    echo apply_filters( 'bp_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . '/admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) );
     
    23412341
    23422342function bp_group_request_time_since_requested() {
    2343     global $requests_template; 
     2343    global $requests_template;
    23442344
    23452345    echo apply_filters( 'bp_group_request_time_since_requested', sprintf( __( 'requested %s ago', 'buddypress' ), bp_core_time_since( strtotime( $requests_template->request->date_modified ) ) ) );
     
    23482348function bp_group_request_comment() {
    23492349    global $requests_template;
    2350    
     2350
    23512351    echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) );
    23522352}
     
    23542354function bp_group_request_user_link() {
    23552355    global $requests_template;
    2356    
     2356
    23572357    echo apply_filters( 'bp_group_request_user_link', bp_core_get_userlink( $requests_template->request->user_id ) );
    23582358}
     
    23682368    var $invites;
    23692369    var $invite;
    2370    
     2370
    23712371    var $in_the_loop;
    2372    
     2372
    23732373    var $pag_page;
    23742374    var $pag_num;
    23752375    var $pag_links;
    23762376    var $total_invite_count;
    2377    
     2377
    23782378    function bp_groups_invite_template( $user_id, $group_id ) {
    23792379        global $bp;
    23802380
    23812381        $this->invites = groups_get_invites_for_group( $user_id, $group_id );
    2382         $this->invite_count = count( $this->invites ); 
    2383     }
    2384    
     2382        $this->invite_count = count( $this->invites );
     2383    }
     2384
    23852385    function has_invites() {
    23862386        if ( $this->invite_count )
    23872387            return true;
    2388        
     2388
    23892389        return false;
    23902390    }
    2391    
     2391
    23922392    function next_invite() {
    23932393        $this->current_invite++;
    23942394        $this->invite = $this->invites[$this->current_invite];
    2395        
     2395
    23962396        return $this->invite;
    23972397    }
    2398    
     2398
    23992399    function rewind_invites() {
    24002400        $this->current_invite = -1;
     
    24032403        }
    24042404    }
    2405    
    2406     function invites() { 
     2405
     2406    function invites() {
    24072407        if ( $this->current_invite + 1 < $this->invite_count ) {
    24082408            return true;
     
    24162416        return false;
    24172417    }
    2418    
     2418
    24192419    function the_invite() {
    24202420        global $invite;
     
    24222422        $this->in_the_loop = true;
    24232423        $user_id = $this->next_invite();
    2424        
     2424
    24252425        $this->invite = new stdClass;
    24262426        $this->invite->user = new BP_Core_User( $user_id );
    24272427        $this->invite->group_id = $group_id; // Globaled in bp_group_has_invites()
    2428        
     2428
    24292429        if ( 0 == $this->current_invite ) // loop has just started
    24302430            do_action('loop_start');
     
    24342434function bp_group_has_invites( $args = '' ) {
    24352435    global $bp, $invites_template, $group_id;
    2436    
     2436
    24372437    $defaults = array(
    24382438        'group_id' => false,
     
    24422442    $r = wp_parse_args( $args, $defaults );
    24432443    extract( $r, EXTR_SKIP );
    2444    
     2444
    24452445    if ( !$group_id ) {
    24462446        /* Backwards compatibility */
     
    24482448        if ( $bp->groups->new_group_id ) $group_id = $bp->groups->new_group_id;
    24492449    }
    2450    
     2450
    24512451    if ( !$group_id )
    24522452        return false;
     
    24582458function bp_group_invites() {
    24592459    global $invites_template;
    2460    
     2460
    24612461    return $invites_template->invites();
    24622462}
     
    24642464function bp_group_the_invite() {
    24652465    global $invites_template;
    2466    
     2466
    24672467    return $invites_template->the_invite();
    24682468}
     
    25092509    function bp_get_group_invite_user_remove_invite_url() {
    25102510        global $invites_template;
    2511        
     2511
    25122512        return wp_nonce_url( site_url( BP_GROUPS_SLUG . '/' . $invites_template->invite->group_id . '/invites/remove/' . $invites_template->invite->user->id ), 'groups_invite_uninvite_user' );
    25132513    }
  • trunk/bp-groups/bp-groups-widgets.php

    r1926 r2077  
    33/* Register widgets for groups component */
    44function groups_register_widgets() {
    5     add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );   
     5    add_action('widgets_init', create_function('', 'return register_widget("BP_Groups_Widget");') );
    66}
    77add_action( 'plugins_loaded', 'groups_register_widgets' );
     
    1212    function bp_groups_widget() {
    1313        parent::WP_Widget( false, $name = __( 'Groups', 'buddypress' ) );
    14        
     14
    1515        if ( is_active_widget( false, false, $this->id_base ) )
    16             wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') );       
     16            wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery', 'jquery-livequery-pack') );
    1717    }
    1818
    1919    function widget($args, $instance) {
    2020        global $bp;
    21        
     21
    2222        extract( $args );
    23        
     23
    2424        echo $before_widget;
    2525        echo $before_title
    26            . $widget_name 
     26           . $widget_name
    2727           . $after_title; ?>
    28        
     28
    2929        <?php if ( bp_has_site_groups( 'type=popular&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>
    3030            <div class="item-options" id="groups-list-options">
    3131                <span class="ajax-loader" id="ajax-loader-groups"></span>
    32                 <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> | 
    33                 <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> | 
     32                <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="newest-groups"><?php _e("Newest", 'buddypress') ?></a> |
     33                <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="recently-active-groups"><?php _e("Active", 'buddypress') ?></a> |
    3434                <a href="<?php echo site_url() . '/' . $bp->groups->slug ?>" id="popular-groups" class="selected"><?php _e("Popular", 'buddypress') ?></a>
    3535            </div>
    36            
     36
    3737            <ul id="groups-list" class="item-list">
    3838                <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
     
    4949
    5050                <?php endwhile; ?>
    51             </ul>       
     51            </ul>
    5252            <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
    5353            <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
    54            
     54
    5555        <?php else: ?>
    5656
     
    6060
    6161        <?php endif; ?>
    62            
     62
    6363        <?php echo $after_widget; ?>
    6464    <?php
     
    8484function groups_ajax_widget_groups_list() {
    8585    global $bp;
    86        
     86
    8787    check_ajax_referer('groups_widget_groups_list');
    8888
     
    101101    if ( bp_has_site_groups( 'type=' . $type . '&per_page=' . $_POST['max_groups'] . '&max=' . $_POST['max_groups'] ) ) : ?>
    102102        <?php echo "0[[SPLIT]]"; ?>
    103                
     103
    104104        <ul id="groups-list" class="item-list">
    105105            <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
     
    113113                        <div class="item-meta">
    114114                            <span class="activity">
    115                                 <?php 
     115                                <?php
    116116                                if ( 'newest-groups' == $_POST['filter'] ) {
    117117                                    bp_the_site_group_date_created();
     
    128128
    129129            <?php endwhile; ?>
    130         </ul>       
     130        </ul>
    131131        <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
    132132        <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $_POST['max_groups'] ); ?>" />
    133        
     133
    134134    <?php else: ?>
    135135
     
    137137
    138138    <?php endif;
    139    
     139
    140140}
    141141add_action( 'wp_ajax_widget_groups_list', 'groups_ajax_widget_groups_list' );
  • trunk/bp-groups/deprecated/bp-groups-deprecated.php

    r1906 r2077  
    44 *
    55 * This file contains functions that are deprecated.
    6  * You should not under any circumstance use these functions as they are 
     6 * You should not under any circumstance use these functions as they are
    77 * either no longer valid, or have been replaced with something much more awesome.
    88 *
     
    1313 * Of course, things will still work if you use these functions but you will
    1414 * be the laughing stock of the BuddyPress community. We will all point and laugh at
    15  * you. You'll also be making things harder for yourself in the long run, 
     15 * you. You'll also be making things harder for yourself in the long run,
    1616 * and you will miss out on lovely performance and functionality improvements.
    17  * 
     17 *
    1818 * If you've checked you are not using any deprecated functions and finished your little
    1919 * dance, you can add the following line to your wp-config.php file to prevent any of
     
    2525function groups_deprecated_globals() {
    2626    global $bp;
    27    
     27
    2828    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    2929    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     
    3232    $bp->groups->image_base = BP_PLUGIN_URL . '/bp-groups/deprecated/images';
    3333}
    34 add_action( 'plugins_loaded', 'groups_deprecated_globals', 5 ); 
     34add_action( 'plugins_loaded', 'groups_deprecated_globals', 5 );
    3535add_action( 'admin_menu', 'groups_deprecated_globals', 2 );
    3636
     
    4040
    4141        <p>
    42             <input type="file" name="file" id="file" /> 
     42            <input type="file" name="file" id="file" />
    4343            <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
    4444            <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
     
    5050
    5151        <h3><?php _e( 'Crop Group Avatar', 'buddypress' ) ?></h3>
    52    
     52
    5353        <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
    5454
    5555        <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
    56    
     56
    5757        <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
    5858        <input type="hidden" name="upload" id="upload" />
     
    6868function groups_get_avatar_hrefs( $avatars ) {
    6969    global $bp;
    70    
     70
    7171    $src = $bp->root_domain . '/';
    7272
    7373    $thumb_href = str_replace( ABSPATH, $src, stripslashes( $avatars['v1_out'] ) );
    7474    $full_href = str_replace( ABSPATH, $src, stripslashes ( $avatars['v2_out'] ) );
    75    
     75
    7676    return array( 'thumb_href' => $thumb_href, 'full_href' => $full_href );
    7777}
     
    9393function groups_force_buddypress_theme( $template ) {
    9494    global $bp;
    95    
     95
    9696    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    9797    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     
    120120    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    121121        return $stylesheet;
    122        
     122
    123123    if ( $bp->current_component != $bp->groups->slug )
    124124        return $stylesheet;
     
    142142    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    143143        return false;
    144        
     144
    145145    if ( $bp->current_component == $bp->groups->slug )
    146146        wp_enqueue_script( 'bp-groups-js', BP_PLUGIN_URL . '/bp-groups/deprecated/js/general.js' );
     
    152152    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    153153        return false;
    154        
     154
    155155    /* Enqueue the structure CSS file to give basic positional formatting for components */
    156     wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/deprecated/css/structure.css' );   
     156    wp_enqueue_style( 'bp-groups-structure', BP_PLUGIN_URL . '/bp-groups/deprecated/css/structure.css' );
    157157}
    158158add_action( 'bp_styles', 'groups_add_structure_css' );
     
    162162    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    163163        return false;
    164        
     164
    165165    wp_enqueue_script( 'bp-groups-directory-groups', BP_PLUGIN_URL . '/bp-groups/deprecated/js/directory-groups.js', array( 'jquery', 'jquery-livequery-pack' ) );
    166166}
     
    170170function bp_groups_random_selection( $total_groups = 5 ) {
    171171    global $bp;
    172    
     172
    173173    if ( !$group_ids = wp_cache_get( 'groups_random_groups', 'bp' ) ) {
    174174        $group_ids = BP_Groups_Group::get_random( $total_groups, 1 );
    175175        wp_cache_set( 'groups_random_groups', $group_ids, 'bp' );
    176176    }
    177 ?> 
     177?>
    178178    <?php if ( $group_ids['groups'] ) { ?>
    179179        <ul class="item-list" id="random-groups-list">
    180         <?php 
    181             for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) { 
     180        <?php
     181            for ( $i = 0; $i < count( $group_ids['groups'] ); $i++ ) {
    182182                if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, 'bp' ) ) {
    183183                    $group = new BP_Groups_Group( $group_ids['groups'][$i]->group_id, false, false );
    184184                    wp_cache_set( 'groups_group_nouserdata_' . $group_ids['groups'][$i]->group_id, $group, 'bp' );
    185185                }
    186             ?> 
     186            ?>
    187187            <li>
    188188                <div class="item-avatar">
     
    195195                    <div class="item-meta desc"><?php echo bp_create_excerpt( $group->description ) ?></div>
    196196                </div>
    197                
     197
    198198                <div class="action">
    199199                    <?php bp_group_join_button( $group ) ?>
    200200                    <div class="meta">
    201201                        <?php $member_count = groups_get_groupmeta( $group->id, 'total_member_count' ) ?>
    202                         <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> / 
     202                        <?php echo ucwords($group->status) ?> <?php _e( 'Group', 'buddypress' ) ?> /
    203203                        <?php if ( 1 == $member_count ) : ?>
    204204                            <?php printf( __( '%d member', 'buddypress' ), $member_count ) ?>
     
    208208                    </div>
    209209                </div>
    210                
     210
    211211                <div class="clear"></div>
    212212            </li>
     
    216216        <div id="message" class="info">
    217217            <p><?php _e( "There aren't enough groups to show a random sample just yet.", 'buddypress' ) ?></p>
    218         </div>     
     218        </div>
    219219    <?php } ?>
    220220<?php
     
    224224function bp_groups_random_groups( $total_groups = 5 ) {
    225225    global $bp;
    226    
     226
    227227    if ( !$group_ids = wp_cache_get( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, 'bp' ) ) {
    228228        $group_ids = groups_get_random_groups_for_user( $bp->displayed_user->id, $total_groups, 1 );
    229229        wp_cache_set( 'groups_random_user_groups_' . $bp->displayed_user->id . '_' . $total_groups, $group_ids, 'bp' );
    230230    }
    231    
    232 ?> 
     231
     232?>
    233233    <div class="info-group">
    234234        <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php echo BP_Groups_Member::total_group_count() ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->groups->slug ?>"><?php _e('See All', 'buddypress') ?> &raquo;</a></span></h4>
    235235        <?php if ( $group_ids ) { ?>
    236236            <ul class="horiz-gallery">
    237             <?php 
     237            <?php
    238238            for ( $i = 0; $i < count( $group_ids ); $i++ ) {
    239239                if ( !$group = wp_cache_get( 'groups_group_nouserdata_' . $group_ids[$i], 'bp' ) ) {
     
    263263    if ( !$group )
    264264        $group =& $groups_template->group;
    265        
     265
    266266    $forum_id = groups_get_groupmeta( $group->id, 'forum_id' );
    267267
     
    269269        if ( function_exists( 'bp_forums_setup' ) ) {
    270270            $latest_topics = bp_forums_get_forum_topics( array( 'forum_id' => $forum_id ) );
    271        
     271
    272272            if ( $latest_topics ) { ?>
    273273                <ul class="item-list" id="recent-forum-topics"><?php
    274                
     274
    275275                $counter = 0;
    276                
     276
    277277                foreach( $latest_topics as $topic ) {
    278278                    $alt = ( $counter % 2 == 1 ) ? ' class="alt"' : '';
    279279                    $forum_template->topic = (object)$topic; ?>
    280                    
     280
    281281                    <li<?php echo $alt ?>>
    282282                        <div class="avatar">
     
    284284                        </div>
    285285
    286                         <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 
     286                        <a href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a>
    287287                        <span class="small">- <?php bp_the_topic_total_post_count() ?> </span>
    288288                        <p><span class="activity"><?php echo sprintf( __( 'updated %s ago', 'buddypress' ), bp_the_topic_time_since_last_post( false ) ) ?></span></p>
    289                
     289
    290290                        <div class="latest-post">
    291291                            <?php _e( 'Latest by', 'buddypress' ) ?> <?php bp_the_topic_last_poster_name() ?>:
     
    294294                    </li>
    295295                    <?php $counter++ ?>
    296                    
     296
    297297                <?php } ?>
    298298                </ul>
     
    313313function bp_group_send_invite_form( $group = false ) {
    314314    global $bp, $groups_template, $invites;
    315    
     315
    316316    if ( !$group )
    317317        $group =& $groups_template->group;
     
    325325
    326326    <div class="main-column">
    327        
     327
    328328        <div id="message" class="info">
    329329            <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p>
     
    331331
    332332        <?php $invites = groups_get_invites_for_group( $bp->loggedin_user->id, $group->id ) ?>
    333        
     333
    334334        <ul id="friend-list" class="item-list">
    335335            <?php for ( $i = 0; $i < count($invites); $i++ ) {
     
    344344                    <span class="activity"><?php echo $user->last_active ?></span>
    345345                    <div class="action">
    346                         <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 
     346                        <a class="remove" href="<?php echo wp_nonce_url( site_url( $bp->groups->slug . '/' . $group->id . '/invites/remove/' . $user->id ), 'groups_invite_uninvite_user' ) ?>" id="uid-<?php echo $user->id ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
    347347                    </div>
    348348                </li>
    349349            <?php } // end for ?>
    350350        </ul>
    351        
     351
    352352        <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites' ) ?>
    353353    </div>
     
    358358function bp_group_list_invite_friends( $args = '' ) {
    359359    global $bp, $invites;
    360            
     360
    361361    if ( !function_exists('friends_install') )
    362362        return false;
     
    370370            <div id="invite-list">
    371371                <ul>
    372                     <?php 
     372                    <?php
    373373                        for ( $i = 0; $i < count( $friends ); $i++ ) {
    374374                            if ( $invites ) {
     
    377377                                } else {
    378378                                    $checked = '';
    379                                 } 
     379                                }
    380380                            }
    381381                    ?>
    382                    
     382
    383383                    <li><input<?php echo $checked ?> type="checkbox" name="friends[]" id="f-<?php echo $friends[$i]['id'] ?>" value="<?php echo attribute_escape( $friends[$i]['id'] ); ?>" /> <?php echo $friends[$i]['full_name']; ?></li>
    384384                    <?php } ?>
     
    399399
    400400    $members = &$group->random_members;
    401 ?> 
     401?>
    402402    <ul class="horiz-gallery">
    403403    <?php for ( $i = 0; $i < count( $members ); $i++ ) { ?>
     
    418418    if ( !$user_id )
    419419        $user_id = $members_template->member->user_id;
    420        
     420
    421421    echo bp_get_group_member_promote_link( $user_id );
    422422}
     
    426426        if ( !$user_id )
    427427            $user_id = $members_template->member->user_id;
    428            
     428
    429429        if ( !$group )
    430430            $group =& $groups_template->group;
     
    443443            <label for="group-name">* <?php _e('Group Name', 'buddypress') ?></label>
    444444            <input type="text" name="group-name" id="group-name" value="<?php echo attribute_escape( ( $bp->groups->new_group ) ? $bp->groups->current_group->name : $_POST['group-name'] ); ?>" />
    445        
     445
    446446            <label for="group-desc">* <?php _e('Group Description', 'buddypress') ?></label>
    447447            <textarea name="group-desc" id="group-desc"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->description : $_POST['group-desc'] ); ?></textarea>
    448        
     448
    449449            <label for="group-news"><?php _e('Recent News', 'buddypress') ?></label>
    450450            <textarea name="group-news" id="group-news"><?php echo htmlspecialchars( ( $bp->groups->new_group ) ? $bp->groups->current_group->news : $_POST['group-news'] ); ?></textarea>
    451            
     451
    452452            <?php do_action( 'groups_custom_group_fields_editable' ) ?>
    453453
     
    455455
    456456        <?php break; ?>
    457        
     457
    458458        <?php case 'group-settings': ?>
    459459            <?php if ( bp_are_previous_group_creation_steps_complete( 'group-settings' ) ) { ?>
     
    463463                </div>
    464464                <?php endif; ?>
    465                
     465
    466466                <?php if ( function_exists('bp_forums_setup') ) : ?>
    467467                    <?php if ( bp_forums_is_installed_correctly() ) { ?>
     
    479479                    }?>
    480480                <?php endif; ?>
    481                
     481
    482482                <?php if ( function_exists('bp_albums_install') ) : ?>
    483483                <div class="checkbox with-suboptions">
     
    489489                </div>
    490490                <?php endif; ?>
    491            
     491
    492492                <h3><?php _e( 'Privacy Options', 'buddypress' ); ?></h3>
    493            
     493
    494494                <div class="radio">
    495                     <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> /> 
     495                    <label><input type="radio" name="group-status" value="public"<?php if ( 'public' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
    496496                        <strong><?php _e( 'This is a public group', 'buddypress' ) ?></strong>
    497497                        <ul>
     
    501501                        </ul>
    502502                    </label>
    503                    
     503
    504504                    <label><input type="radio" name="group-status" value="private"<?php if ( 'private' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
    505505                        <strong><?php _e( 'This is a private group', 'buddypress' ) ?></strong>
     
    510510                        </ul>
    511511                    </label>
    512                    
     512
    513513                    <label><input type="radio" name="group-status" value="hidden"<?php if ( 'hidden' == $bp->groups->current_group->status ) { ?> checked="checked"<?php } ?> />
    514514                        <strong><?php _e('This is a hidden group', 'buddypress') ?></strong>
     
    528528            <?php } ?>
    529529        <?php break; ?>
    530        
     530
    531531        <?php case 'group-avatar': ?>
    532532            <?php if ( bp_are_previous_group_creation_steps_complete( 'group-avatar' ) ) { ?>
     
    534534                    <?php bp_new_group_avatar() ?>
    535535                </div>
    536                
     536
    537537                <div class="main-column">
    538538                    <p><?php _e("Upload an image to use as an avatar for this group. The image will be shown on the main group page, and in search results.", 'buddypress') ?></p>
    539                    
     539
    540540                    <?php groups_avatar_upload() ?>
    541541
    542542                </div>
    543                
     543
    544544                <?php wp_nonce_field( 'groups_step3_save' ) ?>
    545545            <?php } else { ?>
     
    549549            <?php } ?>
    550550
    551             <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?>       
     551            <?php wp_nonce_field( 'groups_create_save_group-avatar' ) ?>
    552552
    553553        <?php break; ?>
    554554        <?php case 'group-invites': ?>
    555             <?php 
     555            <?php
    556556            if ( bp_are_previous_group_creation_steps_complete( 'group-invites' ) ) {
    557557                $group_link = bp_get_group_permalink( $bp->groups->new_group );
    558                
     558
    559559                if ( function_exists('friends_install') ) {
    560560                    if ( friends_get_friend_count_for_user( $bp->loggedin_user->id ) ) {
     
    570570
    571571                <?php wp_nonce_field( 'groups_step4_save' ) ?>
    572                
     572
    573573                <?php
    574574            } else { ?>
     
    582582        <?php break; ?>
    583583    <?php } ?>
    584    
     584
    585585        <?php do_action( 'groups_custom_create_steps' ) // Allow plugins to add custom group creation steps ?>
    586        
     586
    587587        <div class="clear"></div>
    588        
     588
    589589        <div id="previous-next">
    590590            <!-- Previous Button -->
     
    597597                 &nbsp; <input type="submit" value="<?php _e('Next Step', 'buddypress') ?> &rarr;" id="group-creation-next" name="save" />
    598598            <?php endif;?>
    599            
     599
    600600            <!-- Create Button -->
    601601            <?php if ( bp_is_first_group_creation_step() ) : ?>
    602602                <input type="submit" value="<?php _e('Create Group and Continue', 'buddypress') ?> &rarr;" id="group-creation-create" name="save" />
    603603            <?php endif; ?>
    604            
     604
    605605            <!-- Finish Button -->
    606606            <?php if ( bp_is_last_group_creation_step() ) : ?>
     
    622622    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    623623        return false;
    624        
     624
    625625    check_ajax_referer( 'groups_invite_uninvite_user' );
    626626
     
    633633    if ( !friends_check_friendship( $bp->loggedin_user->id, $_POST['friend_id'] ) )
    634634        return false;
    635    
     635
    636636    if ( 'invite' == $_POST['friend_action'] ) {
    637                
     637
    638638        if ( !groups_invite_user( array( 'user_id' => $_POST['friend_id'], 'group_id' => $_POST['group_id'] ) ) )
    639639            return false;
    640        
     640
    641641        $user = new BP_Core_User( $_POST['friend_id'] );
    642        
     642
    643643        echo '<li id="uid-' . $user->id . '">';
    644644        echo $user->avatar_thumb;
     
    646646        echo '<span class="activity">' . attribute_escape( $user->last_active ) . '</span>';
    647647        echo '<div class="action">
    648                 <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . attribute_escape( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a> 
     648                <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . attribute_escape( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
    649649              </div>';
    650650        echo '</li>';
    651        
     651
    652652    } else if ( 'uninvite' == $_POST['friend_action'] ) {
    653        
     653
    654654        if ( !groups_uninvite_user( $_POST['friend_id'], $_POST['group_id'] ) )
    655655            return false;
    656        
     656
    657657        return true;
    658        
     658
    659659    } else {
    660660        return false;
     
    669669    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    670670        return false;
    671        
     671
    672672    check_ajax_referer( 'group-filter-box' );
    673    
     673
    674674    locate_template( array( 'groups/group-loop.php' ), true );
    675675}
     
    683683        return false;
    684684    ?>
    685    
     685
    686686    <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] ) ) : ?>
    687        
     687
    688688        <?php if ( bp_group_member_needs_pagination() ) : ?>
    689689            <div id="member-count" class="pag-count">
     
    695695            </div>
    696696        <?php endif; ?>
    697        
     697
    698698        <ul id="member-list" class="item-list">
    699699        <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
     
    702702                <h5><?php bp_group_member_link() ?></h5>
    703703                <span class="activity"><?php bp_group_member_joined_since() ?></span>
    704                
     704
    705705                <?php if ( function_exists( 'friends_install' ) ) : ?>
    706706                    <div class="action">
     
    730730        return false;
    731731    ?>
    732    
     732
    733733    <?php if ( bp_group_has_members( 'group_id=' . $_REQUEST['group_id'] . '&per_page=' . $_REQUEST['num'] ) ) : ?>
    734    
     734
    735735        <?php if ( bp_group_member_needs_pagination() ) : ?>
    736736            <div id="member-count" class="pag-count">
     
    742742            </div>
    743743        <?php endif; ?>
    744    
     744
    745745        <ul id="members-list" class="item-list single-line">
    746746        <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
     
    777777    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    778778        return false;
    779        
     779
    780780    check_ajax_referer('directory_groups');
    781781
     
    793793    if ( groups_is_user_banned( $bp->loggedin_user->id, $_POST['gid'] ) )
    794794        return false;
    795    
     795
    796796    if ( !$group = new BP_Groups_Group( $_POST['gid'], false, false ) )
    797797        return false;
    798    
     798
    799799    if ( 'hidden' == $group->status )
    800800        return false;
    801    
     801
    802802    if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
    803803
    804804        if ( 'public' == $group->status ) {
    805            
     805
    806806            check_ajax_referer( 'groups_join_group' );
    807            
     807
    808808            if ( !groups_join_group( $group->id ) ) {
    809809                _e( 'Error joining group', 'buddypress' );
    810810            } else {
    811811                echo '<a id="group-' . attribute_escape( $group->id ) . '" class="leave-group" rel="leave" title="' . __( 'Leave Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    812             }   
    813                    
     812            }
     813
    814814        } else if ( 'private' == $group->status ) {
    815            
     815
    816816            check_ajax_referer( 'groups_request_membership' );
    817            
     817
    818818            if ( !groups_send_membership_request( $bp->loggedin_user->id, $group->id ) ) {
    819                 _e( 'Error requesting membership', 'buddypress' ); 
     819                _e( 'Error requesting membership', 'buddypress' );
    820820            } else {
    821                 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';             
    822             }       
     821                echo '<a id="group-' . attribute_escape( $group->id ) . '" class="membership-requested" rel="membership-requested" title="' . __( 'Membership Requested', 'buddypress' ) . '" href="' . bp_get_group_permalink( $group ) . '">' . __( 'Membership Requested', 'buddypress' ) . '</a>';
     822            }
    823823        }
    824        
     824
    825825    } else {
    826826
    827827        check_ajax_referer( 'groups_leave_group' );
    828        
     828
    829829        if ( !groups_leave_group( $group->id ) ) {
    830830            _e( 'Error leaving group', 'buddypress' );
    831831        } else {
    832832            if ( 'public' == $group->status ) {
    833                 echo '<a id="group-' . attribute_escape( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';             
     833                echo '<a id="group-' . attribute_escape( $group->id ) . '" class="join-group" rel="join" title="' . __( 'Join Group', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
    834834            } else if ( 'private' == $group->status ) {
    835835                echo '<a id="group-' . attribute_escape( $group->id ) . '" class="request-membership" rel="join" title="' . __( 'Request Membership', 'buddypress' ) . '" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . '/request-membership', 'groups_send_membership_request' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
  • trunk/bp-loader.php

    r2042 r2077  
    4040    include( BP_PLUGIN_DIR . '/bp-groups.php' );
    4141
    42 /* Private Messaging */ 
     42/* Private Messaging */
    4343if ( !isset( $deactivated['bp-messages.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-messages.php') )
    4444    include( BP_PLUGIN_DIR . '/bp-messages.php' );
    45    
     45
    4646/* Wire Support */
    4747if ( !isset( $deactivated['bp-wire.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-wire.php') )
    4848    include( BP_PLUGIN_DIR . '/bp-wire.php' );
    4949
    50 /* Extended Profiles */ 
     50/* Extended Profiles */
    5151if ( !isset( $deactivated['bp-xprofile.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-xprofile.php') )
    5252    include( BP_PLUGIN_DIR . '/bp-xprofile.php' );
    5353
    54 /* Status Updates */   
     54/* Status Updates */
    5555if ( !isset( $deactivated['bp-status.php'] ) && file_exists( BP_PLUGIN_DIR . '/bp-status.php') )
    5656    include( BP_PLUGIN_DIR . '/bp-status.php' );
  • trunk/bp-messages.php

    r2020 r2077  
    1515if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    1616    require ( BP_PLUGIN_DIR . '/bp-messages/deprecated/bp-messages-deprecated.php' );
    17    
     17
    1818function messages_install() {
    1919    global $wpdb, $bp;
    20    
     20
    2121    if ( !empty($wpdb->charset) )
    2222        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    23    
     23
    2424    $sql[] = "CREATE TABLE {$bp->messages->table_name_threads} (
    2525                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    3333                KEY last_sender_id (last_sender_id)
    3434               ) {$charset_collate};";
    35    
     35
    3636    $sql[] = "CREATE TABLE {$bp->messages->table_name_recipients} (
    3737                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    5656                KEY sender_id (sender_id)
    5757               ) {$charset_collate};";
    58    
     58
    5959    $sql[] = "CREATE TABLE {$bp->messages->table_name_notices} (
    6060                id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    6565                KEY is_active (is_active)
    6666               ) {$charset_collate};";
    67    
     67
    6868    require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    6969    dbDelta($sql);
    70    
     70
    7171    add_site_option( 'bp-messages-db-version', BP_MESSAGES_DB_VERSION );
    7272}
     
    7777    /* For internal identification */
    7878    $bp->messages->id = 'messages';
    79    
     79
    8080    $bp->messages->table_name_threads = $wpdb->base_prefix . 'bp_messages_threads';
    8181    $bp->messages->table_name_messages = $wpdb->base_prefix . 'bp_messages_messages';
     
    9191    do_action( 'messages_setup_globals' );
    9292}
    93 add_action( 'plugins_loaded', 'messages_setup_globals', 5 );   
     93add_action( 'plugins_loaded', 'messages_setup_globals', 5 );
    9494add_action( 'admin_menu', 'messages_setup_globals', 2 );
    9595
    96 function messages_check_installed() {   
     96function messages_check_installed() {
    9797    global $wpdb, $bp;
    9898
    9999    if ( !is_site_admin() )
    100100        return false;
    101    
     101
    102102    /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    103103    if ( get_site_option('bp-messages-db-version') < BP_MESSAGES_DB_VERSION )
     
    117117    /* Add 'Messages' to the main navigation */
    118118    bp_core_new_nav_item( array( 'name' => __('Messages', 'buddypress'), 'slug' => $bp->messages->slug, 'position' => 50, 'show_for_displayed_user' => false, 'screen_function' => 'messages_screen_inbox', 'default_subnav_slug' => 'inbox', 'item_css_id' => $bp->messages->id ) );
    119    
     119
    120120    $messages_link = $bp->loggedin_user->domain . $bp->messages->slug . '/';
    121    
     121
    122122    /* Add the subnav items to the profile */
    123123    bp_core_new_subnav_item( array( 'name' => __( 'Inbox', 'buddypress' ) . $count_indicator, 'slug' => 'inbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_inbox', 'position' => 10, 'user_has_access' => bp_is_home() ) );
    124124    bp_core_new_subnav_item( array( 'name' => __( 'Sent Messages', 'buddypress' ), 'slug' => 'sentbox', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_sentbox', 'position' => 20, 'user_has_access' => bp_is_home() ) );
    125125    bp_core_new_subnav_item( array( 'name' => __( 'Compose', 'buddypress' ), 'slug' => 'compose', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_compose', 'position' => 30, 'user_has_access' => bp_is_home() ) );
    126    
     126
    127127    if ( is_site_admin() )
    128128        bp_core_new_subnav_item( array( 'name' => __( 'Notices', 'buddypress' ), 'slug' => 'notices', 'parent_url' => $messages_link, 'parent_slug' => $bp->messages->slug, 'screen_function' => 'messages_screen_notices', 'position' => 90, 'user_has_access' => is_site_admin() ) );
     
    130130    if ( $bp->current_component == $bp->messages->slug ) {
    131131        if ( bp_is_home() ) {
    132             $bp->bp_options_title = __( 'My Messages', 'buddypress' );         
     132            $bp->bp_options_title = __( 'My Messages', 'buddypress' );
    133133        } else {
    134134            $bp_options_avatar =  bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
     
    136136        }
    137137    }
    138    
     138
    139139    do_action( 'messages_setup_nav' );
    140140}
     
    153153function messages_screen_inbox() {
    154154    do_action( 'messages_screen_inbox' );
    155     bp_core_load_template( apply_filters( 'messages_template_inbox', 'messages/index' ) ); 
     155    bp_core_load_template( apply_filters( 'messages_template_inbox', 'messages/index' ) );
    156156}
    157157
     
    163163function messages_screen_compose() {
    164164    global $bp;
    165    
     165
    166166    // Remove any saved message data from a previous session.
    167167    messages_remove_callback_values();
     
    169169    /* Check if the message form has been submitted */
    170170    if ( isset( $_POST['send'] ) ) {
    171        
     171
    172172        /* Check the nonce */
    173173        check_admin_referer( 'messages_send_message' );
    174        
     174
    175175        /* Check we have what we need */
    176176        if ( empty( $_POST['subject'] ) || empty( $_POST['content'] ) ) {
     
    185185                $typed_recipients = explode( ' ', $_POST['send_to_usernames'] );
    186186                $recipients = array_merge( (array) $autocomplete_recipients, (array) $typed_recipients );
    187            
     187
    188188                /* Send the message */
    189189                if ( $thread_id = messages_new_message( array( 'recipients' => $recipients, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) ) {
     
    197197
    198198    }
    199    
     199
    200200    do_action( 'messages_screen_compose' );
    201    
     201
    202202    bp_core_load_template( apply_filters( 'messages_template_compose', 'messages/compose' ) );
    203203}
     
    205205function messages_screen_notices() {
    206206    global $bp, $notice_id;
    207        
     207
    208208    if ( !is_site_admin() )
    209209        return false;
    210        
     210
    211211    $notice_id = $bp->action_variables[1];
    212212
     
    216216        if ( 'deactivate' == $bp->action_variables[0] ) {
    217217            if ( !$notice->deactivate() ) {
    218                 bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' ); 
     218                bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' );
    219219            } else {
    220220                bp_core_add_message( __('Notice deactivated.', 'buddypress') );
     
    235235        bp_core_redirect( $bp->loggedin_user->domain . $bp->messages->slug . '/notices' );
    236236    }
    237    
     237
    238238    do_action( 'messages_screen_notices' );
    239    
    240     bp_core_load_template( apply_filters( 'messages_template_notices', 'messages/notices' ) ); 
    241 }
    242 
    243 function messages_screen_notification_settings() { 
     239
     240    bp_core_load_template( apply_filters( 'messages_template_notices', 'messages/notices' ) );
     241}
     242
     243function messages_screen_notification_settings() {
    244244    global $current_user; ?>
    245245    <table class="notification-settings" id="messages-notification-settings">
     
    262262            <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_messages_new_notice' ) ) { ?>checked="checked" <?php } ?>/></td>
    263263        </tr>
    264        
     264
    265265        <?php do_action( 'messages_screen_notification_settings' ) ?>
    266266    </table>
    267 <?php   
     267<?php
    268268}
    269269add_action( 'bp_notification_settings', 'messages_screen_notification_settings', 2 );
     
    280280function messages_action_view_message() {
    281281    global $bp, $thread_id;
    282    
     282
    283283    if ( $bp->current_component != $bp->messages->slug || $bp->current_action != 'view' )
    284284        return false;
    285        
     285
    286286    $thread_id = $bp->action_variables[0];
    287    
     287
    288288    if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) && !is_site_admin() ) )
    289289        bp_core_redirect( $bp->displayed_user->domain . $bp->current_component );
    290        
     290
    291291    /* Check if a new reply has been submitted */
    292292    if ( isset( $_POST['send'] ) ) {
    293        
     293
    294294        /* Check the nonce */
    295295        check_admin_referer( 'messages_send_message', 'send_message_nonce' );
    296        
     296
    297297        /* Send the reply */
    298298        if ( messages_new_message( array( 'thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content'] ) ) )
     
    300300        else
    301301            bp_core_add_message( __( 'There was a problem sending your reply, please try again', 'buddypress' ), 'error' );
    302        
    303         bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/view/' . $thread_id . '/' );     
    304     }
    305    
     302
     303        bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/view/' . $thread_id . '/' );
     304    }
     305
    306306    /* Mark message read */
    307307    messages_mark_thread_read( $thread_id );
    308    
     308
    309309    do_action( 'messages_action_view_message' );
    310    
     310
    311311    bp_core_new_subnav_item( array( 'name' => sprintf( __( 'From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id) ), 'slug' => 'view', 'parent_url' => $bp->loggedin_user->domain . $bp->messages->slug . '/', 'parent_slug' => $bp->messages->slug, 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_home() ) );
    312312    bp_core_load_template( apply_filters( 'messages_template_view_message', 'messages/view' ) );
     
    316316function messages_action_delete_message() {
    317317    global $bp, $thread_id;
    318    
     318
    319319    if ( $bp->current_component != $bp->messages->slug || 'notices' == $bp->current_action || $bp->action_variables[0] != 'delete' )
    320320        return false;
    321    
     321
    322322    $thread_id = $bp->action_variables[1];
    323323
     
    341341function messages_action_bulk_delete() {
    342342    global $bp, $thread_ids;
    343    
     343
    344344    if ( $bp->current_component != $bp->messages->slug || $bp->action_variables[0] != 'bulk-delete' )
    345345        return false;
    346    
     346
    347347    $thread_ids = $_POST['thread_ids'];
    348348
    349349    if ( !$thread_ids || !messages_check_thread_access($thread_ids) ) {
    350         bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );           
     350        bp_core_redirect( $bp->displayed_user->domain . $bp->current_component . '/' . $bp->current_action );
    351351    } else {
    352352        if ( !check_admin_referer( 'messages_delete_thread' ) )
    353353            return false;
    354            
     354
    355355        if ( !messages_delete_thread( $thread_ids ) ) {
    356356            bp_core_add_message( __('There was an error deleting messages.', 'buddypress'), 'error' );
     
    373373function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
    374374    global $bp;
    375    
     375
    376376    if ( 'new_message' == $action ) {
    377377        if ( (int)$total_items > 1 )
    378             return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );       
     378            return apply_filters( 'bp_messages_multiple_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new messages', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    379379        else
    380380            return apply_filters( 'bp_messages_single_new_message_notification', '<a href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/inbox" title="Inbox">' . sprintf( __('You have %d new message', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    381381    }
    382    
     382
    383383    do_action( 'messages_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    384    
     384
    385385    return false;
    386386}
     
    398398function messages_new_message( $args = '' ) {
    399399    global $bp;
    400    
     400
    401401    $defaults = array(
    402402        'thread_id' => false, // false for a new message, thread id for a reply to a thread.
     
    409409
    410410    $r = wp_parse_args( $args, $defaults );
    411     extract( $r, EXTR_SKIP );   
    412    
     411    extract( $r, EXTR_SKIP );
     412
    413413    if ( !$sender_id || !$subject || !$content )
    414414        return false;
    415        
    416     /* Create a new message object */   
     415
     416    /* Create a new message object */
    417417    $message = new BP_Messages_Message;
    418418    $message->thread_id = $thread_id;
     
    425425    if ( $thread_id ) {
    426426        $thread = new BP_Messages_Thread($thread_id);
    427         $message->recipients = $thread->get_recipients();       
     427        $message->recipients = $thread->get_recipients();
    428428    } else {
    429429        if ( empty( $recipients ) )
    430430            return false;
    431        
     431
    432432        /* Loop the recipients and convert all usernames to user_ids where needed */
    433433        foreach( (array) $recipients as $recipient ) {
    434434            if ( is_numeric( trim( $recipient ) ) )
    435435                $recipient_ids[] = (int)trim( $recipient );
    436            
     436
    437437            if ( $recipient_id = bp_core_get_userid( trim( $recipient ) ) )
    438438                $recipient_ids[] = (int)$recipient_id;
     
    445445        /* Remove duplicates */
    446446        $recipient_ids = array_unique( (array)$recipient_ids );
    447        
     447
    448448        if ( empty( $recipient_ids ) )
    449449            return false;
    450        
    451         $message->recipients = $recipient_ids; 
    452     }
    453    
     450
     451        $message->recipients = $recipient_ids;
     452    }
     453
    454454    if ( $message->send() ) {
    455455        require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
     
    457457        // Send screen notifications to the recipients
    458458        foreach ( (array)$message->recipients as $recipient ) {
    459             bp_core_add_notification( $message->id, $recipient, 'messages', 'new_message' );   
    460         }
    461        
     459            bp_core_add_notification( $message->id, $recipient, 'messages', 'new_message' );
     460        }
     461
    462462        // Send email notifications to the recipients
    463463        messages_notification_new_message( array( 'item_id' => $message->id, 'recipient_ids' => $message->recipients, 'thread_id' => $message->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
    464    
     464
    465465        do_action( 'messages_message_sent', &$message );
    466        
     466
    467467        return $message->thread_id;
    468468    }
    469    
     469
    470470    return false;
    471471}
     
    483483        $notice->is_active = 1;
    484484        $notice->save(); // send it.
    485        
     485
    486486        do_action( 'messages_send_notice', $subject, $message );
    487        
     487
    488488        return true;
    489489    }
     
    497497                $error = 1;
    498498        }
    499        
     499
    500500        if ( $error )
    501501            return false;
    502        
     502
    503503        do_action( 'messages_delete_thread', $thread_ids );
    504        
     504
    505505        return true;
    506506    } else {
    507507        if ( !BP_Messages_Thread::delete($thread_ids) )
    508508            return false;
    509        
     509
    510510        do_action( 'messages_delete_thread', $thread_ids );
    511        
     511
    512512        return true;
    513513    }
     
    516516function messages_check_thread_access( $thread_id, $user_id = false ) {
    517517    global $bp;
    518    
     518
    519519    if ( !$user_id )
    520520        $user_id = $bp->loggedin_user->id;
    521    
     521
    522522    return BP_Messages_Thread::check_access( $thread_id, $user_id );
    523523}
     
    528528
    529529function messages_mark_thread_unread( $thread_id ) {
    530     return BP_Messages_Thread::mark_as_unread( $thread_id );   
     530    return BP_Messages_Thread::mark_as_unread( $thread_id );
    531531}
    532532
     
    545545function messages_get_unread_count( $user_id = false ) {
    546546    global $bp;
    547    
    548     if ( !$user_id ) 
     547
     548    if ( !$user_id )
    549549        $user_id = $bp->loggedin_user->id;
    550        
     550
    551551    return BP_Messages_Thread::get_inbox_count( $user_id );
    552552}
  • trunk/bp-messages/bp-messages-classes.php

    r2020 r2077  
    11<?php
    22
    3 Class BP_Messages_Thread { 
     3Class BP_Messages_Thread {
    44    var $thread_id;
    55    var $message_ids;
    66    var $first_post_date;
    7    
     7
    88    var $last_post_date;
    99    var $last_sender_id;
     
    1212    var $last_message_message;
    1313    var $last_message_date_sent;
    14    
     14
    1515    var $messages = null;
    1616    var $has_access = false;
    1717    var $unread_count = 0;
    1818    var $recipients = null;
    19    
     19
    2020    var $box;
    2121    var $get_all_messages;
    22    
     22
    2323    function bp_messages_thread( $id = null, $get_all_messages = false, $box = 'inbox' ) {
    2424        $this->box = $box;
    2525        $this->get_all_messages = $get_all_messages;
    26        
     26
    2727        if ( $id ) {
    2828            $this->populate( $id );
    2929        }
    30        
     30
    3131        if ( $this->get_all_messages ) {
    3232            $this->messages = $this->get_messages();
     
    3434        }
    3535    }
    36    
    37     function populate( $id ) { 
     36
     37    function populate( $id ) {
    3838        global $wpdb, $bp;
    3939
    4040        $thread = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_threads} WHERE id = %d", $id ) );
    41        
     41
    4242        if ( $thread ) {
    43            
     43
    4444            // If we're only viewing a thread in a list of threads, don't bother using
    4545            // up resources checking if we have access. Only check if we're viewing the full
     
    5757                // filter the users messages out
    5858                if ( !$this->get_all_messages ) {
    59                    
     59
    6060                    // Flip the array to start from the newest message
    6161                    $this->message_ids = array_reverse( $this->message_ids );
    62                    
     62
    6363                    foreach ( $this->message_ids as $key => $message_id ) {
    6464                        if ( 'sentbox' == $this->box ) {
     
    6767                            } else {
    6868                                break;
    69                             }                       
     69                            }
    7070                        } else {
    7171                            if ( messages_is_user_sender( $bp->loggedin_user->id, $message_id ) ) {
     
    7373                            } else {
    7474                                break;
    75                             }                           
     75                            }
    7676                        }
    7777                    }
     
    8686                $this->first_post_date = $thread->first_post_date;
    8787                $this->last_post_date = $thread->last_post_date;
    88                
     88
    8989                if ( !empty($this->message_ids) )
    9090                    $this->message_ids = implode( ',', $this->message_ids );
    9191                else
    9292                    $this->message_ids = false;
    93                
     93
    9494                $this->unread_count = $this->get_unread();
    9595
    96                 $last_message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $this->last_message_id ) ); 
    97                
     96                $last_message = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $this->last_message_id ) );
     97
    9898                if ( $last_message ) {
    9999                    $this->last_message_subject = $last_message->subject;
     
    101101                    $this->last_message_date_sent = $last_message->date_sent;
    102102                }
    103                
     103
    104104                $this->recipients = $this->get_recipients();
    105105            }
    106106        }
    107107    }
    108    
     108
    109109    function get_messages() {
    110110        global $wpdb, $bp;
    111            
     111
    112112        if ( $this->message_ids)
    113113            return $wpdb->get_results( "SELECT * FROM {$bp->messages->table_name_messages} WHERE id IN (" . $wpdb->escape($this->message_ids) . ")" );
     
    121121        $sql = $wpdb->prepare( "SELECT unread_count FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $this->thread_id, $bp->loggedin_user->id );
    122122        $unread_count = $wpdb->get_var($sql);
    123        
     123
    124124        return $unread_count;
    125125    }
    126    
     126
    127127    function mark_read() {
    128128        BP_Messages_Thread::mark_as_read($this->thread_id);
    129129    }
    130    
     130
    131131    function mark_unread() {
    132132        BP_Messages_Thread::mark_as_unread($this->thread_id);
    133133    }
    134    
     134
    135135    function get_recipients() {
    136136        global $wpdb, $bp;
     
    144144                $recipient_ids[] = $recipient;
    145145        }
    146        
     146
    147147        return $recipient_ids;
    148148    }
    149    
     149
    150150    /** Static Functions **/
    151    
     151
    152152    function delete( $thread_id ) {
    153153        global $wpdb, $bp;
    154        
     154
    155155        $delete_for_user = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, $bp->loggedin_user->id ) );
    156        
     156
    157157        // Check to see if any more recipients remain for this message
    158158        // if not, then delete the message from the database.
     
    163163            $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
    164164            $message_ids = unserialize($message_ids);
    165            
     165
    166166            // delete thread:
    167167            $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
    168            
     168
    169169            // delete messages:
    170170            for ( $i = 0; $i < count($message_ids); $i++ ) {
    171171                $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_ids[$i] ) );
    172172            }
    173            
     173
    174174            // delete the recipients
    175175            $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_recipients} WHERE id = %d", $thread_id ) );
     
    178178        return true;
    179179    }
    180    
     180
    181181    function get_current_threads_for_user( $user_id, $box = 'inbox', $limit = null, $page = null, $type = 'all' ) {
    182182        global $wpdb, $bp;
     
    185185        if ( $limit && $page )
    186186            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    187        
     187
    188188        if ( $type == 'unread' )
    189189            $type_sql = $wpdb->prepare( " AND r.unread_count != 0 " );
    190190        else if ( $type == 'read' )
    191191            $type_sql = $wpdb->prepare( " AND r.unread_count = 0 " );
    192            
     192
    193193        $sql = $wpdb->prepare( "SELECT r.thread_id FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_threads} t WHERE t.id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d$exclude_sender $type_sql ORDER BY t.last_post_date DESC$pag_sql", $bp->loggedin_user->id );
    194194
    195195        if ( !$thread_ids = $wpdb->get_results($sql) )
    196196            return false;
    197        
     197
    198198        $threads = false;
    199        
     199
    200200        for ( $i = 0; $i < count($thread_ids); $i++ ) {
    201201            $threads[$i] = new BP_Messages_Thread( $thread_ids[$i]->thread_id, false, $box );
     
    206206
    207207        // reset keys
    208         return array_reverse( array_reverse( $threads ) ); 
    209     }
    210    
     208        return array_reverse( array_reverse( $threads ) );
     209    }
     210
    211211    function mark_as_read( $thread_id ) {
    212212        global $wpdb, $bp;
    213        
     213
    214214        $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id );
    215215        $wpdb->query($sql);
    216216    }
    217    
     217
    218218    function mark_as_unread( $thread_id ) {
    219219        global $wpdb, $bp;
    220        
     220
    221221        $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", $bp->loggedin_user->id, $thread_id );
    222222        $wpdb->query($sql);
    223223    }
    224    
     224
    225225    function get_total_threads_for_user( $user_id, $box = 'inbox', $type = 'all' ) {
    226226        global $wpdb, $bp;
     
    229229        if ( $box != 'sentbox' )
    230230            $exclude_sender = ' AND sender_only != 1';
    231        
     231
    232232        if ( $type == 'unread' )
    233233            $type_sql = $wpdb->prepare( " AND unread_count != 0 " );
     
    237237        return (int) $wpdb->get_var( $wpdb->prepare( "SELECT count(thread_id) FROM {$bp->messages->table_name_recipients} WHERE user_id = %d AND is_deleted = 0$exclude_sender $type_sql", $user_id ) );
    238238    }
    239    
     239
    240240    function user_is_sender($thread_id) {
    241241        global $wpdb, $bp;
    242        
    243         $sender_ids = $wpdb->get_var( $wpdb->prepare( "SELECT sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );   
    244        
     242
     243        $sender_ids = $wpdb->get_var( $wpdb->prepare( "SELECT sender_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
     244
    245245        if ( !$sender_ids )
    246246            return false;
    247            
     247
    248248        $sender_ids = unserialize($sender_ids);
    249        
     249
    250250        return in_array( $bp->loggedin_user->id, $sender_ids );
    251251    }
     
    255255
    256256        $sql = $wpdb->prepare("SELECT last_sender_id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id);
    257    
     257
    258258        if ( !$sender_id = $wpdb->get_var($sql) )
    259259            return false;
    260        
     260
    261261        return bp_core_get_userlink( $sender_id, true );
    262262    }
    263    
     263
    264264    function get_inbox_count() {
    265265        global $wpdb, $bp;
     
    269269        if ( !$unread_counts = $wpdb->get_results($sql) )
    270270            return false;
    271        
     271
    272272        $count = 0;
    273273        for ( $i = 0; $i < count($unread_counts); $i++ ) {
    274274            $count += $unread_counts[$i]->unread_count;
    275275        }
    276        
     276
    277277        return $count;
    278278    }
    279    
     279
    280280    function check_access( $thread_id, $user_id = false ) {
    281281        global $wpdb, $bp;
    282        
     282
    283283        if ( !$user_id )
    284284            $user_id = $bp->loggedin_user->id;
    285        
     285
    286286        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d AND user_id = %d", $thread_id, $user_id ) );
    287287    }
     
    289289    function is_valid( $thread_id ) {
    290290        global $wpdb, $bp;
    291        
     291
    292292        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
    293293    }
    294    
     294
    295295    function get_recipient_links($recipients) {
    296296        if ( count($recipients) >= 5 )
     
    311311    var $message;
    312312    var $date_sent;
    313    
     313
    314314    var $thread_id;
    315315    var $recipients = false;
     
    325325        }
    326326    }
    327    
     327
    328328    function populate( $id ) {
    329329        global $wpdb, $bp;
    330        
     330
    331331        $sql = $wpdb->prepare("SELECT * FROM {$bp->messages->table_name_messages} WHERE id = %d", $id);
    332332
     
    340340
    341341    }
    342    
    343     function send() {   
    344         global $wpdb, $bp;
    345        
     342
     343    function send() {
     344        global $wpdb, $bp;
     345
    346346        $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id );
    347347        $this->subject = apply_filters( 'messages_message_subject_before_save', $this->subject, $this->id );
    348348        $this->message = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
    349         $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id ); 
     349        $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
    350350
    351351        do_action( 'messages_message_before_save', $this );
    352        
     352
    353353        // First insert the message into the messages table
    354354        if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( sender_id, subject, message, date_sent ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d) )", $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )
    355355            return false;
    356            
     356
    357357        // Next, if thread_id is set, we are adding to an existing thread, if not, start a new one.
    358358        if ( $this->thread_id ) {
     
    362362            $message_ids[] = $wpdb->insert_id;
    363363            $message_ids = serialize($message_ids);
    364            
     364
    365365            // We need this so we can return the new message ID.
    366366            $message_id = $wpdb->insert_id;
    367            
     367
    368368            // Update the sender ids for the thread
    369369            $sender_ids = unserialize($the_ids->sender_ids);
     
    371371            if ( !in_array( $this->sender_id, $sender_ids ) || !$sender_ids )
    372372                $sender_ids[] = $this->sender_id;
    373                
    374             $sender_ids = serialize($sender_ids);           
    375            
     373
     374            $sender_ids = serialize($sender_ids);
     375
    376376            // Update the thread the message belongs to.
    377377            $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_threads} SET message_ids = %s, sender_ids = %s, last_message_id = %d, last_sender_id = %d, last_post_date = FROM_UNIXTIME(%d) WHERE id = %d", $message_ids, $sender_ids, $wpdb->insert_id, $this->sender_id, $this->date_sent, $this->thread_id ) );
    378                        
     378
    379379            // Find the recipients and update the unread counts for each
    380380            if ( !$this->recipients )
    381381                $this->recipients = $this->get_recipients();
    382            
     382
    383383            for ( $i = 0; $i < count($this->recipients); $i++ ) {
    384384                if ( $this->recipients[$i]->user_id != $bp->loggedin_user->id )
     
    390390            $serialized_message_id = serialize( array( (int)$message_id ) );
    391391            $serialized_sender_id = serialize( array( (int)$bp->loggedin_user->id ) );
    392            
    393             $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_threads} ( message_ids, sender_ids, first_post_date, last_post_date, last_message_id, last_sender_id ) VALUES ( %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d, %d )", $serialized_message_id, $serialized_sender_id, $this->date_sent, $this->date_sent, $message_id, $this->sender_id ); 
    394            
     392
     393            $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_threads} ( message_ids, sender_ids, first_post_date, last_post_date, last_message_id, last_sender_id ) VALUES ( %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d, %d )", $serialized_message_id, $serialized_sender_id, $this->date_sent, $this->date_sent, $message_id, $this->sender_id );
     394
    395395            if ( false === $wpdb->query($sql) )
    396396                return false;
    397            
     397
    398398
    399399            $this->thread_id = $wpdb->insert_id;
    400            
     400
    401401            // Add a new entry for each recipient;
    402402            for ( $i = 0; $i < count($this->recipients); $i++ ) {
    403403                $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, unread_count ) VALUES ( %d, %d, 1 )", $this->recipients[$i], $this->thread_id ) );
    404404            }
    405            
     405
    406406            if ( !in_array( $this->sender_id, (array)$this->recipients ) ) {
    407407                // Finally, add a recipient entry for the sender, as replies need to go to this person too.
     
    409409            }
    410410        }
    411        
     411
    412412        $this->id = $message_id;
    413413        messages_remove_callback_values();
    414414
    415415        do_action( 'messages_message_after_save', $this );
    416        
     416
    417417        return $this->thread_id;
    418418    }
    419    
     419
    420420    function get_recipients() {
    421421        global $bp, $wpdb;
    422        
     422
    423423        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $this->thread_id ) );
    424424    }
    425    
     425
    426426    // Static Functions
    427    
     427
    428428    function get_recipient_ids( $recipient_usernames ) {
    429429        if ( !$recipient_usernames )
    430430            return false;
    431    
     431
    432432        if ( is_array($recipient_usernames) ) {
    433433            for ( $i = 0; $i < count($recipient_usernames); $i++ ) {
     
    436436            }
    437437        }
    438        
     438
    439439        return $recipient_ids;
    440440    }
    441    
     441
    442442    function get_last_sent_for_user( $thread_id ) {
    443443        global $wpdb, $bp;
    444        
     444
    445445        $message_ids = $wpdb->get_var( $wpdb->prepare( "SELECT message_ids FROM {$bp->messages->table_name_threads} WHERE id = %d", $thread_id ) );
    446446        $message_ids = implode( ',', unserialize($message_ids));
     
    448448        $sql = $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages}  WHERE sender_id = %d AND id IN (" . $wpdb->escape($message_ids) . ") ORDER BY date_sent DESC LIMIT 1", $bp->loggedin_user->id );
    449449        return $wpdb->get_var($sql);
    450     }   
    451    
     450    }
     451
    452452    function is_user_sender( $user_id, $message_id ) {
    453453        global $wpdb, $bp;
    454454        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE sender_id = %d AND id = %d", $user_id, $message_id ) );
    455455    }
    456    
     456
    457457    function get_message_sender( $message_id ) {
    458458        global $wpdb, $bp;
    459         return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );     
     459        return $wpdb->get_var( $wpdb->prepare( "SELECT sender_id FROM {$bp->messages->table_name_messages} WHERE id = %d", $message_id ) );
    460460    }
    461461}
     
    467467    var $date_sent;
    468468    var $is_active;
    469    
     469
    470470    function bp_messages_notice($id = null) {
    471471        if ( $id ) {
     
    474474        }
    475475    }
    476    
     476
    477477    function populate() {
    478478        global $wpdb, $bp;
    479        
     479
    480480        $notice = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id ) );
    481        
     481
    482482        if ( $notice ) {
    483483            $this->subject = $notice->subject;
     
    487487        }
    488488    }
    489    
     489
    490490    function save() {
    491491        global $wpdb, $bp;
    492        
     492
    493493        $this->subject = apply_filters( 'messages_notice_subject_before_save', $this->subject, $this->id );
    494494        $this->message = apply_filters( 'messages_notice_message_before_save', $this->message, $this->id );
    495495
    496496        do_action( 'messages_notice_before_save', $this );
    497        
     497
    498498        if ( !$this->id ) {
    499             $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, FROM_UNIXTIME(%d), %d)", $this->subject, $this->message, $this->date_sent, $this->is_active ); 
     499            $sql = $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, FROM_UNIXTIME(%d), %d)", $this->subject, $this->message, $this->date_sent, $this->is_active );
    500500        } else {
    501             $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d", $this->subject, $this->message, $this->is_active, $this->id );               
    502         }
    503    
     501            $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d", $this->subject, $this->message, $this->is_active, $this->id );
     502        }
     503
    504504        if ( !$wpdb->query($sql) )
    505505            return false;
    506        
     506
    507507        if ( !$id = $this->id )
    508508            $id = $wpdb->insert_id;
    509            
     509
    510510        // Now deactivate all notices apart from the new one.
    511511        $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_notices} SET is_active = 0 WHERE id != %d", $id ) );
    512        
    513         update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) ); 
     512
     513        update_usermeta( $bp->loggedin_user->id, 'last_activity', date( 'Y-m-d H:i:s' ) );
    514514
    515515        do_action( 'messages_notice_after_save', $this );
    516                
     516
    517517        return true;
    518518    }
    519    
     519
    520520    function activate() {
    521521        $this->is_active = 1;
    522522        if ( !$this->save() )
    523523            return false;
    524            
     524
    525525        return true;
    526526    }
    527    
     527
    528528    function deactivate() {
    529529        $this->is_active = 0;
    530530        if ( !$this->save() )
    531531            return false;
    532        
     532
    533533        return true;
    534534    }
    535    
     535
    536536    function delete() {
    537537        global $wpdb, $bp;
    538        
     538
    539539        $sql = $wpdb->prepare( "DELETE FROM {$bp->messages->table_name_notices} WHERE id = %d", $this->id );
    540        
     540
    541541        if ( !$wpdb->query($sql) )
    542542            return false;
    543        
    544         return true;   
    545     }
    546    
     543
     544        return true;
     545    }
     546
    547547    // Static Functions
    548    
     548
    549549    function get_notices() {
    550550        global $wpdb, $bp;
    551        
     551
    552552        $notices = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_notices} ORDER BY date_sent DESC" ) );
    553553        return $notices;
    554554    }
    555    
     555
    556556    function get_total_notice_count() {
    557557        global $wpdb, $bp;
    558        
     558
    559559        $notice_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM " . $bp->messages->table_name_notices ) );
    560560        return $notice_count;
    561561    }
    562    
     562
    563563    function get_active() {
    564564        global $wpdb, $bp;
    565        
     565
    566566        $notice_id = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_notices} WHERE is_active = 1") );
    567567        return new BP_Messages_Notice($notice_id);
  • trunk/bp-messages/bp-messages-cssjs.php

    r1905 r2077  
    33function messages_add_autocomplete_js() {
    44    global $bp;
    5    
     5
    66    // Include the autocomplete JS for composing a message.
    77    if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
    88        add_action( 'wp_head', 'messages_autocomplete_init_jsblock' );
    9        
     9
    1010        wp_enqueue_script( 'bp-jquery-autocomplete', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocomplete.js', array( 'jquery' ) );
    1111        wp_enqueue_script( 'bp-jquery-autocomplete-fb', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.autocompletefb.js' );
    1212        wp_enqueue_script( 'bp-jquery-bgiframe', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.bgiframe.min.js' );
    13         wp_enqueue_script( 'bp-jquery-dimensions', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.dimensions.js' );   
     13        wp_enqueue_script( 'bp-jquery-dimensions', BP_PLUGIN_URL . '/bp-messages/js/autocomplete/jquery.dimensions.js' );
    1414    }
    1515
     
    2121
    2222    if ( $bp->current_component == $bp->messages->slug && 'compose' == $bp->current_action ) {
    23         wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.css' ); 
     23        wp_enqueue_style( 'bp-messages-autocomplete', BP_PLUGIN_URL . '/bp-messages/css/autocomplete/jquery.autocompletefb.css' );
    2424        wp_print_styles();
    2525    }
     
    3131    <script type="text/javascript">
    3232        jQuery(document).ready(function() {
    33             var acfb = 
     33            var acfb =
    3434            jQuery("ul.first").autoCompletefb({urlLookup:'<?php echo $bp->root_domain . str_replace( 'index.php', 'wp-load.php', $_SERVER['SCRIPT_NAME'] ) ?>'});
    3535
  • trunk/bp-messages/bp-messages-notifications.php

    r1905 r2077  
    44    global $bp;
    55    extract($args);
    6    
     6
    77    $message = new BP_Messages_Message( $item_id );
    8    
     8
    99    $sender_name = bp_core_get_user_displayname( $message->sender_id );
    1010
     
    1313
    1414        $ud = get_userdata( $recipient_ids[$i] );
    15         $message_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'messages/view/' . $message->id; 
    16         $settings_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'settings/notifications'; 
    17        
     15        $message_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'messages/view/' . $message->id;
     16        $settings_link = bp_core_get_user_domain( $recipient_ids[$i] ) . 'settings/notifications';
     17
    1818        // Set up and send the message
    1919        $to = $ud->user_email;
    2020        $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) );
    2121
    22         $content = sprintf( __( 
     22        $content = sprintf( __(
    2323'%s sent you a new message:
    2424
     
    4545
    4646    $users = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_email, user_login FROM {$wpdb->base_prefix}users WHERE user_status = 0 AND spam = 0 AND deleted = 0" ) );
    47    
     47
    4848    for ( $i = 0; $i < count($users); $i++ ) {
    4949        if ( get_usermeta( $users[$i]->user_id, 'notification_messages_new_notice' ) == 'no' ) continue;
    5050
    51         $message_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'messages'; 
    52         $settings_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'settings/notifications'; 
     51        $message_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'messages';
     52        $settings_link = bp_core_get_user_domain( $users[$i]->user_id ) . 'settings/notifications';
    5353
    5454        // Set up and send the message
     
    5656        $subject = __( 'New Site Notice', 'buddypress' );
    5757
    58         $message = sprintf( __( 
     58        $message = sprintf( __(
    5959'A new site notice has been posted on %s:
    6060
     
    7070        // Send it
    7171        wp_mail( $to, $subject, $message );
    72        
     72
    7373        unset($message);
    7474        unset($subject);
  • trunk/bp-messages/bp-messages-templatetags.php

    r1989 r2077  
    1111    var $threads;
    1212    var $thread;
    13    
     13
    1414    var $in_the_loop;
    1515    var $user_id;
    1616    var $box;
    17    
     17
    1818    var $pag_page;
    1919    var $pag_num;
     
    2525        $this->user_id = $user_id;
    2626        $this->box = $box;
    27        
     27
    2828        if ( 'notices' == $this->box )
    2929            $this->threads = BP_Messages_Notice::get_notices();
    3030        else
    3131            $this->threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->pag_num, $this->pag_page, $type );
    32        
     32
    3333        if ( !$this->threads ) {
    3434            $this->thread_count = 0;
    3535            $this->total_thread_count = 0;
    36         } else { 
     36        } else {
    3737            $total_notice_count = BP_Messages_Notice::get_total_notice_count();
    38            
     38
    3939            if ( !$max || $max >= (int)$total_notice_count ) {
    4040                if ( 'notices' == $this->box )
     
    4545                $this->total_thread_count = (int)$max;
    4646            }
    47            
     47
    4848            if ( $max ) {
    4949                if ( $max >= count($this->threads) )
     
    6666        ));
    6767    }
    68    
     68
    6969    function has_threads() {
    7070        if ( $this->thread_count )
    7171            return true;
    72        
     72
    7373        return false;
    7474    }
    75    
     75
    7676    function next_thread() {
    7777        $this->current_thread++;
    7878        $this->thread = $this->threads[$this->current_thread];
    79        
     79
    8080        return $this->thread;
    8181    }
    82    
     82
    8383    function rewind_threads() {
    8484        $this->current_thread = -1;
     
    8787        }
    8888    }
    89    
    90     function message_threads() { 
     89
     90    function message_threads() {
    9191        if ( $this->current_thread + 1 < $this->thread_count ) {
    9292            return true;
     
    100100        return false;
    101101    }
    102    
     102
    103103    function the_message_thread() {
    104104        global $thread;
     
    114114function bp_has_message_threads( $args = '' ) {
    115115    global $bp, $messages_template;
    116    
     116
    117117    $defaults = array(
    118118        'user_id' => $bp->loggedin_user->id,
     
    131131        if ( 'inbox' == $bp->current_action )
    132132            bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, 'messages', 'new_message' );
    133        
     133
    134134        if ( 'sentbox' == $bp->current_action )
    135135            $box = 'sentbox';
     
    137137        if ( 'notices' == $bp->current_action )
    138138            $box = 'notices';
    139    
     139
    140140        $messages_template = new BP_Messages_Box_Template( $user_id, $box, $per_page, $max, $type );
    141141    }
    142    
     142
    143143    return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), &$messages_template );
    144144}
    145145
    146 function bp_message_threads() { 
     146function bp_message_threads() {
    147147    global $messages_template;
    148148    return $messages_template->message_threads();
     
    202202        return apply_filters( 'bp_get_message_thread_view_link', $bp->loggedin_user->domain . $bp->messages->slug . '/view/' . $messages_template->thread->thread_id );
    203203    }
    204    
     204
    205205function bp_message_thread_delete_link() {
    206206    echo bp_get_message_thread_delete_link();
     
    210210        return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/' . $bp->current_action . '/delete/' . $messages_template->thread->thread_id, 'messages_delete_thread' ) );
    211211    }
    212    
     212
    213213function bp_message_thread_has_unread() {
    214214    global $messages_template;
     
    216216    if ( $messages_template->thread->unread_count )
    217217        return true;
    218    
     218
    219219    return false;
    220220}
     
    225225    function bp_get_message_thread_unread_count() {
    226226        global $messages_template;
    227        
     227
    228228        if ( (int)$messages_template->thread->unread_count )
    229229            return apply_filters( 'bp_get_message_thread_unread_count', $messages_template->thread->unread_count );
    230        
     230
    231231        return false;
    232232    }
     
    276276
    277277    echo sprintf( __( 'Viewing message %d to %d (of %d messages)', 'buddypress' ), $from_num, $to_num, $messages_template->total_thread_count ); ?> &nbsp;
    278     <span class="ajax-loader"></span><?php 
     278    <span class="ajax-loader"></span><?php
    279279}
    280280
     
    315315function bp_messages_options() {
    316316    global $bp;
    317    
     317
    318318    if ( $bp->current_action != 'sentbox' ) {
    319319?>
    320         <?php _e( 'Select:', 'buddypress' ) ?> 
     320        <?php _e( 'Select:', 'buddypress' ) ?>
    321321        <select name="message-type-select" id="message-type-select">
    322322            <option value=""></option>
     
    329329    <?php } ?>
    330330        <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
    331 <?php   
     331<?php
    332332}
    333333
    334334function bp_message_is_active_notice() {
    335335    global $messages_template;
    336    
     336
    337337    if ( $messages_template->thread->is_active ) {
    338338        echo "<strong>";
     
    346346        if ( $messages_template->thread->is_active )
    347347            return true;
    348        
     348
    349349        return false;
    350350    }
     
    392392            $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/deactivate/' . $messages_template->thread->id, 'messages_deactivate_notice' );
    393393        } else {
    394             $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' );       
     394            $link = wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . '/notices/activate/' . $messages_template->thread->id, 'messages_activate_notice' );
    395395        }
    396396        return apply_filters( 'bp_get_message_activate_deactivate_link', $link );
     
    406406            $text = __('Deactivate', 'buddypress');
    407407        } else {
    408             $text = __('Activate', 'buddypress');       
     408            $text = __('Activate', 'buddypress');
    409409        }
    410410        return apply_filters( 'bp_message_activate_deactivate_text', $text );
     
    413413function bp_message_get_notices() {
    414414    global $userdata;
    415    
     415
    416416    $notice = BP_Messages_Notice::get_active();
    417417    $closed_notices = get_usermeta( $userdata->ID, 'closed_notices');
     
    429429            </div>
    430430            <?php
    431         }   
     431        }
    432432    }
    433433}
     
    438438    function bp_get_send_message_button() {
    439439        global $bp;
    440    
     440
    441441        if ( bp_is_home() || !is_user_logged_in() )
    442442            return false;
    443    
    444         $ud = get_userdata( $bp->displayed_user->id ); 
    445        
     443
     444        $ud = get_userdata( $bp->displayed_user->id );
     445
    446446        return apply_filters( 'bp_get_send_message_button', '<div class="generic-button"><a class="send-message" title="' . __( 'Send Message', 'buddypress' ) . '" href="' . $bp->loggedin_user->domain . $bp->messages->slug . '/compose/?r=' . $ud->user_login . '">' . __( 'Send Message', 'buddypress' ) . '</a></div>' );
    447447    }
     
    457457function bp_message_get_recipient_tabs() {
    458458    global $bp;
    459    
     459
    460460    if ( isset( $_GET['r'] ) ) {
    461461        $user_id = bp_core_get_userid( $_GET['r'] );
    462        
     462
    463463        if ( $user_id ) {
    464464            ?>
     
    467467                    <?php echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) ) ?>
    468468                    <?php echo bp_core_get_userlink( $user_id ) ?>
    469                 </span> 
     469                </span>
    470470            </li>
    471471            <?php
     
    490490    var $message_count;
    491491    var $message;
    492    
     492
    493493    var $thread;
    494    
     494
    495495    var $in_the_loop;
    496    
     496
    497497    var $pag_page;
    498498    var $pag_num;
    499499    var $pag_links;
    500500    var $total_message_count;
    501    
     501
    502502    function bp_messages_thread_template( $thread_id, $order ) {
    503503        global $bp;
    504        
     504
    505505        $this->thread = new BP_Messages_Thread( $thread_id, true );
    506506        $this->message_count = count( $this->thread->messages );
    507507    }
    508    
     508
    509509    function has_messages() {
    510510        if ( $this->message_count )
    511511            return true;
    512        
     512
    513513        return false;
    514514    }
    515    
     515
    516516    function next_message() {
    517517        $this->current_message++;
    518518        $this->message = $this->thread->messages[$this->current_message];
    519        
     519
    520520        return $this->message;
    521521    }
    522    
     522
    523523    function rewind_messages() {
    524524        $this->current_message = -1;
     
    527527        }
    528528    }
    529    
    530     function messages() { 
     529
     530    function messages() {
    531531        if ( $this->current_message + 1 < $this->message_count ) {
    532532            return true;
     
    540540        return false;
    541541    }
    542    
     542
    543543    function the_message() {
    544544        global $message;
     
    554554function bp_thread_has_messages( $args = '' ) {
    555555    global $bp, $thread_template, $group_id;
    556    
     556
    557557    $defaults = array(
    558558        'thread_id' => false,
     
    572572function bp_thread_messages() {
    573573    global $thread_template;
    574    
     574
    575575    return $thread_template->messages();
    576576}
     
    578578function bp_thread_the_message() {
    579579    global $thread_template;
    580    
     580
    581581    return $thread_template->the_message();
    582582}
     
    587587    function bp_get_the_thread_id() {
    588588        global $thread_template;
    589        
     589
    590590        return apply_filters( 'bp_get_the_thread_id', $thread_template->thread->thread_id );
    591591    }
     
    605605    function bp_get_the_thread_recipients() {
    606606        global $thread_template;
    607        
     607
    608608        if ( count($thread_template->thread->recipients) >= 5 )
    609609            return apply_filters( 'bp_get_the_thread_recipients', sprintf( __( '%d Recipients', 'buddypress' ), count($thread_template->thread->recipients) ) );
    610        
     610
    611611        foreach( $thread_template->thread->recipients as $recipient )
    612612            $recipient_links[] = bp_core_get_userlink( $recipient );
     
    620620    function bp_get_the_thread_message_alt_class() {
    621621        global $thread_template;
    622        
     622
    623623        if ( $thread_template->current_message % 2 == 1 )
    624624            $class = ' alt';
    625625        else
    626626            $class = '';
    627        
     627
    628628        return apply_filters( 'bp_get_the_thread_message_alt_class', $class );
    629629    }
    630    
     630
    631631function bp_the_thread_message_sender_avatar( $args = '' ) {
    632632    echo bp_get_the_thread_message_sender_avatar_thumb( $args );
    633633}
    634634    function bp_get_the_thread_message_sender_avatar_thumb( $args = '' ) {
    635         global $thread_template;   
    636            
     635        global $thread_template;
     636
    637637        $defaults = array(
    638638            'type' => 'thumb',
     
    652652    function bp_get_the_thread_message_sender_link() {
    653653        global $thread_template;
    654        
     654
    655655        return apply_filters( 'bp_get_the_thread_message_sender_link', bp_core_get_userlink( $thread_template->message->sender_id, false, true ) );
    656656    }
    657    
     657
    658658function bp_the_thread_message_sender_name() {
    659659    echo bp_get_the_thread_message_sender_name();
     
    661661    function bp_get_the_thread_message_sender_name() {
    662662        global $thread_template;
    663        
    664         return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) );     
     663
     664        return apply_filters( 'bp_get_the_thread_message_sender_name', bp_core_get_user_displayname( $thread_template->message->sender_id ) );
    665665    }
    666666
     
    670670    function bp_get_the_thread_message_time_since() {
    671671        global $thread_template;
    672        
     672
    673673        return apply_filters( 'bp_get_the_thread_message_time_since', sprintf( __( 'Sent %s ago', 'buddypress' ), bp_core_time_since( strtotime( $thread_template->message->date_sent ) ) ) );
    674674    }
     
    679679    function bp_get_the_thread_message_content() {
    680680        global $thread_template;
    681        
    682         return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );       
    683     }
    684    
     681
     682        return apply_filters( 'bp_get_the_thread_message_content', $thread_template->message->message );
     683    }
     684
    685685
    686686/*** DEPRECATED FUNCTIONS (DO NOT USE) **********************************************************/
    687687
    688 /* DEPRECATED - please use the view message template loop. */   
     688/* DEPRECATED - please use the view message template loop. */
    689689function messages_view_thread( $thread_id ) {
    690690    global $bp;
    691691
    692692    $thread = new BP_Messages_Thread( $thread_id, true );
    693    
     693
    694694    if ( !$thread->has_access ) {
    695695        unset($_GET['mode']); ?>
     
    697697            <p><?php _e( 'There was an error when viewing that message', 'buddypress' ) ?></p>
    698698        </div>
    699     <?php   
     699    <?php
    700700    } else {
    701701        if ( $thread->messages ) { ?>
    702702            <?php $thread->mark_read() ?>
    703                
     703
    704704            <div class="wrap">
    705705                <h2 id="message-subject"><?php echo $thread->subject; ?></h2>
     
    709709                            <td>
    710710                                <img src="<?php echo $bp->messages->image_base ?>/email_open.gif" alt="Message" style="vertical-align: top;" /> &nbsp;
    711                                 <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?> 
    712                                 <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>. 
     711                                <?php _e('Sent between ', 'buddypress') ?> <?php echo BP_Messages_Thread::get_recipient_links($thread->recipients) ?>
     712                                <?php _e('and', 'buddypress') ?> <?php echo bp_core_get_userlink($bp->loggedin_user->id) ?>.
    713713                            </td>
    714714                        </tr>
    715715                    </tbody>
    716716                </table>
    717                
     717
    718718        <?php
    719719            $counter = 0;
    720            
     720
    721721            foreach ( $thread->messages as $message ) {
    722722                $alt = ( $counter % 2 == 1 ) ? ' alt' : '';
     
    729729                            <small><?php echo apply_filters( 'bp_get_message_date_sent', bp_format_time( strtotime($message->date_sent ) ) ) ?></small>
    730730                        </div>
    731                        
     731
    732732                        <?php do_action( 'messages_custom_fields_output_before' ) ?>
    733                        
     733
    734734                        <?php echo apply_filters( 'bp_get_the_message_thread_content', stripslashes($message->message) ); ?>
    735                        
     735
    736736                        <?php do_action( 'messages_custom_fields_output_after' ) ?>
    737        
     737
    738738                        <div class="clear"></div>
    739739                    </div>
     
    741741                $counter++;
    742742            }
    743        
     743
    744744            ?>
    745745                <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post">
     
    748748                                <div class="avatar-box">
    749749                                    <?php echo  bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => 'thumb' ) ); ?>
    750                    
     750
    751751                                    <h3><?php _e("Reply: ", 'buddypress') ?></h3>
    752752                                </div>
     
    762762                            <input type="hidden" name="subject" id="subject" value="<?php _e('Re: ', 'buddypress'); echo str_replace( 'Re: ', '', $thread->last_message_subject); ?>" />
    763763                    </div>
    764                    
     764
    765765                    <?php wp_nonce_field( 'messages_send_message', '_wpnonce_send_message' ) ?>
    766766                </form>
  • trunk/bp-messages/deprecated/bp-messages-deprecated.php

    r1957 r2077  
    44 *
    55 * This file contains functions that are deprecated.
    6  * You should not under any circumstance use these functions as they are 
     6 * You should not under any circumstance use these functions as they are
    77 * either no longer valid, or have been replaced with something much more awesome.
    88 *
     
    1313 * Of course, things will still work if you use these functions but you will
    1414 * be the laughing stock of the BuddyPress community. We will all point and laugh at
    15  * you. You'll also be making things harder for yourself in the long run, 
     15 * you. You'll also be making things harder for yourself in the long run,
    1616 * and you will miss out on lovely performance and functionality improvements.
    17  * 
     17 *
    1818 * If you've checked you are not using any deprecated functions and finished your little
    1919 * dance, you can add the following line to your wp-config.php file to prevent any of
     
    2424function messages_deprecated_globals() {
    2525    global $bp;
    26    
     26
    2727    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    2828    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
     
    3131    $bp->groups->image_base = BP_PLUGIN_URL . '/bp-messages/deprecated/images';
    3232}
    33 add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 );   
     33add_action( 'plugins_loaded', 'messages_deprecated_globals', 5 );
    3434add_action( 'admin_menu', 'messages_deprecated_globals', 2 );
    3535
     
    5050    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    5151        return $template;
    52        
     52
    5353    /* Enqueue the structure CSS file to give basic positional formatting for components */
    54     wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' );   
     54    wp_enqueue_style( 'bp-messages-structure', BP_PLUGIN_URL . '/bp-messages/deprecated/css/structure.css' );
    5555}
    5656add_action( 'bp_styles', 'messages_add_structure_css' );
     
    6262    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    6363        return false;
    64        
     64
    6565    check_ajax_referer( 'messages_send_message' );
    66    
    67     $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true); 
     66
     67    $result = messages_send_message($_REQUEST['send_to'], $_REQUEST['subject'], $_REQUEST['content'], $_REQUEST['thread_id'], true, false, true);
    6868
    6969    if ( $result['status'] ) { ?>
    7070            <div class="avatar-box">
    7171                <?php echo bp_core_fetch_avatar( array( 'item_id' => $result['reply']->sender_id, 'type' => 'thumb' ) ); ?>
    72    
     72
    7373                <h3><?php echo bp_core_get_userlink($result['reply']->sender_id) ?></h3>
    7474                <small><?php echo bp_format_time($result['reply']->date_sent) ?></small>
     
    9090    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    9191        return false;
    92        
     92
    9393    if ( !isset($_POST['thread_ids']) ) {
    9494        echo "-1[[split]]" . __('There was a problem marking messages as unread.', 'buddypress');
    9595    } else {
    9696        $thread_ids = explode( ',', $_POST['thread_ids'] );
    97        
     97
    9898        for ( $i = 0; $i < count($thread_ids); $i++ ) {
    9999            BP_Messages_Thread::mark_as_unread($thread_ids[$i]);
     
    108108    /* If we are using a BuddyPress 1.1+ theme ignore this. */
    109109    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    110         return false;   
    111        
     110        return false;
     111
    112112    if ( !isset($_POST['thread_ids']) ) {
    113113        echo "-1[[split]]" . __('There was a problem marking messages as read.', 'buddypress');
     
    128128    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    129129        return false;
    130        
     130
    131131    if ( !isset($_POST['thread_ids']) ) {
    132132        echo "-1[[split]]" . __( 'There was a problem deleting messages.', 'buddypress' );
     
    137137            BP_Messages_Thread::delete($thread_ids[$i]);
    138138        }
    139        
     139
    140140        _e('Messages deleted.', 'buddypress');
    141141    }
     
    149149    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    150150        return false;
    151        
     151
    152152    if ( !isset($_POST['notice_id']) ) {
    153153        echo "-1[[split]]" . __('There was a problem closing the notice.', 'buddypress');
    154154    } else {
    155155        $notice_ids = get_usermeta( $userdata->ID, 'closed_notices' );
    156    
     156
    157157        $notice_ids[] = (int) $_POST['notice_id'];
    158        
     158
    159159        update_usermeta( $userdata->ID, 'closed_notices', $notice_ids );
    160160    }
     
    168168    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    169169        return false;
    170            
     170
    171171    $friends = false;
    172172
     
    183183            echo bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'width' => 15, 'height' => 15 ) )  . ' ' . bp_core_get_user_displayname( $user_id ) . ' (' . $username . ')
    184184            ';
    185         }       
     185        }
    186186    }
    187187}
     
    193193    global $message, $type;
    194194    global $bp, $current_user;
    195        
     195
    196196    messages_add_callback_values( $recipients, $subject, $content );
    197    
     197
    198198    if ( isset( $_POST['send-notice'] ) ) {
    199199        if ( messages_send_notice( $subject, $content, $from_template ) ) {
    200200            bp_core_add_message( __('Notice posted successfully.', 'buddypress') );
    201201        } else {
    202             bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' );           
     202            bp_core_add_message( __('There was an error posting that notice.', 'buddypress'), 'error' );
    203203        }
    204204        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/notices' );
    205205        return true;
    206206    }
    207    
     207
    208208    $recipients = explode( ' ', $recipients );
    209    
     209
    210210    // If there are no recipients
    211211    if ( count( $recipients ) < 1 ) {
    212         if ( !$from_ajax ) {   
     212        if ( !$from_ajax ) {
    213213            bp_core_add_message( __('Please enter at least one valid user to send this message to.', 'buddypress'), 'error' );
    214214            bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
     
    216216            return array('status' => 0, 'message' => __('There was an error sending the reply, please try again.', 'buddypress'));
    217217        }
    218        
     218
    219219    // If there is only 1 recipient and it is the logged in user.
    220220    } else if ( 1 == count( $recipients ) && $recipients[0] == $current_user->user_login ) {
    221221        bp_core_add_message( __('You must send your message to one or more users not including yourself.', 'buddypress'), 'error' );
    222         bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );   
    223    
     222        bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
     223
    224224    // If the subject or content boxes are empty.
    225225    } else if ( empty( $subject ) || empty( $content ) ) {
     
    230230            return array('status' => 0, 'message' => __('Please make sure you have typed a message before sending a reply.', 'buddypress'));
    231231        }
    232        
     232
    233233    // Passed validation continue.
    234234    } else {
     
    237237        if ( $key = array_search( $current_user->user_login, $recipients ) )
    238238            unset( $recipients[$key] );
    239        
     239
    240240        $pmessage = new BP_Messages_Message;
    241241
     
    245245        $pmessage->thread_id = $thread_id;
    246246        $pmessage->date_sent = time();
    247        
     247
    248248        if ( $is_reply ) {
    249249            $thread = new BP_Messages_Thread($thread_id);
     
    257257                $message = __('Message could not be sent, please try again.', 'buddypress');
    258258                $type = 'error';
    259        
     259
    260260                if ( $from_ajax ) {
    261261                    return array('status' => 0, 'message' => $message);
     
    263263                    bp_core_add_message( $message, $type );
    264264                    bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/compose' );
    265                 } 
     265                }
    266266            } else {
    267267                $message = __('Message sent successfully!', 'buddypress');
    268268                $type = 'success';
    269                
     269
    270270                // Send screen notifications to the recipients
    271271                for ( $i = 0; $i < count($pmessage->recipients); $i++ ) {
    272272                    if ( $pmessage->recipients[$i] != $bp->loggedin_user->id ) {
    273                         bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );   
     273                        bp_core_add_notification( $pmessage->id, $pmessage->recipients[$i], 'messages', 'new_message' );
    274274                    }
    275275                }
    276                
     276
    277277                // Send email notifications to the recipients
    278278                require_once( BP_PLUGIN_DIR . '/bp-messages/bp-messages-notifications.php' );
     
    280280
    281281                do_action( 'messages_send_message', array( 'item_id' => $pmessage->id, 'recipient_ids' => $pmessage->recipients, 'thread_id' => $pmessage->thread_id, 'component_name' => $bp->messages->slug, 'component_action' => 'message_sent', 'is_private' => 1 ) );
    282        
     282
    283283                if ( $from_ajax ) {
    284284                    return array('status' => 1, 'message' => $message, 'reply' => $pmessage);
     
    291291            $message = __('Message could not be sent, please try again.', 'buddypress');
    292292            $type = 'error';
    293        
     293
    294294            if ( $from_ajax ) {
    295295                return array('status' => 0, 'message' => $message);
  • trunk/bp-status.php

    r2037 r2077  
    1212    $bp->status->id = 'status';
    1313    $bp->status->slug = BP_STATUS_SLUG;
    14    
     14
    1515    /* Register this in the active components array */
    1616    $bp->active_components[$bp->status->slug] = $bp->status->id;
     
    1818    do_action( 'bp_status_setup_globals' );
    1919}
    20 add_action( 'plugins_loaded', 'bp_status_setup_globals', 5 );   
     20add_action( 'plugins_loaded', 'bp_status_setup_globals', 5 );
    2121add_action( 'admin_menu', 'bp_status_setup_globals', 2 );
    2222
     
    3131function bp_status_register_activity_actions() {
    3232    global $bp;
    33    
     33
    3434    if ( !function_exists( 'bp_activity_set_action' ) )
    3535        return false;
     
    4444function bp_status_record_activity( $user_id, $content, $primary_link, $component_action = 'new_status' ) {
    4545    global $bp;
    46    
     46
    4747    if ( !function_exists( 'bp_activity_add' ) )
    4848        return false;
    49    
    50     return bp_activity_add( array( 
    51             'user_id' => $user_id, 
    52             'content' => $content, 
    53             'primary_link' => $primary_link, 
     49
     50    return bp_activity_add( array(
     51            'user_id' => $user_id,
     52            'content' => $content,
     53            'primary_link' => $primary_link,
    5454            'component_name' => $bp->status->id,
    5555            'component_action' => $component_action
     
    6666function bp_status_register_activity_action( $key, $value ) {
    6767    global $bp;
    68    
     68
    6969    if ( !function_exists( 'bp_activity_set_action' ) )
    7070        return false;
    71    
     71
    7272    return apply_filters( 'bp_status_register_activity_action', bp_activity_set_action( $bp->status->id, $key, $value ), $key, $value );
    7373}
     
    8787    if ( $bp->current_component != BP_STATUS_SLUG || 'add' != $bp->current_action )
    8888        return false;
    89    
     89
    9090    if ( !check_admin_referer( 'bp_status_add_status', '_wpnonce_add_status' ) )
    9191        return false;
     
    9595    else
    9696        bp_core_add_message( __( 'There was a problem updating your status. Please try again.', 'buddypress' ), 'error' );
    97    
     97
    9898    bp_core_redirect( $bp->loggedin_user->domain );
    9999}
     
    112112function bp_status_add_status( $user_id, $content, $recorded_time = false ) {
    113113    global $bp;
    114    
     114
    115115    $content = apply_filters( 'bp_status_content_before_save', $content );
    116    
    117     if ( !$recorded_time ) 
     116
     117    if ( !$recorded_time )
    118118        $recorded_time = time();
    119    
     119
    120120    if ( !$content || empty($content) )
    121121        return false;
    122    
     122
    123123    bp_status_clear_existing_activity( $user_id );
    124    
     124
    125125    /* Store the status in usermeta for easy access. */
    126126    update_usermeta( $user_id, 'bp_status', array( 'content' => $content, 'recorded_time' => $recorded_time ) );
     
    132132
    133133    bp_status_record_activity( $user_id, apply_filters( 'bp_status_activity_new', $activity_content, $content, $user_link ), apply_filters( 'bp_status_activity_new_primary_link', $user_link, $user_id ) );
    134    
     134
    135135    do_action( 'bp_status_add_status', $user_id, $content );
    136136
     
    140140function bp_status_clear_status( $user_id = false ) {
    141141    global $bp;
    142    
     142
    143143    if ( !$user_id )
    144144        $user_id = $bp->loggedin_user->id;
    145    
     145
    146146    bp_status_clear_existing_activity( $user_id );
    147    
     147
    148148    return delete_usermeta( $user_id, 'bp_status' );
    149149}
     
    152152    /* Fetch existing status update if there is one. */
    153153    $existing_status = get_usermeta( $user_id, 'bp_status' );
    154    
     154
    155155    if ( '' != $existing_status ) {
    156156        if ( strtotime( '+5 minutes', $existing_status['recorded_time'] ) >= time() ) {
  • trunk/bp-status/bp-status-templatetags.php

    r2038 r2077  
    1111        if ( 'clear' == $_GET['status'] && is_user_logged_in() )
    1212            bp_status_clear_status();
    13        
     13
    1414        echo bp_get_the_status( $args );
    1515    }
     
    1717    function bp_get_the_status( $args = false ) {
    1818        global $bp;
    19    
     19
    2020        $defaults = array(
    2121            'user_id' => $bp->displayed_user->id,
     
    2424            'no_anchor' => false
    2525        );
    26    
     26
    2727        $r = wp_parse_args( $args, $defaults );
    2828        extract( $r, EXTR_SKIP );
    29        
     29
    3030        if ( !$user_id )
    3131            $user_id = $bp->displayed_user->id;
    32        
    33         $status = apply_filters( 'bp_status_from_usermeta', get_usermeta( $user_id, 'bp_status' ) ); 
    34        
     32
     33        $status = apply_filters( 'bp_status_from_usermeta', get_usermeta( $user_id, 'bp_status' ) );
     34
    3535        if ( empty($status) )
    3636            return bp_get_update_status_button( 'text=' . $new_button_text );
    37        
     37
    3838        $time_since = sprintf( __( '%s ago', 'buddypress' ), bp_core_time_since( $status['recorded_time'] ) );
    3939        $content = apply_filters( 'the_status_content', $status['content'] );
    40        
     40
    4141        if ( !(int)$no_anchor && $user_id == $bp->loggedin_user->id )
    4242            $content = '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $content . '</a>';
     
    4444        $content .= ' <span class="time-since">' . $time_since . '</span>';
    4545        $content .= ' ' . bp_get_clear_status_button( 'text=' . $clear_button_text );
    46        
     46
    4747        return apply_filters( 'bp_get_the_status', $content );
    4848    }
    49    
     49
    5050function bp_update_status_button( $args = false ) {
    5151    echo bp_get_update_status_button( $args );
     
    5858            'text' => __( 'Update Your Status', 'buddypress' )
    5959        );
    60    
     60
    6161        $r = wp_parse_args( $args, $defaults );
    6262        extract( $r, EXTR_SKIP );
    63        
     63
    6464        if ( !$user_id )
    6565            $user_id = $bp->displayed_user->id;
    66        
     66
    6767        if ( $user_id != $bp->loggedin_user->id )
    6868            return false;
    69        
     69
    7070        return apply_filters( 'bp_get_update_status_button', '<div class="generic-button"><a href="' . bp_core_get_user_domain( $user_id ) . '?status=new" id="status-new-status">' . $text . '</a></div>' );
    7171    }
     
    8181            'text' => __( 'Clear', 'buddypress' )
    8282        );
    83    
     83
    8484        $r = wp_parse_args( $args, $defaults );
    8585        extract( $r, EXTR_SKIP );
    86        
     86
    8787        if ( !$user_id )
    8888            $user_id = $bp->displayed_user->id;
    89        
     89
    9090        if ( $user_id != $bp->loggedin_user->id )
    9191            return false;
    92        
     92
    9393        return apply_filters( 'bp_get_clear_status_button', '<a href="' . bp_core_get_user_domain( $user_id ) . '?status=clear" id="status-clear-status">' . $text . '</a>' );
    9494    }
     
    9696function bp_status_form_action( $user_id = false ) {
    9797    global $bp;
    98    
     98
    9999    if ( !$user_id )
    100100        $user_id = $bp->loggedin_user->id;
    101        
     101
    102102    echo apply_filters( 'bp_status_form_action', bp_core_get_user_domain( $user_id ) . BP_STATUS_SLUG . '/add' );
    103103}
  • trunk/bp-themes/bp-default/_inc/css/adminbar.css

    r2009 r2077  
    2727        padding-right: 0;
    2828    }
    29    
     29
    3030#wp-admin-bar ul li ul a {
    3131    color: #666 !important;
     
    144144    -webkit-border-radius: 2px !important;
    145145    margin-left: 2px !important;
    146 } 
     146}
  • trunk/bp-themes/bp-default/style.css

    r2042 r2077  
    1 /* 
     1/*
    22Theme Name: BuddyPress Default
    33Theme URI: http://buddypress.org/extend/themes/
  • trunk/bp-themes/bp-sn-parent/404.php

    r1905 r2077  
    22
    33    <div id="content">
    4    
     4
    55        <?php do_action( 'bp_before_404' ) ?>
    6    
     6
    77        <div class="page 404">
    8        
     8
    99            <h2 class="pagetitle"><?php _e( 'Page Not Found', 'buddypress' ) ?></h2>
    1010
    1111            <div id="message" class="info">
    12            
     12
    1313                <p><?php _e( 'The page you were looking for was not found.', 'buddypress' ) ?>
    14        
     14
    1515            </div>
    1616
     
    2020
    2121        <?php do_action( 'bp_after_404' ) ?>
    22    
     22
    2323    </div>
    24    
     24
    2525    <?php get_sidebar() ?>
    2626
  • trunk/bp-themes/bp-sn-parent/activity/just-me.php

    r1905 r2077  
    99
    1010        <?php do_action( 'bp_before_my_activity_content' ) ?>
    11    
     11
    1212        <div class="left-menu">
    1313            <!-- Profile Menu (Avatar, Add Friend, Send Message buttons etc) -->
     
    1616
    1717        <div class="main-column">
    18        
     18
    1919            <?php bp_get_profile_header() ?>
    2020
     
    2727
    2828                <?php if ( bp_has_activities( 'type=personal&per_page=25&max=500' ) ) : ?>
    29                    
     29
    3030                    <div class="pagination">
    31                        
     31
    3232                        <div class="pag-count" id="activity-count">
    3333                            <?php bp_activity_pagination_count() ?>
    3434                        </div>
    35        
     35
    3636                        <div class="pagination-links" id="activity-pag">
    3737                            &nbsp; <?php bp_activity_pagination_links() ?>
    3838                        </div>
    39                        
     39
    4040                    </div>
    41                    
     41
    4242                    <ul id="activity-list" class="item-list activity-list">
    4343                    <?php while ( bp_activities() ) : bp_the_activity(); ?>
     
    4646                                <?php bp_activity_avatar() ?>
    4747                            </div>
    48                            
     48
    4949                            <?php bp_activity_content() ?>
    50                            
     50
    5151                            <?php do_action( 'bp_my_activity_item' ) ?>
    5252                        </li>
    5353                    <?php endwhile; ?>
    5454                    </ul>
    55                    
     55
    5656                    <?php do_action( 'bp_my_activity_content' ) ?>
    5757
     
    6464                <?php endif;?>
    6565            </div>
    66        
     66
    6767        </div>
    6868
  • trunk/bp-themes/bp-sn-parent/activity/my-friends.php

    r1905 r2077  
    99
    1010        <?php do_action( 'bp_before_friends_activity_content' ) ?>
    11    
     11
    1212        <div class="left-menu">
    1313            <!-- Profile Menu (Avatar, Add Friend, Send Message buttons etc) -->
     
    2929
    3030                    <div class="pagination">
    31                        
     31
    3232                        <div class="pag-count" id="activity-count">
    3333                            <?php bp_activity_pagination_count() ?>
    3434                        </div>
    35        
     35
    3636                        <div class="pagination-links" id="activity-pag">
    3737                            &nbsp; <?php bp_activity_pagination_links() ?>
    3838                        </div>
    39                        
     39
    4040                    </div>
    41                    
     41
    4242                    <ul id="activity-list" class="item-list activity-list">
    4343                    <?php while ( bp_activities() ) : bp_the_activity(); ?>
     
    4646                                <?php bp_activity_avatar() ?>
    4747                            </div>
    48                            
     48
    4949                            <?php bp_activity_content() ?>
    5050
     
    5353                    <?php endwhile; ?>
    5454                    </ul>
    55                    
     55
    5656                    <?php do_action( 'bp_friends_activity_content' ) ?>
    5757
     
    6464                <?php endif;?>
    6565            </div>
    66        
     66
    6767        </div>
    6868
  • trunk/bp-themes/bp-sn-parent/archive.php

    r1905 r2077  
    44
    55        <?php do_action( 'bp_before_archive' ) ?>
    6        
     6
    77        <div class="page" id="blog-archives">
    8        
     8
    99            <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2>
    10            
     10
    1111            <?php if ( have_posts() ) : ?>
    1212
     
    1414
    1515                <div class="navigation">
    16                    
     16
    1717                    <div class="alignleft"><?php next_posts_link( __( '&laquo; Previous Entries', 'buddypress' ) ) ?></div>
    1818                    <div class="alignright"><?php previous_posts_link( __( 'Next Entries &raquo;', 'buddypress' ) ) ?></div>
    19                
     19
    2020                </div>
    2121
     
    2323
    2424                    <?php do_action( 'bp_before_blog_post' ) ?>
    25                
     25
    2626                    <div class="post">
    27                        
     27
    2828                        <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    2929                        <small><?php the_time('F j, Y') ?></small>
     
    4242
    4343                <div class="navigation">
    44                    
     44
    4545                    <div class="alignleft"><?php next_posts_link( __( '&laquo; Previous Entries', 'buddypress' ) ) ?></div>
    4646                    <div class="alignright"><?php previous_posts_link( __( 'Next Entries &raquo;', 'buddypress' ) ) ?></div>
    47                
     47
    4848                </div>
    4949
     
    5252                <h2 class="center"><?php _e( 'Not Found', 'buddypress' ) ?></h2>
    5353                <?php locate_template( array( 'searchform.php' ), true ) ?>
    54            
     54
    5555            <?php endif; ?>
    5656
     
    5858
    5959        <?php do_action( 'bp_after_archive' ) ?>
    60        
     60
    6161    </div>
    6262
  • trunk/bp-themes/bp-sn-parent/attachment.php

    r1905 r2077  
    44
    55        <?php do_action( 'bp_before_attachment' ) ?>
    6        
     6
    77        <div class="page" id="attachments-page">
    8        
     8
    99            <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2>
    10        
     10
    1111                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    1212
     
    1515                    <?php $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800)); // This also populates the iconsize for the next line ?>
    1616                    <?php $_post = &get_post($post->ID); $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment'; // This lets us style narrow icons specially ?>
    17                
     17
    1818                    <div class="post" id="post-<?php the_ID(); ?>">
    19                
     19
    2020                        <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> &raquo; <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    21                
     21
    2222                        <div class="entry">
    2323                            <p class="<?php echo $classname; ?>"><?php echo $attachment_link; ?><br /><?php echo basename($post->guid); ?></p>
     
    2727                            <?php wp_link_pages( array( 'before' => __( '<p><strong>Pages:</strong> ', 'buddypress' ), 'after' => '</p>', 'next_or_number' => 'number')); ?>
    2828                        </div>
    29                    
     29
    3030                    </div>
    3131
  • trunk/bp-themes/bp-sn-parent/blogs/create.php

    r1905 r2077  
    88
    99        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    10        
     10
    1111        <h2><?php _e( 'Create a Blog', 'buddypress' ) ?></h2>
    1212
     
    1414
    1515        <?php if ( bp_blog_signup_enabled() ) : ?>
    16        
     16
    1717            <?php bp_show_blog_signup_form() ?>
    18    
     18
    1919        <?php else: ?>
    2020
  • trunk/bp-themes/bp-sn-parent/blogs/my-blogs.php

    r1905 r2077  
    88
    99        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    10        
     10
    1111        <h2><?php bp_word_or_name( __( "My Blogs", 'buddypress' ), __( "%s's Blogs", 'buddypress' ) ) ?></h2>
    1212
     
    1414
    1515        <?php if ( bp_has_blogs() ) : ?>
    16            
     16
    1717            <ul id="blog-list" class="item-list">
    1818                <?php while ( bp_blogs() ) : bp_the_blog(); ?>
    19                    
     19
    2020                    <li>
    2121                        <h4><a href="<?php bp_blog_permalink() ?>"><?php bp_blog_title() ?></a></h4>
     
    2424                        <?php do_action( 'bp_my_blogs_item' ) ?>
    2525                    </li>
    26                    
     26
    2727                <?php endwhile; ?>
    2828            </ul>
    29            
     29
    3030            <?php do_action( 'bp_my_blogs_content' ) ?>
    31            
     31
    3232        <?php else: ?>
    3333
  • trunk/bp-themes/bp-sn-parent/blogs/recent-comments.php

    r1905 r2077  
    88
    99        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    10            
     10
    1111        <h2><?php _e("Recent Comments", "buddypress"); ?></h2>
    1212
     
    1717            <ul id="comment-list" class="item-list">
    1818                <?php while ( bp_comments() ) : bp_the_comment(); ?>
    19                    
     19
    2020                    <li id="comment-<?php bp_comment_id() ?>">
    2121                        <span class="small"><?php printf( __( 'On %1$s %2$s said:', 'buddypress' ), bp_comment_date( __( 'F jS, Y', 'buddypress' ), false ), bp_comment_author( false ) ); ?></span>
     
    2525                        <?php do_action( 'bp_recent_comments_item' ) ?>
    2626                    </li>
    27                    
     27
    2828                <?php endwhile; ?>
    2929            </ul>
    30            
     30
    3131            <?php do_action( 'bp_recent_comments_content' ) ?>
    3232
  • trunk/bp-themes/bp-sn-parent/blogs/recent-posts.php

    r1905 r2077  
    88
    99        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    10        
     10
    1111        <h2><?php _e("Recent Posts", "buddypress"); ?></h2>
    1212
    13         <?php do_action( 'bp_before_recent_posts_content' ) ?>     
     13        <?php do_action( 'bp_before_recent_posts_content' ) ?>
    1414
    1515        <?php if ( bp_has_posts() ) : ?>
    16            
     16
    1717            <?php while ( bp_posts() ) : bp_the_post(); ?>
    18            
     18
    1919                <div class="post" id="post-<?php bp_post_id(); ?>">
    20                    
     20
    2121                    <h2><a href="<?php bp_post_permalink() ?>" rel="bookmark" title="<?php printf ( __( 'Permanent Link to %s', 'buddypress' ), bp_post_title( false ) ); ?>"><?php bp_post_title(); ?></a></h2>
    22                    
     22
    2323                    <p class="date"><?php printf( __( '%1$s <em>in %2$s by %3$s</em>', 'buddypress' ), bp_post_date(__('F jS, Y', 'buddypress'), false ), bp_post_category( ', ', '', null, false ), bp_post_author( false ) ); ?></p>
    2424                    <?php bp_post_content(__('Read the rest of this entry &raquo;')); ?>
    2525                    <p class="postmetadata"><?php bp_post_tags( '<span class="tags">', ', ', '</span>' ); ?>  <span class="comments"><?php bp_post_comments( __('No Comments'), __('1 Comment'), __('% Comments') ); ?></span></p>
    26                    
    27                     <?php do_action( 'bp_recent_posts_item' ) ?>       
     26
     27                    <?php do_action( 'bp_recent_posts_item' ) ?>
    2828
    2929                    <hr />
    30                    
     30
    3131                </div>
    32            
     32
    3333            <?php endwhile; ?>
    3434
    35             <?php do_action( 'bp_recent_posts_content' ) ?>     
    36                
     35            <?php do_action( 'bp_recent_posts_content' ) ?>
     36
    3737        <?php else: ?>
    3838
     
    4343        <?php endif;?>
    4444
    45         <?php do_action( 'bp_after_recent_posts_content' ) ?>       
     45        <?php do_action( 'bp_after_recent_posts_content' ) ?>
    4646
    4747    </div>
  • trunk/bp-themes/bp-sn-parent/comments.php

    r1905 r2077  
    2727
    2828                <?php if ( get_option( 'page_comments' ) ) : ?>
    29            
     29
    3030                    <div class="comment-navigation paged-navigation">
    31                
     31
    3232                        <?php paginate_comments_links(); ?>
    3333
     
    7676
    7777                    <?php do_action( 'bp_before_blog_comment_form' ) ?>
    78            
     78
    7979                    <form action="<?php echo get_option( 'siteurl' ); ?>/wp-comments-post.php" method="post" id="commentform" class="standard-form">
    8080
     
    132132
    133133        <?php endif; ?>
    134    
     134
    135135    </div>
    136    
  • trunk/bp-themes/bp-sn-parent/directories/blogs/blogs-loop.php

    r1905 r2077  
    11<?php if ( bp_has_site_blogs( 'type=active&per_page=10' ) ) : ?>
    2    
     2
    33    <div class="pagination">
    4        
     4
    55        <div class="pag-count" id="blog-dir-count">
    66            <?php bp_site_blogs_pagination_count() ?>
     
    1010            <?php bp_site_blogs_pagination_links() ?>
    1111        </div>
    12        
     12
    1313    </div>
    1414
    15     <?php do_action( 'bp_before_directory_blogs_list' ) ?>     
     15    <?php do_action( 'bp_before_directory_blogs_list' ) ?>
    1616
    1717    <ul id="blogs-list" class="item-list">
     
    3434                    <a href="<?php bp_the_site_blog_link() ?>" class="visit" title="<?php _e( 'Visit Blog', 'buddypress' ) ?>"><?php _e( 'Visit Blog', 'buddypress' ) ?></a>
    3535                </div>
    36                
     36
    3737                <div class="meta">
    3838                    <?php bp_the_site_blog_latest_post() ?>
    3939                </div>
    40                
     40
    4141                <?php do_action( 'bp_directory_blogs_actions' ) ?>
    4242            </div>
     
    4646
    4747    <?php endwhile; ?>
    48     </ul>       
     48    </ul>
    4949
    50     <?php do_action( 'bp_after_directory_blogs_list' ) ?>       
    51            
     50    <?php do_action( 'bp_after_directory_blogs_list' ) ?>
     51
    5252<?php else: ?>
    5353
  • trunk/bp-themes/bp-sn-parent/directories/blogs/index.php

    r1905 r2077  
    11<?php get_header() ?>
    22
    3     <?php do_action( 'bp_before_directory_blogs_content' ) ?>       
     3    <?php do_action( 'bp_before_directory_blogs_content' ) ?>
    44
    55    <div id="content">
    6    
     6
    77        <div class="page" id="blogs-directory-page">
    8    
     8
    99            <form action="<?php echo site_url() . '/' ?>" method="post" id="blogs-directory-form">
    1010                <h3><?php _e( 'Blog Directory', 'buddypress' ) ?></h3>
    11        
     11
    1212                <ul id="letter-list">
    1313                    <li><a href="#a" id="letter-a">A</a></li>
     
    4141                <div id="blogs-directory-listing" class="directory-listing">
    4242                    <h3><?php _e( 'Blog Listing', 'buddypress' ) ?></h3>
    43            
     43
    4444                    <div id="blog-dir-list">
    4545                        <?php locate_template( array( 'directories/blogs/blogs-loop.php' ), true ) ?>
     
    4949
    5050                <?php do_action( 'bp_directory_blogs_content' ) ?>
    51        
     51
    5252                <?php wp_nonce_field( 'directory_blogs', '_wpnonce-blog-filter' ) ?>
    5353
    5454            </form>
    55    
     55
    5656        </div>
    57    
     57
    5858    </div>
    5959
    60     <?php do_action( 'bp_after_directory_blogs_content' ) ?>       
    61     <?php do_action( 'bp_before_directory_blogs_sidebar' ) ?>       
     60    <?php do_action( 'bp_after_directory_blogs_content' ) ?>
     61    <?php do_action( 'bp_before_directory_blogs_sidebar' ) ?>
    6262
    6363    <div id="sidebar" class="directory-sidebar">
    6464
    65         <?php do_action( 'bp_before_directory_blogs_search' ) ?>   
     65        <?php do_action( 'bp_before_directory_blogs_search' ) ?>
    6666
    6767        <div id="blogs-directory-search" class="directory-widget">
    68            
     68
    6969            <h3><?php _e( 'Find Blogs', 'buddypress' ) ?></h3>
    7070
    7171            <?php bp_directory_blogs_search_form() ?>
    7272
    73             <?php do_action( 'bp_directory_blogs_search' ) ?>   
     73            <?php do_action( 'bp_directory_blogs_search' ) ?>
    7474
    7575        </div>
    7676
    77         <?php do_action( 'bp_after_directory_blogs_search' ) ?> 
    78         <?php do_action( 'bp_before_directory_blogs_featured' ) ?> 
     77        <?php do_action( 'bp_after_directory_blogs_search' ) ?>
     78        <?php do_action( 'bp_before_directory_blogs_featured' ) ?>
    7979
    8080        <div id="blogs-directory-featured" class="directory-widget">
    81            
     81
    8282            <h3><?php _e( 'Random Blogs', 'buddypress' ) ?></h3>
    83        
     83
    8484            <?php if ( bp_has_site_blogs( 'type=random&max=3' ) ) : ?>
    8585
     
    9595                                <div class="item-title"><a href="<?php bp_the_site_blog_link() ?>"><?php bp_the_site_blog_name() ?></a></div>
    9696                                <div class="item-meta"><span class="activity"><?php bp_the_site_blog_last_active() ?></span></div>
    97                        
     97
    9898                                <div class="field-data">
    9999                                    <div class="field-name">
     
    102102                                    </div>
    103103                                </div>
    104                        
     104
    105105                                <?php do_action( 'bp_directory_blogs_featured_item' ) ?>
    106106                            </div>
     
    108108
    109109                    <?php endwhile; ?>
    110                 </ul>           
     110                </ul>
    111111
    112                 <?php do_action( 'bp_directory_blogs_featured' ) ?> 
    113        
     112                <?php do_action( 'bp_directory_blogs_featured' ) ?>
     113
    114114            <?php else: ?>
    115115
     
    119119
    120120            <?php endif; ?>
    121    
     121
    122122        </div>
    123123
    124         <?php do_action( 'bp_after_directory_blogs_featured' ) ?>   
     124        <?php do_action( 'bp_after_directory_blogs_featured' ) ?>
    125125
    126126    </div>
    127127
    128     <?php do_action( 'bp_after_directory_blogs_sidebar' ) ?>       
     128    <?php do_action( 'bp_after_directory_blogs_sidebar' ) ?>
    129129
    130130<?php get_footer() ?>
  • trunk/bp-themes/bp-sn-parent/directories/forums/forums-loop.php

    r1924 r2077  
    1 <?php if ( bp_has_forum_topics( 'type=' . bp_get_forum_topic_type() . '&per_page=25&max=250' ) ) : ?>   
    2        
     1<?php if ( bp_has_forum_topics( 'type=' . bp_get_forum_topic_type() . '&per_page=25&max=250' ) ) : ?>
     2
    33    <div class="pagination">
    4    
     4
    55        <div id="post-count" class="pag-count">
    66            <?php bp_forum_pagination_count() ?>
     
    1010            <?php bp_forum_pagination() ?>
    1111        </div>
    12    
     12
    1313    </div>
    1414
    15     <?php do_action( 'bp_before_directory_forums_list' ) ?>     
    16    
     15    <?php do_action( 'bp_before_directory_forums_list' ) ?>
     16
    1717    <table id="global-forum-topic-list">
    18        
     18
    1919        <tr>
    2020            <th id="th-title"><?php _e( 'Topic Title', 'buddypress' ) ?></th>
     
    2424            <th id="th-freshness"><?php _e( 'Freshness', 'buddypress' ) ?></th>
    2525        </tr>
    26        
     26
    2727        <?php while ( bp_forum_topics() ) : bp_the_forum_topic(); ?>
    28            
     28
    2929        <tr class="<?php bp_the_topic_css_class() ?>">
    3030            <td class="td-title">
     
    3636                <a href="<?php bp_the_topic_permalink() ?>">
    3737                    <?php bp_the_topic_last_poster_avatar( 'type=thumb&width=20&height=20' ) ?>
    38                 </a> 
     38                </a>
    3939                <div class="poster-name"><?php bp_the_topic_last_poster_name() ?></div>
    4040            </td>
    4141            <td class="td-group">
    42                 <a href="<?php bp_the_topic_object_permalink() ?>"><?php bp_the_topic_object_avatar( 'type=thumb&width=20&height=20' ) ?></a> 
     42                <a href="<?php bp_the_topic_object_permalink() ?>"><?php bp_the_topic_object_avatar( 'type=thumb&width=20&height=20' ) ?></a>
    4343                <div class="object-name"><a href="<?php bp_the_topic_object_permalink() ?>" title="<?php bp_the_topic_object_name() ?>"><?php bp_the_topic_object_name() ?></a></div>
    4444            </td>
     
    5050            </td>
    5151
    52             <?php do_action( 'bp_directory_forums_extra_cell' ) ?>     
     52            <?php do_action( 'bp_directory_forums_extra_cell' ) ?>
    5353        </tr>
    5454
    55         <?php do_action( 'bp_directory_forums_extra_row' ) ?>       
    56        
     55        <?php do_action( 'bp_directory_forums_extra_row' ) ?>
     56
    5757        <?php endwhile; ?>
    58        
     58
    5959    </table>
    6060
    61     <?php do_action( 'bp_after_directory_forums_list' ) ?>     
    62    
     61    <?php do_action( 'bp_after_directory_forums_list' ) ?>
     62
    6363<?php else: ?>
    6464
  • trunk/bp-themes/bp-sn-parent/directories/forums/index.php

    r2018 r2077  
    11<?php get_header() ?>
    22
    3     <?php do_action( 'bp_before_directory_forums_content' ) ?>     
     3    <?php do_action( 'bp_before_directory_forums_content' ) ?>
    44
    55    <div id="content">
    6    
     6
    77        <div class="page" id="forums-directory-page">
    8    
     8
    99            <form action="<?php echo site_url() . '/' ?>" method="post" id="forums-directory-form">
    1010
     
    1313                    <div id="popular-group-forum-listing">
    1414                        <h3><?php _e( 'Popular Group Forums', 'buddypress' ) ?></h3>
    15    
    16                         <?php do_action( 'bp_before_directory_popular_group_forums' ) ?>       
     15
     16                        <?php do_action( 'bp_before_directory_popular_group_forums' ) ?>
    1717
    1818                        <?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
     
    3333                        <?php endwhile; ?>
    3434
    35                         <?php do_action( 'bp_after_directory_popular_group_forums' ) ?>     
    36    
     35                        <?php do_action( 'bp_after_directory_popular_group_forums' ) ?>
     36
    3737                    </div>
    38                    
     38
    3939                <?php endif; ?>
    4040
    4141                <div id="forums-directory-listing" class="directory-listing">
    4242                    <h3><?php _e( 'Latest Forum Topics', 'buddypress' ) ?></h3>
    43                    
     43
    4444                    <div id="forum-dir-list">
    45                        
     45
    4646                        <?php do_action( 'bp_before_directory_forums_topic_filters' ) ?>
    47                        
     47
    4848                        <div id="global-forum-topic-filters">
    4949                            <ul>
     
    5151                                <li<?php if ( 'popular' == bp_current_action() ) : ?> class="selected"<?php endif; ?> id="forums-popular"><a href="<?php bp_popular_forum_topics_link() ?>" title="<?php _e( 'Most Popular Topics', 'buddypress' ) ?>"><?php _e( 'Most Popular Topics', 'buddypress') ?></a></li>
    5252                                <li<?php if ( 'unreplied' == bp_current_action() ) : ?> class="selected"<?php endif; ?> id="forums-unreplied"><a href="<?php bp_unreplied_forum_topics_link() ?>" title="<?php _e( 'Unreplied Topics', 'buddypress' ) ?>"><?php _e( 'Unreplied Topics', 'buddypress') ?></a></li>
    53        
     53
    5454                                <?php if ( is_user_logged_in() ) : ?>
    5555                                    <li<?php if ( 'personal' == bp_current_action() ) : ?> class="selected"<?php endif; ?> id="forums-personal"><a href="<?php bp_my_forum_topics_link() ?>" title="<?php _e( 'Topics I have started or replied to', 'buddypress' ) ?>"><?php _e( 'My Topics', 'buddypress') ?></a></li>
    5656                                <?php endif; ?>
    57                                
     57
    5858                                <?php if ( 'tag' == bp_current_action() ) : ?>
    5959                                    <li class="selected" id="forums-tag"><a href="<?php bp_newest_forum_topics_link() ?>" title="<?php _e( 'Tag', 'buddypress' ) ?>"><?php printf( __( 'Tagged: %s', 'buddypress' ), bp_get_forums_tag_name() ) ?></a></li>
    6060                                <?php endif; ?>
    61                                
     61
    6262                                <?php if ( isset( $_GET['fs'] ) ) : ?>
    6363                                    <li class="selected" id="forums-search"><a href="<?php bp_newest_forum_topics_link() ?>" title="<?php _e( 'Search', 'buddypress' ) ?>"><?php printf( __( 'Matching: %s', 'buddypress' ), attribute_escape( $_GET['fs'] ) ) ?></a></li>
    6464                                <?php endif; ?>
    65                                
     65
    6666                                <?php do_action( 'bp_directory_forums_topic_filters' ) ?>
    67                             </ul>                               
     67                            </ul>
    6868                        </div>
    69                        
     69
    7070                        <?php do_action( 'bp_after_directory_forums_topic_filters' ) ?>
    7171
     
    7474
    7575                </div>
    76            
     76
    7777                <?php do_action( 'bp_directory_forums_content' ) ?>
    7878
    7979            </form>
    80    
     80
    8181        </div>
    82    
     82
    8383    </div>
    8484
    85     <?php do_action( 'bp_after_directory_forums_content' ) ?>       
    86     <?php do_action( 'bp_before_directory_forums_sidebar' ) ?>     
     85    <?php do_action( 'bp_after_directory_forums_content' ) ?>
     86    <?php do_action( 'bp_before_directory_forums_sidebar' ) ?>
    8787
    8888    <div id="sidebar" class="directory-sidebar">
    8989
    90         <?php do_action( 'bp_before_directory_forums_search' ) ?>   
     90        <?php do_action( 'bp_before_directory_forums_search' ) ?>
    9191
    9292        <div id="forums-directory-search" class="directory-widget">
    93            
     93
    9494            <h3><?php _e( 'Forum Topic Search', 'buddypress' ) ?></h3>
    9595
     
    9797
    9898            <?php do_action( 'bp_directory_forums_search' ) ?>
    99                
     99
    100100        </div>
    101101
    102102        <?php do_action( 'bp_after_directory_forums_search' ) ?>
    103         <?php do_action( 'bp_before_directory_forums_tags' ) ?> 
     103        <?php do_action( 'bp_before_directory_forums_tags' ) ?>
    104104
    105105        <div id="forums-directory-tags" class="directory-widget">
    106            
     106
    107107            <h3><?php _e( 'Forum Topic Tags', 'buddypress' ) ?></h3>
    108108
     
    110110
    111111            <?php do_action( 'bp_directory_forums_search' ) ?>
    112                
     112
    113113        </div>
    114114
    115         <?php do_action( 'bp_after_directory_forums_search' ) ?>   
     115        <?php do_action( 'bp_after_directory_forums_search' ) ?>
    116116
    117117    </div>
    118    
    119     <?php do_action( 'bp_after_directory_forums_sidebar' ) ?> 
     118
     119    <?php do_action( 'bp_after_directory_forums_sidebar' ) ?>
    120120
    121121<?php get_footer() ?>
  • trunk/bp-themes/bp-sn-parent/directories/groups/groups-loop.php

    r1921 r2077  
    11<?php if ( bp_has_site_groups( 'type=active&per_page=10' ) ) : ?>
    2    
     2
    33    <div class="pagination">
    4        
     4
    55        <div class="pag-count" id="group-dir-count">
    66            <?php bp_site_groups_pagination_count() ?>
     
    1010            <?php bp_site_groups_pagination_links() ?>
    1111        </div>
    12    
     12
    1313    </div>
    14    
    15     <?php do_action( 'bp_before_directory_groups_list' ) ?>     
     14
     15    <?php do_action( 'bp_before_directory_groups_list' ) ?>
    1616
    1717    <ul id="groups-list" class="item-list">
     
    3838                    <?php bp_the_site_group_type() ?> / <?php bp_the_site_group_member_count() ?>
    3939                </div>
    40                
     40
    4141                <?php do_action( 'bp_directory_groups_actions' ) ?>
    4242            </div>
     
    4646
    4747    <?php endwhile; ?>
    48     </ul>       
     48    </ul>
    4949
    50     <?php do_action( 'bp_after_directory_groups_list' ) ?>     
    51            
     50    <?php do_action( 'bp_after_directory_groups_list' ) ?>
     51
    5252<?php else: ?>
    5353
  • trunk/bp-themes/bp-sn-parent/directories/groups/index.php

    r1921 r2077  
    11<?php get_header() ?>
    22
    3     <?php do_action( 'bp_before_directory_groups_content' ) ?>     
     3    <?php do_action( 'bp_before_directory_groups_content' ) ?>
    44
    55    <div id="content">
    6    
     6
    77        <div class="page" id="groups-directory-page">
    8    
     8
    99            <form action="<?php echo site_url() . '/' ?>" method="post" id="groups-directory-form">
    1010                <h3><?php _e( 'Groups Directory', 'buddypress' ) ?></h3>
    11        
     11
    1212                <ul id="letter-list">
    1313                    <li><a href="#a" id="letter-a">A</a></li>
     
    4141                <div id="groups-directory-listing" class="directory-listing">
    4242                    <h3><?php _e( 'Groups Listing', 'buddypress' ) ?></h3>
    43            
     43
    4444                    <div id="group-dir-list">
    4545                        <?php locate_template( array( 'directories/groups/groups-loop.php' ), true ) ?>
     
    4747
    4848                </div>
    49            
     49
    5050                <?php do_action( 'bp_directory_groups_content' ) ?>
    5151
     
    5353
    5454            </form>
    55    
     55
    5656        </div>
    57    
     57
    5858    </div>
    5959
    60     <?php do_action( 'bp_after_directory_groups_content' ) ?>       
    61     <?php do_action( 'bp_before_directory_groups_sidebar' ) ?>     
     60    <?php do_action( 'bp_after_directory_groups_content' ) ?>
     61    <?php do_action( 'bp_before_directory_groups_sidebar' ) ?>
    6262
    6363    <div id="sidebar" class="directory-sidebar">
    6464
    65         <?php do_action( 'bp_before_directory_groups_search' ) ?>   
     65        <?php do_action( 'bp_before_directory_groups_search' ) ?>
    6666
    6767        <div id="groups-directory-search" class="directory-widget">
    68            
     68
    6969            <h3><?php _e( 'Find Groups', 'buddypress' ) ?></h3>
    7070
     
    7272
    7373            <?php do_action( 'bp_directory_groups_search' ) ?>
    74                
     74
    7575        </div>
    7676
    77         <?php do_action( 'bp_after_directory_groups_search' ) ?>   
    78         <?php do_action( 'bp_before_directory_groups_featured' ) ?> 
     77        <?php do_action( 'bp_after_directory_groups_search' ) ?>
     78        <?php do_action( 'bp_before_directory_groups_featured' ) ?>
    7979
    8080        <div id="groups-directory-featured" class="directory-widget">
    81            
     81
    8282            <h3><?php _e( 'Random Groups', 'buddypress' ) ?></h3>
    83        
     83
    8484            <?php if ( bp_has_site_groups( 'type=random&max=3' ) ) : ?>
    8585
     
    9393
    9494                            <div class="item">
    95                            
     95
    9696                                <div class="item-title"><a href="<?php bp_the_site_group_link() ?>"><?php bp_the_site_group_name() ?></a></div>
    9797                                <div class="item-meta"><span class="activity"><?php bp_the_site_group_last_active() ?></span></div>
    98                        
     98
    9999                                <div class="field-data">
    100100                                    <div class="field-name">
     
    102102                                        <?php bp_the_site_group_member_count() ?>
    103103                                    </div>
    104                            
     104
    105105                                    <div class="field-name">
    106106                                        <strong><?php _e( 'Description:', 'buddypress' ) ?></strong>
     
    108108                                    </div>
    109109                                </div>
    110                        
     110
    111111                                <?php do_action( 'bp_directory_groups_featured_item' ) ?>
    112                            
     112
    113113                            </div>
    114114
     
    116116
    117117                    <?php endwhile; ?>
    118                 </ul>       
     118                </ul>
    119119
    120                 <?php do_action( 'bp_directory_groups_featured' ) ?>   
    121                
     120                <?php do_action( 'bp_directory_groups_featured' ) ?>
     121
    122122            <?php else: ?>
    123123
     
    127127
    128128            <?php endif; ?>
    129    
     129
    130130        </div>
    131131
    132         <?php do_action( 'bp_after_directory_groups_featured' ) ?> 
     132        <?php do_action( 'bp_after_directory_groups_featured' ) ?>
    133133
    134134    </div>
    135    
    136     <?php do_action( 'bp_after_directory_groups_sidebar' ) ?> 
     135
     136    <?php do_action( 'bp_after_directory_groups_sidebar' ) ?>
    137137
    138138<?php get_footer() ?>
  • trunk/bp-themes/bp-sn-parent/directories/members/index.php

    r1905 r2077  
    11<?php get_header() ?>
    22
    3     <?php do_action( 'bp_before_directory_members_content' ) ?>     
     3    <?php do_action( 'bp_before_directory_members_content' ) ?>
    44
    55    <div id="content">
    6    
     6
    77        <div class="page" id="members-directory-page">
    8    
     8
    99            <form action="<?php echo site_url() . '/' ?>" method="post" id="members-directory-form">
    1010                <h3><?php _e( 'Members Directory', 'buddypress' ) ?></h3>
    11        
     11
    1212                <ul id="letter-list">
    1313                    <li><a href="#a" id="letter-a">A</a></li>
     
    4141                <div id="members-directory-listing" class="directory-widget">
    4242                    <h3><?php _e( 'Member Listing', 'buddypress' ) ?></h3>
    43            
     43
    4444                    <div id="member-dir-list">
    4545                        <?php locate_template( array( 'directories/members/members-loop.php' ), true ) ?>
     
    4949
    5050                <?php do_action( 'bp_directory_members_content' ) ?>
    51                
    52                 <?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ) ?> 
    53                
     51
     52                <?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ) ?>
     53
    5454            </form>
    55    
     55
    5656        </div>
    5757
    5858    </div>
    59    
    60     <?php do_action( 'bp_after_directory_members_content' ) ?>     
    61     <?php do_action( 'bp_before_directory_members_sidebar' ) ?>     
     59
     60    <?php do_action( 'bp_after_directory_members_content' ) ?>
     61    <?php do_action( 'bp_before_directory_members_sidebar' ) ?>
    6262
    6363    <div id="sidebar" class="directory-sidebar">
    64        
     64
    6565        <?php do_action( 'bp_before_directory_members_search' ) ?>
    6666
     
    7373        </div>
    7474
    75         <?php do_action( 'bp_after_directory_members_search' ) ?>   
    76         <?php do_action( 'bp_before_directory_members_featured' ) ?>   
     75        <?php do_action( 'bp_after_directory_members_search' ) ?>
     76        <?php do_action( 'bp_before_directory_members_featured' ) ?>
    7777
    7878        <div id="members-directory-featured" class="directory-widget">
    7979            <h3><?php _e( 'Random Members', 'buddypress' ) ?></h3>
    80        
     80
    8181            <?php if ( bp_has_site_members( 'type=random&max=3' ) ) : ?>
    8282
     
    9292                            <div class="item-title"><a href="<?php bp_the_site_member_link() ?>"><?php bp_the_site_member_name() ?></a></div>
    9393                            <div class="item-meta"><span class="activity"><?php bp_the_site_member_last_active() ?></span></div>
    94                        
     94
    9595                            <div class="field-data">
    9696                                <div class="field-name"><?php bp_the_site_member_total_friend_count() ?></div>
    9797                                <div class="field-name xprofile-data"><?php bp_the_site_member_random_profile_data() ?></div>
    9898                            </div>
    99                        
     99
    100100                            <?php do_action( 'bp_directory_members_featured_item' ) ?>
    101101                        </div>
     
    103103
    104104                <?php endwhile; ?>
    105                 </ul>           
     105                </ul>
    106106
    107                 <?php do_action( 'bp_directory_members_featured' ) ?>   
    108            
     107                <?php do_action( 'bp_directory_members_featured' ) ?>
     108
    109109            <?php else: ?>
    110110
     
    114114
    115115            <?php endif; ?>
    116    
     116
    117117        </div>
    118118
    119         <?php do_action( 'bp_after_directory_members_featured' ) ?> 
     119        <?php do_action( 'bp_after_directory_members_featured' ) ?>
    120120
    121121    </div>
    122122
    123     <?php do_action( 'bp_after_directory_members_sidebar' ) ?>     
     123    <?php do_action( 'bp_after_directory_members_sidebar' ) ?>
    124124
    125125<?php get_footer() ?>
  • trunk/bp-themes/bp-sn-parent/directories/members/members-loop.php

    r1905 r2077  
    11<?php if ( bp_has_site_members( 'type=active&per_page=10' ) ) : ?>
    2    
     2
    33    <div class="pagination">
    4        
     4
    55        <div class="pag-count" id="member-dir-count">
    66            <?php bp_site_members_pagination_count() ?>
     
    1212
    1313    </div>
    14    
    15     <?php do_action( 'bp_before_directory_members_list' ) ?>       
     14
     15    <?php do_action( 'bp_before_directory_members_list' ) ?>
    1616
    1717    <ul id="members-list" class="item-list">
     
    4040
    4141    <?php endwhile; ?>
    42     </ul>       
     42    </ul>
    4343
    44     <?php do_action( 'bp_after_directory_members_list' ) ?>     
    45            
     44    <?php do_action( 'bp_after_directory_members_list' ) ?>
     45
    4646<?php else: ?>
    4747
  • trunk/bp-themes/bp-sn-parent/footer.php

    r1905 r2077  
    11        </div> <!-- #container -->
    2        
     2
    33        <?php do_action( 'bp_after_container' ) ?>
    4    
     4
    55        <div class="clear"></div>
    6    
    7         <?php do_action( 'bp_before_footer' ) ?>       
     6
     7        <?php do_action( 'bp_before_footer' ) ?>
    88
    99        <div id="footer">
    1010            <p><?php printf( __( '%s is proudly powered by <a href="http://mu.wordpress.org">WordPress MU</a> and <a href="http://buddypress.org">BuddyPress</a>', 'buddypress' ), bloginfo('name') ); ?></p>
    11    
     11
    1212            <?php do_action( 'bp_footer' ) ?>
    1313        </div>
     
    1616
    1717        <?php wp_footer(); ?>
    18    
     18
    1919    </body>
    2020
  • trunk/bp-themes/bp-sn-parent/friends/friends-loop.php

    r1905 r2077  
    1 <?php do_action( 'bp_before_my_friends_loop' ) ?>       
     1<?php do_action( 'bp_before_my_friends_loop' ) ?>
    22
    33<div id="friends-loop">
    4    
     4
    55    <?php if ( bp_has_friendships() ) : ?>
    6        
     6
    77        <div class="pagination">
    88
     
    1010                <?php bp_friend_pagination_count() ?>
    1111            </div>
    12            
     12
    1313            <div class="pagination-links" id="pag">
    1414                <?php bp_friend_pagination() ?>
    1515            </div>
    16        
     16
    1717        </div>
    18        
     18
    1919        <?php do_action( 'bp_before_my_friends_list' ) ?>
    20        
     20
    2121        <ul id="friend-list" class="item-list">
    2222            <?php while ( bp_user_friendships() ) : bp_the_friendship(); ?>
    23            
     23
    2424                <li>
    2525                    <?php bp_friend_avatar_thumb() ?>
     
    2727                    <span class="activity"><?php bp_friend_last_active() ?></span>
    2828
    29                     <?php do_action( 'bp_my_friends_list_item' ) ?> 
    30                                
     29                    <?php do_action( 'bp_my_friends_list_item' ) ?>
     30
    3131                    <div class="action">
    3232                        <?php bp_add_friend_button() ?>
    33                        
     33
    3434                        <?php do_action( 'bp_my_friends_list_item_action' ) ?>
    3535                    </div>
    3636                </li>
    37        
     37
    3838            <?php endwhile; ?>
    3939        </ul>
    4040
    4141        <?php do_action( 'bp_after_my_friends_list' ) ?>
    42        
     42
    4343    <?php else: ?>
    4444
    4545        <?php if ( bp_friends_is_filtered() ) : ?>
    46            
     46
    4747            <div id="message" class="info">
    4848                <p><?php _e( "No friends matched your search filter terms", 'buddypress' ) ?></p>
    49             </div>         
    50            
     49            </div>
     50
    5151        <?php else : ?>
    52            
     52
    5353            <div id="message" class="info">
    5454                <p><?php bp_word_or_name( __( "Your friends list is currently empty", 'buddypress' ), __( "%s's friends list is currently empty", 'buddypress' ) ) ?></p>
    5555            </div>
    56            
     56
    5757        <?php endif; ?>
    58        
     58
    5959        <?php if ( bp_is_home() && !bp_friends_is_filtered() ) : ?>
    6060
    6161            <?php do_action( 'bp_before_random_members_list' ) ?>
    62                        
     62
    6363            <h3><?php _e( 'Why not make friends with some of these members?', 'buddypress' ) ?></h3>
    6464            <?php bp_friends_random_members() ?>
    6565
    6666            <?php do_action( 'bp_after_random_members_list' ) ?>
    67        
     67
    6868        <?php endif; ?>
    69        
     69
    7070    <?php endif;?>
    71    
     71
    7272</div>
    7373
    74 <?php do_action( 'bp_after_my_friends_loop' ) ?>   
     74<?php do_action( 'bp_after_my_friends_loop' ) ?>
  • trunk/bp-themes/bp-sn-parent/friends/index.php

    r1905 r2077  
    1010        <h2><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> &raquo; <?php bp_friends_filter_title() ?></h2>
    1111
    12         <?php do_action( 'bp_before_my_friends_content' ) ?>       
    13    
     12        <?php do_action( 'bp_before_my_friends_content' ) ?>
     13
    1414        <div class="left-menu">
    1515            <?php do_action( 'bp_before_my_friends_search' ) ?>
    1616
    1717            <?php bp_friend_search_form() ?>
    18            
     18
    1919            <?php do_action( 'bp_after_my_friends_search' ) ?>
    2020        </div>
     
    2222        <div class="main-column">
    2323            <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    24        
     24
    2525            <?php locate_template( array( 'friends/friends-loop.php' ), true ) ?>
    2626        </div>
    2727
    28         <?php do_action( 'bp_after_my_friends_content' ) ?>     
     28        <?php do_action( 'bp_after_my_friends_content' ) ?>
    2929    </div>
    3030
  • trunk/bp-themes/bp-sn-parent/friends/requests.php

    r1905 r2077  
    55
    66    <div id="content">
    7        
     7
    88        <div class="pagination">
    9        
     9
    1010            <div class="pagination-links" id="pag">
    1111                <?php bp_friend_pagination() ?>
    1212            </div>
    13        
     13
    1414        </div>
    15        
     15
    1616        <h2><?php _e( 'Friendship Requests', 'buddypress' ); ?></h2>
    1717        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    1818
    19         <?php do_action( 'bp_before_friend_requests_content' ) ?>       
    20    
     19        <?php do_action( 'bp_before_friend_requests_content' ) ?>
     20
    2121        <?php if ( bp_has_friendships() ) : ?>
    22            
     22
    2323            <ul id="friend-list" class="item-list">
    2424                <?php while ( bp_user_friendships() ) : bp_the_friendship(); ?>
    25                    
     25
    2626                    <li>
    2727                        <?php bp_friend_avatar_thumb() ?>
    2828                        <h4><?php bp_friend_link() ?></h4>
    2929                        <span class="activity"><?php bp_friend_time_since_requested() ?></span>
    30                        
    31                         <?php do_action( 'bp_friend_requests_item' ) ?> 
    32                        
     30
     31                        <?php do_action( 'bp_friend_requests_item' ) ?>
     32
    3333                        <div class="action">
    3434                            <div class="generic-button accept">
    3535                                <a href="<?php bp_friend_accept_request_link() ?>"><?php _e( 'Accept', 'buddypress' ); ?></a>
    3636                            </div>
    37                    
    38                              &nbsp; 
    39                    
     37
     38                             &nbsp;
     39
    4040                            <div class="generic-button reject">
    4141                                <a href="<?php bp_friend_reject_request_link() ?>"><?php _e( 'Reject', 'buddypress' ); ?></a>
    4242                            </div>
    43                            
    44                             <?php do_action( 'bp_friend_requests_item_action' ) ?> 
     43
     44                            <?php do_action( 'bp_friend_requests_item_action' ) ?>
    4545                        </div>
    4646                    </li>
    47                    
     47
    4848                <?php endwhile; ?>
    4949            </ul>
    50            
    51             <?php do_action( 'bp_friend_requests_content' ) ?>     
    52            
     50
     51            <?php do_action( 'bp_friend_requests_content' ) ?>
     52
    5353        <?php else: ?>
    5454
     
    5959        <?php endif;?>
    6060
    61         <?php do_action( 'bp_after_friend_requests_content' ) ?>       
    62        
     61        <?php do_action( 'bp_after_friend_requests_content' ) ?>
     62
    6363    </div>
    6464
  • trunk/bp-themes/bp-sn-parent/functions.php

    r2013 r2077  
    22
    33/* Register the widget columns */
    4 register_sidebars( 1, 
    5     array( 
     4register_sidebars( 1,
     5    array(
    66        'name' => 'first-section',
    77        'before_widget' => '<div id="%1$s" class="widget %2$s">',
     
    99        'before_title' => '<h2 class="widgettitle">',
    1010        'after_title' => '</h2>'
    11     ) 
     11    )
    1212);
    1313
    1414register_sidebars( 1,
    15     array( 
     15    array(
    1616        'name' => 'second-section',
    1717        'before_widget' => '<div id="%1$s" class="widget %2$s">',
     
    1919        'before_title' => '<h2 class="widgettitle">',
    2020        'after_title' => '</h2>'
    21     ) 
     21    )
    2222);
    2323
    2424register_sidebars( 1,
    25     array( 
     25    array(
    2626        'name' => 'third-section',
    2727        'before_widget' => '<div id="%1$s" class="widget %2$s">',
     
    2929        'before_title' => '<h2 class="widgettitle">',
    3030        'after_title' => '</h2>'
    31     ) 
     31    )
    3232);
    3333
    3434register_sidebars( 1,
    35     array( 
     35    array(
    3636        'name' => 'blog-sidebar',
    3737        'before_widget' => '<div id="%1$s" class="widget %2$s">',
     
    3939        'before_title' => '<h2 class="widgettitle">',
    4040        'after_title' => '</h2>'
    41     ) 
     41    )
    4242);
    4343
     
    5252function bp_dtheme_show_home_blog() {
    5353    global $bp, $query_string, $paged;
    54    
    55     if ( $bp->current_component == BP_HOME_BLOG_SLUG && ( !$bp->current_action || 'page' == $bp->current_action ) ) {               
     54
     55    if ( $bp->current_component == BP_HOME_BLOG_SLUG && ( !$bp->current_action || 'page' == $bp->current_action ) ) {
    5656        unset( $query_string );
    57        
     57
    5858        if ( ( 'page' == $bp->current_action && $bp->action_variables[0] ) && false === strpos( $query_string, 'paged' ) ) {
    5959            $query_string .= '&paged=' . $bp->action_variables[0];
     
    6262
    6363        query_posts($query_string);
    64        
     64
    6565        bp_core_load_template( 'index', true );
    6666    }
  • trunk/bp-themes/bp-sn-parent/groups/group-loop.php

    r1991 r2077  
    22
    33<div id="group-loop">
    4    
     4
    55    <?php if ( bp_has_groups() ) : ?>
    6        
     6
    77        <div class="pagination">
    8            
     8
    99            <div class="pag-count">
    1010                <?php bp_group_pagination_count() ?>
    1111            </div>
    12            
     12
    1313            <div class="pagination-links" id="<?php bp_group_pag_id() ?>">
    1414                <?php bp_group_pagination() ?>
    1515            </div>
    16        
     16
    1717        </div>
    18        
     18
    1919        <?php do_action( 'bp_before_my_groups_list' ) ?>
    2020
    2121        <ul id="group-list" class="item-list">
    2222            <?php while ( bp_groups() ) : bp_the_group(); ?>
    23                
     23
    2424                <li>
    2525                    <?php bp_group_avatar_thumb() ?>
    2626                    <h4><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a><span class="small"> - <?php printf( __( '%s members', 'buddypress' ), bp_group_total_members( false ) ) ?></span></h4>
    27    
     27
    2828                    <?php if ( bp_group_has_requested_membership() ) : ?>
    2929                        <p class="request-pending"><?php _e( 'Membership Pending Approval', 'buddypress' ); ?></p>
    3030                    <?php endif; ?>
    31                    
     31
    3232                    <div class="desc">
    3333                        <?php bp_group_description_excerpt() ?>
    3434                    </div>
    35                
     35
    3636                    <?php do_action( 'bp_before_my_groups_list_item' ) ?>
    3737                </li>
    38                
     38
    3939            <?php endwhile; ?>
    4040        </ul>
    41    
     41
    4242        <?php do_action( 'bp_after_my_groups_list' ) ?>
    43        
     43
    4444    <?php else: ?>
    4545
     
    5151
    5252            <?php if ( bp_is_home() ) : ?>
    53                
     53
    5454                <?php do_action( 'bp_before_random_groups_list' ) ?>
    55                
     55
    5656                <h3><?php _e( 'Why not join a few of these groups?', 'buddypress') ?></h3>
    5757                <?php bp_groups_random_selection() ?>
    58                
     58
    5959                <?php do_action( 'bp_after_random_groups_list' ) ?>
    60                
     60
    6161            <?php endif; ?>
    6262
     
    7070
    7171    <?php endif;?>
    72    
     72
    7373</div>
    7474
  • trunk/bp-themes/bp-sn-parent/groups/index.php

    r1905 r2077  
    88
    99    <div id="content">
    10        
     10
    1111        <h2><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> &raquo; <?php bp_groups_filter_title() ?></h2>
    1212
    1313        <?php do_action( 'bp_before_my_groups_content' ) ?>
    14    
     14
    1515        <div class="left-menu">
    1616            <?php bp_group_search_form() ?>
    1717        </div>
    18    
     18
    1919        <div class="main-column">
    2020            <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    21        
     21
    2222            <?php locate_template( array( 'groups/group-loop.php' ), true ) ?>
    2323        </div>
  • trunk/bp-themes/bp-sn-parent/groups/invites.php

    r1905 r2077  
    1313
    1414        <?php if ( bp_has_groups() ) : ?>
    15            
     15
    1616            <ul id="group-list" class="invites item-list">
    1717
    1818                <?php while ( bp_groups() ) : bp_the_group(); ?>
    19                    
     19
    2020                    <li>
    2121                        <?php bp_group_avatar_thumb() ?>
     
    2424                            <?php bp_group_description_excerpt() ?>
    2525                        </p>
    26                        
     26
    2727                        <?php do_action( 'bp_group_invites_item' ) ?>
    28                        
     28
    2929                        <div class="action">
    30                    
     30
    3131                            <div class="generic-button accept">
    32                                 <a href="<?php bp_group_accept_invite_link() ?>"><?php _e( 'Accept', 'buddypress' ) ?></a> 
     32                                <a href="<?php bp_group_accept_invite_link() ?>"><?php _e( 'Accept', 'buddypress' ) ?></a>
    3333                            </div>
    34                    
    35                              &nbsp; 
     34
     35                             &nbsp;
    3636
    3737                            <div class="generic-button reject">
    38                                 <a href="<?php bp_group_reject_invite_link() ?>"><?php _e( 'Reject', 'buddypress' ) ?></a> 
     38                                <a href="<?php bp_group_reject_invite_link() ?>"><?php _e( 'Reject', 'buddypress' ) ?></a>
    3939                            </div>
    4040
    4141                            <?php do_action( 'bp_group_invites_item_action' ) ?>
    42                    
     42
    4343                        </div>
    4444                        <hr />
     
    4747                <?php endwhile; ?>
    4848            </ul>
    49            
     49
    5050        <?php else: ?>
    5151
  • trunk/bp-themes/bp-sn-parent/groups/single/home.php

    r2014 r2077  
    44
    55    </div>
    6    
     6
    77    <div id="content">
    8        
     8
    99        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    1010
     
    1212
    1313            <?php do_action( 'bp_before_group_content' ) ?>
    14    
     14
    1515            <div class="left-menu">
    1616                <?php locate_template( array( 'groups/single/menu.php' ), true ) ?>
     
    2121
    2222                    <?php do_action( 'bp_before_group_name' ) ?>
    23            
     23
    2424                    <div id="group-name">
    2525                        <h1><a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?>"><?php bp_group_name() ?></a></h1>
    2626                        <p class="status"><?php bp_group_type() ?></p>
    2727                    </div>
    28                    
     28
    2929                    <?php do_action( 'bp_after_group_name' ) ?>
    30                    
     30
    3131                    <?php if ( !bp_group_is_visible() ) : ?>
    32                        
     32
    3333                        <?php do_action( 'bp_before_group_status_message' ) ?>
    34                        
     34
    3535                        <div id="message" class="info">
    3636                            <p><?php bp_group_status_message() ?></p>
    3737                        </div>
    38                        
     38
    3939                        <?php do_action( 'bp_after_group_status_message' ) ?>
    40                        
    41                     <?php endif; ?>
    42        
     40
     41                    <?php endif; ?>
     42
    4343                    <?php do_action( 'bp_before_group_description' ) ?>
    44                
     44
    4545                    <div class="bp-widget">
    4646                        <h4><?php _e( 'Description', 'buddypress' ); ?></h4>
    4747                        <p><?php bp_group_description() ?></p>
    4848                    </div>
    49                    
     49
    5050                    <?php do_action( 'bp_after_group_description' ) ?>
    51        
     51
    5252                    <?php if ( bp_group_is_visible() && bp_group_has_news() ) : ?>
    53                        
     53
    5454                        <?php do_action( 'bp_before_group_news' ) ?>
    55                        
     55
    5656                        <div class="bp-widget">
    5757                            <h4><?php _e( 'News', 'buddypress' ); ?></h4>
    5858                            <p><?php bp_group_news() ?></p>
    5959                        </div>
    60                        
     60
    6161                        <?php do_action( 'bp_after_group_news' ) ?>
    62                        
    63                     <?php endif; ?>
    64                    
     62
     63                    <?php endif; ?>
     64
    6565                    <?php if ( function_exists( 'bp_has_activities' ) && bp_group_is_visible() ) : ?>
    66                                            
     66
    6767                        <?php if ( bp_has_activities( 'object=groups&primary_id=' . bp_get_group_id() . '&max=150&per_page=5' ) ) : ?>
    6868
     
    7171                            <div class="bp-widget">
    7272                                <h4><?php _e( 'Group Activity', 'buddypress' ); ?></h4>
    73                                
     73
    7474                                <div class="pagination">
    7575                                    <div class="pag-count" id="activity-count">
    7676                                        <?php bp_activity_pagination_count() ?>
    7777                                    </div>
    78        
     78
    7979                                    <div class="pagination-links" id="activity-pag">
    8080                                        &nbsp; <?php bp_activity_pagination_links() ?>
     
    8888                                            <?php bp_activity_avatar() ?>
    8989                                        </div>
    90                        
     90
    9191                                        <?php bp_activity_content() ?>
    9292                                    </li>
     
    9595
    9696                            </div>
    97                            
     97
    9898                            <?php do_action( 'bp_after_group_activity' ) ?>
    99                            
    100                         <?php endif; ?> 
    101                        
    102                     <?php endif; ?>
    103            
     99
     100                        <?php endif; ?>
     101
     102                    <?php endif; ?>
     103
    104104                    <?php if ( bp_group_is_visible() && bp_group_is_forum_enabled() && function_exists( 'bp_forums_setup') ) : ?>
    105                        
     105
    106106                        <?php do_action( 'bp_before_group_active_topics' ) ?>
    107                        
     107
    108108                        <div class="bp-widget">
    109109                            <h4><?php _e( 'Recently Active Topics', 'buddypress' ); ?> <span><a href="<?php bp_group_forum_permalink() ?>"><?php _e( 'See All', 'buddypress' ) ?> &rarr;</a></span></h4>
    110                
     110
    111111                            <?php if ( bp_has_topics( 'no_stickies=true&max=5&per_page=5' ) ) : ?>
    112                                                                    
     112
    113113                                <ul id="forum-topic-list" class="item-list">
    114114                                    <?php while ( bp_topics() ) : bp_the_topic(); ?>
    115                                    
     115
    116116                                        <li>
    117117                                            <a class="topic-avatar" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_last_poster_avatar( 'width=30&height=30') ?></a>
    118                                             <a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a> 
     118                                            <a class="topic-title" href="<?php bp_the_topic_permalink() ?>" title="<?php bp_the_topic_title() ?> - <?php _e( 'Permalink', 'buddypress' ) ?>"><?php bp_the_topic_title() ?></a>
    119119                                            <span class="small topic-meta">(<?php bp_the_topic_total_post_count() ?> &rarr; <?php bp_the_topic_time_since_last_post() ?> ago)</span>
    120120                                            <span class="small latest topic-excerpt"><?php bp_the_topic_latest_post_excerpt() ?></span>
    121                                        
     121
    122122                                            <?php do_action( 'bp_group_active_topics_item' ) ?>
    123123                                        </li>
    124                                    
     124
    125125                                    <?php endwhile; ?>
    126126                                </ul>
    127                                
     127
    128128                            <?php else: ?>
    129129
     
    133133
    134134                            <?php endif;?>
    135                    
    136                         </div>
    137                        
     135
     136                        </div>
     137
    138138                        <?php do_action( 'bp_after_group_active_topics' ) ?>
    139                        
    140                     <?php endif; ?>
    141        
     139
     140                    <?php endif; ?>
     141
    142142                    <?php if ( bp_group_is_visible() ) : ?>
    143                        
     143
    144144                        <?php do_action( 'bp_before_group_member_widget' ) ?>
    145                        
     145
    146146                        <div class="bp-widget">
    147147                            <h4><?php printf( __( 'Members (%d)', 'buddypress' ), bp_get_group_total_members() ); ?> <span><a href="<?php bp_group_all_members_permalink() ?>"><?php _e( 'See All', 'buddypress' ) ?> &rarr;</a></span></h4>
    148148
    149149                            <?php if ( bp_group_has_members( 'max=5&exclude_admins_mods=0' ) ) : ?>
    150                        
     150
    151151                                <ul class="horiz-gallery">
    152152                                    <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
    153                                    
     153
    154154                                        <li>
    155155                                            <a href="<?php bp_group_member_url() ?>"><?php bp_group_member_avatar_thumb() ?></a>
     
    158158                                    <?php endwhile; ?>
    159159                                </ul>
    160                                
     160
    161161                            <?php endif; ?>
    162                            
    163                         </div>
    164                        
     162
     163                        </div>
     164
    165165                        <?php do_action( 'bp_after_group_member_widget' ) ?>
    166                        
    167                     <?php endif; ?>
    168            
     166
     167                    <?php endif; ?>
     168
    169169                    <?php do_action( 'groups_custom_group_boxes' ) ?>
    170        
     170
    171171                    <?php if ( bp_group_is_visible() && bp_group_is_wire_enabled() ) : ?>
    172                        
     172
    173173                        <?php if ( function_exists('bp_wire_get_post_list') ) : ?>
    174                            
     174
    175175                            <?php do_action( 'bp_before_group_wire_widget' ) ?>
    176                            
     176
    177177                            <?php bp_wire_get_post_list( bp_get_group_id(), __( 'Group Wire', 'buddypress' ), sprintf( __( 'There are no wire posts for %s', 'buddypress' ), bp_get_group_name() ), bp_group_is_member(), true ) ?>
    178                        
     178
    179179                            <?php do_action( 'bp_after_group_wire_widget' ) ?>
    180                            
     180
    181181                        <?php endif; ?>
    182                    
    183                     <?php endif; ?>
    184        
     182
     183                    <?php endif; ?>
     184
    185185                </div>
    186                
     186
    187187            </div>
    188188
     
    190190
    191191        <?php endwhile; else: ?>
    192            
     192
    193193            <div id="message" class="error">
    194194                <p><?php _e("Sorry, the group does not exist.", "buddypress"); ?></p>
    195195            </div>
    196            
     196
    197197        <?php endif;?>
    198198
  • trunk/bp-themes/bp-sn-parent/groups/single/leave-confirm.php

    r1905 r2077  
    22
    33    <div class="content-header">
    4    
     4
    55    </div>
    66
    7     <div id="content"> 
     7    <div id="content">
    88
    99        <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?>
    10    
     10
    1111            <?php do_action( 'bp_before_group_leave_confirm_content' ) ?>
    12            
     12
    1313            <div class="left-menu">
    1414                <?php locate_template( array( 'groups/single/menu.php' ), true ) ?>
     
    3030                        <h4><?php _e( 'Confirm Leave Group', 'buddypress' ); ?></h4>
    3131                        <h3><?php _e( 'Are you sure you want to leave this group?', 'buddypress' ); ?></h3>
    32    
     32
    3333                        <p>
    34                             <a href="<?php bp_group_leave_confirm_link() ?>"><?php _e( "Yes, I'd like to leave this group.", 'buddypress' ) ?></a> | 
     34                            <a href="<?php bp_group_leave_confirm_link() ?>"><?php _e( "Yes, I'd like to leave this group.", 'buddypress' ) ?></a> |
    3535                            <a href="<?php bp_group_leave_reject_link() ?>"><?php _e( "No, I'll stay!", 'buddypress' ) ?></a>
    3636                        </p>
    37                        
     37
    3838                        <?php do_action( 'bp_group_leave_confirm_content' ) ?>
    3939                    </div>
    40        
     40
    4141                </div>
    4242            </div>
    4343
    4444            <?php do_action( 'bp_after_group_leave_confirm_content' ) ?>
    45    
     45
    4646        <?php endwhile; endif; ?>
    47        
     47
    4848    </div>
    4949
  • trunk/bp-themes/bp-sn-parent/groups/single/members.php

    r1905 r2077  
    22
    33    <div class="content-header">
    4    
     4
    55    </div>
    66
    7     <div id="content"> 
     7    <div id="content">
    88        <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?>
    99
    1010            <?php do_action( 'bp_before_group_members_content' ) ?>
    11    
     11
    1212            <div class="left-menu">
    1313                <?php locate_template( array( 'groups/single/menu.php' ), true ) ?>
     
    1818
    1919                    <?php do_action( 'bp_before_group_name' ) ?>
    20            
     20
    2121                    <div id="group-name">
    2222                        <h1><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a></h1>
     
    2626                    <?php do_action( 'bp_after_group_name' ) ?>
    2727                    <?php do_action( 'bp_before_group_administrators_list' ) ?>
    28        
     28
    2929                    <div class="bp-widget">
    3030                        <h4><?php _e( 'Administrators', 'buddypress' ); ?></h4>
     
    3333
    3434                    <?php do_action( 'bp_after_group_administrators_list' ) ?>
    35        
     35
    3636                    <?php if ( bp_group_has_moderators() ) : ?>
    3737
     
    4949                    <div class="bp-widget">
    5050                        <h4><?php _e( 'Group Members', 'buddypress' ); ?></h4>
    51            
     51
    5252                        <form action="<?php bp_group_form_action('members') ?>" method="post" id="group-members-form">
    5353                            <?php if ( bp_group_has_members() ) : ?>
    54                
     54
    5555                                <?php if ( bp_group_member_needs_pagination() ) : ?>
    56                                    
     56
    5757                                    <div class="pagination">
    5858
     
    6666
    6767                                    </div>
    68                                    
     68
    6969                                <?php endif; ?>
    7070
     
    7373                                <ul id="member-list" class="item-list">
    7474                                    <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
    75                                        
     75
    7676                                        <li>
    7777                                            <?php bp_group_member_avatar_thumb() ?>
    7878                                            <h5><?php bp_group_member_link() ?></h5>
    7979                                            <span class="activity"><?php bp_group_member_joined_since() ?></span>
    80                        
     80
    8181                                            <?php do_action( 'bp_group_members_list_item' ) ?>
    82                                            
     82
    8383                                            <?php if ( function_exists( 'friends_install' ) ) : ?>
    84                                                
     84
    8585                                                <div class="action">
    8686                                                    <?php bp_add_friend_button( bp_get_group_member_id() ) ?>
    87                                                    
     87
    8888                                                    <?php do_action( 'bp_group_members_list_item_action' ) ?>
    8989                                                </div>
    90                                                
     90
    9191                                            <?php endif; ?>
    9292                                        </li>
    93                                        
     93
    9494                                    <?php endwhile; ?>
    95                                    
     95
    9696                                </ul>
    9797
    9898                                <?php do_action( 'bp_after_group_members_list' ) ?>
    99                                
     99
    100100                            <?php else: ?>
    101101
     
    105105
    106106                            <?php endif;?>
    107            
     107
    108108                        <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id() ?>" />
    109109                        </form>
    110110                    </div>
    111        
     111
    112112                </div>
    113113
    114114                <?php do_action( 'bp_after_group_members_content' ) ?>
    115    
     115
    116116            </div>
    117    
     117
    118118        <?php endwhile; endif; ?>
    119119    </div>
  • trunk/bp-themes/bp-sn-parent/groups/single/request-membership.php

    r1905 r2077  
    22
    33    <div class="content-header">
    4    
     4
    55    </div>
    66
    7     <div id="content"> 
     7    <div id="content">
    88        <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?>
    99
     
    2727            <div class="bp-widget">
    2828                <h4><?php _e( 'Request Membership', 'buddypress' ); ?></h4>
    29            
     29
    3030                <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    3131
     
    4040
    4141                        <p><input type="submit" name="group-request-send" id="group-request-send" value="<?php _e( 'Send Request', 'buddypress' ) ?> &raquo;" />
    42                    
     42
    4343                        <?php wp_nonce_field( 'groups_request_membership' ) ?>
    4444                    </form>
    4545                <?php endif; ?>
    46            
     46
    4747            </div>
    48    
     48
    4949        </div>
    5050
    5151        <?php do_action( 'bp_after_group_request_membership_content' ) ?>
    52    
     52
    5353        <?php endwhile; endif; ?>
    5454    </div>
  • trunk/bp-themes/bp-sn-parent/groups/single/send-invite.php

    r1905 r2077  
    22
    33    <div class="content-header">
    4    
     4
    55    </div>
    66
    77    <div id="content">
    8        
     8
    99        <div class="pagination">
    1010
     
    1616
    1717        <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?>
    18        
     18
    1919            <h2><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a> &raquo; <?php _e( 'Send Invites', 'buddypress' ); ?></h2>
    2020
    2121            <?php do_action( 'bp_before_group_send_invites_content' ) ?>
    22    
     22
    2323            <?php if ( bp_has_friends_to_invite() ) : ?>
    24            
     24
    2525                <form action="<?php bp_group_send_invite_form_action() ?>" method="post" id="send-invite-form">
    2626
    2727                    <div class="left-menu">
    28                
     28
    2929                        <h4><?php _e( 'Select Friends', 'buddypress' ) ?> <span class="ajax-loader"></span></h4>
    30                
     30
    3131                        <div id="invite-list">
    3232                            <ul>
    3333                                <?php bp_new_group_invite_friend_list() ?>
    3434                            </ul>
    35                    
     35
    3636                            <?php wp_nonce_field( 'groups_invite_uninvite_user', '_wpnonce_invite_uninvite_user' ) ?>
    3737                        </div>
    38                
     38
    3939                    </div>
    4040
    4141                    <div class="main-column">
    42        
     42
    4343                        <div id="message" class="info">
    4444                            <p><?php _e('Select people to invite from your friends list.', 'buddypress'); ?></p>
    4545                        </div>
    46                        
     46
    4747                        <?php do_action( 'bp_before_group_send_invites_list' ) ?>
    4848
     
    5050                        <ul id="friend-list" class="item-list">
    5151                        <?php if ( bp_group_has_invites() ) : ?>
    52                    
     52
    5353                            <?php while ( bp_group_invites() ) : bp_group_the_invite(); ?>
    5454
    5555                                <li id="<?php bp_group_invite_item_id() ?>">
    5656                                    <?php bp_group_invite_user_avatar() ?>
    57                            
     57
    5858                                    <h4><?php bp_group_invite_user_link() ?></h4>
    5959                                    <span class="activity"><?php bp_group_invite_user_last_active() ?></span>
    60                            
     60
    6161                                    <?php do_action( 'bp_group_send_invites_item' ) ?>
    6262
    6363                                    <div class="action">
    64                                         <a class="remove" href="<?php bp_group_invite_user_remove_invite_url() ?>" id="<?php bp_group_invite_item_id() ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a> 
    65                                        
     64                                        <a class="remove" href="<?php bp_group_invite_user_remove_invite_url() ?>" id="<?php bp_group_invite_item_id() ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
     65
    6666                                        <?php do_action( 'bp_group_send_invites_item_action' ) ?>
    6767                                    </div>
     
    7272                        <?php endif; ?>
    7373                        </ul>
    74                        
     74
    7575                        <?php do_action( 'bp_after_group_send_invites_list' ) ?>
    76                        
     76
    7777                    </div>
    78            
     78
    7979                    <div class="clear"></div>
    8080
    8181                    <p class="clear"><input type="submit" name="submit" id="submit" value="<?php _e( 'Send Invites', 'buddypress' ) ?>" /></p>
    8282                    <?php wp_nonce_field( 'groups_send_invites', '_wpnonce_send_invites') ?>
    83                    
     83
    8484                    <!-- Don't leave out this hidden field -->
    8585                    <input type="hidden" name="group_id" id="group_id" value="<?php bp_group_id() ?>" />
    8686                </form>
    87        
     87
    8888            <?php else : ?>
    89        
     89
    9090                <div id="message" class="info">
    9191                    <p><?php _e( 'You either need to build up your friends list, or your friends have already been invited or are current members.', 'buddypress' ); ?></p>
    9292                </div>
    93        
     93
    9494            <?php endif; ?>
    9595
    9696            <?php do_action( 'bp_before_group_send_invites_content' ) ?>
    97        
     97
    9898        <?php endwhile; endif; ?>
    99    
     99
    100100    </div>
    101101
  • trunk/bp-themes/bp-sn-parent/groups/single/wire.php

    r1905 r2077  
    22
    33    <div class="content-header">
    4    
     4
    55    </div>
    66
    7     <div id="content"> 
     7    <div id="content">
    88        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    9    
     9
    1010        <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?>
    1111
    1212            <?php do_action( 'bp_before_group_wire_content' ) ?>
    13    
     13
    1414            <div class="left-menu">
    1515                <?php locate_template( array( 'groups/single/menu.php' ), true ) ?>
     
    1818            <div class="main-column">
    1919                <div class="inner-tube">
    20            
     20
    2121                    <div id="group-name">
    2222                        <h1><a href="<?php bp_group_permalink() ?>"><?php bp_group_name() ?></a></h1>
     
    2626                    <div class="bp-widget">
    2727                        <?php if ( function_exists('bp_wire_get_post_list') ) : ?>
    28                            
     28
    2929                            <?php bp_wire_get_post_list( bp_group_id( false, false), __( 'Group Wire', 'buddypress' ), sprintf( __( 'There are no wire posts for %s', 'buddypress' ), bp_group_name(false) ), bp_group_is_member(), true ) ?>
    30                        
     30
    3131                        <?php endif; ?>
    3232                    </div>
    33            
     33
    3434                </div>
    3535            </div>
    36    
     36
    3737        <?php endwhile; endif; ?>
    3838
  • trunk/bp-themes/bp-sn-parent/header.php

    r2016 r2077  
    2929
    3030    <body <?php body_class() ?>>
    31        
    32         <?php do_action( 'bp_before_search_login_bar' ) ?> 
    33        
     31
     32        <?php do_action( 'bp_before_search_login_bar' ) ?>
     33
    3434        <div id="search-login-bar">
    35    
     35
    3636            <form action="<?php echo bp_search_form_action() ?>" method="post" id="search-form">
    37                 <input type="text" id="search-terms" name="search-terms" value="" /> 
     37                <input type="text" id="search-terms" name="search-terms" value="" />
    3838                <?php echo bp_search_form_type_select() ?>
    39    
     39
    4040                <input type="submit" name="search-submit" id="search-submit" value="<?php _e( 'Search', 'buddypress' ) ?>" />
    4141                <?php wp_nonce_field( 'bp_search_form' ) ?>
    4242            </form>
    43            
     43
    4444            <?php if ( !is_user_logged_in() ) : ?>
    45        
     45
    4646                <form name="login-form" id="login-form" action="<?php echo site_url( 'wp-login.php' ) ?>" method="post">
    4747                    <input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" />
    4848                    <input type="password" name="pwd" id="user_pass" class="input" value="" />
    49            
     49
    5050                    <input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" />
    51            
    52                     <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>       
    53                    
    54                     <?php if ( 'none' != bp_get_signup_allowed() && 'blog' != bp_get_signup_allowed() ) : ?>       
     51
     52                    <input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>
     53
     54                    <?php if ( 'none' != bp_get_signup_allowed() && 'blog' != bp_get_signup_allowed() ) : ?>
    5555                        <input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" />
    5656                    <?php endif; ?>
    57                    
     57
    5858                    <input type="hidden" name="redirect_to" value="<?php echo bp_root_domain() ?>" />
    5959                    <input type="hidden" name="testcookie" value="1" />
    60                        
     60
    6161                    <?php do_action( 'bp_login_bar_logged_out' ) ?>
    6262                </form>
    63    
     63
    6464            <?php else : ?>
    65        
     65
    6666                <div id="logout-link">
    6767                    <?php bp_loggedin_user_avatar( 'width=20&height=20' ) ?> &nbsp; <?php bp_loggedinuser_link() ?> / <?php bp_log_out_link() ?>
    68                    
     68
    6969                    <?php do_action( 'bp_login_bar_logged_in' ) ?>
    7070                </div>
    71        
     71
    7272            <?php endif; ?>
    73            
     73
    7474            <?php do_action( 'bp_search_login_bar' ) ?>
    7575
    7676        </div>
    7777
    78         <?php do_action( 'bp_after_search_login_bar' ) ?>           
    79         <?php do_action( 'bp_before_header' ) ?>       
     78        <?php do_action( 'bp_after_search_login_bar' ) ?>
     79        <?php do_action( 'bp_before_header' ) ?>
    8080
    81         <div id="header">   
    82        
     81        <div id="header">
     82
    8383            <h1 id="logo"><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php bp_site_name() ?></a></h1>
    84    
     84
    8585            <ul id="nav">
    8686                <li<?php if ( bp_is_page( 'home' ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo get_option('home') ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a></li>
     
    9595                    <li<?php if ( bp_is_page( BP_FORUMS_SLUG ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_FORUMS_SLUG ?>" title="<?php _e( 'Forums', 'buddypress' ) ?>"><?php _e( 'Forums', 'buddypress' ) ?></a></li>
    9696                <?php endif; ?>
    97                
     97
    9898                <?php if ( function_exists( 'bp_blogs_install' ) ) : ?>
    9999                    <li<?php if ( bp_is_page( BP_BLOGS_SLUG ) ) : ?> class="selected"<?php endif; ?>><a href="<?php echo get_option('home') ?>/<?php echo BP_BLOGS_SLUG ?>" title="<?php _e( 'Blogs', 'buddypress' ) ?>"><?php _e( 'Blogs', 'buddypress' ) ?></a></li>
     
    104104
    105105            <?php do_action( 'bp_header' ) ?>
    106    
     106
    107107        </div>
    108108
    109109        <?php do_action( 'bp_after_header' ) ?>
    110110        <?php do_action( 'bp_before_container' ) ?>
    111        
     111
    112112        <div id="container">
    113    
     113
    114114            <?php if ( !bp_is_blog_page() && !bp_is_directory() && !bp_is_register_page() && !bp_is_activation_page() ) : ?>
    115        
     115
    116116                <?php locate_template( array( 'userbar.php' ), true ) /* Load the user navigation */ ?>
    117117                <?php locate_template( array( 'optionsbar.php' ), true ) /* Load the currently displayed object navigation */ ?>
    118        
     118
    119119            <?php endif; ?>
    120            
  • trunk/bp-themes/bp-sn-parent/home.php

    r1932 r2077  
    88            <?php if ( !function_exists('dynamic_sidebar')
    99                    || !dynamic_sidebar('third-section') ) : ?>
    10        
     10
    1111            <div class="widget-error">
    1212                <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&amp;show=&amp;sidebar=first-section"><?php _e( 'Add Widgets', 'buddypress' ) ?></a>
    1313            </div>
    14        
     14
    1515            <?php endif; ?>
    1616        </div>
    17        
     17
    1818        <div id="second-section" class="widget-section">
    1919            <?php if ( !function_exists('dynamic_sidebar')
    2020                    || !dynamic_sidebar('second-section') ) : ?>
    21        
     21
    2222            <div class="widget-error">
    2323                <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&amp;show=&amp;sidebar=second-section"><?php _e( 'Add Widgets', 'buddypress' ) ?></a>
    2424            </div>
    25        
     25
    2626            <?php endif; ?>
    2727        </div>
     
    3333            <div class="widget-error">
    3434                <?php _e( 'Please log in and add widgets to this section.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&amp;show=&amp;sidebar=third-section"><?php _e( 'Add Widgets', 'buddypress' ) ?></a>
    35             </div>     
    36        
     35            </div>
     36
    3737            <?php endif; ?>
    3838        </div>
  • trunk/bp-themes/bp-sn-parent/index.php

    r1905 r2077  
    66
    77        <div class="page" id="blog-latest">
    8        
     8
    99            <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2>
    10        
     10
    1111            <?php if ( have_posts() ) : ?>
    1212
    1313                <?php while (have_posts()) : the_post(); ?>
    14                
     14
    1515                    <?php do_action( 'bp_before_blog_post' ) ?>
    16                
     16
    1717                    <div class="post" id="post-<?php the_ID(); ?>">
    18                    
     18
    1919                        <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    20                    
     20
    2121                        <p class="date"><?php the_time('F j, Y') ?> <em><?php _e( 'in', 'buddypress' ) ?> <?php the_category(', ') ?> <?php printf( __( 'by %s', 'buddypress' ), bp_core_get_userlink($post->post_author) ) ?></em></p>
    2222
     
    3434
    3535                <div class="navigation">
    36                
     36
    3737                    <div class="alignleft"><?php next_posts_link( __( '&laquo; Previous Entries', 'buddypress' ) ) ?></div>
    3838                    <div class="alignright"><?php previous_posts_link( __( 'Next Entries &raquo;', 'buddypress' ) ) ?></div>
    39                
     39
    4040                </div>
    4141
  • trunk/bp-themes/bp-sn-parent/links.php

    r1905 r2077  
    1212
    1313        <div class="page" id="blog-latest">
    14        
     14
    1515            <h2 class="pagetitle"><?php _e( 'Links', 'buddypress' ) ?></h2>
    1616
     
    1818                <?php get_links_list(); ?>
    1919            </ul>
    20        
     20
    2121        </div>
    2222
  • trunk/bp-themes/bp-sn-parent/messages/compose.php

    r1998 r2077  
    77    <div id="content">
    88        <h2><?php _e( 'Compose Message', 'buddypress' ); ?></h2>
    9    
     9
    1010        <?php do_action( 'template_notices' ) ?>
    11        
     11
    1212        <form action="<?php bp_messages_form_action('compose') ?>" method="post" id="send_message_form" class="standard-form">
    1313
    1414            <?php do_action( 'bp_before_messages_compose_content' ) ?>
    15            
     15
    1616            <label for="send-to-input"><?php _e("Send To", 'buddypress') ?> &nbsp; <span class="ajax-loader"></span></label>
    1717            <ul class="first acfb-holder">
     
    2121                </li>
    2222            </ul>
    23        
     23
    2424            <?php if ( is_site_admin() ) : ?>
    2525                <input type="checkbox" id="send-notice" name="send-notice" value="1" /> <?php _e( "This is a notice to all users.", "buddypress" ) ?>
     
    3333
    3434            <input type="hidden" name="send_to_usernames" id="send-to-usernames" value="<?php bp_message_get_recipient_usernames(); ?>" class="<?php bp_message_get_recipient_usernames() ?>" />
    35        
     35
    3636            <?php do_action( 'bp_after_messages_compose_content' ) ?>
    3737
     
    3939                <input type="submit" value="<?php _e("Send", 'buddypress') ?> &raquo;" name="send" id="send" />
    4040            </p>
    41        
     41
    4242            <?php wp_nonce_field( 'messages_send_message' ) ?>
    4343        </form>
    44    
     44
    4545        <script type="text/javascript">
    4646            document.getElementById("send-to-input").focus();
  • trunk/bp-themes/bp-sn-parent/messages/index.php

    r1905 r2077  
    44
    55        <div class="content-header">
    6             <div class="messages-options"> 
     6            <div class="messages-options">
    77                <?php bp_messages_options() ?>
    88            </div>
     
    1111        <div id="content">
    1212            <h2><?php _e( "Inbox", "buddypress" ); ?></h2>
    13            
     13
    1414            <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    1515
    1616            <?php do_action( 'bp_before_messages_inbox_content' ) ?>
    17    
     17
    1818            <?php bp_message_get_notices(); // (admin created site wide notices) ?>
    1919
    2020            <?php if ( bp_has_message_threads() ) : ?>
    21                
     21
    2222                <div class="pagination">
    2323
     
    2727
    2828                </div>
    29                
     29
    3030                <?php do_action( 'bp_before_messages_inbox_list' ) ?>
    31    
     31
    3232                <table id="message-threads">
    3333                    <?php while ( bp_message_threads() ) : bp_message_thread(); ?>
    34                    
     34
    3535                        <tr id="m-<?php bp_message_thread_id() ?>"<?php if ( bp_message_thread_has_unread() ) : ?> class="unread"<?php else: ?> class="read"<?php endif; ?>>
    3636                            <td width="1%">
     
    4646                                <p><?php bp_message_thread_excerpt() ?></p>
    4747                            </td>
    48                            
     48
    4949                            <?php do_action( 'bp_messages_inbox_list_item' ) ?>
    50                            
     50
    5151                            <td width="10%">
    52                                 <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> &nbsp; 
     52                                <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> &nbsp;
    5353                                <input type="checkbox" name="message_ids[]" value="<?php bp_message_thread_id() ?>" />
    5454                            </td>
    5555                        </tr>
    56                    
     56
    5757                    <?php endwhile; ?>
    5858                </table>
    5959
    6060                <?php do_action( 'bp_after_messages_inbox_list' ) ?>
    61        
     61
    6262            <?php else: ?>
    63        
     63
    6464                <div id="message" class="info">
    6565                    <p><?php _e( 'You have no messages in your inbox.', 'buddypress' ); ?></p>
    66                 </div> 
    67        
     66                </div>
     67
    6868            <?php endif;?>
    6969
  • trunk/bp-themes/bp-sn-parent/messages/notices.php

    r1905 r2077  
    66
    77    <div id="content">
    8        
     8
    99        <div class="pagination">
    10        
     10
    1111            <div class="pagination-links">
    1212                <?php bp_messages_pagination() ?>
    1313            </div>
    14        
     14
    1515        </div>
    16    
     16
    1717        <h2><?php _e( 'Sent Notices', 'buddypress' ); ?></h2>
    18    
     18
    1919        <?php do_action( 'template_notices' ) ?>
    2020
     
    2424
    2525            <?php do_action( 'bp_before_messages_notices_list' ) ?>
    26        
     26
    2727            <table id="message-threads" class="notices">
    2828                <?php while ( bp_message_threads() ) : bp_message_thread(); ?>
     
    3939                            <p class="date"><?php _e("Sent:", "buddypress"); ?> <?php bp_message_notice_post_date() ?></p>
    4040                        </td>
    41                            
     41
    4242                        <?php do_action( 'bp_messages_notices_list_item' ) ?>
    4343
    4444                        <td width="4%">
    45                             <a href="<?php bp_message_activate_deactivate_link() ?>" class="confirm"><?php bp_message_activate_deactivate_text() ?></a> 
    46                             <a href="<?php bp_message_notice_delete_link() ?>" class="confirm" title="<?php _e("Delete Message", "buddypress"); ?>"><?php _e("Delete", "buddypress"); ?></a> 
     45                            <a href="<?php bp_message_activate_deactivate_link() ?>" class="confirm"><?php bp_message_activate_deactivate_text() ?></a>
     46                            <a href="<?php bp_message_notice_delete_link() ?>" class="confirm" title="<?php _e("Delete Message", "buddypress"); ?>"><?php _e("Delete", "buddypress"); ?></a>
    4747                        </td>
    4848                    </tr>
    49                    
     49
    5050                <?php endwhile; ?>
    5151            </table>
    5252
    5353            <?php do_action( 'bp_after_messages_notices_list' ) ?>
    54        
     54
    5555        <?php else: ?>
    56        
     56
    5757            <div id="message" class="info">
    5858                <p><?php _e("You have not sent any notices.", "buddypress"); ?></p>
    59             </div> 
     59            </div>
    6060
    6161        <?php endif; ?>
  • trunk/bp-themes/bp-sn-parent/messages/sentbox.php

    r1905 r2077  
    22
    33    <div class="content-header">
    4         <div class="messages-options"> 
     4        <div class="messages-options">
    55            <?php bp_messages_options() ?>
    66        </div>
    77    </div>
    88
    9     <div id="content"> 
     9    <div id="content">
    1010        <h2><?php _e("Sent Messages", "buddypress"); ?></h2>
    11    
     11
    1212        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    1313
     
    1515
    1616        <?php if ( bp_has_message_threads() ) : ?>
    17            
     17
    1818            <div class="pagination">
    1919
     
    2121                    <?php bp_messages_pagination() ?>
    2222                </div>
    23            
     23
    2424            </div>
    2525
    2626            <?php do_action( 'bp_before_messages_sentbox_list' ) ?>
    27                
     27
    2828            <table id="message-threads">
    2929                <?php while ( bp_message_threads() ) : bp_message_thread(); ?>
    30                
     30
    3131                    <tr id="m-<?php bp_message_thread_id() ?>">
    3232                        <td width="1%">
     
    4545
    4646                        <td width="10%">
    47                             <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> &nbsp; 
     47                            <a href="<?php bp_message_thread_delete_link() ?>" title="<?php _e("Delete Message", "buddypress"); ?>" class="delete confirm"><?php _e("Delete", "buddypress"); ?></a> &nbsp;
    4848                            <input type="checkbox" name="message_ids[]" value="<?php bp_message_thread_id() ?>" />
    4949                        </td>
    5050                    </tr>
    51                
     51
    5252                <?php endwhile; ?>
    5353            </table>
    54        
     54
    5555            <?php do_action( 'bp_after_messages_sentbox_list' ) ?>
    56            
     56
    5757        <?php else: ?>
    58        
     58
    5959            <div id="message" class="info">
    6060                <p><?php _e("You have no sent messages.", "buddypress"); ?></p>
    61             </div> 
     61            </div>
    6262
    6363        <?php endif;?>
    6464
    6565        <?php do_action( 'bp_after_messages_sentbox_content' ) ?>
    66        
     66
    6767    </div>
    6868
  • trunk/bp-themes/bp-sn-parent/messages/view.php

    r1905 r2077  
    22
    33    <div class="content-header">
    4    
     4
    55    </div>
    66
    77    <div id="content">
    8    
     8
    99        <?php do_action( 'template_notices' ) ?>
    1010
    1111        <?php do_action( 'bp_before_message_thread_content' ) ?>
    12    
     12
    1313        <?php if ( bp_thread_has_messages() ) : ?>
    14            
     14
    1515            <h2 id="message-subject"><?php bp_the_thread_subject() ?></h2>
    16            
     16
    1717            <p id="message-recipients">
    1818                <?php printf( __('Sent between %s and %s', 'buddypress'), bp_get_the_thread_recipients(), '<a href="' . bp_get_loggedin_user_link() . '" title="' . bp_get_loggedin_user_fullname() . '">' . bp_get_loggedin_user_fullname() . '</a>' ) ?>
    1919            </p>
    20            
     20
    2121            <?php do_action( 'bp_before_message_thread_list' ) ?>
    22            
     22
    2323            <?php while ( bp_thread_messages() ) : bp_thread_the_message(); ?>
    24                
     24
    2525                <div class="message-box<?php bp_the_thread_message_alt_class() ?>">
    26                    
     26
    2727                    <div class="message-metadata">
    28                        
     28
    2929                        <?php do_action( 'bp_before_message_meta' ) ?>
    30                        
     30
    3131                        <?php bp_the_thread_message_sender_avatar( 'type=thumb&width=30&height=30' ) ?>
    3232                        <h3><a href="<?php bp_the_thread_message_sender_link() ?>" title="<?php bp_the_thread_message_sender_name() ?>"><?php bp_the_thread_message_sender_name() ?></a></h3>
    33                        
     33
    3434                        <small>
    3535                            <?php bp_the_thread_message_time_since() ?>
    3636                        </small>
    37                        
     37
    3838                        <?php do_action( 'bp_after_message_meta' ) ?>
    39                    
     39
    4040                    </div>
    41                    
     41
    4242                    <?php do_action( 'bp_before_message_content' ) ?>
    43                    
     43
    4444                    <div class="message-content">
    45                        
     45
    4646                        <?php bp_the_thread_message_content() ?>
    47                    
     47
    4848                    </div>
    49                    
     49
    5050                    <?php do_action( 'bp_after_message_content' ) ?>
    51    
     51
    5252                    <div class="clear"></div>
    53                    
     53
    5454                </div>
    55                
     55
    5656            <?php endwhile; ?>
    57        
     57
    5858            <?php do_action( 'bp_after_message_thread_list' ) ?>
    5959
    6060            <?php do_action( 'bp_before_message_thread_reply' ) ?>
    61        
     61
    6262            <form id="send-reply" action="<?php bp_messages_form_action() ?>" method="post" class="standard-form">
    63        
     63
    6464                <div class="message-box">
    65                    
     65
    6666                    <div class="message-metadata">
    67                        
    68                         <?php do_action( 'bp_before_message_meta' ) ?>                 
    69                        
     67
     68                        <?php do_action( 'bp_before_message_meta' ) ?>
     69
    7070                        <div class="avatar-box">
    7171                            <?php echo bp_core_fetch_avatar( array( 'item_id' => bp_loggedin_user_id(), 'type' => 'thumb', 'width' => 30, 'height' => 30 ) ); ?>
     
    7575
    7676                        <?php do_action( 'bp_after_message_meta' ) ?>
    77                        
     77
    7878                    </div>
    79                
     79
    8080                    <div class="message-content">
    81                
     81
    8282                        <?php do_action( 'bp_before_message_reply_box' ) ?>
    83                    
     83
    8484                        <textarea name="content" id="message_content" rows="15" cols="40"></textarea>
    8585
    8686                        <?php do_action( 'bp_after_message_reply_box' ) ?>
    87                    
     87
    8888                        <p class="submit">
    8989                            <input type="submit" name="send" value="<?php _e( 'Send Reply', 'buddypress' ) ?> &rarr;" id="send_reply_button"/>
     
    9393                        <input type="hidden" name="subject" id="subject" value="<?php _e( 'Re: ', 'buddypress' ); echo str_replace( 'Re: ', '', bp_get_the_thread_subject() ); ?>" />
    9494                        <?php wp_nonce_field( 'messages_send_message', 'send_message_nonce' ) ?>
    95                        
     95
    9696                    </div>
    97                    
     97
    9898                </div>
    99        
     99
    100100            </form>
    101            
     101
    102102            <?php do_action( 'bp_after_message_thread_reply' ) ?>
    103        
     103
    104104        <?php endif; ?>
    105105
  • trunk/bp-themes/bp-sn-parent/optionsbar.php

    r1905 r2077  
    22
    33<div id="optionsbar">
    4    
     4
    55    <h3><?php bp_get_options_title() ?></h3>
    66
    77    <?php do_action( 'bp_inside_before_options_bar' ) ?>
    8    
     8
    99    <?php if ( bp_has_options_avatar() ) : ?>
    1010
     
    1414
    1515    <?php endif; ?>
    16        
     16
    1717        <ul id="options-nav">
    1818            <?php bp_get_options_nav() ?>
    1919        </ul>
    20    
     20
    2121    <?php do_action( 'bp_inside_after_options_bar' ) ?>
    2222
  • trunk/bp-themes/bp-sn-parent/page.php

    r1905 r2077  
    44
    55        <?php do_action( 'bp_before_blog_page' ) ?>
    6    
     6
    77        <div class="page" id="blog-page">
    8            
     8
    99            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    10            
     10
    1111                <h2 class="pagetitle"><?php the_title(); ?></h2>
    1212
    1313                <div class="post" id="post-<?php the_ID(); ?>">
    14                    
     14
    1515                    <div class="entry">
    16                        
     16
    1717                        <?php the_content( __( '<p class="serif">Read the rest of this page &raquo;</p>', 'buddypress' ) ); ?>
    1818
    1919                        <?php wp_link_pages( array( 'before' => __( '<p><strong>Pages:</strong> ', 'buddypress' ), 'after' => '</p>', 'next_or_number' => 'number')); ?>
    2020                        <?php edit_post_link( __( 'Edit this entry.', 'buddypress' ), '<p>', '</p>'); ?>
    21                        
     21
    2222                    </div>
    23                    
     23
    2424                </div>
    25                
     25
    2626            <?php endwhile; endif; ?>
    27            
     27
    2828        </div>
    2929
    3030        <?php do_action( 'bp_after_blog_page' ) ?>
    31    
     31
    3232    </div>
    3333
  • trunk/bp-themes/bp-sn-parent/plugin-template.php

    r1905 r2077  
    77    <div id="content">
    88        <h2><?php do_action('bp_template_title') ?></h2>
    9    
     9
    1010        <?php do_action('bp_template_content') ?>
    1111    </div>
  • trunk/bp-themes/bp-sn-parent/profile/change-avatar.php

    r1905 r2077  
    66
    77    <div id="content">
    8    
     8
    99        <h2><?php _e( 'Change Avatar', 'buddypress' ) ?></h2>
    10        
     10
    1111        <?php do_action( 'template_notices' ) ?>
    12    
     12
    1313        <?php do_action( 'bp_before_profile_avatar_upload_content' ) ?>
    1414
    1515        <p><?php _e( 'Your avatar will be used on your profile and throughout the site. If there is a <a href="http://gravatar.com">Gravatar</a> associated with your account email we will use that, or you can upload an image from your computer.', 'buddypress') ?></p>
    16        
    17         <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">   
    18            
     16
     17        <form action="" method="post" id="avatar-upload-form" enctype="multipart/form-data">
     18
    1919            <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?>
    20            
     20
    2121                <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3>
    22        
     22
    2323                <p id="current-avatar">
    2424                    <?php bp_displayed_user_avatar( 'type=full') ?>
    2525                    <?php bp_displayed_user_avatar( 'type=thumb' ) ?>
    2626                </p>
    27                
     27
    2828                <?php if ( bp_get_user_has_avatar() ) : ?>
    2929                    <div class="generic-button" id="delete-avatar-button">
     
    3131                    </div>
    3232                <?php endif; ?>
    33                
     33
    3434                <h3><?php _e( 'Upload a New Avatar', 'buddypress' ) ?></h3>
    3535
    3636                <p><?php _e( 'Click below to select a JPG, GIF or PNG format photo from your computer and then click \'Upload Image\' to proceed.', 'buddypress' ) ?></p>
    37                
     37
    3838                <p id="avatar-upload">
    39                     <input type="file" name="file" id="file" /> 
     39                    <input type="file" name="file" id="file" />
    4040                    <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
    4141                    <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
     
    4343
    4444                <?php wp_nonce_field( 'bp_avatar_upload' ) ?>
    45                
     45
    4646            <?php endif; ?>
    47            
     47
    4848            <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
    49            
     49
    5050                <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3>
    51                
     51
    5252                <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
    53                
     53
    5454                <div id="avatar-crop-pane">
    5555                    <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" />
     
    5757
    5858                <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
    59                
     59
    6060                <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
    6161                <input type="hidden" id="x" name="x" />
     
    6565
    6666                <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?>
    67                
     67
    6868            <?php endif; ?>
    69            
     69
    7070        </form>
    71        
     71
    7272        <?php do_action( 'bp_after_profile_avatar_upload_content' ) ?>
    73        
     73
    7474    </div>
    7575
  • trunk/bp-themes/bp-sn-parent/profile/edit.php

    r1920 r2077  
    22
    33    <div class="content-header">
    4    
     4
    55        <ul class="content-header-nav">
    66            <?php bp_profile_group_tabs(); ?>
    77        </ul>
    8    
     8
    99    </div>
    1010
     
    1212
    1313        <?php do_action( 'template_notices' ) // (error/success feedback) ?>
    14    
     14
    1515        <?php do_action( 'bp_before_profile_edit_content' ) ?>
    16        
     16
    1717        <?php if ( bp_has_profile( 'profile_group_id=' . bp_get_current_profile_group_id() ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    1818
     
    2020
    2121            <?php do_action( 'bp_before_profile_field_content' ) ?>
    22        
     22
    2323                <h2><?php printf( __( "Editing '%s'", "buddypress" ), bp_get_the_profile_group_name() ); ?></h2>
    24            
     24
    2525                <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
    26                
     26
    2727                    <div<?php bp_field_css_class( 'editfield' ) ?>>
    28                    
     28
    2929                        <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>
    30                    
     30
    3131                            <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    3232                            <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="<?php bp_the_profile_field_edit_value() ?>" />
    33                        
     33
    3434                        <?php endif; ?>
    35                
     35
    3636                        <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?>
    37                        
     37
    3838                            <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    3939                            <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_edit_value() ?></textarea>
    40                        
     40
    4141                        <?php endif; ?>
    4242
    4343                        <?php if ( 'selectbox' == bp_get_the_profile_field_type() ) : ?>
    44                    
     44
    4545                            <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    4646                            <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>">
    4747                                <?php bp_the_profile_field_options() ?>
    4848                            </select>
    49                        
     49
    5050                        <?php endif; ?>
    5151
    5252                        <?php if ( 'multiselectbox' == bp_get_the_profile_field_type() ) : ?>
    53                    
     53
    5454                            <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    5555                            <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple">
    5656                                <?php bp_the_profile_field_options() ?>
    5757                            </select>
    58                    
     58
    5959                        <?php endif; ?>
    6060
    6161                        <?php if ( 'radio' == bp_get_the_profile_field_type() ) : ?>
    62                    
     62
    6363                            <div class="radio">
    6464                                <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
    65                            
     65
    6666                                <?php bp_the_profile_field_options() ?>
    67                            
     67
    6868                                <?php if ( !bp_get_the_profile_field_is_required() ) : ?>
    6969                                    <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a>
    7070                                <?php endif; ?>
    7171                            </div>
    72                    
    73                         <?php endif; ?> 
    74                
     72
     73                        <?php endif; ?>
     74
    7575                        <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?>
    76                    
     76
    7777                            <div class="checkbox">
    7878                                <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
    79                            
     79
    8080                                <?php bp_the_profile_field_options() ?>
    81                             </div> 
    82                    
    83                         <?php endif; ?>                 
     81                            </div>
     82
     83                        <?php endif; ?>
    8484
    8585                        <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?>
    86                    
     86
    8787                            <div class="datebox">
    8888                                <label for="<?php bp_the_profile_field_input_name() ?>_day"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    89                            
     89
    9090                                <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day">
    9191                                    <?php bp_the_profile_field_options( 'type=day' ) ?>
    9292                                </select>
    93                            
     93
    9494                                <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month">
    9595                                    <?php bp_the_profile_field_options( 'type=month' ) ?>
    9696                                </select>
    97                            
     97
    9898                                <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year">
    9999                                    <?php bp_the_profile_field_options( 'type=year' ) ?>
    100                                 </select>                               
     100                                </select>
    101101                            </div>
    102                    
    103                         <?php endif; ?> 
    104                    
     102
     103                        <?php endif; ?>
     104
    105105                        <?php do_action( 'bp_custom_profile_edit_fields' ) ?>
    106                
     106
    107107                        <p class="description"><?php bp_the_profile_field_description() ?></p>
    108108                    </div>
     
    111111
    112112            <?php do_action( 'bp_after_profile_field_content' ) ?>
    113            
     113
    114114            <input type="submit" name="profile-group-edit-submit" id="profile-group-edit-submit" value="<?php _e( 'Save Changes', 'buddypress' ) ?> " />
    115            
     115
    116116            <input type="hidden" name="field_ids" id="field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />
    117117            <?php wp_nonce_field( 'bp_xprofile_edit' ) ?>
    118            
     118
    119119        </form>
    120        
     120
    121121        <?php endwhile; endif; ?>
    122        
     122
    123123        <?php do_action( 'bp_after_profile_edit_content' ) ?>
    124124
  • trunk/bp-themes/bp-sn-parent/profile/index.php

    r1905 r2077  
    1010
    1111    <?php do_action( 'bp_before_profile_content' ) ?>
    12    
     12
    1313    <div class="left-menu">
    1414        <!-- Profile Menu (Avatar, Add Friend, Send Message buttons etc) -->
     
    1818    <div class="main-column">
    1919        <div class="inner-tube">
    20                        
     20
    2121            <?php /* Profile Header (Name & Status) */ ?>
    2222            <?php locate_template( array( 'profile/profile-header.php' ), true ) ?>
    23        
     23
    2424            <?php /* Profile Data Loop */ ?>
    2525            <?php locate_template( array( 'profile/profile-loop.php' ), true ) ?>
    2626
    2727            <?php do_action( 'bp_before_profile_activity_loop' ) ?>
    28            
     28
    2929            <?php /* Latest Activity Loop */ ?>
    3030            <?php if ( function_exists( 'bp_activity_install')) : ?>
    31                
     31
    3232                <?php do_action( 'bp_before_profile_activity_widget' ) ?>
    3333
     
    4747                                    <?php bp_activity_avatar() ?>
    4848                                </div>
    49                            
     49
    5050                                <?php bp_activity_content() ?>
    5151                            </li>
     
    6161                    <?php endif;?>
    6262                </div>
    63    
     63
    6464                <?php do_action( 'bp_after_profile_activity_widget' ) ?>
    65            
     65
    6666            <?php endif; ?>
    6767
    6868            <?php do_action( 'bp_after_profile_activity_loop' ) ?>
    6969            <?php do_action( 'bp_before_profile_random_groups_loop' ) ?>
    70        
     70
    7171            <?php /* Random Groups Loop */ ?>
    7272            <?php if ( function_exists( 'bp_has_groups' ) ) : ?>
     
    7575
    7676                <?php if ( bp_has_groups( 'type=random&max=5' ) ) : ?>
    77                    
     77
    7878                    <div class="bp-widget">
    7979                        <h4><?php bp_word_or_name( __( "My Groups", 'buddypress' ), __( "%s's Groups", 'buddypress' ) ) ?> (<?php bp_group_total_for_member() ?>) <span><a href="<?php echo bp_displayed_user_domain() . BP_GROUPS_SLUG ?>"><?php _e( 'See All', 'buddypress' ) ?> &rarr;</a></span></h4>
    80                        
     80
    8181                        <ul class="horiz-gallery">
    8282                        <?php while ( bp_groups() ) : bp_the_group(); ?>
     
    9090
    9191                    <?php do_action( 'bp_after_profile_groups_widget' ) ?>
    92                    
     92
    9393                <?php endif; ?>
    94                    
     94
    9595            <?php endif; ?>
    96    
     96
    9797            <?php do_action( 'bp_after_profile_random_groups_loop' ) ?>
    9898            <?php do_action( 'bp_before_profile_random_friends_loop' ) ?>
    99        
     99
    100100            <?php /* Random Friends Loop */ ?>
    101101            <?php if ( function_exists( 'bp_has_friendships' ) ) : ?>
     
    104104
    105105                <?php if ( bp_has_friendships( 'type=random&max=5' ) ) : ?>
    106                    
     106
    107107                    <div class="bp-widget">
    108108                        <h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?> (<?php bp_friend_total_for_member() ?>) <span><a href="<?php echo bp_displayed_user_domain() . BP_FRIENDS_SLUG ?>"><?php _e( 'See All', 'buddypress' ) ?> &rarr;</a></span></h4>
    109                        
     109
    110110                        <ul class="horiz-gallery">
    111111                        <?php while ( bp_user_friendships() ) : bp_the_friendship(); ?>
     
    115115                            </li>
    116116                        <?php endwhile; ?>
    117                         </ul>   
     117                        </ul>
    118118                    </div>
    119                    
     119
    120120                <?php endif; ?>
    121        
     121
    122122                <?php do_action( 'bp_after_profile_friends_widget' ) ?>
    123            
     123
    124124            <?php endif; ?>
    125    
     125
    126126            <?php do_action( 'bp_after_profile_random_friends_loop' ) ?>
    127127            <?php do_action( 'bp_before_profile_wire_loop' ); /* Deprecated -> */ do_action( 'bp_custom_profile_boxes' ) ?>
     
    139139
    140140            <?php do_action( 'bp_after_profile_wire_loop' ) ?>
    141            
     141
    142142        </div>
    143143
  • trunk/bp-themes/bp-sn-parent/profile/profile-header.php

    r1905 r2077  
    33<div id="profile-name">
    44    <h1 class="fn"><a href="<?php bp_user_link() ?>"><?php bp_user_fullname() ?></a></h1>
    5    
     5
    66    <?php if ( function_exists( 'bp_the_status' ) ) : ?>
    77
     
    1111
    1212    <?php endif; ?>
    13    
     13
    1414    <?php do_action( 'bp_profile_header_content' ) ?>
    1515</div>
  • trunk/bp-themes/bp-sn-parent/profile/profile-loop.php

    r1905 r2077  
    11<?php if ( function_exists('xprofile_get_profile') ) : ?>
    2    
    3     <?php if ( bp_has_profile() ) : ?> 
    4        
     2
     3    <?php if ( bp_has_profile() ) : ?>
     4
    55        <?php while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
    66
    77            <?php if ( bp_profile_group_has_fields() ) : ?>
    8                
     8
    99                <?php do_action( 'bp_before_profile_field_content' ) ?>
    10                
     10
    1111                <div class="bp-widget <?php bp_the_profile_group_slug() ?>">
    1212                    <h4><?php bp_the_profile_group_name() ?></h4>
    13                
     13
    1414                    <table class="profile-fields">
    1515                        <?php while ( bp_profile_fields() ) : bp_the_profile_field(); ?>
     
    1717                            <?php if ( bp_field_has_data() ) : ?>
    1818                                <tr<?php bp_field_css_class() ?>>
    19                                
     19
    2020                                    <td class="label">
    2121                                        <?php bp_the_profile_field_name() ?>
     
    2424                                        <?php bp_the_profile_field_value() ?>
    2525                                    </td>
    26                                    
     26
    2727                                </tr>
    2828                            <?php endif; ?>
    29                            
     29
    3030                            <?php do_action( 'bp_profile_field_item' ) ?>
    3131
     
    3535
    3636                <?php do_action( 'bp_after_profile_field_content' ) ?>
    37                
    38             <?php endif; ?> 
    39        
     37
     38            <?php endif; ?>
     39
    4040        <?php endwhile; ?>
    41    
     41
    4242        <div class="button-block">
    4343            <?php if ( bp_is_home() || is_site_admin() ) : ?>
    44                
     44
    4545                <?php bp_edit_profile_button() ?>
    46                
     46
    4747            <?php endif; ?>
    48            
     48
    4949            <?php do_action( 'bp_profile_field_buttons' ) ?>
    5050        </div>
    51    
     51
    5252    <?php else: ?>
    53    
     53
    5454        <div id="message" class="info">
    5555            <p><?php _e( 'Sorry, this person does not have a public profile.', 'buddypress' ) ?></p>
    5656        </div>
    57    
     57
    5858    <?php endif;?>
    5959
    6060<?php else : ?>
    61    
     61
    6262    <?php bp_core_get_wp_profile() ?>
    6363
  • trunk/bp-themes/bp-sn-parent/profile/profile-menu.php

    r1982 r2077  
    44
    55<div class="button-block">
    6    
     6
    77    <?php if ( function_exists('bp_add_friend_button') ) : ?>
    8        
     8
    99        <?php bp_add_friend_button() ?>
    10        
     10
    1111    <?php endif; ?>
    12    
     12
    1313    <?php if ( function_exists('bp_send_message_button') ) : ?>
    14        
     14
    1515        <?php bp_send_message_button() ?>
    16        
     16
    1717    <?php endif; ?>
    18    
     18
    1919    <?php do_action( 'bp_before_profile_menu_buttons' ) ?>
    2020
  • trunk/bp-themes/bp-sn-parent/registration/activate.php

    r1905 r2077  
    66
    77        <div class="page" id="activate-page">
    8        
     8
    99            <div class="register bp_core_widget_welcome">
    10            
     10
    1111                <?php do_action( 'template_notices' ) ?>
    1212
    1313                <?php if ( bp_account_was_activated() ) : ?>
    14        
     14
    1515                    <h2 class="widgettitle"><?php _e( 'Account Activated', 'buddypress' ) ?></h2>
    16                    
     16
    1717                    <?php do_action( 'bp_before_activate_content' ) ?>
    18    
     18
    1919                    <p><?php _e( 'Your account was activated successfully! You can now log in with the username and password you provided when you signed up.', 'buddypress' ) ?></p>
    20            
    21                
     20
     21
    2222                <?php else : ?>
    23                
     23
    2424                    <h2 class="widgettitle"><?php _e( 'Activate your Account', 'buddypress' ) ?></h2>
    25                    
     25
    2626                    <?php do_action( 'bp_before_activate_content' ) ?>
    27    
     27
    2828                    <p><?php _e( 'Please provide a valid activation key.', 'buddypress' ) ?></p>
    29                    
     29
    3030                    <form action="" method="get" class="standard-form" id="activation-form">
    31                        
     31
    3232                        <label for="key"><?php _e( 'Activation Key:', 'buddypress' ) ?></label>
    3333                        <input type="text" name="key" id="key" value="" />
    34                        
     34
    3535                        <p class="submit">
    3636                            <input type="submit" name="submit" value="<?php _e( 'Activate', 'buddypress' ) ?> &rarr;" />
    3737                        </p>
    38                        
     38
    3939                    </form>
    40                    
     40
    4141                <?php endif; ?>
    4242
    4343                <?php do_action( 'bp_after_activate_content' ) ?>
    44            
     44
    4545            </div>
    46        
     46
    4747        </div>
    4848
     
    5050
    5151    </div>
    52    
     52
    5353    <?php get_sidebar() ?>
    5454
  • trunk/bp-themes/bp-sn-parent/registration/register.php

    r1983 r2077  
    44
    55        <?php do_action( 'bp_before_register_page' ) ?>
    6    
     6
    77        <div class="page" id="register-page">
    8        
     8
    99            <form action="" name="signup_form" id="signup_form" class="standard-form" method="post" enctype="multipart/form-data">
    10            
     10
    1111            <?php if ( 'request-details' == bp_get_current_signup_step() ) : ?>
    12        
     12
    1313                <h2 class="pagetitle"><?php _e( 'Sign Up', 'buddypress' ) ?></h2>
    14    
     14
    1515                <?php do_action( 'template_notices' ) ?>
    16    
     16
    1717                <p><?php _e( 'Registering for this site is easy, just fill in the fields below and we\'ll get a new account set up for you in no time.', 'buddypress' ) ?></p>
    1818
    1919                <?php do_action( 'bp_before_account_details_fields' ) ?>
    20            
     20
    2121                <div class="register-section" id="basic-details-section">
    22            
     22
    2323                    <?php /***** Basic Account Details ******/ ?>
    24        
     24
    2525                    <h3><?php _e( 'Account Details', 'buddypress' ) ?></h3>
    26    
     26
    2727                    <label for="signup_username"><?php _e( 'Username', 'buddypress' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label>
    2828                    <?php do_action( 'bp_signup_username_errors' ) ?>
     
    4040                    <?php do_action( 'bp_signup_password_confirm_errors' ) ?>
    4141                    <input type="password" name="signup_password_confirm" id="signup_password_confirm" value="" />
    42            
     42
    4343                </div>
    44            
     44
    4545                <?php do_action( 'bp_after_account_details_fields' ) ?>
    4646
     
    5151
    5252                <div class="register-section" id="profile-details-section">
    53        
     53
    5454                    <h3><?php _e( 'Profile Details', 'buddypress' ) ?></h3>
    55        
     55
    5656                    <?php /* Use the profile field loop to render input fields for the 'base' profile field group */ ?>
    5757                    <?php if ( function_exists( 'bp_has_profile' ) ) : if ( bp_has_profile( 'profile_group_id=1' ) ) : while ( bp_profile_groups() ) : bp_the_profile_group(); ?>
     
    6262
    6363                            <?php if ( 'textbox' == bp_get_the_profile_field_type() ) : ?>
    64                        
     64
    6565                                <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    6666                                <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    6767                                <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="<?php bp_the_profile_field_edit_value() ?>" />
    68    
     68
    6969                            <?php endif; ?>
    7070
    7171                            <?php if ( 'textarea' == bp_get_the_profile_field_type() ) : ?>
    72    
     72
    7373                                <label for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    7474                                <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    7575                                <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_edit_value() ?></textarea>
    76    
     76
    7777                            <?php endif; ?>
    7878
     
    8484                                    <?php bp_the_profile_field_options() ?>
    8585                                </select>
    86    
     86
    8787                            <?php endif; ?>
    8888
     
    101101                                <div class="radio">
    102102                                    <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
    103        
     103
    104104                                    <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    105105                                    <?php bp_the_profile_field_options() ?>
    106        
     106
    107107                                    <?php if ( !bp_get_the_profile_field_is_required() ) : ?>
    108108                                        <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a>
     
    110110                                </div>
    111111
    112                             <?php endif; ?> 
     112                            <?php endif; ?>
    113113
    114114                            <?php if ( 'checkbox' == bp_get_the_profile_field_type() ) : ?>
     
    116116                                <div class="checkbox">
    117117                                    <span class="label"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></span>
    118                        
     118
    119119                                    <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    120120                                    <?php bp_the_profile_field_options() ?>
    121                                 </div> 
    122 
    123                             <?php endif; ?>                 
     121                                </div>
     122
     123                            <?php endif; ?>
    124124
    125125                            <?php if ( 'datebox' == bp_get_the_profile_field_type() ) : ?>
     
    128128                                    <label for="<?php bp_the_profile_field_input_name() ?>_day"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></label>
    129129                                    <?php do_action( 'bp_' . bp_get_the_profile_field_input_name() . '_errors' ) ?>
    130                        
     130
    131131                                    <select name="<?php bp_the_profile_field_input_name() ?>_day" id="<?php bp_the_profile_field_input_name() ?>_day">
    132132                                        <?php bp_the_profile_field_options( 'type=day' ) ?>
    133133                                    </select>
    134        
     134
    135135                                    <select name="<?php bp_the_profile_field_input_name() ?>_month" id="<?php bp_the_profile_field_input_name() ?>_month">
    136136                                        <?php bp_the_profile_field_options( 'type=month' ) ?>
    137137                                    </select>
    138        
     138
    139139                                    <select name="<?php bp_the_profile_field_input_name() ?>_year" id="<?php bp_the_profile_field_input_name() ?>_year">
    140140                                        <?php bp_the_profile_field_options( 'type=year' ) ?>
    141                                     </select>                               
     141                                    </select>
    142142                                </div>
    143143
    144                             <?php endif; ?> 
     144                            <?php endif; ?>
    145145
    146146                            <?php do_action( 'bp_custom_profile_edit_fields' ) ?>
    147147
    148148                            <p class="description"><?php bp_the_profile_field_description() ?></p>
    149        
     149
    150150                        </div>
    151151
     
    153153
    154154                    <input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="<?php bp_the_profile_group_field_ids() ?>" />
    155        
     155
    156156                </div>
    157            
     157
    158158                <?php endwhile; endif; endif; ?>
    159    
     159
    160160                <?php do_action( 'bp_after_signup_profile_fields' ) ?>
    161            
     161
    162162                <?php if ( 'all' == bp_get_signup_allowed() || 'blog' == bp_get_signup_allowed() ) : ?>
    163163
     
    167167
    168168                    <div class="register-section" id="blog-details-section">
    169                
     169
    170170                        <h3><?php _e( 'Blog Details', 'buddypress' ) ?></h3>
    171    
     171
    172172                        <p><input type="checkbox" name="signup_with_blog" id="signup_with_blog" value="1"<?php if ( (int) bp_get_signup_with_blog_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes, I\'d like to create a new blog', 'buddypress' ) ?></p>
    173173
    174174                        <div id="blog-details">
    175        
     175
    176176                            <label for="signup_blog_url"><?php _e( 'Blog URL', 'buddypress' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label>
    177177                            <?php do_action( 'bp_signup_blog_url_errors' ) ?>
    178            
     178
    179179                            <?php if ( 'yes' == VHOST ) : ?>
    180180                                http:// <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value() ?>" /> .<?php echo str_replace( 'http://', '', site_url() ) ?>
    181181                            <?php else : ?>
    182                                 <?php echo site_url() ?>/ <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value() ?>" />             
    183                             <?php endif; ?>
    184        
     182                                <?php echo site_url() ?>/ <input type="text" name="signup_blog_url" id="signup_blog_url" value="<?php bp_signup_blog_url_value() ?>" />
     183                            <?php endif; ?>
     184
    185185                            <label for="signup_blog_title"><?php _e( 'Blog Title', 'buddypress' ) ?> <?php _e( '(required)', 'buddypress' ) ?></label>
    186186                            <?php do_action( 'bp_signup_blog_title_errors' ) ?>
     
    189189                            <span class="label"><?php _e( 'I would like my blog to appear in search engines, and in public listings around this site', 'buddypress' ) ?>:</span>
    190190                            <?php do_action( 'bp_signup_blog_privacy_errors' ) ?>
    191            
     191
    192192                            <label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_public" value="public"<?php if ( 'public' == bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'Yes' ) ?></label>
    193193                            <label><input type="radio" name="signup_blog_privacy" id="signup_blog_privacy_private" value="private"<?php if ( 'private' == bp_get_signup_blog_privacy_value() ) : ?> checked="checked"<?php endif; ?> /> <?php _e( 'No' ) ?></label>
    194        
    195                         </div>
    196            
     194
     195                        </div>
     196
    197197                    </div>
    198            
     198
    199199                    <?php do_action( 'bp_after_blog_details_fields' ) ?>
    200200
    201201                <?php endif; ?>
    202            
     202
    203203                <?php do_action( 'bp_before_registration_submit_buttons' ) ?>
    204    
     204
    205205                <p class="submit">
    206206                    <input type="submit" name="signup_submit" id="signup_submit" value="<?php _e( 'Complete Sign Up', 'buddypress' ) ?> &rarr;" />
     
    212212
    213213            <?php endif; // request-details signup step ?>
    214            
     214
    215215            <?php if ( 'completed-confirmation' == bp_get_current_signup_step() ) : ?>
    216        
     216
    217217                <h2 class="pagetitle"><?php _e( 'Sign Up Complete!', 'buddypress' ) ?></h2>
    218        
     218
    219219                <?php do_action( 'template_notices' ) ?>
    220        
     220
    221221                <p><?php _e( 'You have successfully created your account! To begin using this site you will need to activate your account via the email we have just sent to your address.', 'buddypress' ) ?></p>
    222222
    223223                <?php if ( !(int)get_site_option( 'bp-disable-avatar-uploads' ) ) : ?>
    224                
     224
    225225                    <?php if ( 'upload-image' == bp_get_avatar_admin_step() ) : ?>
    226        
     226
    227227                        <h3><?php _e( 'Your Current Avatar', 'buddypress' ) ?></h3>
    228228                        <p><?php _e( "We've fetched an avatar for your new account. If you'd like to change this, why not upload a new one while you wait for your activation email?", 'buddypress' ) ?></p>
    229                    
     229
    230230                        <div id="signup-avatar">
    231231                            <?php bp_signup_avatar() ?>
    232232                        </div>
    233                
     233
    234234                        <p>
    235                             <input type="file" name="file" id="file" /> 
     235                            <input type="file" name="file" id="file" />
    236236                            <input type="submit" name="upload" id="upload" value="<?php _e( 'Upload Image', 'buddypress' ) ?>" />
    237237                            <input type="hidden" name="action" id="action" value="bp_avatar_upload" />
     
    241241
    242242                        <?php wp_nonce_field( 'bp_avatar_upload' ) ?>
    243            
     243
    244244                    <?php endif; ?>
    245                
     245
    246246                    <?php if ( 'crop-image' == bp_get_avatar_admin_step() ) : ?>
    247        
     247
    248248                        <h3><?php _e( 'Crop Your New Avatar', 'buddypress' ) ?></h3>
    249            
     249
    250250                        <img src="<?php bp_avatar_to_crop() ?>" id="avatar-to-crop" class="avatar" alt="<?php _e( 'Avatar to crop', 'buddypress' ) ?>" />
    251            
     251
    252252                        <div id="avatar-crop-pane">
    253253                            <img src="<?php bp_avatar_to_crop() ?>" id="avatar-crop-preview" class="avatar" alt="<?php _e( 'Avatar preview', 'buddypress' ) ?>" />
     
    255255
    256256                        <input type="submit" name="avatar-crop-submit" id="avatar-crop-submit" value="<?php _e( 'Crop Image', 'buddypress' ) ?>" />
    257                    
     257
    258258                        <input type="hidden" name="signup_email" id="signup_email" value="<?php bp_signup_email_value() ?>" />
    259259                        <input type="hidden" name="signup_username" id="signup_username" value="<?php bp_signup_username_value() ?>" />
    260260                        <input type="hidden" name="signup_avatar_dir" id="signup_avatar_dir" value="<?php bp_signup_avatar_dir_value() ?>" />
    261                    
     261
    262262                        <input type="hidden" name="image_src" id="image_src" value="<?php bp_avatar_to_crop_src() ?>" />
    263263                        <input type="hidden" id="x" name="x" />
     
    267267
    268268                        <?php wp_nonce_field( 'bp_avatar_cropstore' ) ?>
    269            
     269
    270270                    <?php endif; ?>
    271                
     271
    272272                <?php else : ?>
    273                
     273
    274274                    <p><?php _e( "We've fetched an avatar for your new account. If you'd like to change this you can use the <a href=\"http://gravatar.com\">Gravatar</a> service to upload a new one.", 'buddypress' ) ?></p>
    275                    
     275
    276276                <?php endif; ?>
    277            
     277
    278278            <?php endif; // completed-confirmation signup step ?>
    279        
     279
    280280            <?php do_action( 'bp_custom_signup_steps' ) ?>
    281        
     281
    282282            </form>
    283            
     283
    284284        </div>
    285285
    286286        <?php do_action( 'bp_after_register_page' ) ?>
    287    
     287
    288288    </div>
    289    
     289
    290290    <?php get_sidebar(); ?>
    291291
  • trunk/bp-themes/bp-sn-parent/search.php

    r1952 r2077  
    44
    55        <?php do_action( 'bp_before_blog_search' ) ?>
    6        
     6
    77        <div class="page" id="blog-search">
    8            
     8
    99            <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2>
    1010
    1111            <?php if (have_posts()) : ?>
    12        
     12
    1313                <h3 class="pagetitle"><?php _e( 'Search Results', 'buddypress' ) ?></h3>
    1414
     
    2323
    2424                    <div class="post">
    25                        
     25
    2626                        <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent Link to', 'buddypress' ) ?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    2727                        <small><?php the_time('l, F jS, Y') ?></small>
    2828
    2929                        <p class="postmetadata"><?php _e( 'Posted in', 'buddypress' ) ?> <?php the_category(', ') ?> | <?php edit_post_link( __( 'Edit', 'buddypress' ), '', ' | '); ?>  <?php comments_popup_link( __( 'No Comments &#187;', 'buddypress' ), __( '1 Comment &#187;', 'buddypress' ), __( '% Comments &#187;', 'buddypress' ) ); ?></p>
    30                    
     30
    3131                        <?php do_action( 'bp_blog_post' ) ?>
    3232
     
    5050
    5151        </div>
    52        
     52
    5353        <?php do_action( 'bp_after_blog_search' ) ?>
    54        
     54
    5555    </div>
    5656
  • trunk/bp-themes/bp-sn-parent/sidebar.php

    r1905 r2077  
    33<div id="sidebar">
    44    <?php do_action( 'bp_inside_before_blog_sidebar' ) ?>
    5    
     5
    66    <?php if ( !function_exists('dynamic_sidebar')
    77            || !dynamic_sidebar('blog-sidebar') ) : ?>
    8    
     8
    99            <div class="widget-error">
    1010                <?php _e( 'Please log in and add widgets to this column.', 'buddypress' ) ?> <a href="<?php echo get_option('siteurl') ?>/wp-admin/widgets.php?s=&amp;show=&amp;sidebar=blog-sidebar"><?php _e( 'Add Widgets', 'buddypress' ) ?></a>
     
    1212
    1313    <?php endif; ?>
    14    
     14
    1515    <?php do_action( 'bp_inside_after_blog_sidebar' ) ?>
    1616</div>
  • trunk/bp-themes/bp-sn-parent/single.php

    r1905 r2077  
    44
    55        <?php do_action( 'bp_before_blog_single_post' ) ?>
    6    
     6
    77        <div class="page" id="blog-single">
    8        
     8
    99            <h2 class="pagetitle"><?php _e( 'Blog', 'buddypress' ) ?></h2>
    1010
    1111            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    12            
     12
    1313                <div class="item-options">
    14                
     14
    1515                    <div class="alignleft"><?php next_posts_link( __( '&laquo; Previous Entries', 'buddypress' ) ) ?></div>
    1616                    <div class="alignright"><?php previous_posts_link( __( 'Next Entries &raquo;', 'buddypress' ) ) ?></div>
    17                
     17
    1818                </div>
    1919
     
    2121
    2222                    <?php do_action( 'bp_before_blog_post' ) ?>
    23            
     23
    2424                    <h3><a href="<?php echo get_permalink() ?>" rel="bookmark" title="<?php _e( 'Permanent link to', 'buddypress' ) ?> <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    2525
    2626                    <div class="entry">
    27                        
     27
    2828                        <?php the_content( __( '<p class="serif">Read the rest of this entry &raquo;</p>', 'buddypress' ) ); ?>
    2929
     
    4343
    4444            <?php endif; ?>
    45        
     45
    4646        </div>
    4747
  • trunk/bp-themes/bp-sn-parent/status/post-form.php

    r1905 r2077  
    66    <label for="status-update-input"><?php _e( 'What are you up to?', 'buddypress' ) ?></label>
    77    <textarea id="status-update-input" name="status-update-input" tabindex="99"></textarea>
    8    
     8
    99    <?php do_action( 'bp_after_status_update_input' ) ?>
    10    
     10
    1111    <div id="status-update-buttons">
    1212        <input type="submit" name="status-update-post" id="status-update-post" tabindex="100" value="<?php _e( 'Update', 'buddypress' ) ?>" />
    13        
     13
    1414        <?php do_action( 'bp_status_update_buttons' ) ?>
    1515    </div>
    16    
     16
    1717    <?php wp_nonce_field( 'bp_status_add_status', '_wpnonce_add_status' ) ?>
    1818</form>
  • trunk/bp-themes/bp-sn-parent/style.css

    r2042 r2077  
    1 /* 
     1/*
    22Theme Name: BuddyPress Social Network Parent Theme
    33Theme URI: http://buddypress.org/extend/themes/
  • trunk/bp-themes/bp-sn-parent/userbar.php

    r1996 r2077  
    55
    66    <?php do_action( 'bp_inside_before_user_bar' ) ?>
    7    
     7
    88    <?php if ( is_user_logged_in() ) : ?>
    9        
     9
    1010        <p class="avatar">
    1111            <?php bp_loggedin_user_avatar( 'type=thumb' ) ?>
    1212        </p>
    13        
     13
    1414        <ul id="bp-nav">
    1515            <?php bp_get_loggedin_user_nav() ?>
    1616        </ul>
    17        
     17
    1818    <?php else : ?>
    19        
     19
    2020        <p class="avatar">
    2121            <img src="<?php echo get_template_directory_uri() . '/_inc/images/mystery-man.jpg' ?>" alt="No User" width="50" height="50" />
    2222        </p>
    23        
     23
    2424        <p id="login-text"><?php _e( 'You must log in to access your account.', 'buddypress' ) ?></p>
    25    
     25
    2626        <form name="userbar_loginform" id="userbar_loginform" action="<?php echo site_url( 'wp-login.php', 'login' ) ?>" method="post">
    2727            <p>
     
    4040            </p>
    4141        </form>
    42    
     42
    4343    <?php endif ?>
    44    
     44
    4545    <?php do_action( 'bp_inside_after_user_bar' ) ?>
    4646
  • trunk/bp-wire/bp-wire-classes.php

    r1905 r2077  
    33class BP_Wire_Post {
    44    var $table_name;
    5    
     5
    66    var $id;
    77    var $item_id;
     
    99    var $content;
    1010    var $date_posted;
    11    
     11
    1212    function bp_wire_post( $table_name, $id = null, $populate = true ) {
    1313        $this->table_name = $table_name;
    14        
     14
    1515        if ( $id ) {
    1616            $this->id = $id;
    17            
     17
    1818            if ( $populate )
    1919                $this->populate();
    2020        }
    2121    }
    22    
     22
    2323    function populate() {
    2424        global $wpdb, $bp;
     
    3535        }
    3636    }
    37    
     37
    3838    function save() {
    3939        global $wpdb, $bp;
    40        
    41         $this->item_id = apply_filters( 'bp_wire_post_item_id_before_save', $this->item_id, $this->id ); 
    42         $this->user_id = apply_filters( 'bp_wire_post_user_id_before_save', $this->user_id, $this->id ); 
    43         $this->content = apply_filters( 'bp_wire_post_content_before_save', $this->content, $this->id ); 
     40
     41        $this->item_id = apply_filters( 'bp_wire_post_item_id_before_save', $this->item_id, $this->id );
     42        $this->user_id = apply_filters( 'bp_wire_post_user_id_before_save', $this->user_id, $this->id );
     43        $this->content = apply_filters( 'bp_wire_post_content_before_save', $this->content, $this->id );
    4444        $this->date_posted = apply_filters( 'bp_wire_post_date_posted_before_save', $this->date_posted, $this->id );
    4545
    46         do_action( 'bp_wire_post_before_save', $this );     
    47        
     46        do_action( 'bp_wire_post_before_save', $this );
     47
    4848        if ( $this->id ) {
    49             $sql = $wpdb->prepare( 
    50                 "UPDATE {$this->table_name} SET 
    51                     item_id = %d, 
    52                     user_id = %d, 
    53                     content = %s, 
     49            $sql = $wpdb->prepare(
     50                "UPDATE {$this->table_name} SET
     51                    item_id = %d,
     52                    user_id = %d,
     53                    content = %s,
    5454                    date_posted = FROM_UNIXTIME(%d)
    5555                WHERE
    5656                    id = %d
    5757                ",
    58                     $this->item_id, 
    59                     $this->user_id, 
    60                     $this->content, 
    61                     $this->date_posted, 
     58                    $this->item_id,
     59                    $this->user_id,
     60                    $this->content,
     61                    $this->date_posted,
    6262                    $this->id
    6363            );
    6464        } else {
    65             $sql = $wpdb->prepare( 
    66                 "INSERT INTO {$this->table_name} ( 
     65            $sql = $wpdb->prepare(
     66                "INSERT INTO {$this->table_name} (
    6767                    item_id,
    6868                    user_id,
     
    7272                    %d, %d, %s, FROM_UNIXTIME(%d)
    7373                )",
    74                     $this->item_id, 
    75                     $this->user_id, 
    76                     $this->content, 
    77                     $this->date_posted, 
    78                     $this->id 
     74                    $this->item_id,
     75                    $this->user_id,
     76                    $this->content,
     77                    $this->date_posted,
     78                    $this->id
    7979            );
    8080        }
    8181
    8282        $result = $wpdb->query($sql);
    83        
     83
    8484        if ( !$this->id )
    8585            $this->id = $wpdb->insert_id;
    8686
    87         do_action( 'bp_wire_post_after_save', $this );     
    88        
     87        do_action( 'bp_wire_post_after_save', $this );
     88
    8989        return $result;
    9090    }
    91    
     91
    9292    function delete() {
    9393        global $wpdb, $bp;
    94        
     94
    9595        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$this->table_name} WHERE id = %d", $this->id ) );
    9696    }
    97    
     97
    9898    /* Static Functions */
    99    
     99
    100100    function get_all_for_item( $item_id, $table_name, $page = false, $limit = false ) {
    101101        global $wpdb, $bp;
    102        
     102
    103103        if ( $limit && $page )
    104104            $pag_sql = $wpdb->prepare( " LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
    105        
     105
    106106        $wire_posts = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$table_name} WHERE item_id = %d ORDER BY date_posted DESC $pag_sql", $item_id ) );
    107107        $count = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$table_name} WHERE item_id = %d", $item_id ) );
    108        
     108
    109109        return array( 'wire_posts' => $wire_posts, 'count' => $count );
    110110    }
    111    
     111
    112112    function delete_all_for_item( $item_id, $table_name ) {
    113113        global $wpdb, $bp;
    114        
     114
    115115        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE item_id = %d", $item_id ) );
    116116    }
  • trunk/bp-wire/bp-wire-filters.php

    r1925 r2077  
    1717function bp_wire_filter_kses( $content ) {
    1818    global $allowedtags;
    19    
     19
    2020    $wire_allowedtags = $allowedtags;
    21     $wire_allowedtags['img'] = array(); 
     21    $wire_allowedtags['img'] = array();
    2222    $wire_allowedtags['img']['src'] = array();
    2323    $wire_allowedtags['img']['alt'] = array();
  • trunk/bp-wire/bp-wire-templatetags.php

    r1910 r2077  
    66    var $wire_posts;
    77    var $wire_post;
    8    
     8
    99    var $in_the_loop;
    10    
     10
    1111    var $pag_page;
    1212    var $pag_num;
    1313    var $pag_links;
    1414    var $total_wire_post_count;
    15    
     15
    1616    var $can_post;
    17    
     17
    1818    var $table_name;
    19    
     19
    2020    function bp_wire_posts_template( $item_id, $component_slug, $can_post, $per_page, $max ) {
    2121        global $bp;
     
    2525        } else
    2626            $this->table_name = $bp->{$bp->active_components[$component_slug]}->table_name_wire;
    27        
     27
    2828        $this->pag_page = isset( $_REQUEST['wpage'] ) ? intval( $_REQUEST['wpage'] ) : 1;
    2929        $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
     
    3131        $this->wire_posts = BP_Wire_Post::get_all_for_item( $item_id, $this->table_name, $this->pag_page, $this->pag_num );
    3232        $this->total_wire_post_count = (int)$this->wire_posts['count'];
    33        
     33
    3434        $this->wire_posts = $this->wire_posts['wire_posts'];
    3535        $this->wire_post_count = count($this->wire_posts);
    36        
     36
    3737        if ( is_site_admin() || ( (int)get_site_option('non-friend-wire-posting') && ( $bp->current_component == $bp->profile->slug || $bp->current_component == $bp->wire->slug ) ) )
    3838            $this->can_post = 1;
    3939        else
    4040            $this->can_post = $can_post;
    41        
     41
    4242        $this->pag_links = paginate_links( array(
    4343            'base' => add_query_arg( 'wpage', '%#%', $bp->displayed_user->domain ),
     
    4949            'mid_size' => 1
    5050        ));
    51        
    52     }
    53    
     51
     52    }
     53
    5454    function has_wire_posts() {
    5555        if ( $this->wire_post_count )
    5656            return true;
    57        
     57
    5858        return false;
    5959    }
    60    
     60
    6161    function next_wire_post() {
    6262        $this->current_wire_post++;
    6363        $this->wire_post = $this->wire_posts[$this->current_wire_post];
    64        
     64
    6565        return $this->wire_post;
    6666    }
    67    
     67
    6868    function rewind_wire_posts() {
    6969        $this->current_wire_post = -1;
     
    7272        }
    7373    }
    74    
    75     function user_wire_posts() { 
     74
     75    function user_wire_posts() {
    7676        if ( $this->current_wire_post + 1 < $this->wire_post_count ) {
    7777            return true;
     
    8585        return false;
    8686    }
    87    
     87
    8888    function the_wire_post() {
    8989        global $wire_post;
     
    9999function bp_has_wire_posts( $args = '' ) {
    100100    global $wire_posts_template, $bp;
    101    
     101
    102102    $defaults = array(
    103103        'item_id' => false,
     
    110110    $r = wp_parse_args( $args, $defaults );
    111111    extract( $r, EXTR_SKIP );
    112    
     112
    113113    if ( !$item_id )
    114114        return false;
    115        
    116     $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $component_slug, $can_post, $per_page, $max );     
     115
     116    $wire_posts_template = new BP_Wire_Posts_Template( $item_id, $component_slug, $can_post, $per_page, $max );
    117117    return apply_filters( 'bp_has_wire_posts', $wire_posts_template->has_wire_posts(), &$wire_posts_template );
    118118}
     
    133133    if ( !$item_id )
    134134        return false;
    135    
     135
    136136    if ( !$empty_message )
    137137        $empty_message = __("There are currently no wire posts.", 'buddypress');
    138    
     138
    139139    if ( !$title )
    140140        $title = __('Wire', 'buddypress');
     
    146146    $bp_wire_can_post = $can_post;
    147147    $bp_wire_show_email_notify = $show_email_notify;
    148    
     148
    149149    locate_template( array( '/wire/post-list.php' ), true );
    150150}
     
    157157        return apply_filters( 'bp_get_wire_title', $bp_wire_header );
    158158    }
    159    
     159
    160160function bp_wire_item_id( $deprecated = false ) {
    161161    global $bp_item_id;
    162    
     162
    163163    if ( $deprecated )
    164164        echo bp_get_wire_item_id();
     
    179179        return apply_filters( 'bp_get_wire_no_posts_message', $bp_wire_msg );
    180180    }
    181    
     181
    182182function bp_wire_can_post() {
    183183    global $bp_wire_can_post;
     
    192192function bp_wire_post_id( $deprecated = true ) {
    193193    global $wire_posts_template;
    194    
     194
    195195    if ( !$deprecated )
    196196        return bp_get_wire_post_id();
     
    218218    if ( $wire_posts_template->total_wire_post_count > $wire_posts_template->pag_num )
    219219        return true;
    220    
     220
    221221    return false;
    222222}
     
    230230        return apply_filters( 'bp_get_wire_pagination', $wire_posts_template->pag_links );
    231231    }
    232    
     232
    233233function bp_wire_pagination_count() {
    234234    echo bp_get_wire_pagination_count();
     
    238238
    239239        $from_num = intval( ( $wire_posts_template->pag_page - 1 ) * $wire_posts_template->pag_num ) + 1;
    240         $to_num = ( $from_num + ( $wire_posts_template->pag_num - 1) > $wire_posts_template->total_wire_post_count ) ? $wire_posts_template->total_wire_post_count : $from_num + ( $wire_posts_template->pag_num - 1); 
    241 
    242         return apply_filters( 'bp_get_wire_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $wire_posts_template->total_wire_post_count ) ); 
    243     }
    244    
     240        $to_num = ( $from_num + ( $wire_posts_template->pag_num - 1) > $wire_posts_template->total_wire_post_count ) ? $wire_posts_template->total_wire_post_count : $from_num + ( $wire_posts_template->pag_num - 1);
     241
     242        return apply_filters( 'bp_get_wire_pagination_count', sprintf( __( 'Viewing post %d to %d (%d total posts)', 'buddypress' ), $from_num, $to_num, $wire_posts_template->total_wire_post_count ) );
     243    }
     244
    245245function bp_wire_ajax_loader_src() {
    246246    echo bp_get_wire_ajax_loader_src();
     
    262262    function bp_get_wire_post_date() {
    263263        global $wire_posts_template;
    264        
     264
    265265        return apply_filters( 'bp_get_wire_post_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format'), $wire_posts_template->wire_post->date_posted ) );
    266266    }
     
    268268function bp_wire_post_author_name( $deprecated = true ) {
    269269    global $wire_posts_template;
    270    
     270
    271271    if ( !$deprecated )
    272272        return bp_get_wire_post_author_name();
     
    291291function bp_wire_get_post_form() {
    292292    global $wire_posts_template;
    293    
     293
    294294    if ( is_user_logged_in() && $wire_posts_template->can_post )
    295         locate_template( array( '/wire/post-form.php' ), true );   
     295        locate_template( array( '/wire/post-form.php' ), true );
    296296}
    297297
     
    339339        return bp_get_wire_poster_date();
    340340    else
    341         echo bp_get_wire_poster_date(); 
     341        echo bp_get_wire_poster_date();
    342342}
    343343    function bp_get_wire_poster_date() {
    344         return apply_filters( 'bp_get_wire_poster_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format' ), date("Y-m-d H:i:s") ) );   
     344        return apply_filters( 'bp_get_wire_poster_date', mysql2date( get_blog_option( BP_ROOT_BLOG, 'date_format' ), date("Y-m-d H:i:s") ) );
    345345    }
    346346
  • trunk/bp-wire/deprecated/bp-wire-deprecated.php

    r1905 r2077  
    44 *
    55 * This file contains functions that are deprecated.
    6  * You should not under any circumstance use these functions as they are 
     6 * You should not under any circumstance use these functions as they are
    77 * either no longer valid, or have been replaced with something much more awesome.
    88 *
     
    1313 * Of course, things will still work if you use these functions but you will
    1414 * be the laughing stock of the BuddyPress community. We will all point and laugh at
    15  * you. You'll also be making things harder for yourself in the long run, 
     15 * you. You'll also be making things harder for yourself in the long run,
    1616 * and you will miss out on lovely performance and functionality improvements.
    17  * 
     17 *
    1818 * If you've checked you are not using any deprecated functions and finished your little
    1919 * dance, you can add the following line to your wp-config.php file to prevent any of
     
    2727    if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) )
    2828        return $template;
    29    
     29
    3030    /* Enqueue the structure CSS file to give basic positional formatting for components */
    31     wp_enqueue_style( 'bp-wire-structure', BP_PLUGIN_URL . '/bp-wire/deprecated/css/structure.css' );   
     31    wp_enqueue_style( 'bp-wire-structure', BP_PLUGIN_URL . '/bp-wire/deprecated/css/structure.css' );
    3232}
    3333add_action( 'bp_styles', 'bp_wire_add_structure_css' );
     
    4646            <span class="ajax-loader"></span>
    4747        </div>
    48            
     48
    4949        <div id="wire-pagination" class="pagination-links">
    5050            <?php bp_wire_pagination() ?>
    5151        </div>
    52        
     52
    5353        <ul id="wire-post-list">
    5454        <?php $counter = 0; ?>
     
    5757                <div class="wire-post-metadata">
    5858                    <?php bp_wire_post_author_avatar() ?>
    59                     <?php _e( 'On', 'buddypress' ) ?> <?php bp_wire_post_date() ?> 
     59                    <?php _e( 'On', 'buddypress' ) ?> <?php bp_wire_post_date() ?>
    6060                    <?php bp_wire_post_author_name() ?> <?php _e( 'said:', 'buddypress' ) ?>
    6161                    <?php bp_wire_delete_link() ?>
    6262                </div>
    63                
     63
    6464                <div class="wire-post-content">
    6565                    <?php bp_wire_post_content() ?>
     
    6969        <?php endwhile; ?>
    7070        </ul>
    71    
     71
    7272    <?php else: ?>
    7373
     
    7777
    7878    <?php endif; ?>
    79    
     79
    8080    <input type="hidden" name="bp_wire_item_id" id="bp_wire_item_id" value="<?php echo attribute_escape( $_POST['bp_wire_item_id'] ) ?>" />
    8181    <?php
  • trunk/bp-xprofile.php

    r2059 r2077  
    1515/* Include deprecated functions if settings allow */
    1616if ( !defined( 'BP_IGNORE_DEPRECATED' ) )
    17     require ( BP_PLUGIN_DIR . '/bp-xprofile/deprecated/bp-xprofile-deprecated.php' );   
     17    require ( BP_PLUGIN_DIR . '/bp-xprofile/deprecated/bp-xprofile-deprecated.php' );
    1818
    1919/* Assign the base group and fullname field names to constants to use in SQL statements */
     
    2525 *
    2626 * Set up the database tables needed for the xprofile component.
    27  * 
     27 *
    2828 * @package BuddyPress XProfile
    2929 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    3636    if ( !empty($wpdb->charset) )
    3737        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    38    
     38
    3939    if ( '' == get_site_option( 'bp-xprofile-base-group-name' ) )
    4040        update_site_option( 'bp-xprofile-base-group-name', 'Base' );
    41    
     41
    4242    if ( '' == get_site_option( 'bp-xprofile-fullname-field-name' ) )
    43         update_site_option( 'bp-xprofile-fullname-field-name', 'Name' );   
    44    
     43        update_site_option( 'bp-xprofile-fullname-field-name', 'Name' );
     44
    4545    $sql[] = "CREATE TABLE {$bp->profile->table_name_groups} (
    4646              id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    5050              KEY can_delete (can_delete)
    5151    ) {$charset_collate};";
    52    
     52
    5353    $sql[] = "CREATE TABLE {$bp->profile->table_name_fields} (
    5454              id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    7070              KEY is_required (is_required)
    7171    ) {$charset_collate};";
    72    
     72
    7373    $sql[] = "CREATE TABLE {$bp->profile->table_name_data} (
    7474              id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
     
    8080              KEY user_id (user_id)
    8181    ) {$charset_collate};";
    82    
     82
    8383    if ( '' == get_site_option( 'bp-xprofile-db-version' ) ) {
    8484        $sql[] = "INSERT INTO {$bp->profile->table_name_groups} VALUES ( 1, '" . get_site_option( 'bp-xprofile-base-group-name' ) . "', '', 0 );";
    85    
    86         $sql[] = "INSERT INTO {$bp->profile->table_name_fields} ( 
     85
     86        $sql[] = "INSERT INTO {$bp->profile->table_name_fields} (
    8787                    id, group_id, parent_id, type, name, is_required, can_delete
    8888                  ) VALUES (
     
    9090                  );";
    9191    }
    92    
     92
    9393    require_once( ABSPATH . 'wp-admin/upgrade-functions.php' );
    9494    dbDelta($sql);
    95    
     95
    9696    if ( function_exists('bp_wire_install') )
    9797        xprofile_wire_install();
    98    
     98
    9999    update_site_option( 'bp-xprofile-db-version', BP_XPROFILE_DB_VERSION );
    100100}
     
    124124 *
    125125 * Add the profile globals to the $bp global for use across the installation
    126  * 
     126 *
    127127 * @package BuddyPress XProfile
    128128 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    132132function xprofile_setup_globals() {
    133133    global $bp, $wpdb;
    134    
     134
    135135    /* For internal identification */
    136136    $bp->profile->id = 'profile';
    137        
     137
    138138    $bp->profile->table_name_groups = $wpdb->base_prefix . 'bp_xprofile_groups';
    139139    $bp->profile->table_name_fields = $wpdb->base_prefix . 'bp_xprofile_fields';
     
    145145    /* Register this in the active components array */
    146146    $bp->active_components[$bp->profile->slug] = $bp->profile->id;
    147    
     147
    148148    /* Set the support field type ids */
    149149    $bp->profile->field_types = apply_filters( 'xprofile_field_types', array( 'textbox', 'textarea', 'radio', 'checkbox', 'selectbox', 'multiselectbox', 'datebox' ) );
     
    151151    if ( function_exists( 'bp_wire_install' ) )
    152152        $bp->profile->table_name_wire = $wpdb->base_prefix . 'bp_xprofile_wire';
    153    
     153
    154154    do_action( 'xprofile_setup_globals' );
    155155}
     
    162162 * Creates the administration interface menus and checks to see if the DB
    163163 * tables are set up.
    164  * 
     164 *
    165165 * @package BuddyPress XProfile
    166166 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    171171 * @uses add_submenu_page() Adds a submenu tab to a top level tab in the admin area
    172172 * @uses xprofile_install() Runs the DB table installation function
    173  * @return 
     173 * @return
    174174 */
    175175function xprofile_add_admin_menu() {
    176176    global $wpdb, $bp;
    177    
     177
    178178    if ( !is_site_admin() )
    179179        return false;
    180            
     180
    181181    /* Add the administration tab under the "Site Admin" tab for site administrators */
    182182    add_submenu_page( 'bp-general-settings', __("Profile Field Setup", 'buddypress'), __("Profile Field Setup", 'buddypress'), 'manage-options', 'bp-profile-setup', "xprofile_admin" );
     
    192192 *
    193193 * Sets up the navigation items for the xprofile component
    194  * 
     194 *
    195195 * @package BuddyPress XProfile
    196196 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    203203function xprofile_setup_nav() {
    204204    global $bp;
    205    
     205
    206206    /* Add 'Profile' to the main navigation */
    207207    bp_core_new_nav_item( array( 'name' => __( 'Profile', 'buddypress' ), 'slug' => $bp->profile->slug, 'position' => 20, 'screen_function' => 'xprofile_screen_display_profile', 'default_subnav_slug' => 'public', 'item_css_id' => $bp->profile->id ) );
    208208
    209209    $profile_link = $bp->loggedin_user->domain . $bp->profile->slug . '/';
    210    
     210
    211211    /* Add the subnav items to the profile */
    212212    bp_core_new_subnav_item( array( 'name' => __( 'Public', 'buddypress' ), 'slug' => 'public', 'parent_url' => $profile_link, 'parent_slug' => $bp->profile->slug, 'screen_function' => 'xprofile_screen_display_profile', 'position' => 10 ) );
     
    219219        } else {
    220220            $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
    221             $bp->bp_options_title = $bp->displayed_user->fullname; 
     221            $bp->bp_options_title = $bp->displayed_user->fullname;
    222222        }
    223223    }
    224    
     224
    225225    do_action( 'xprofile_setup_nav' );
    226226}
     
    233233 *
    234234 * Adds an admin bar menu to any profile page providing site admin options for that user.
    235  * 
     235 *
    236236 * @package BuddyPress XProfile
    237237 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    239239function xprofile_setup_adminbar_menu() {
    240240    global $bp;
    241    
     241
    242242    if ( !$bp->displayed_user->id )
    243243        return false;
    244    
     244
    245245    /* Don't show this menu to non site admins or if you're viewing your own profile */
    246246    if ( !is_site_admin() || bp_is_home() )
     
    249249    <li id="bp-adminbar-adminoptions-menu">
    250250        <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
    251        
     251
    252252        <ul>
    253253            <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit/"><?php printf( __( "Edit %s's Profile", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
    254254            <li><a href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/change-avatar/"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
    255            
     255
    256256            <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
    257257                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Mark as Spammer", 'buddypress' ) ?></a></li>
     
    259259                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
    260260            <?php endif; ?>
    261            
     261
    262262            <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s", 'buddypress' ), attribute_escape( $bp->displayed_user->fullname ) ) ?></a></li>
    263            
     263
    264264            <?php do_action( 'xprofile_adminbar_menu_items' ) ?>
    265265        </ul>
     
    281281 *
    282282 * Handles the display of the profile page by loading the correct template file.
    283  * 
     283 *
    284284 * @package BuddyPress Xprofile
    285285 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
     
    292292    if ( isset($_GET['new']) )
    293293        bp_core_delete_notifications_for_user_by_item_id( $bp->loggedin_user->id, $bp->displayed_user->id, 'friends', 'friendship_accepted' );
    294    
     294
    295295    do_action( 'xprofile_screen_display_profile', $_GET['new'] );
    296296    bp_core_load_template( apply_filters( 'xprofile_template_display_profile', 'profile/index' ) );
     
    302302 * Handles the display of the profile edit page by loading the correct template file.
    303303 * Also checks to make sure this can only be accessed for the logged in users profile.
    304  * 
     304 *
    305305 * @package BuddyPress Xprofile
    306306 * @uses bp_is_home() Checks to make sure the current user being viewed equals the logged in user
     
    309309function xprofile_screen_edit_profile() {
    310310    global $bp;
    311    
     311
    312312    if ( !bp_is_home() && !is_site_admin() )
    313313        return false;
    314    
     314
    315315    /* Check to see if any new information has been submitted */
    316316    if ( isset($_POST['field_ids']) ) {
    317        
     317
    318318        /* Check the nonce */
    319319        check_admin_referer( 'bp_xprofile_edit' );
    320        
     320
    321321        /* Check we have field ID's */
    322322        if ( empty( $_POST['field_ids'] ) )
    323323            bp_core_redirect( $bp->displayed_user->domain . BP_XPROFILE_SLUG . '/edit/group/' . $bp->action_variables[1] . '/' );
    324        
     324
    325325        /* Explode the posted field IDs into an array so we know which fields have been submitted */
    326326        $posted_field_ids = explode( ',', $_POST['field_ids'] );
    327                
     327
    328328        /* Loop through the posted fields formatting any datebox values then validate the field */
    329         foreach ( $posted_field_ids as $field_id ) {       
    330 
     329        foreach ( $posted_field_ids as $field_id ) {
    331330            if ( !isset( $_POST['field_' . $field_id] ) ) {
    332331
    333332                if ( is_numeric( $_POST['field_' . $field_id . '_day'] ) ) {
    334333                    /* Concatenate the values. */
    335                     $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . 
     334                    $date_value = $_POST['field_' . $field_id . '_day'] . ' ' .
    336335                                  $_POST['field_' . $field_id . '_month'] . ' ' .
    337336                                  $_POST['field_' . $field_id . '_year'];
     
    348347
    349348        if ( $errors )
    350             bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );         
    351         else {     
     349            bp_core_add_message( __( 'Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress' ), 'error' );
     350        else {
    352351            /* Reset the errors var */
    353352            $errors = false;
    354        
     353
    355354            /* Now we've checked for required fields, lets save the values. */
    356             foreach ( $posted_field_ids as $field_id ) {       
     355            foreach ( $posted_field_ids as $field_id ) {
    357356                if ( !xprofile_set_field_data( $field_id, $bp->displayed_user->id, $_POST['field_' . $field_id] ) )
    358357                    $errors = true;
     
    360359                    do_action( 'xprofile_profile_field_data_updated', $field_id, $_POST['field_' . $field_id] );
    361360            }
    362                
     361
    363362            do_action( 'xprofile_updated_profile', $posted_field_ids, $errors );
    364        
     363
    365364            /* Set the feedback messages */
    366365            if ( $errors )
    367366                bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' );
    368             else 
     367            else
    369368                bp_core_add_message( __( 'Changes saved.', 'buddypress' ) );
    370369
     
    375374
    376375    do_action( 'xprofile_screen_edit_profile' );
    377     bp_core_load_template( apply_filters( 'xprofile_template_edit_profile', 'profile/edit' ) );         
     376    bp_core_load_template( apply_filters( 'xprofile_template_edit_profile', 'profile/edit' ) );
    378377}
    379378
     
    382381 *
    383382 * Handles the uploading and cropping of a user avatar. Displays the change avatar page.
    384  * 
     383 *
    385384 * @package BuddyPress Xprofile
    386385 * @uses bp_is_home() Checks to make sure the current user being viewed equals the logged in user
     
    389388function xprofile_screen_change_avatar() {
    390389    global $bp;
    391    
     390
    392391    if ( !bp_is_home() && !is_site_admin() )
    393392        return false;
    394    
     393
    395394    $bp->avatar_admin->step = 'upload-image';
    396    
     395
    397396    if ( !empty( $_FILES ) ) {
    398        
     397
    399398        /* Check the nonce */
    400399        check_admin_referer( 'bp_avatar_upload' );
    401400
    402         /* Pass the file to the avatar upload handler */       
    403         if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) {     
     401        /* Pass the file to the avatar upload handler */
     402        if ( bp_core_avatar_handle_upload( $_FILES, 'xprofile_avatar_upload_dir' ) ) {
    404403            $bp->avatar_admin->step = 'crop-image';
    405404
     
    408407        }
    409408    }
    410    
     409
    411410    /* If the image cropping is done, crop the image and save a full/thumb version */
    412411    if ( isset( $_POST['avatar-crop-submit'] ) ) {
    413        
     412
    414413        /* Check the nonce */
    415414        check_admin_referer( 'bp_avatar_cropstore' );
     
    424423
    425424    do_action( 'xprofile_screen_change_avatar' );
    426    
     425
    427426    bp_core_load_template( apply_filters( 'xprofile_template_change_avatar', 'profile/change-avatar' ) );
    428427}
     
    434433 * Settings are hooked into the function: bp_core_screen_notification_settings_content()
    435434 * in bp-core/bp-core-settings.php
    436  * 
     435 *
    437436 * @package BuddyPress Xprofile
    438437 * @global $current_user WordPress global variable containing current logged in user information
    439438 */
    440 function xprofile_screen_notification_settings() { 
     439function xprofile_screen_notification_settings() {
    441440    global $current_user; ?>
    442441    <?php if ( function_exists('bp_wire_install') ) { ?>
     
    455454            <td class="no"><input type="radio" name="notifications[notification_profile_wire_post]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_profile_wire_post' ) ) { ?>checked="checked" <?php } ?>/></td>
    456455        </tr>
    457        
     456
    458457        <?php do_action( 'xprofile_screen_notification_settings' ) ?>
    459458    </table>
    460459    <?php } ?>
    461 <?php   
     460<?php
    462461}
    463462add_action( 'bp_notification_settings', 'xprofile_screen_notification_settings', 1 );
     
    479478 *
    480479 * The function will delete the active avatar for a user.
    481  * 
     480 *
    482481 * @package BuddyPress Xprofile
    483482 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    491490    if ( $bp->profile->slug != $bp->current_component || 'change-avatar' != $bp->current_action || 'delete-avatar' != $bp->action_variables[0] )
    492491        return false;
    493    
     492
    494493    /* Check the nonce */
    495494    check_admin_referer( 'bp_delete_avatar_link' );
    496    
     495
    497496    if ( !bp_is_home() && !is_site_admin() )
    498497        return false;
    499    
     498
    500499    if ( bp_core_delete_existing_avatar( array( 'item_id' => $bp->displayed_user->id ) ) )
    501500        bp_core_add_message( __( 'Your avatar was deleted successfully!', 'buddypress' ) );
     
    503502        bp_core_add_message( __( 'There was a problem deleting that avatar, please try again.', 'buddypress' ), 'error' );
    504503
    505     bp_core_redirect( wp_get_referer() ); 
     504    bp_core_redirect( wp_get_referer() );
    506505}
    507506add_action( 'wp', 'xprofile_action_delete_avatar', 3 );
     
    510509 * xprofile_action_new_wire_post()
    511510 *
    512  * Posts a new wire post to the users profile wire. 
    513  * 
     511 * Posts a new wire post to the users profile wire.
     512 *
    514513 * @package BuddyPress XProfile
    515514 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    523522    if ( $bp->current_component != $bp->wire->slug )
    524523        return false;
    525    
     524
    526525    if ( 'post' != $bp->current_action )
    527526        return false;
    528        
     527
    529528    /* Check the nonce */
    530     if ( !check_admin_referer( 'bp_wire_post' ) ) 
    531         return false;
    532        
     529    if ( !check_admin_referer( 'bp_wire_post' ) )
     530        return false;
     531
    533532    if ( !$wire_post = bp_wire_new_post( $bp->displayed_user->id, $_POST['wire-post-textarea'], $bp->profile->slug, false, $bp->profile->table_name_wire ) ) {
    534533        bp_core_add_message( __( 'Wire message could not be posted. Please try again.', 'buddypress' ), 'error' );
    535534    } else {
    536535        bp_core_add_message( __( 'Wire message successfully posted.', 'buddypress' ) );
    537        
     536
    538537        /* Record the notification for the reciever if it's not on their own wire */
    539538        if ( !bp_is_home() )
    540             bp_core_add_notification( $bp->loggedin_user->id, $bp->displayed_user->id, $bp->profile->id, 'new_wire_post' ); 
    541        
     539            bp_core_add_notification( $bp->loggedin_user->id, $bp->displayed_user->id, $bp->profile->id, 'new_wire_post' );
     540
    542541        /* Record this on the poster's activity screen */
    543542        if ( ( $wire_post->item_id == $bp->loggedin_user->id && $wire_post->user_id == $bp->loggedin_user->id ) || ( $wire_post->item_id == $bp->displayed_user->id && $wire_post->user_id == $bp->displayed_user->id ) ) {
    544543            $from_user_link = bp_core_get_userlink($wire_post->user_id);
    545             $content = sprintf( __('%s wrote on their own wire', 'buddypress'), $from_user_link ) . ': <span class="time-since">%s</span>';             
    546             $primary_link = bp_core_get_userlink( $wire_post->user_id, false, true );   
     544            $content = sprintf( __('%s wrote on their own wire', 'buddypress'), $from_user_link ) . ': <span class="time-since">%s</span>';
     545            $primary_link = bp_core_get_userlink( $wire_post->user_id, false, true );
    547546        } else if ( ( $wire_post->item_id != $bp->loggedin_user->id && $wire_post->user_id == $bp->loggedin_user->id ) || ( $wire_post->item_id != $bp->displayed_user->id && $wire_post->user_id == $bp->displayed_user->id ) ) {
    548547            $from_user_link = bp_core_get_userlink($wire_post->user_id);
    549548            $to_user_link = bp_core_get_userlink( $wire_post->item_id, false, false, true, true );
    550             $content = sprintf( __('%s wrote on %s wire', 'buddypress'), $from_user_link, $to_user_link ) . ': <span class="time-since">%s</span>';         
     549            $content = sprintf( __('%s wrote on %s wire', 'buddypress'), $from_user_link, $to_user_link ) . ': <span class="time-since">%s</span>';
    551550            $primary_link = bp_core_get_userlink( $wire_post->item_id, false, true );
    552         } 
    553        
     551        }
     552
    554553        $content .= '<blockquote>' . bp_create_excerpt($wire_post->content) . '</blockquote>';
    555554
     
    563562        ) );
    564563
    565         do_action( 'xprofile_new_wire_post', &$wire_post ); 
     564        do_action( 'xprofile_new_wire_post', &$wire_post );
    566565    }
    567566
     
    577576 * xprofile_action_delete_wire_post()
    578577 *
    579  * Deletes a wire post from the users profile wire. 
    580  * 
     578 * Deletes a wire post from the users profile wire.
     579 *
    581580 * @package BuddyPress XProfile
    582581 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
     
    588587function xprofile_action_delete_wire_post() {
    589588    global $bp;
    590    
     589
    591590    if ( $bp->current_component != $bp->wire->slug )
    592591        return false;
    593    
     592
    594593    if ( $bp->current_action != 'delete' )
    595594        return false;
    596    
     595
    597596    if ( !check_admin_referer( 'bp_wire_delete_link' ) )
    598597        return false;
    599            
     598
    600599    $wire_post_id = $bp->action_variables[0];
    601600
     
    605604        /* Delete the post from activity streams */
    606605        xprofile_delete_activity( array( 'item_id' => $wire_post_id, 'component_action' => 'new_wire_post' ) );
    607        
    608         do_action( 'xprofile_delete_wire_post', $wire_post_id );                       
     606
     607        do_action( 'xprofile_delete_wire_post', $wire_post_id );
    609608    } else {
    610609        bp_core_add_message( __('Wire post could not be deleted, please try again.', 'buddypress'), 'error' );
    611610    }
    612    
     611
    613612    if ( !strpos( wp_get_referer(), $bp->wire->slug ) ) {
    614613        bp_core_redirect( $bp->displayed_user->domain );
     
    629628function xprofile_register_activity_actions() {
    630629    global $bp;
    631    
     630
    632631    if ( !function_exists( 'bp_activity_set_action' ) )
    633632        return false;
     
    647646 * Records activity for the logged in user within the profile component so that
    648647 * it will show in the users activity stream (if installed)
    649  * 
     648 *
    650649 * @package BuddyPress XProfile
    651650 * @param $args Array containing all variables used after extract() call
     
    655654function xprofile_record_activity( $args = true ) {
    656655    global $bp;
    657    
     656
    658657    if ( !function_exists( 'bp_activity_add' ) )
    659658        return false;
     
    672671
    673672    $r = wp_parse_args( $args, $defaults );
    674     extract( $r, EXTR_SKIP );   
    675    
     673    extract( $r, EXTR_SKIP );
     674
    676675    return bp_activity_add( array( 'user_id' => $user_id, 'content' => $content, 'primary_link' => $primary_link, 'component_name' => $component_name, 'component_action' => $component_action, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) );
    677676}
     
    682681 * Deletes activity for a user within the profile component so that
    683682 * it will be removed from the users activity stream and sitewide stream (if installed)
    684  * 
     683 *
    685684 * @package BuddyPress XProfile
    686685 * @param $args Array containing all variables used after extract() call
     
    690689function xprofile_delete_activity( $args = '' ) {
    691690    global $bp;
    692    
     691
    693692    if ( function_exists('bp_activity_delete_by_item_id') ) {
    694693        extract($args);
     
    699698function xprofile_register_activity_action( $key, $value ) {
    700699    global $bp;
    701    
     700
    702701    if ( !function_exists( 'bp_activity_set_action' ) )
    703702        return false;
    704    
     703
    705704    return apply_filters( 'xprofile_register_activity_action', bp_activity_set_action( $bp->profile->id, $key, $value ), $key, $value );
    706705}
     
    710709 *
    711710 * Format notifications into something that can be read and displayed
    712  * 
     711 *
    713712 * @package BuddyPress Xprofile
    714713 * @param $item_id The ID of the specific item for which the activity is recorded (could be a wire post id, user id etc)
     
    724723    if ( 'new_wire_post' == $action ) {
    725724        if ( (int)$total_items > 1 ) {
    726             return apply_filters( 'bp_xprofile_multiple_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __( 'Wire', 'buddypress' ) . '">' . sprintf( __( 'You have %d new posts on your wire', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );       
     725            return apply_filters( 'bp_xprofile_multiple_new_wire_post_notification', '<a href="' . $bp->loggedin_user->domain . $bp->wire->slug . '" title="' . __( 'Wire', 'buddypress' ) . '">' . sprintf( __( 'You have %d new posts on your wire', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
    727726        } else {
    728727            $user_fullname = bp_core_get_user_displayname( $item_id );
     
    730729        }
    731730    }
    732    
     731
    733732    do_action( 'xprofile_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    734    
     733
    735734    return false;
    736735}
     
    758757
    759758    $r = wp_parse_args( $args, $defaults );
    760     extract( $r, EXTR_SKIP );   
     759    extract( $r, EXTR_SKIP );
    761760
    762761    if ( !$name )
    763762        return false;
    764        
     763
    765764    $field_group = new BP_XProfile_Group( $field_group_id );
    766765    $field_group->name = $name;
    767766    $field_group->description = $description;
    768767    $field_group->can_delete = $can_delete;
    769    
     768
    770769    return $field_group->save();
    771770}
     
    785784function xprofile_insert_field( $args = '' ) {
    786785    global $bp;
    787    
     786
    788787    extract( $args );
    789    
     788
    790789    /**
    791790     * Possible parameters (pass as assoc array):
     
    803802     *  'option_order'
    804803     */
    805    
     804
    806805    /* Check we have the minimum details */
    807806    if ( !$field_group_id )
    808807        return false;
    809    
     808
    810809    /* Check this is a valid field type */
    811810    if ( !in_array( $type, (array) $bp->profile->field_types ) )
    812811        return false;
    813    
     812
    814813    /* Instantiate a new field object */
    815814    if ( $field_id )
     
    819818
    820819    $field->group_id = $field_group_id;
    821    
     820
    822821    if ( !empty( $parent_id ) )
    823822        $field->parent_id = $parent_id;
    824    
     823
    825824    if ( !empty( $type ) )
    826825        $field->type = $type;
    827    
     826
    828827    if ( !empty( $name ) )
    829828        $field->name = $name;
     
    831830    if ( !empty( $description ) )
    832831        $field->description = $description;
    833    
     832
    834833    if ( !empty( $is_required ) )
    835834        $field->is_required = $is_required;
    836        
     835
    837836    if ( !empty( $can_delete ) )
    838837        $field->can_delete = $can_delete;
    839    
     838
    840839    if ( !empty( $field_order ) )
    841840        $field->field_order = $field_order;
    842    
     841
    843842    if ( !empty( $order_by ) )
    844843        $field->order_by = $order_by;
    845    
     844
    846845    if ( !empty( $is_default_option ) )
    847846        $field->is_default_option = $is_default_option;
    848    
     847
    849848    if ( !empty( $option_order ) )
    850849        $field->option_order = $option_order;
    851    
     850
    852851    if ( !$field->save() )
    853852        return false;
     
    872871 *
    873872 * Fetches profile data for a specific field for the user.
    874  * 
     873 *
    875874 * @package BuddyPress Core
    876875 * @param $field The ID of the field, or the $name of the field.
     
    882881function xprofile_get_field_data( $field, $user_id = null ) {
    883882    global $bp;
    884    
     883
    885884    if ( !$user_id )
    886885        $user_id = $bp->displayed_user->id;
    887    
     886
    888887    if ( !$user_id )
    889888        return false;
     
    904903 *
    905904 * A simple function to set profile data for a specific field for a specific user.
    906  * 
     905 *
    907906 * @package BuddyPress Core
    908907 * @param $field The ID of the field, or the $name of the field.
     
    918917    else
    919918        $field_id = xprofile_get_field_id_from_name( $field );
    920    
     919
    921920    if ( !$field_id )
    922921        return false;
    923    
     922
    924923    $field = new BP_XProfile_ProfileData();
    925924    $field->field_id = $field_id;
    926925    $field->user_id = $user_id;
    927926    $field->value = maybe_serialize( $value );
    928    
     927
    929928    return $field->save();
    930929}
     
    935934    else
    936935        $field_id = xprofile_get_field_id_from_name( $field );
    937    
     936
    938937    if ( !$field_id )
    939938        return false;
    940    
     939
    941940    $field = new BP_XProfile_ProfileData( $field_id );
    942941    return $field->delete();
     
    945944function xprofile_check_is_required_field( $field_id ) {
    946945    $field = new BP_Xprofile_Field( $field_id );
    947    
     946
    948947    if ( (int)$field->is_required )
    949948        return true;
    950    
     949
    951950    return false;
    952951}
     
    956955 *
    957956 * Returns the ID for the field based on the field name.
    958  * 
     957 *
    959958 * @package BuddyPress Core
    960959 * @param $field_name The name of the field to get the ID for.
     
    969968 *
    970969 * Fetches a random piece of profile data for the user.
    971  * 
     970 *
    972971 * @package BuddyPress Core
    973972 * @param $user_id User ID of the user to get random data for
     
    982981    $field_data = BP_XProfile_ProfileData::get_random( $user_id, $exclude_fullname );
    983982    $field_data[0]->value = xprofile_format_profile_field( $field_data[0]->type, $field_data[0]->value );
    984    
     983
    985984    if ( !$field_data[0]->value || empty( $field_data[0]->value ) )
    986985        return false;
    987    
     986
    988987    return apply_filters( 'xprofile_get_random_profile_data', $field_data );
    989988}
     
    993992 *
    994993 * Formats a profile field according to its type. [ TODO: Should really be moved to filters ]
    995  * 
     994 *
    996995 * @package BuddyPress Core
    997996 * @param $field_type The type of field: datebox, selectbox, textbox etc
     
    10031002    if ( !isset($field_value) || empty( $field_value ) )
    10041003        return false;
    1005        
     1004
    10061005    $field_value = bp_unserialize_profile_field( $field_value );
    1007        
     1006
    10081007    if ( 'datebox' == $field_type ) {
    10091008        $field_value = bp_format_time( $field_value, true );
     
    10131012        $field_value = str_replace(']]>', ']]&gt;', $content);
    10141013    }
    1015    
     1014
    10161015    return stripslashes( stripslashes( $field_value ) );
    10171016}
     
    10251024 *
    10261025 * Setup the avatar upload directory for a user.
    1027  * 
     1026 *
    10281027 * @package BuddyPress Core
    10291028 * @param $directory The root directory name
     
    10361035    if ( !$user_id )
    10371036        $user_id = $bp->displayed_user->id;
    1038    
     1037
    10391038    if ( !$directory )
    10401039        $directory = 'avatars';
     
    10451044
    10461045    $newbdir = $newdir;
    1047    
     1046
    10481047    if ( !file_exists( $newdir ) )
    10491048        @wp_mkdir_p( $newdir );
     
    10601059 *
    10611060 * Syncs Xprofile data to the standard built in WordPress profile data.
    1062  * 
     1061 *
    10631062 * @package BuddyPress Core
    10641063 */
    10651064function xprofile_sync_wp_profile() {
    10661065    global $bp, $wpdb;
    1067    
     1066
    10681067    if ( (int)get_site_option( 'bp-disable-profile-sync' ) )
    10691068        return true;
    1070    
     1069
    10711070    $fullname = xprofile_get_field_data( BP_XPROFILE_FULLNAME_FIELD_NAME, $bp->loggedin_user->id );
    10721071    $space = strpos( $fullname, ' ' );
    1073    
     1072
    10741073    if ( false === $space ) {
    10751074        $firstname = $fullname;
     
    10771076    } else {
    10781077        $firstname = substr( $fullname, 0, $space );
    1079         $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );     
    1080     }
    1081    
     1078        $lastname = trim( substr( $fullname, $space, strlen($fullname) ) );
     1079    }
     1080
    10821081    update_usermeta( $bp->loggedin_user->id, 'nickname', $fullname );
    10831082    update_usermeta( $bp->loggedin_user->id, 'first_name', $firstname );
     
    10951094 * Removes notifications from the notification menu when a user clicks on them and
    10961095 * is taken to a specific screen.
    1097  * 
     1096 *
    10981097 * @package BuddyPress Core
    10991098 */
    11001099function xprofile_remove_screen_notifications() {
    11011100    global $bp;
    1102    
     1101
    11031102    bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->profile->id, 'new_wire_post' );
    11041103}
     
    11111110 * profile data from each table. Also we need to clean anything up in the usermeta table
    11121111 * that this component uses.
    1113  * 
     1112 *
    11141113 * @package BuddyPress XProfile
    11151114 * @param $user_id The ID of the deleted user
     
    11201119function xprofile_remove_data( $user_id ) {
    11211120    BP_XProfile_ProfileData::delete_data_for_user( $user_id );
    1122    
     1121
    11231122    // delete any avatar files.
    11241123    @unlink( get_usermeta( $user_id, 'bp_core_avatar_v1_path' ) );
    11251124    @unlink( get_usermeta( $user_id, 'bp_core_avatar_v2_path' ) );
    1126    
     1125
    11271126    // unset the usermeta for avatars from the usermeta table.
    11281127    delete_usermeta( $user_id, 'bp_core_avatar_v1' );
     
    11441143
    11451144function xprofile_clear_profile_data_object_cache( $group_id ) {
    1146     global $bp; 
     1145    global $bp;
    11471146    wp_cache_delete( 'xprofile_fields_' . $group_id . '_' . $bp->loggedin_user->id, 'bp' );
    11481147    wp_cache_delete( 'bp_user_fullname_' . $bp->loggedin_user->id, 'bp' );
  • trunk/bp-xprofile/bp-xprofile-admin.php

    r2066 r2077  
    44/**************************************************************************
    55 xprofile_admin()
    6  
     6
    77 Handles all actions for the admin area for creating, editing and deleting
    88 profile groups and fields.
     
    3131        xprofile_admin_manage_group($_GET['group_id']);
    3232    } else {
    33 ?> 
     33?>
    3434    <div class="wrap">
    35        
     35
    3636        <h2><?php _e( 'Profile Field Setup', 'buddypress') ?></h2>
    3737        <br />
    38         <p><?php _e( 'Your users will distinguish themselves through their profile page. 
    39            You must give them profile fields that allow them to describe themselves 
     38        <p><?php _e( 'Your users will distinguish themselves through their profile page.
     39           You must give them profile fields that allow them to describe themselves
    4040            in a way that is relevant to the theme of your social network.', 'buddypress') ?></p>
    41            
     41
    4242        <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p>
    43        
     43
    4444        <form action="" id="profile-field-form" method="post">
    45            
     45
    4646            <?php wp_nonce_field( 'bp_reorder_fields', '_wpnonce_reorder_fields' ); ?>
    47                    
     47
    4848            <?php
    4949                if ( $message != '' ) {
     
    5454                </div>
    5555            <?php }
    56        
     56
    5757            if ( $groups ) { ?>
    58                 <?php 
     58                <?php
    5959                for ( $i = 0; $i < count($groups); $i++ ) { // TODO: foreach
    6060                ?>
     
    6565                                <th scope="col">&nbsp;</th>
    6666                                <th scope="col" colspan="<?php if ( $groups[$i]->can_delete ) { ?>3<?php } else { ?>5<?php } ?>"><?php echo attribute_escape( $groups[$i]->name ); ?></th>
    67                                 <?php if ( $groups[$i]->can_delete ) { ?>       
     67                                <?php if ( $groups[$i]->can_delete ) { ?>
    6868                                    <th scope="col"><a class="edit" href="admin.php?page=bp-profile-setup&amp;mode=edit_group&amp;group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Edit', 'buddypress' ) ?></a></th>
    6969                                    <th scope="col"><a class="delete" href="admin.php?page=bp-profile-setup&amp;mode=delete_group&amp;group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>"><?php _e( 'Delete', 'buddypress' ) ?></a></th>
     
    7979                        </thead>
    8080                        <tbody id="the-list">
    81                        
     81
    8282                          <?php if ( $groups[$i]->fields ) { ?>
    83                            
     83
    8484                                <?php for ( $j = 0; $j < count($groups[$i]->fields); $j++ ) { ?>
    85                        
    86                                     <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?>     
     85
     86                                    <?php if ( 0 == $j % 2 ) { $class = ""; } else { $class = "alternate"; } ?>
    8787                                    <?php $field = new BP_XProfile_Field($groups[$i]->fields[$j]->id); ?>
    8888                                    <?php if ( !$field->can_delete ) { $class .= ' core'; } ?>
    89                            
     89
    9090                                    <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) { echo ' ' . $class; } ?>">
    9191                                        <td width="10"><img src="<?php echo BP_PLUGIN_URL ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ) ?>" /></td>
     
    9696                                        <td style="text-align:center;"><?php if ( !$field->can_delete ) { ?><strike><?php _e( 'Delete', 'buddypress' ) ?></strike><?php } else { ?><a class="delete" href="admin.php?page=bp-profile-setup&amp;field_id=<?php echo attribute_escape( $field->id ); ?>&amp;mode=delete_field"><?php _e( 'Delete', 'buddypress' ) ?></a><?php } ?></td>
    9797                                    </tr>
    98                            
     98
    9999                                <?php } ?>
    100                            
     100
    101101                            <?php } else { ?>
    102                            
     102
    103103                                <tr class="nodrag">
    104104                                    <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ) ?></td>
    105105                                </tr>
    106                            
     106
    107107                            <?php } ?>
    108                    
     108
    109109                        </tbody>
    110                    
     110
    111111                        <tfoot>
    112                        
     112
    113113                                <tr class="nodrag">
    114114                                    <td colspan="6"><a href="admin.php?page=bp-profile-setup&amp;group_id=<?php echo attribute_escape( $groups[$i]->id ); ?>&amp;mode=add_field"><?php _e( 'Add New Field', 'buddypress' ) ?></a></td>
    115115                                </tr>
    116                        
     116
    117117                        </tfoot>
    118                    
     118
    119119                    </table>
    120120                    </p>
    121                
     121
    122122                <?php } /* End For */ ?>
    123            
     123
    124124                    <p>
    125125                        <a class="button" href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ) ?></a>
    126126                    </p>
    127                
     127
    128128            <?php } else { ?>
    129129                <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div>
    130130                <p><a href="admin.php?page=bp-profile-setup&amp;mode=add_group"><?php _e( 'Add New Group', 'buddypress' ) ?></a></p>
    131131            <?php } ?>
    132        
     132
    133133        </form>
    134        
     134
    135135    </div>
    136136<?php
     
    141141/**************************************************************************
    142142 xprofile_admin_manage_group()
    143  
     143
    144144 Handles the adding or editing of groups.
    145145 **************************************************************************/
     
    154154            $group->name = wp_filter_kses( $_POST['group_name'] );
    155155            $group->description = wp_filter_kses( $_POST['group_desc'] );
    156            
     156
    157157            if ( !$group->save() ) {
    158158                $message = __('There was an error saving the group. Please try again', 'buddypress');
     
    161161                $message = __('The group was saved successfully.', 'buddypress');
    162162                $type = 'success';
    163                
     163
    164164                do_action( 'xprofile_groups_saved_group', $group );
    165165            }
    166            
     166
    167167            unset($_GET['mode']);
    168168            xprofile_admin( $message, $type );
     
    172172        }
    173173    } else {
    174         $group->render_admin_form();               
     174        $group->render_admin_form();
    175175    }
    176176}
     
    178178/**************************************************************************
    179179 xprofile_admin_delete_group()
    180  
     180
    181181 Handles the deletion of profile data groups.
    182182 **************************************************************************/
     
    184184function xprofile_admin_delete_group( $group_id ) {
    185185    global $message, $type;
    186    
     186
    187187    $group = new BP_XProfile_Group($group_id);
    188    
     188
    189189    if ( !$group->delete() ) {
    190190        $message = __('There was an error deleting the group. Please try again', 'buddypress');
     
    193193        $message = __('The group was deleted successfully.', 'buddypress');
    194194        $type = 'success';
    195        
     195
    196196        do_action( 'xprofile_groups_deleted_group', $group );
    197197    }
    198    
     198
    199199    unset($_GET['mode']); // TODO: wtf?
    200200    xprofile_admin( $message, $type );
     
    204204/**************************************************************************
    205205 xprofile_admin_manage_field()
    206  
     206
    207207 Handles the adding or editing of profile field data for a user.
    208208 **************************************************************************/
     
    210210function xprofile_admin_manage_field( $group_id, $field_id = null ) {
    211211    global $bp, $wpdb, $message, $groups;
    212    
     212
    213213    $field = new BP_XProfile_Field($field_id);
    214214    $field->group_id = $group_id;
     
    228228                $field->field_order++;
    229229            }
    230            
     230
    231231            if ( !$field->save() ) {
    232232                $message = __('There was an error saving the field. Please try again', 'buddypress');
    233233                $type = 'error';
    234                
     234
    235235                unset($_GET['mode']);
    236236                xprofile_admin($message, $type);
     
    238238                $message = __('The field was saved successfully.', 'buddypress');
    239239                $type = 'success';
    240                
     240
    241241                unset($_GET['mode']);
    242                
     242
    243243                do_action( 'xprofile_fields_saved_field', $field );
    244                
     244
    245245                $groups = BP_XProfile_Group::get_all();
    246246                xprofile_admin( $message, $type );
     
    250250        }
    251251    } else {
    252         $field->render_admin_form();               
     252        $field->render_admin_form();
    253253    }
    254254}
     
    256256/**************************************************************************
    257257 xprofile_admin_delete_field()
    258  
     258
    259259 Handles the deletion of a profile field [or option].
    260260**************************************************************************/
     
    262262function xprofile_admin_delete_field( $field_id, $type = 'field' ) {
    263263    global $message, $type;
    264    
     264
    265265    if ( 'field' == $type ) {
    266266        $type = __('field', 'buddypress');
     
    268268        $type = __('option', 'buddypress');
    269269    }
    270    
     270
    271271    $field = new BP_XProfile_Field($field_id);
    272272
     
    277277        $message = sprintf( __('The %s was deleted successfully!', 'buddypress'), $type);
    278278        $type = 'success';
    279        
     279
    280280        do_action( 'xprofile_fields_deleted_field', $field );
    281281    }
    282    
     282
    283283    unset($_GET['mode']);
    284284    xprofile_admin($message, $type);
     
    287287function xprofile_ajax_reorder_fields() {
    288288    global $bp;
    289    
     289
    290290    /* Check the nonce */
    291291    check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' );
    292    
     292
    293293    if ( empty( $_POST['field_order'] ) )
    294294        return false;
    295    
     295
    296296    parse_str($_POST['field_order'], $order );
    297297
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r2066 r2077  
    77    var $can_delete;
    88    var $fields;
    9    
     9
    1010    function bp_xprofile_group( $id = null ) {
    1111        global $bp, $wpdb;
     
    1515        }
    1616    }
    17    
     17
    1818    function populate( $id ) {
    1919        global $wpdb, $bp;
    20        
     20
    2121        $sql = $wpdb->prepare("SELECT * FROM {$bp->profile->table_name_groups} WHERE id = %d", $id);
    2222
     
    2626            $this->description = $group->description;
    2727            $this->can_delete = $group->can_delete;
    28            
     28
    2929            // get the fields for this group.
    3030            $this->fields = $this->get_fields();
     
    3535    function save() {
    3636        global $wpdb, $bp;
    37        
     37
    3838        $this->name = apply_filters( 'xprofile_group_name_before_save', $this->name, $this->id );
    3939        $this->description = apply_filters( 'xprofile_group_description_before_save', $this->description, $this->id );
     
    4444            $sql = $wpdb->prepare( "UPDATE {$bp->profile->table_name_groups} SET name = %s, description = %s WHERE id = %d", $this->name, $this->description, $this->id );
    4545        } else {
    46             $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description );       
    47         }
    48        
     46            $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description );
     47        }
     48
    4949        if ( !$wpdb->query($sql) )
    5050            return false;
    5151
    5252        do_action( 'xprofile_group_after_save', $this );
    53        
     53
    5454        return true;
    5555    }
    56    
     56
    5757    function delete() {
    5858        global $wpdb, $bp;
    59        
     59
    6060        if ( !$this->can_delete )
    6161            return false;
    62        
     62
    6363        $sql = $wpdb->prepare( "DELETE FROM {$bp->profile->table_name_groups} WHERE id = %d", $this->id );
    6464
     
    6969            if ( BP_XProfile_Field::delete_for_group($this->id) ) {
    7070                // Now delete all the profile data for the groups fields
    71                 for ( $i = 0; $i < count($this->fields); $i++ ) {   
     71                for ( $i = 0; $i < count($this->fields); $i++ ) {
    7272                    BP_XProfile_ProfileData::delete_for_field($this->fields[$i]->id);
    7373                }
    7474            }
    75            
     75
    7676            return true;
    7777        }
    7878    }
    79    
     79
    8080    function get_fields() {
    8181        global $wpdb, $bp;
    82        
     82
    8383        /* Find the max value for field_order, if it is zero, order by field_id instead -- provides backwards compat ordering */
    8484        if ( !(int) $wpdb->get_var( $wpdb->prepare( "SELECT MAX(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $this->id ) ) )
     
    9090        if ( !$fields = $wpdb->get_results( $wpdb->prepare("SELECT id, type FROM {$bp->profile->table_name_fields} WHERE group_id = %d AND parent_id = 0 {$order_sql}", $this->id ) ) )
    9191            return false;
    92        
     92
    9393        return $fields;
    9494    }
    95    
     95
    9696    /** Static Functions **/
    97    
     97
    9898    function get_all( $hide_empty = false ) {
    9999        global $wpdb, $bp;
     
    107107        if ( !$groups_temp = $wpdb->get_results($sql) )
    108108            return false;
    109            
     109
    110110        for ( $i = 0; $i < count($groups_temp); $i++ ) {
    111111            $group = new BP_XProfile_Group($groups_temp[$i]->id);
     
    115115        return $groups;
    116116    }
    117