Skip to:
Content

BuddyPress.org

Changeset 375


Ignore:
Timestamp:
10/09/2008 04:37:49 AM (16 years ago)
Author:
apeatling
Message:
  • Moved all group pages to the root, rather than using a member URL
  • Introduced groupmeta support - groups_update_groupmeta / groups_delete_groupmeta / groups_get_groupmeta
  • Added widgets for site wide activity and who's online
  • Updated home theme to support display of new BuddyPress widgets
  • Added site wide activity feed support
  • Fixed bug where ajax functions would only work when logged in
  • Various other bug fixes
Location:
trunk
Files:
3 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r373 r375  
    33
    44define ( 'BP_ACTIVITY_IS_INSTALLED', 1 );
    5 define ( 'BP_ACTIVITY_VERSION', '0.1.8' );
    6 
    7 /* Use english formatted times - e.g. 6 hours / 8 hours / 1 day / 15 minutes */
    8 define ( 'BP_ACTIVITY_CACHE_LENGTH', '6 hours' );
     5define ( 'BP_ACTIVITY_VERSION', '0.1.9' );
     6
     7/* How long before activity items in streams are re-cached? */
     8define ( 'BP_ACTIVITY_CACHE_LENGTH', '6 HOURS' );
    99
    1010include_once( 'bp-activity/bp-activity-classes.php' );
     11include_once( 'bp-activity/bp-activity-templatetags.php' );
     12include_once( 'bp-activity/bp-activity-widgets.php' );
    1113//include_once( 'bp-activity/bp-activity-ajax.php' );
    1214//include_once( 'bp-activity/bp-activity-cssjs.php' );
    13 /*include_once( 'bp-messages/bp-activity-admin.php' );*/
    14 include_once( 'bp-activity/bp-activity-templatetags.php' );
    15 
     15//include_once( 'bp-activity/bp-activity-admin.php' );
    1616
    1717/**************************************************************************
     
    6464                KEY component_name (component_name)
    6565               );";
     66
     67    $sql[] = "CREATE TABLE ". $bp['activity']['table_name_sitewide'] ." (
     68                id int(11) NOT NULL AUTO_INCREMENT,
     69                user_id int(11) NOT NULL,
     70                content longtext NOT NULL,
     71                component_name varchar(75) NOT NULL,
     72                date_cached datetime NOT NULL,
     73                date_recorded datetime NOT NULL,
     74                PRIMARY KEY id (id),
     75                KEY date_cached (date_cached),
     76                KEY date_recorded (date_recorded),
     77                KEY user_id (user_id),
     78                KEY component_name (component_name)
     79               );";
    6680   
    6781    require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
     
    89103       
    90104        'table_name_loggedin_user_friends_cached' => $wpdb->base_prefix . $bp['loggedin_homebase_id'] . '_friends_activity_cached',
     105        'table_name_sitewide' => $wpdb->base_prefix . 'bp_activity_sitewide',
    91106       
    92107        'image_base' => site_url() . '/wp-content/mu-plugins/bp-activity/images',
  • trunk/bp-activity/bp-activity-classes.php

    r364 r375  
    6767            $activity_cached = $wpdb->query( $wpdb->prepare( "INSERT INTO " . $this->table_name_cached . " ( content, component_name, date_cached, date_recorded, is_private ) VALUES ( %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d), %d )", $activity_content, $this->component_name, time(), $this->date_recorded, $this->is_private ) );
    6868       
     69            // Add the cached version of the activity to the cached activity table.
     70            $sitewide_cached = $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp['activity']['table_name_sitewide'] . " ( user_id, content, component_name, date_cached, date_recorded ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d), FROM_UNIXTIME(%d) )", $bp['loggedin_userid'], $activity_content, $this->component_name, time(), $this->date_recorded ) );
     71           
    6972            if ( $activity && $activity_cached )
    7073                return true;
     
    104107        $last_cached = get_usermeta( $bp['current_userid'], 'bp_activity_last_cached' );
    105108       
    106         if ( strtotime( BP_ACTIVITY_CACHE_LENGTH, (int)$last_cached ) >= time() ) {
     109        if ( strtotime( BP_ACTIVITY_CACHE_LENGTH, (int)$last_cached ) <= time() ) {
    107110           
    108111            //echo '<small style="color: green">** Debug: Using Cache **</small>';
     
    140143                    unset($activities_formatted[$i]);
    141144            }
    142            
     145       
    143146            if ( count($activities_formatted) )
    144                 BP_Activity_Activity::cache_activities( $activities_formatted );
     147                BP_Activity_Activity::cache_activities( $activities_formatted, $user_id );
    145148        }
    146149       
     
    209212    }
    210213   
     214    function get_sitewide_activity( $limit = 15 ) {
     215        global $wpdb, $bp;
     216       
     217        if ( $limit )
     218            $limit_sql = $wpdb->prepare( " LIMIT %d", $limit );
     219       
     220        /* Remove entries that are older than 1 week */
     221        $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['activity']['table_name_sitewide'] . " WHERE DATE_ADD(date_recorded, INTERVAL 1 WEEK) <= NOW()" ) );
     222       
     223        $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $bp['activity']['table_name_sitewide'] . " ORDER BY date_recorded DESC $limit_sql" ) );
     224       
     225        for ( $i = 0; $i < count( $activities ); $i++ ) {
     226            $activities_formatted[$i]['content'] = $activities[$i]->content;
     227            $activities_formatted[$i]['date_recorded'] = $activities[$i]->date_recorded;
     228            $activities_formatted[$i]['component_name'] = $activities[$i]->component_name;
     229        }
     230       
     231        return $activities_formatted;
     232    }
     233   
    211234    function cache_friends_activities( $activity_array ) {
    212235        global $wpdb, $bp;
     
    223246    }
    224247   
    225     function cache_activities( $activity_array ) {
     248    function cache_activities( $activity_array, $user_id ) {
    226249        global $wpdb, $bp;
    227250       
     
    229252        $wpdb->query( "TRUNCATE TABLE " . $bp['activity']['table_name_current_user_cached'] );
    230253       
     254        /* Empty user's activities from the sitewide stream */
     255        $wpdb->query( $wpdb->prepare( "DELETE FROM " . $bp['activity']['table_name_sitewide'] . " WHERE user_id = %d", $user_id ) );
     256       
    231257        for ( $i = 0; $i < count($activity_array); $i++ ) {
     258            if ( $activity_array[$i]['content'] == '' ) continue;
     259           
    232260            // Cache that sucka...
    233261            $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp['activity']['table_name_current_user_cached'] . " ( content, component_name, date_cached, date_recorded, is_private ) VALUES ( %s, %s, FROM_UNIXTIME(%d), %s, %d )", $activity_array[$i]['content'], $activity_array[$i]['component_name'], time(), $activity_array[$i]['date_recorded'], $activity_array[$i]['is_private'] ) );
     262           
     263            // Add to the sitewide activity stream
     264            if ( !$activity_array[$i]['is_private'] )
     265                $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp['activity']['table_name_sitewide'] . " ( user_id, content, component_name, date_cached, date_recorded ) VALUES ( %d, %s, %s, FROM_UNIXTIME(%d), %s )", $user_id, $activity_array[$i]['content'], $activity_array[$i]['component_name'], time(), $activity_array[$i]['date_recorded'] ) );
    234266        }
    235267       
  • trunk/bp-activity/bp-activity-templatetags.php

    r364 r375  
    134134
    135135function bp_activity_content_filter( $content, $date_recorded, $full_name, $insert_time = true, $is_home = true ) {
    136 
     136    if ( !$content )
     137        return false;
     138       
    137139    /* Split the content so we don't evaluate and replace text on content we don't want to */
    138140    $content = explode( '%s', $content );
  • trunk/bp-blogs.php

    r373 r375  
    222222            $post = BP_Blogs_Post::fetch_post_content($post);
    223223
    224             $content = bp_core_get_userlink($post->user_id) . ' ' . __('wrote a new blog post') . ' <a href="' . bp_post_get_permalink( $post, $post->blog_id ) . '">' . $post->post_title . '</a> <span class="time-since">%s</span>';     
     224            $content = bp_core_get_userlink($post->post_author_id) . ' ' . __('wrote a new blog post') . ' <a href="' . bp_post_get_permalink( $post, $post->blog_id ) . '">' . $post->post_title . '</a> <span class="time-since">%s</span>';     
    225225            $content .= '<blockquote>' . bp_create_excerpt($post->post_content) . '</blockquote>';
    226226            return $content;
  • trunk/bp-blogs/bp-blogs-widgets.php

    r374 r375  
    4747                            <h4 class="item-title"><a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo apply_filters( 'the_title', $post->post_title ) ?></a></h4>
    4848                            <?php if ( !$counter ) : ?>
    49                                 <div class="item-content"><?php echo apply_filters( 'the_excerpt', $post->post_content ) ?></div>
     49                                <div class="item-content"><?php echo bp_create_excerpt($post->post_content) ?></div>
    5050                            <?php endif; ?>
    5151                            <div class="item-meta"><em>by <?php echo bp_core_get_userlink($post->post_author) ?> from the blog "<a href="<?php echo get_blog_option($post->blog_id, 'siteurl') ?>"><?php echo get_blog_option($post->blog_id, 'blogname') ?></a>"</em></div>
  • trunk/bp-core.php

    r373 r375  
    108108    if ( !$bp['current_component'] )
    109109        $bp['current_component'] = $bp['default_component'];
    110 
    111110}
    112111add_action( 'wp', 'bp_core_setup_globals', 1 );
     
    213212 */
    214213function bp_core_get_current_userid() {
    215     global $current_blog;
    216    
    217     /* Get the ID of the current blog being viewed. */
    218     $blog_id = $current_blog->blog_id;
    219    
     214    global $current_blog, $current_user;
     215   
     216    if ( $current_blog->blog_id == 1 )
     217        return $current_user->ID;
     218       
    220219    /* Check to see if this is a user home, and if it is, get the user id */
    221     if ( !$current_userid = bp_core_get_homebase_userid( $blog_id ) )
     220    if ( !$current_userid = bp_core_get_homebase_userid( $current_blog->blog_id ) )
    222221        return false; // return false if this is a normal blog, and not a user home.
    223222   
  • trunk/bp-core/bp-core-catchuri.php

    r359 r375  
    110110    $pages = $bp_path;
    111111   
    112     if ( $wpdb->blogid == $bp['current_homebase_id'] ) {
    113         if ( !file_exists( TEMPLATEPATH . "/header.php" ) || !file_exists( TEMPLATEPATH . "/footer.php" ) )
    114             wp_die( 'Please make sure your BuddyPress enabled theme includes a header.php and footer.php file.');
     112    if ( !file_exists( TEMPLATEPATH . "/header.php" ) || !file_exists( TEMPLATEPATH . "/footer.php" ) )
     113        wp_die( 'Please make sure your BuddyPress enabled theme includes a header.php and footer.php file.');
    115114
    116         do_action( 'get_header' );
    117         load_template( TEMPLATEPATH . "/header.php" );
    118    
    119         if ( is_array( $pages ) ) {
    120             foreach( $pages as $page ) {
    121                 if ( file_exists( TEMPLATEPATH . "/" . $page . ".php" ) ) {
    122                     load_template( TEMPLATEPATH . "/" . $page . ".php" );
    123                 }
    124             }
    125         } else {
    126             if ( file_exists( TEMPLATEPATH . "/" . $pages . ".php" ) ) {
    127                 load_template( TEMPLATEPATH . "/" . $pages . ".php" );
    128             } else {
    129                 load_template( TEMPLATEPATH . "/index.php" );
     115    do_action( 'get_header' );
     116    load_template( TEMPLATEPATH . "/header.php" );
     117
     118    if ( is_array( $pages ) ) {
     119        foreach( $pages as $page ) {
     120            if ( file_exists( TEMPLATEPATH . "/" . $page . ".php" ) ) {
     121                load_template( TEMPLATEPATH . "/" . $page . ".php" );
    130122            }
    131123        }
    132    
    133         do_action( 'get_footer' );
    134         load_template( TEMPLATEPATH . "/footer.php" );
    135         die;
     124    } else {
     125        if ( file_exists( TEMPLATEPATH . "/" . $pages . ".php" ) ) {
     126            load_template( TEMPLATEPATH . "/" . $pages . ".php" );
     127        } else {
     128            if ( file_exists( TEMPLATEPATH . "/home.php" ) )
     129                load_template( TEMPLATEPATH . "/home.php" );
     130            else
     131                load_template( TEMPLATEPATH . "/index.php" );   
     132        }
    136133    }
     134
     135    do_action( 'get_footer' );
     136    load_template( TEMPLATEPATH . "/footer.php" );
     137    die;
    137138}
    138139?>
  • trunk/bp-core/bp-core-classes.php

    r373 r375  
    9494            $limit = 5;
    9595           
    96         return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$wpdb->base_prefix}usermeta um WHERE meta_key = 'last_activity' ORDER BY meta_value ASC LIMIT %d", $limit ) );
     96        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$wpdb->base_prefix}usermeta um WHERE meta_key = 'last_activity' ORDER BY meta_value DESC LIMIT %d", $limit ) );
    9797    }
    9898
     
    107107
    108108        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$wpdb->base_prefix}usermeta um WHERE meta_key = 'total_friend_count' ORDER BY meta_value DESC LIMIT %d", $limit ) );
     109    }
     110   
     111    function get_online_users( $limit = 5 ) {
     112        global $wpdb;
    109113       
     114        if ( !$limit )
     115            $limit = 5;
     116
     117        return $wpdb->get_results( $wpdb->prepare( "SELECT user_id FROM {$wpdb->base_prefix}usermeta um WHERE meta_key = 'last_activity' AND DATE_ADD( FROM_UNIXTIME(meta_value), INTERVAL 5 MINUTE ) >= NOW() ORDER BY meta_value DESC LIMIT %d", $limit ) );     
    110118    }
    111 
    112119}
    113120
  • trunk/bp-core/bp-core-cssjs.php

    r373 r375  
    2525 */
    2626function bp_core_add_ajax_js() {
    27     echo '<script type="text/javascript">var ajaxurl = "' . site_url() . '/wp-admin/admin-ajax.php";</script>';
     27    echo '<script type="text/javascript">var ajaxurl = "' . site_url() . '/wp-content/mu-plugins/bp-core/bp-core-ajax-handler.php";</script>';
    2828}
    2929add_action( 'wp_head', 'bp_core_add_ajax_js' );
  • trunk/bp-core/bp-core-templatetags.php

    r359 r375  
    2222 */
    2323function bp_get_nav() {
    24     global $bp;
     24    global $bp, $current_blog;
    2525   
    2626    /* Sort the nav by key as the array has been put together in different locations */
     
    3030    foreach( (array) $bp['bp_nav'] as $nav_item ) {
    3131        /* If the current component matches the nav item id, then add a highlight CSS class. */
    32         if ( $bp['current_component'] == $nav_item['css_id'] && $bp['current_userid'] == $bp['loggedin_userid'] ) {
     32        if ( $bp['current_component'] == $nav_item['css_id'] && bp_is_home() ) {
    3333            $selected = ' class="current"';
    3434        } else {
     
    3939           then check to see if the two users are friends. if they are, add a highligh CSS class
    4040           to the friends nav item if it exists. */
    41         if ( $bp['current_userid'] != $bp['loggedin_userid'] ) {
     41        if ( !bp_is_home() ) {
    4242            if ( function_exists('friends_check_friendship') ) {
    4343                if ( friends_check_friendship( $bp['current_userid'] ) == 'is_friend' && $nav_item['css_id'] == $bp['friends']['slug'] ) {
     
    5454   
    5555    /* Always add a log out list item to the end of the navigation */
    56     echo '<li><a id="wp-logout" href="' . get_option('home') . '/wp-login.php?action=logout">Log Out</a><li>';
     56    echo '<li><a id="wp-logout" href="' . site_url() . '/wp-login.php?action=logout">Log Out</a><li>';
    5757}
    5858
     
    301301}
    302302
     303function bp_loggedinuser_link() {
     304    global $bp;
     305    echo bp_core_get_userlink( $bp['loggedin_userid'] );
     306}
     307
    303308/* Template functions for fetching globals, without querying the DB again
    304309   also means we dont have to use the $bp variable in the template (looks messy) */
  • trunk/bp-core/bp-core-widgets.php

    r374 r375  
    1919        if ( is_active_widget( 'bp_core_widget_members' ) )
    2020            wp_enqueue_script( 'bp_core_widget_members-js', site_url() . '/wp-content/mu-plugins/bp-core/js/widget-members.js', array('jquery', 'jquery-livequery-pack') );     
    21     }
     21    } else {
     22       
     23        /* Widgets we specifically only want on member home bases, or blogs and not the main home blog */
     24
     25    }
     26   
     27    /* Widgets that can be enabled anywhere */
     28    register_sidebar_widget( __('Who\'s Online'), 'bp_core_widget_whos_online');
     29    register_widget_control( __('Who\'s Online'), 'bp_core_widget_whos_online_control' );   
     30
    2231}
    2332add_action( 'plugins_loaded', 'bp_core_register_widgets' );
     
    91100    <?php if ( $users ) : ?>
    92101        <div class="item-options" id="members-list-options">
    93             <img id="ajax-loader-members" src="<?php echo $bp['core']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" />
     102            <img id="ajax-loader-members" src="<?php echo $bp['core']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /> &nbsp;
    94103            <a href="<?php echo site_url() . '/members' ?>" id="newest-members" class="selected"><?php _e("Newest") ?></a> |
    95104            <a href="<?php echo site_url() . '/members' ?>" id="recently-active-members"><?php _e("Active") ?></a> |
     
    150159<?php
    151160}
     161
     162/*** WHO'S ONLINE WIDGET *****************/
     163
     164function bp_core_widget_whos_online($args) {
     165    global $current_blog;
     166   
     167    extract($args);
     168    $options = get_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online' );
     169?>
     170    <?php echo $before_widget; ?>
     171    <?php echo $before_title
     172        . $widget_name
     173        . $after_title; ?>
     174
     175    <?php $users = BP_Core_User::get_online_users($options['max_members']) ?>
     176
     177    <?php if ( $users ) : ?>
     178            <div class="avatar-block">
     179            <?php foreach ( (array) $users as $user ) : ?>
     180                <?php if ( !bp_core_user_has_home($user->user_id) || !$user->user_id ) continue; ?>
     181                <div class="item-avatar">
     182                    <a href="<?php echo bp_core_get_userurl($user->user_id) ?>" title="<?php bp_fetch_user_fullname( $user->user_id, true ) ?>"><?php echo bp_core_get_avatar( $user->user_id, 1 ) ?></a>
     183                </div>
     184            <?php endforeach; ?>
     185            </div>
     186        </ul>
     187
     188        <?php
     189        if ( function_exists('wp_nonce_field') )
     190            wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members' );
     191        ?>
     192
     193        <input type="hidden" name="bp_core_widget_members_max" id="bp_core_widget_members_max" value="<?php echo $options['max_members'] ?>" />
     194
     195    <?php else: ?>
     196        <div class="widget-error">
     197            <?php _e('There are no users currently online.') ?>
     198        </div>
     199    <?php endif; ?>
     200
     201    <?php echo $after_widget; ?>
     202<?php
     203}
     204
     205function bp_core_widget_whos_online_control() {
     206    global $current_blog;
     207   
     208    $options = $newoptions = get_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online' );
     209
     210    if ( $_POST['bp-widget-whos-online-submit'] ) {
     211        $newoptions['max_members'] = strip_tags( stripslashes( $_POST['bp-widget-whos-online-max-members'] ) );
     212    }
     213   
     214    if ( $options != $newoptions ) {
     215        $options = $newoptions;
     216        update_blog_option( $current_blog->blog_id, 'bp_core_widget_whos_online', $options );
     217    }
     218   
     219    $max_members = attribute_escape( $options['max_members'] );
     220?>
     221        <p><label for="bp-widget-whos-online-max-members"><?php _e('Maximum number of members to show:'); ?><br /><input class="widefat" id="bp-widget-whos-online-max-members" name="bp-widget-whos-online-max-members" type="text" value="<?php echo $max_members; ?>" style="width: 30%" /></label></p>
     222        <input type="hidden" id="bp-widget-whos-online-submit" name="bp-widget-whos-online-submit" value="1" />
     223<?php
     224}
  • trunk/bp-friends.php

    r373 r375  
    194194            $friendship = new BP_Friends_Friendship( $friendship_id, false, false );
    195195
    196             if ( !$friendship )
     196            if ( !$friendship->initiator_user_id || !$friendship->friend_user_id )
    197197                return false;
    198198           
  • trunk/bp-friends/bp-friends-ajax.php

    r373 r375  
    134134    if ( BP_Friends_Friendship::check_is_friend( $bp['loggedin_userid'], $_POST['fid'] ) == 'is_friend' ) {
    135135        if ( !friends_remove_friend( $bp['loggedin_userid'], $bp['current_userid'] ) ) {
    136             echo "-1[[SPLIT]]" . __("Friendship could not be canceled.");
     136            echo __("Friendship could not be canceled.");
    137137        } else {
    138138            friends_update_friend_totals( $bp['loggedin_userid'], $bp['current_userid'], 'remove' );
     
    141141    } else if ( BP_Friends_Friendship::check_is_friend( $bp['loggedin_userid'], $_POST['fid'] ) == 'not_friends' ) {
    142142        if ( !friends_add_friend( $bp['loggedin_userid'], $_POST['fid'] ) ) {
    143             echo "-1[[SPLIT]]" . __("Friend could not be added.");
     143            echo __("Friendship could not be requested.");
    144144        } else {
    145145            echo __('Friendship Requested');
  • trunk/bp-groups.php

    r373 r375  
    33
    44define ( 'BP_GROUPS_IS_INSTALLED', 1 );
    5 define ( 'BP_GROUPS_VERSION', '0.1.6' );
     5define ( 'BP_GROUPS_VERSION', '0.1.9' );
    66
    77include_once( 'bp-groups/bp-groups-classes.php' );
     
    5858            KEY is_confirmed (is_confirmed)
    5959           );";
     60
     61    $sql[] = "CREATE TABLE ". $bp['groups']['table_name_groupmeta'] ." (
     62            id int(11) NOT NULL AUTO_INCREMENT,
     63            group_id int(11) NOT NULL,
     64            meta_key varchar(255) DEFAULT NULL,
     65            meta_value longtext DEFAULT NULL,
     66            PRIMARY KEY (id),
     67            KEY group_id (group_id),
     68            KEY meta_key (meta_key)
     69           );";
    6070   
    6171    if ( function_exists('bp_wire_install') ) {
     
    8696 **************************************************************************/
    8797
    88 function groups_setup_globals() {
    89     global $bp, $wpdb;
    90 
     98function groups_setup_globals( $global = true ) {
     99    global $wpdb;
     100   
     101    if ( $global )
     102        global $bp;
     103   
    91104    $bp['groups'] = array(
    92105        'table_name' => $wpdb->base_prefix . 'bp_groups',
    93106        'table_name_members' => $wpdb->base_prefix . 'bp_groups_members',
     107        'table_name_groupmeta' => $wpdb->base_prefix . 'bp_groups_groupmeta',
    94108        'image_base' => site_url() . '/wp-content/mu-plugins/bp-groups/images',
    95109        'format_activity_function' => 'groups_format_activity',
     
    101115   
    102116    $bp['groups']['forbidden_names'] = array( 'my-groups', 'group-finder', 'create', 'invites', 'delete', 'add' );
     117
     118    return $bp;
    103119}
    104120add_action( 'wp', 'groups_setup_globals', 1 ); 
     
    124140    if ( ( $wpdb->get_var("show tables like '%" . $bp['groups']['table_name'] . "%'") == false ) || ( get_site_option('bp-groups-version') < BP_GROUPS_VERSION )  )
    125141        groups_install(BP_GROUPS_VERSION);
    126        
     142   
    127143}
    128144add_action( 'admin_menu', 'groups_add_admin_menu' );
     
    135151
    136152function groups_setup_nav() {
    137     global $bp;
     153    global $bp, $current_blog;
    138154    global $group_obj, $is_single_group;
    139155   
     
    151167    bp_core_add_nav_default( $bp['groups']['slug'], 'groups_screen_my_groups', 'my-groups' );
    152168       
    153     $groups_link = $group_link = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/';
     169    $groups_link = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/';
    154170   
    155171    /* Add the subnav items to the groups nav item */
     
    170186            $bp['bp_options_title'] = $bp['current_fullname'];
    171187           
    172         } else if ( $is_single_group ) {
     188        } else if ( $is_single_group ) {       
    173189            // We are viewing a single group, so set up the
    174190            // group navigation menu using the $group_obj global.
     
    183199            $bp['bp_options_avatar'] = '<img src="' . $group_obj->avatar_thumb . '" alt="Group Avatar Thumbnail" />';
    184200           
    185             $group_link = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/' . $group_obj->slug . '/';
     201            switch_to_blog(1);
     202            $group_link = site_url() . '/' . $bp['groups']['slug'] . '/' . $group_obj->slug . '/';
     203            switch_to_blog($current_blog->blog_id);
    186204           
    187205            // Reset the existing subnav items
     
    202220           
    203221            bp_core_add_subnav_item( $bp['groups']['slug'], 'members', __('Members'), $group_link, 'groups_screen_group_members', 'group-members' );
    204             bp_core_add_subnav_item( $bp['groups']['slug'], 'send-invites', __('Send Invites'), $group_link, 'groups_screen_group_invite', 'group-invite' );
    205222           
    206223            if ( is_user_logged_in() && groups_is_user_member( $bp['loggedin_userid'], $group_obj->id ) ) {
     224                bp_core_add_subnav_item( $bp['groups']['slug'], 'send-invites', __('Send Invites'), $group_link, 'groups_screen_group_invite', 'group-invite' );
    207225                bp_core_add_subnav_item( $bp['groups']['slug'], 'leave-group', __('Leave Group'), $group_link, 'groups_screen_group_leave', 'group-leave' );
    208226            }
     
    211229}
    212230add_action( 'wp', 'groups_setup_nav', 2 );
     231
     232function groups_get_group_theme() {
     233    global $current_component, $current_action, $is_single_group;
     234   
     235    // The theme filter does not recognize any globals, where as the stylesheet filter does.
     236    // We have to set up the globals to use manually.
     237    bp_core_set_uri_globals();
     238    $groups_bp = groups_setup_globals(false);
     239   
     240    if ( $current_component == $groups_bp['groups']['slug'] )
     241        $is_single_group = BP_Groups_Group::group_exists( $current_action, $groups_bp['groups']['table_name'] );
     242
     243    if ( $current_component == $groups_bp['groups']['slug'] && $is_single_group )
     244        $theme = 'buddypress';
     245    else
     246        $theme = get_option('template');
     247   
     248    return $theme;
     249}
     250add_filter( 'template', 'groups_get_group_theme' );
     251
     252function groups_get_group_stylesheet() {
     253    global $bp, $is_single_group;
     254   
     255    if ( $bp['current_component'] == $bp['groups']['slug'] && $is_single_group )   
     256        return 'buddypress';
     257    else
     258        return get_option('stylesheet');   
     259}
     260add_filter( 'stylesheet', 'groups_get_group_stylesheet' );
     261
    213262
    214263/***** Screens **********/
     
    334383                }
    335384            }
    336        
     385   
    337386        } else if ( $bp['action_variables'][1] == 'delete' && BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $group_obj->id ) ) {
    338                                            
    339             if ( !groups_delete_wire_post( $bp['action_variables'][2], $bp['groups']['table_name_wire'] ) ) {
     387            $wire_message_id = $bp['action_variables'][2];
     388                               
     389            if ( !groups_delete_wire_post( $wire_message_id, $bp['groups']['table_name_wire'] ) ) {
    340390                bp_catch_uri( 'groups/group-home' );
    341391            } else {
     
    412462            } else {
    413463                $bp['message'] = __('You left the group successfully.');
    414                 $bp['message_type'] = 'success';                                   
     464                $bp['message_type'] = 'success';   
    415465            }
    416466            add_action( 'template_notices', 'bp_core_render_notice' );
    417467       
    418             $is_single_group = false;
    419             $bp['current_action'] = 'group-finder';
    420             bp_catch_uri( 'groups/group-finder' );
     468            $bp['current_action'] = 'group-home';
     469            bp_catch_uri( 'groups/group-home' );
    421470       
    422471        } else if ( isset($bp['action_variables']) && $bp['action_variables'][1] == 'no' ) {
     
    445494        } else {
    446495            $bp['message'] = __('You joined the group!');
    447             $bp['message_type'] = 'success';                       
     496            $bp['message_type'] = 'success';   
    448497        }
    449498
     
    469518    }
    470519}
    471 add_action( 'bp_groups_joined_group', 'groups_record_activity' );
    472 add_action( 'bp_groups_created_group', 'groups_record_activity' );
    473 add_action( 'bp_groups_new_wire_post', 'groups_record_activity' );
     520add_action( 'activity_groups_joined_group', 'groups_record_activity' );
     521add_action( 'activity_groups_created_group', 'groups_record_activity' );
     522add_action( 'activity_groups_new_wire_post', 'groups_record_activity' );
    474523
    475524/**************************************************************************
     
    518567
    519568/**************************************************************************
    520  groups_admin_setup()
     569 groups_update_last_activity()
    521570 
    522  Setup CSS, JS and other things needed for the xprofile component.
    523 **************************************************************************/
    524 
    525 function groups_admin_setup() {
    526 }
    527 add_action( 'admin_menu', 'groups_admin_setup' );
    528 
     571 Sets groupmeta for the group with the last activity date for the group based
     572 on specific group activities.
     573 **************************************************************************/
     574
     575function groups_update_last_activity( $args = true ) {
     576    extract($args);
     577
     578    groups_update_groupmeta( $group_id, 'last_activity', time() );
     579}
     580add_action( 'groups_deleted_wire_post', 'groups_update_last_activity' );
     581add_action( 'groups_new_wire_post', 'groups_update_last_activity' );
     582add_action( 'groups_joined_group', 'groups_update_last_activity' );
     583add_action( 'groups_leave_group', 'groups_update_last_activity' );
     584add_action( 'groups_created_group', 'groups_update_last_activity' );
     585
     586
     587/**************************************************************************
     588 groups_get_user_groups()
     589 
     590 Fetch the groups the current user is a member of.
     591 **************************************************************************/
    529592
    530593function groups_get_user_groups( $pag_page, $pag_num ) {
     
    655718                    if ( !$group->save() )
    656719                        return false;
    657                    
     720                                       
    658721                    // Save the creator as the group administrator
    659722                    $admin = new BP_Groups_Member( $bp['loggedin_userid'], $group->id );
     
    663726                    $admin->inviter_id = 0;
    664727                    $admin->is_confirmed = 1;
    665                                    
     728
    666729                    if ( !$admin->save() )
    667730                        return false;
    668                        
     731                   
     732                    /* Set groupmeta */
     733                    groups_update_groupmeta( $group->id, 'total_member_count', 1 );
     734                    groups_update_groupmeta( $group->id, 'theme', 'buddypress' );
     735                    groups_update_groupmeta( $group->id, 'stylesheet', 'buddypress' );
     736                   
    669737                    return $group->id;
    670738                }
     
    680748                $group->enable_photos = 1;
    681749                $group->photos_admin_only = 0;
    682                 $group->date_created = time();
    683750               
    684751                if ( !isset($_POST['group-show-wire']) )
     
    727794                groups_send_invites($group);
    728795               
    729                 do_action( 'bp_groups_created_group', array( 'item_id' => $group->id, 'component_name' => 'groups', 'component_action' => 'created_group', 'is_private' => 0 ) );
     796                /* activity stream recording action */
     797                do_action( 'activity_groups_created_group', array( 'item_id' => $group->id, 'component_name' => 'groups', 'component_action' => 'created_group', 'is_private' => 0 ) );
     798               
     799                /* regular action */
     800                do_action( 'groups_created_group', array( 'group_id' => $group->id ) );
    730801               
    731802                header( "Location: " . $bp['loggedin_domain'] . $bp['groups']['slug'] . "/" . $group->slug );
     
    774845        return false;
    775846   
     847    do_action( 'groups_invite_user', array( 'group_id' => $group_id, 'user_id' => $user_id ) );
     848       
    776849    return true;
    777850}
     
    782855    if ( !BP_Groups_Member::delete( $user_id, $group_id ) )
    783856        return false;
    784    
     857
     858    do_action( 'groups_uninvite_user', array( 'group_id' => $group_id, 'user_id' => $user_id ) );
     859
    785860    return true;
    786861}
     
    824899        wp_mail( $invited_user->email, __("New Group Invitation:") . $group_obj->name, $message, "From: noreply@" . $_SERVER[ 'HTTP_HOST' ]  );
    825900    }
     901
     902    do_action( 'groups_send_invites', array( 'group_id' => $group_obj->id, 'invited_users' => $invited_users ) );
    826903}
    827904
     
    832909    if ( !groups_uninvite_user( $bp['loggedin_userid'], $group_id ) )
    833910        return false;
     911
     912    do_action( 'groups_leave_group', array( 'group_id' => $group_id, 'user_id' => $bp['loggedin_userid'] ) );
     913
     914    /* Modify group member count */
     915    groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') - 1 );
    834916   
    835917    return true;
     
    850932    if ( !$new_member->save() )
    851933        return false;
    852    
    853     do_action( 'bp_groups_joined_group', array( 'item_id' => $new_member->group_id, 'component_name' => 'groups', 'component_action' => 'joined_group', 'is_private' => 0 ) );
     934
     935    /* activity stream recording action */
     936    do_action( 'activity_groups_joined_group', array( 'item_id' => $new_member->group_id, 'component_name' => 'groups', 'component_action' => 'joined_group', 'is_private' => 0 ) );
     937   
     938    /* regular action */
     939    do_action( 'groups_joined_group', array( 'group_id' => $group_id, 'user_id' => $bp['loggedin_userid'] ) );
     940   
     941    /* Modify group member count */
     942    groups_update_groupmeta( $group_id, 'total_member_count', (int) groups_get_groupmeta( $group_id, 'total_member_count') + 1 );
    854943   
    855944    return true;
     
    858947function groups_new_wire_post( $group_id, $content ) {
    859948    if ( $wire_post_id = bp_wire_new_post( $group_id, $content ) ) {
    860         do_action( 'bp_groups_new_wire_post', array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post', 'is_private' => 0 ) );
     949       
     950        /* activity stream recording action */
     951        do_action( 'activity_groups_new_wire_post', array( 'item_id' => $wire_post_id, 'component_name' => 'groups', 'component_action' => 'new_wire_post', 'is_private' => 0 ) );
     952       
     953        /* regular action */
     954        do_action( 'groups_new_wire_post', array( 'group_id' => $group_id, 'wire_post_id' => $wire_post_id ) );
     955       
    861956        return true;
    862957    }
     
    867962function groups_delete_wire_post( $wire_post_id, $table_name ) {
    868963    if ( bp_wire_delete_post( $wire_post_id, $table_name ) ) {
    869         do_action( 'bp_groups_deleted_wire_post', array( 'wire_post_id' => $wire_post_id ) );
     964        do_action( 'groups_deleted_wire_post', array( 'wire_post_id' => $wire_post_id ) );
    870965        return true;
    871966    }
     
    873968    return false;
    874969}
     970
     971function groups_get_newest( $limit = 5 ) {
     972    return BP_Groups_Group::get_newest($limit);
     973}
     974
     975function groups_get_active( $limit = 5 ) {
     976    return BP_Groups_Group::get_active($limit);
     977}
     978
     979function groups_get_popular( $limit = 5 ) {
     980    return BP_Groups_Group::get_popular($limit);
     981}
     982
     983
     984//
     985// Group meta functions
     986//
     987
     988function groups_delete_groupmeta( $group_id, $meta_key, $meta_value = '' ) {
     989    global $wpdb, $bp;
     990   
     991    if ( !is_numeric( $group_id ) )
     992        return false;
     993       
     994    $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
     995
     996    if ( is_array($meta_value) || is_object($meta_value) )
     997        $meta_value = serialize($meta_value);
     998       
     999    $meta_value = trim( $meta_value );
     1000
     1001    if ( !empty($meta_value) )
     1002        $wpdb->query( $wpdb->prepare("DELETE FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE groups_id = %d AND meta_key = %s AND meta_value = %s", $group_id, $meta_key, $meta_value) );
     1003    else
     1004        $wpdb->query( $wpdb->prepare("DELETE FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) );
     1005
     1006    // TODO need to look into using this.
     1007    // wp_cache_delete($group_id, 'groups');
     1008
     1009    return true;
     1010}
     1011
     1012function groups_get_groupmeta( $group_id, $meta_key = '') {
     1013    global $wpdb, $bp;
     1014   
     1015    $group_id = (int) $group_id;
     1016
     1017    if ( !$group_id )
     1018        return false;
     1019
     1020    if ( !empty($meta_key) ) {
     1021        $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
     1022       
     1023        // TODO need to look into using this.
     1024        //$user = wp_cache_get($user_id, 'users');
     1025       
     1026        // Check the cached user object
     1027        //if ( false !== $user && isset($user->$meta_key) )
     1028        //  $metas = array($user->$meta_key);
     1029        //else
     1030        $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key) );
     1031    } else {
     1032        $metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d", $group_id) );
     1033    }
     1034
     1035    if ( empty($metas) ) {
     1036        if ( empty($meta_key) )
     1037            return array();
     1038        else
     1039            return '';
     1040    }
     1041
     1042    $metas = array_map('maybe_unserialize', $metas);
     1043
     1044    if ( count($metas) == 1 )
     1045        return $metas[0];
     1046    else
     1047        return $metas;
     1048}
     1049
     1050function groups_update_groupmeta( $group_id, $meta_key, $meta_value ) {
     1051    global $wpdb, $bp;
     1052   
     1053    if ( !is_numeric( $group_id ) )
     1054        return false;
     1055   
     1056    $meta_key = preg_replace( '|[^a-z0-9_]|i', '', $meta_key );
     1057
     1058    if ( is_string($meta_value) )
     1059        $meta_value = stripslashes($wpdb->escape($meta_value));
     1060       
     1061    $meta_value = maybe_serialize($meta_value);
     1062
     1063    if (empty($meta_value)) {
     1064        return groups_delete_groupmeta( $group_id, $meta_key );
     1065    }
     1066
     1067    $cur = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE group_id = %d AND meta_key = %s", $group_id, $meta_key ) );
     1068   
     1069    if ( !$cur ) {
     1070        $wpdb->query( $wpdb->prepare( "INSERT INTO " . $bp['groups']['table_name_groupmeta'] . " ( group_id, meta_key, meta_value ) VALUES ( %d, %s, %s )", $group_id, $meta_key, $meta_value ) );
     1071    } else if ( $cur->meta_value != $meta_value ) {
     1072        $wpdb->query( $wpdb->prepare( "UPDATE " . $bp['groups']['table_name_groupmeta'] . " SET meta_value = %s WHERE group_id = %d AND meta_key = %s", $meta_value, $group_id, $meta_key ) );
     1073    } else {
     1074        return false;
     1075    }
     1076
     1077    // TODO need to look into using this.
     1078    // wp_cache_delete($user_id, 'users');
     1079
     1080    return true;
     1081}
     1082
    8751083
    8761084function groups_remove_data( $user_id ) {
  • trunk/bp-groups/bp-groups-ajax.php

    r348 r375  
    9494                <img class="avatar" alt="Group Avatar" src="<?php echo $group->avatar_thumb ?>"/>
    9595                <h4>
    96                     <a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] . '/' . $group->slug ?>"><?php echo $group->name ?></a>
    97                     <span class="small"> - <?php echo count($group->user_dataset) ?> members</span>
     96                    <a href="<?php bp_group_permalink( $group ) ?>"><?php echo $group->name ?></a>
     97                    <span class="small"> - <?php echo $group->total_member_count . ' ' . __('members') ?></span>
    9898                </h4>
    9999                <p class="desc"><?php echo bp_create_excerpt( $group->description, 20 ) ?></p>
     
    150150                <img class="avatar" alt="Group Avatar" src="<?php echo $group->avatar_thumb ?>"/>
    151151                <h4>
    152                     <a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] . '/' . $group->slug ?>"><?php echo $group->name ?></a>
    153                     <span class="small"> - <?php echo count($group->user_dataset) ?> members</span>
     152                    <a href="<?php bp_group_permalink( $group ) ?>"><?php echo $group->name ?></a>
     153                    <span class="small"> - <?php echo $group->total_member_count . ' ' . __('members') ?></span>
    154154                </h4>
    155155                <p class="desc"><?php echo bp_create_excerpt( $group->description, 20 ) ?></p>
     
    164164}
    165165add_action( 'wp_ajax_group_finder_search', 'groups_ajax_group_finder_search' );
     166
     167
     168function groups_ajax_widget_groups_list() {
     169    global $bp;
     170
     171    check_ajax_referer('groups_widget_groups_list');
     172
     173    if ( !$bp ) {
     174        bp_core_setup_globals();
     175        groups_setup_globals();
     176    }
     177   
     178    switch ( $_POST['filter'] ) {
     179        case 'newest-groups':
     180            $groups = groups_get_newest($_POST['max-groups']);
     181        break;
     182        case 'recently-active-groups':
     183            $groups = groups_get_active($_POST['max-groups']);
     184        break;
     185        case 'popular-groups':
     186            $groups = groups_get_popular($_POST['max-groups']);
     187        break;
     188    }
     189
     190    if ( $groups ) {
     191        echo '0[[SPLIT]]'; // return valid result.
     192   
     193        foreach ( (array) $groups as $group ) {
     194            $group = new BP_Groups_Group( $group->group_id, false );
     195        ?>
     196            <li>
     197                <div class="item-avatar">
     198                    <img src="<?php echo $group->avatar_thumb ?>" class="avatar" alt="<?php echo $group->name ?> Avatar" />
     199                </div>
     200
     201                <div class="item">
     202                    <div class="item-title"><a href="<?php echo bp_group_permalink( $group, true ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div>
     203                    <div class="item-meta">
     204                        <span class="activity">
     205                            <?php
     206                            if ( $_POST['filter'] == 'newest-groups') {
     207                                echo bp_core_get_last_activity( $group->date_created, __('created '), __(' ago') );
     208                            } else if ( $_POST['filter'] == 'recently-active-groups') {
     209                                echo bp_core_get_last_activity( groups_get_groupmeta( $group->id, 'last_activity' ), __('active '), __(' ago') );
     210                            } else if ( $_POST['filter'] == 'popular-groups') {
     211                                if ( $group->total_member_count == 1 )
     212                                    echo $group->total_member_count . __(' member');
     213                                else
     214                                    echo $group->total_member_count . __(' members');
     215                            }
     216                            ?>
     217                        </span>
     218                    </div> 
     219                </div>
     220            </li>
     221            <?php   
     222        }
     223    } else {
     224        echo "-1[[SPLIT]]<li>" . __("No groups matched the current filter.");
     225    }
     226}
     227add_action( 'wp_ajax_widget_groups_list', 'groups_ajax_widget_groups_list' );
     228
    166229?>
  • trunk/bp-groups/bp-groups-classes.php

    r373 r375  
    5656            $this->enable_photos = $group->enable_photos;
    5757            $this->photos_admin_only = $group->photos_admin_only;
    58             $this->date_created = $group->date_created;
     58            $this->date_created = strtotime($group->date_created);
     59            $this->total_member_count = groups_get_groupmeta( $this->id, 'total_member_count' );
    5960           
    6061            if ( !$group->avatar_thumb )
     
    7071            if ( $get_user_dataset ) {
    7172                $this->user_dataset = $this->get_user_dataset();
    72                 $this->total_member_count = count( $this->user_dataset );
     73               
     74                if ( !$this->total_member_count ) {
     75                    $this->total_member_count = count( $this->user_dataset );
     76                    groups_update_groupmeta( $this->id, 'total_member_count', $this->total_member_count );
     77                }
    7378            }
    7479        }   
     
    159164            );
    160165        }
    161 
     166       
    162167        $result = $wpdb->query($sql);
    163168       
     
    221226            return false;
    222227       
     228        /* Remove groupmeta */
     229        groups_delete_groupmeta( $group_id );
     230       
    223231        return true;
    224232    }
    225233   
    226     function group_exists( $slug ) {
    227         global $wpdb, $bp;
    228         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM " . $bp['groups']['table_name'] . " WHERE slug = %s", $slug ) );
     234    function group_exists( $slug, $table_name = false ) {
     235        global $wpdb, $bp;
     236       
     237        if ( !$table_name )
     238            $table_name = $bp['groups']['table_name'];
     239           
     240        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $table_name WHERE slug = %s", $slug ) );
    229241    }
    230242
     
    313325            $limit = 5;
    314326
    315         return $wpdb->get_results( $wpdb->prepare( "SELECT id FROM " . $bp['groups']['table_name'] . " ORDER BY date_created DESC LIMIT %d", $limit ) );
     327        return $wpdb->get_results( $wpdb->prepare( "SELECT id as group_id FROM " . $bp['groups']['table_name'] . " ORDER BY date_created DESC LIMIT %d", $limit ) );
     328    }
     329   
     330    function get_active( $limit = 5 ) {
     331        global $wpdb, $bp;
     332       
     333        if ( !$limit )
     334            $limit = 5;
     335
     336        return $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE meta_key = 'last_activity' ORDER BY meta_value DESC LIMIT %d", $limit ) );
     337    }
     338   
     339    function get_popular( $limit = 5 ) {
     340        global $wpdb, $bp;
     341       
     342        if ( !$limit )
     343            $limit = 5;
     344
     345        return $wpdb->get_results( $wpdb->prepare( "SELECT group_id FROM " . $bp['groups']['table_name_groupmeta'] . " WHERE meta_key = 'total_member_count' ORDER BY meta_value DESC LIMIT %d", $limit ) );
    316346    }
    317347}
  • trunk/bp-groups/bp-groups-templatetags.php

    r373 r375  
    147147    global $groups_template;
    148148   
    149     ?><img src="<?php echo $groups_template->group->avatar_full ?>" class="avatar" alt="Group Avatar" /><?php
     149    ?><img src="<?php echo $groups_template->group->avatar_full ?>" class="avatar" alt="<?php echo $groups_template->group->name ?> Avatar" /><?php
    150150}
    151151
     
    153153    global $groups_template;
    154154   
    155     ?><img src="<?php echo $groups_template->group->avatar_thumb ?>" class="avatar" alt="Group Avatar" /><?php
    156 }
    157 
    158 
    159 function bp_group_permalink() {
    160     global $groups_template, $bp;
    161     echo $bp['current_domain'] . $bp['groups']['slug'] . '/' . $groups_template->group->slug;
     155    ?><img src="<?php echo $groups_template->group->avatar_thumb ?>" class="avatar" alt="<?php echo $groups_template->group->name ?> Avatar" /><?php
     156}
     157
     158
     159function bp_group_permalink( $group_obj = false, $echo = true ) {
     160    global $groups_template, $bp, $current_blog;
     161
     162    if ( !$group_obj )
     163        $group_obj = $groups_template->group;
     164   
     165    switch_to_blog(1);
     166   
     167    if ( $echo )
     168        echo site_url() . '/' . $bp['groups']['slug'] . '/' . $group_obj->slug;
     169    else
     170        return site_url() . '/' . $bp['groups']['slug'] . '/' . $group_obj->slug;
     171       
     172    switch_to_blog($current_blog->blog_id);
    162173}
    163174
     
    244255function bp_group_all_members_permalink() {
    245256    global $groups_template, $bp;
    246     echo $bp['current_domain'] . $bp['groups']['slug'] . '/' . $groups_template->group->slug . '/members';
     257    echo bp_group_permalink( false, true ) . '/members';
    247258}
    248259
     
    268279
    269280    if ( $bp['current_action'] == 'my-groups' || !$bp['current_action'] ) {
    270         $action = $bp['current_domain'] . $bp['groups']['slug'] . '/my-groups/search/';
     281        $action = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/my-groups/search/';
    271282        $label = __('Filter Groups');
    272283        $type = 'group';
    273284    } else {
    274         $action = $bp['current_domain'] . $bp['groups']['slug'] . '/group-finder/search/';
     285        $action = $bp['loggedin_domain'] . $bp['groups']['slug'] . '/group-finder/search/';
    275286        $label = __('Find a Group');
    276287        $type = 'groupfinder';
     
    505516    global $groups_template, $bp;
    506517   
    507     echo $bp['loggedin_domain'] . $bp['groups']['slug'] . '/' . $groups_template->group->slug . '/leave-group/yes';
     518    echo bp_group_permalink( false, true ) . '/leave-group/yes';   
    508519}
    509520
     
    511522    global $groups_template, $bp;
    512523   
    513     echo $bp['loggedin_domain'] . $bp['groups']['slug'] . '/' . $groups_template->group->slug . '/leave-group/no';
     524    echo bp_group_permalink( false, true );
    514525}
    515526
     
    559570    global $groups_template, $bp;
    560571   
    561     echo $bp['loggedin_domain'] . $bp['groups']['slug'] . '/' . $groups_template->group->slug . '/send-invites/send';
     572    echo bp_group_permalink( false, true ) . '/send-invites/send';
    562573}
    563574
     
    566577   
    567578    if ( is_user_logged_in() && !BP_Groups_Member::check_is_member( $bp['loggedin_userid'], $groups_template->group->id ) ) {
    568         echo '<a class="join-group" href="' . $bp['loggedin_domain'] . $bp['groups']['slug'] . '/' . $groups_template->group->slug . '/join">' . __('Join Group') . '</a>';
     579        echo '<a class="join-group" href="' . bp_group_permalink( false, false ) . '/join">' . __('Join Group') . '</a>';
    569580    }
    570581}
     
    582593                <?php $group = new BP_Groups_Group( $group_ids[$i], false, false ); ?>
    583594                <li>
    584                     <a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] . '/' . $group->slug ?>"><img src="<?php echo $group->avatar_thumb; ?>" class="avatar" alt="Group Avatar" /></a>
    585                     <h5><a href="<?php echo $bp['current_domain'] . $bp['groups']['slug'] . '/' . $group->slug ?>"><?php echo $group->name ?></a></h5>
     595                    <a href="<?php echo bp_group_permalink( $group, false ) ?>"><img src="<?php echo $group->avatar_thumb; ?>" class="avatar" alt="Group Avatar" /></a>
     596                    <h5><a href="<?php echo bp_group_permalink( $group, false ) ?>"><?php echo $group->name ?></a></h5>
    586597                </li>
    587598            <?php } ?>
  • trunk/bp-groups/bp-groups-widgets.php

    r374 r375  
    3737    <?php if ( $groups ) : ?>
    3838        <div class="item-options" id="groups-list-options">
    39             <img id="ajax-loader-groups" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" />
     39            <img id="ajax-loader-groups" src="<?php echo $bp['groups']['image_base'] ?>/ajax-loader.gif" height="7" alt="Loading" style="display: none;" /> &nbsp;
    4040            <a href="<?php echo site_url() . '/groups' ?>" id="newest-groups" class="selected"><?php _e("Newest") ?></a> |
    4141            <a href="<?php echo site_url() . '/groups' ?>" id="recently-active-groups"><?php _e("Active") ?></a> |
     
    4444        <ul id="groups-list" class="item-list">
    4545            <?php foreach ( $groups as $group ) : ?>
    46                 <?php $group = new BP_Groups_Group( $group->id, false ) ?>
     46                <?php $group = new BP_Groups_Group( $group->group_id, false ) ?>
    4747                <li>
    4848                    <div class="item-avatar">
     
    5151
    5252                    <div class="item">
    53                         <div class="item-title"><?php echo $group->name ?></div>
     53                        <div class="item-title"><a href="<?php echo bp_group_permalink( $group ) ?>" title="<?php echo $group->name ?>"><?php echo $group->name ?></a></div>
    5454                        <div class="item-meta"><span class="activity"><?php echo bp_core_get_last_activity( $group->date_created, __('created '), __(' ago') ) ?></span></div>
    5555                    </div>
  • trunk/bp-xprofile.php

    r373 r375  
    263263
    264264            if ( ( $wire_post->item_id == $bp['loggedin_userid'] && $wire_post->user_id == $bp['loggedin_userid'] ) || ( $wire_post->item_id == $bp['current_userid'] && $wire_post->user_id == $bp['current_userid'] ) ) {
    265                 $content = bp_core_get_userlink($wire_post->user_id) . ' ' . __('wrote on') . ' ' . bp_your_or_their() . ' ' . __('own wire') . ': <span class="time-since">%s</span>';             
     265                $content = bp_core_get_userlink($wire_post->user_id) . ' ' . __('wrote on their own wire') . ': <span class="time-since">%s</span>';               
    266266            } else if ( ( $wire_post->item_id != $bp['loggedin_userid'] && $wire_post->user_id == $bp['loggedin_userid'] ) || ( $wire_post->item_id != $bp['current_userid'] && $wire_post->user_id == $bp['current_userid'] ) ) {
    267267                $content = bp_core_get_userlink($wire_post->user_id) . ' ' . __('wrote on ') . bp_core_get_userlink( $wire_post->item_id, false, false, true, true ) . ' wire: <span class="time-since">%s</span>';             
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r359 r375  
    991991            $this->user_id = $profiledata->user_id;
    992992            $this->field_id = $profiledata->field_id;
    993             $this->value = $profiledata->value;
     993            $this->value = stripslashes($profiledata->value);
    994994            $this->last_updated = $profiledata->last_updated;
    995995        }
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r359 r375  
    232232}
    233233
    234 function bp_loggedinuser_avatar_thumbnail() {
    235     global $bp;
    236     echo bp_core_get_avatar( $bp['loggedin_userid'], 1 );
     234function bp_loggedinuser_avatar_thumbnail( $width = false, $height = false ) {
     235    global $bp;
     236   
     237    if ( $width && $height )
     238        echo bp_core_get_avatar( $bp['loggedin_userid'], 1, false, $width, $height );
     239    else
     240        echo bp_core_get_avatar( $bp['loggedin_userid'], 1 );
    237241}
    238242
Note: See TracChangeset for help on using the changeset viewer.