Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/09/2008 04:37:49 AM (18 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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               
Note: See TracChangeset for help on using the changeset viewer.