Skip to:
Content

BuddyPress.org

Changeset 2128


Ignore:
Timestamp:
11/25/2009 08:38:56 PM (12 years ago)
Author:
apeatling
Message:

Activity stream commenting updates

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r2114 r2128  
    241241
    242242        'search_terms' => false, // Pass search terms as a string
     243        'show_hidden' => false, // Show activity items that are hidden site-wide?
    243244
    244245        /**
     
    258259    extract( $r, EXTR_SKIP );
    259260
    260     return apply_filters( 'bp_activity_get_sitewide', BP_Activity_Activity::get_sitewide_activity( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments ), &$r );
     261    return apply_filters( 'bp_activity_get_sitewide', BP_Activity_Activity::get_sitewide_activity( $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ), &$r );
    261262}
    262263
     
    273274
    274275        'search_terms' => false, // Pass search terms as a string
     276        'show_hidden' => false, // Show activity items that are hidden site-wide?
     277
     278        /* See bp_activity_get_sitewide() for filters */
    275279        'filter' => array()
    276280    );
     
    279283    extract( $r, EXTR_SKIP );
    280284
    281     return apply_filters( 'bp_activity_get_for_user', BP_Activity_Activity::get_activity_for_user( $user_id, $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments ), &$r );
     285    return apply_filters( 'bp_activity_get_for_user', BP_Activity_Activity::get_activity_for_user( $user_id, $max, $page, $per_page, $sort, $search_terms, $filter, $display_comments, $show_hidden ), &$r );
    282286}
    283287
  • trunk/bp-activity/bp-activity-classes.php

    r2114 r2128  
    163163    }
    164164
    165     function get_activity_for_user( $user_id, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false ) {
     165    function get_activity_for_user( $user_id, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) {
    166166        global $wpdb, $bp;
    167167
     
    247247    }
    248248
    249     function get_sitewide_activity( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false ) {
    250         global $wpdb, $bp;
     249    function get_sitewide_activity( $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $search_terms = false, $filter = false, $display_comments = false, $show_hidden = false ) {
     250        global $wpdb, $bp;
     251
     252        $where_conditions = array();
    251253
    252254        if ( $per_page && $page )
     
    259261        if ( $search_terms ) {
    260262            $search_terms = $wpdb->escape( $search_terms );
    261             $search_sql = "AND content LIKE '%%" . like_escape( $search_terms ) . "%%'";
     263            $where_conditions['search_sql'] = "content LIKE '%%" . like_escape( $search_terms ) . "%%'";
    262264        }
    263265
    264266        /* Filtering */
    265         if ( $filter )
    266             $filter_sql = BP_Activity_Activity::get_filter_sql( $filter );
     267        if ( $filter && $filter_sql = BP_Activity_Activity::get_filter_sql( $filter ) )
     268            $where_conditions['filter_sql'] = $filter_sql;
    267269
    268270        /* Sorting */
     
    270272            $sort = 'DESC';
    271273
     274        /* Hide Hidden Items? */
     275        if ( !$show_hidden )
     276            $where_conditions['hidden_sql'] = "hide_sitewide = 0";
     277
    272278        /* Alter the query based on whether we want to show activity item comments in the stream like normal comments or threaded below the activity */
    273279        if ( !$display_comments || 'threaded' == $display_comments ) {
     280            $where_conditions[] = "component_action != 'activity_comment'";
     281            $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
     282
    274283            if ( $per_page && $page && $max )
    275                 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$pag_sql}" ) );
     284                $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} {$where_sql} ORDER BY date_recorded {$sort} {$pag_sql}" ) );
    276285            else
    277                 $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$pag_sql} {$max_sql}" ) );
    278 
    279             $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} AND component_action != 'activity_comment' ORDER BY date_recorded {$sort} {$max_sql}" ) );
     286                $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} {$where_sql} ORDER BY date_recorded {$sort} {$pag_sql} {$max_sql}" ) );
     287
     288            $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} {$where_sql} ORDER BY date_recorded {$sort} {$max_sql}" ) );
    280289
    281290            if ( $activities && $display_comments )
     
    286295             * we will need to do things slightly differently.
    287296             */
     297            if ( !empty( $where_conditions ) )
     298                $where_sql = 'WHERE ' . join( ' AND ', $where_conditions );
     299
    288300             if ( !empty( $filter_sql ) ) {
    289                 $all_activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} ORDER BY id {$sort}" ) );
     301                $all_activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} {$where_sql} ORDER BY id {$sort}" ) );
    290302
    291303                foreach ( (array)$all_activities as $activity ) {
     
    296308
    297309                /* Fetch the comments for the activity items */
    298                 $all_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 AND item_id IN ({$activity_ids}) {$search_sql} ORDER BY id {$sort}" ) );
     310                $search_sql = $where_conditions['search_sql'];
     311                $all_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE item_id IN ({$activity_ids}) {$search_sql} ORDER BY id {$sort}" ) );
    299312
    300313                foreach ( (array)$all_comments as $comment ) {
     
    313326             } else {
    314327                if ( $per_page && $page && $max )
    315                     $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} ORDER BY id {$sort} {$pag_sql}" ) );
     328                    $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} {$where_sql} ORDER BY id {$sort} {$pag_sql}" ) );
    316329                else
    317                     $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} ORDER BY id {$sort} {$pag_sql} {$max_sql}" ) );
    318 
    319                 $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} WHERE hide_sitewide = 0 {$search_sql} {$filter_sql} ORDER BY date_recorded {$sort} {$max_sql}" ) );
     330                    $activities = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} {$where_sql} ORDER BY id {$sort} {$pag_sql} {$max_sql}" ) );
     331
     332                $total_activities = $wpdb->get_var( $wpdb->prepare( "SELECT count(id) FROM {$bp->activity->table_name} {$where_sql} ORDER BY date_recorded {$sort} {$max_sql}" ) );
    320333             }
    321334
     
    449462        if ( !empty( $filter_array['object'] ) ) {
    450463            $object_filter = explode( ',', $filter_array['object'] );
    451             $object_sql = ' AND ( ';
     464            $object_sql = ' ( ';
    452465
    453466            $counter = 1;
     
    462475
    463476            $object_sql .= ' )';
     477            $filter_sql[] = $object_sql;
    464478        }
    465479
    466480        if ( !empty( $filter_array['action'] ) ) {
    467481            $action_filter = explode( ',', $filter_array['action'] );
    468             $action_sql = ' AND ( ';
     482            $action_sql = ' ( ';
    469483
    470484            $counter = 1;
     
    479493
    480494            $action_sql .= ' )';
     495            $filter_sql[] = $action_sql;
    481496        }
    482497
    483498        if ( !empty( $filter_array['primary_id'] ) ) {
    484499            $pid_filter = explode( ',', $filter_array['primary_id'] );
    485             $pid_sql = ' AND ( ';
     500            $pid_sql = ' ( ';
    486501
    487502            $counter = 1;
     
    496511
    497512            $pid_sql .= ' )';
     513            $filter_sql[] = $pid_sql;
    498514        }
    499515
    500516        if ( !empty( $filter_array['secondary_id'] ) ) {
    501517            $sid_filter = explode( ',', $filter_array['secondary_id'] );
    502             $sid_sql = ' AND ( ';
     518            $sid_sql = ' ( ';
    503519
    504520            $counter = 1;
     
    513529
    514530            $sid_sql .= ' )';
    515         }
    516 
    517         return $object_sql . $action_sql . $pid_sql . $sid_sql;
     531            $filter_sql[] = $sid_sql;
     532        }
     533
     534        if ( empty($filter_sql) )
     535            return false;
     536
     537        return join( ' AND ', $filter_sql );
    518538    }
    519539
  • trunk/bp-activity/bp-activity-templatetags.php

    r2114 r2128  
    1717    var $full_name;
    1818
    19     function bp_activity_template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments ) {
     19    function bp_activity_template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden ) {
    2020        global $bp;
    2121
     
    2929        } else {
    3030            if ( $type == 'sitewide' )
    31                 $this->activities = bp_activity_get_sitewide( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter ) );
     31                $this->activities = bp_activity_get_sitewide( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
    3232
    3333            if ( $type == 'personal' )
     
    129129        'per_page' => 25, // number of items per page
    130130        'max' => false, // max number to return
     131        'show_hidden' => false, // Show activity items that are hidden site-wide?
    131132
    132133        /* Filtering */
     
    157158        $filter = array( 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
    158159
    159     $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments );
     160    $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );
    160161
    161162    return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
     
    481482
    482483        foreach ( (array) $component_names as $component_name ) {
     484            /* Skip the activity comment filter */
     485            if ( 'activity' == $component_name )
     486                continue;
     487
    483488            if ( isset( $_GET['afilter'] ) && $component_name == $_GET['afilter'] )
    484489                $selected = ' class="selected"';
  • trunk/bp-activity/bp-activity-widgets.php

    r2077 r2128  
    2323           . $after_title; ?>
    2424
    25     <?php if ( bp_has_activities( 'type=sitewide&max=' . $instance['max_items'] . '&per_page=' . $instance['per_page'] ) ) : ?>
     25    <?php if ( bp_has_activities( 'type=sitewide&max=' . $instance['max_items'] . '&per_page=' . $instance['per_page'] . '&display_comments=threaded' ) ) : ?>
    2626
    2727        <?php if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) : ?>
     
    4343        <ul id="site-wide-stream" class="activity-list">
    4444        <?php while ( bp_activities() ) : bp_the_activity(); ?>
    45             <li class="<?php bp_activity_css_class() ?>">
    46                 <?php if ( !file_exists( WP_CONTENT_DIR . '/bp-themes' ) ) : ?>
    47                     <div class="activity-avatar">
    48                         <?php bp_activity_avatar() ?>
     45            <li class="<?php bp_activity_css_class() ?>" id="activity-<?php bp_activity_id() ?>">
     46                <div class="activity-avatar">
     47                    <?php bp_activity_avatar('width=40&height=40') ?>
     48                </div>
     49
     50                <div class="activity-content">
     51                    <?php bp_activity_content() ?>
     52
     53                    <?php if ( is_user_logged_in() ) : ?>
     54                    <div class="activity-meta">
     55                        <a href="#acomment-<?php bp_activity_id() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Comment', 'buddypress' ) ?> (<?php bp_activity_comment_count() ?>)</a>
    4956                    </div>
    50                 <?php endif; ?>
     57                    <?php endif; ?>
     58                </div>
    5159
    52                 <?php bp_activity_content() ?>
     60                <div class="activity-comments">
     61                    <?php bp_activity_comments() ?>
     62
     63                    <?php if ( is_user_logged_in() ) : ?>
     64                    <form action="" method="post" name="activity-comment-form" id="ac-form-<?php bp_activity_id() ?>" class="ac-form">
     65                        <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=25&height=25' ) ?></div>
     66                        <div class="ac-reply-content">
     67                            <textarea id="ac-input-<?php bp_activity_id() ?>" class="ac-input" name="ac-input-<?php bp_activity_id() ?>"></textarea>
     68                            <input type="submit" name="ac-form-submit" value="<?php _e( 'Post', 'buddypress' ) ?> &rarr;" />
     69                        </div>
     70                        <?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ) ?>
     71                    </form>
     72                    <?php endif; ?>
     73                </div>
     74
    5375            </li>
    5476        <?php endwhile; ?>
  • trunk/bp-core.php

    r2114 r2128  
    132132
    133133    /* The default component to use if none are set and someone visits: http://domain.com/members/andy */
    134     if ( defined( 'BP_XPROFILE_SLUG' ) )
    135         $bp->default_component = BP_XPROFILE_SLUG;
    136     else
    137         $bp->default_component = 'profile';
     134    if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) {
     135        if ( defined( 'BP_ACTIVITY_SLUG' ) )
     136            $bp->default_component = BP_ACTIVITY_SLUG;
     137        else
     138            $bp->default_component = 'profile';
     139    } else {
     140        $bp->default_component = BP_DEFAULT_COMPONENT;
     141    }
    138142
    139143    /* Sets up the array container for the component navigation rendered by bp_get_nav() */
     
    13371341    $since = $newer_date - $older_date;
    13381342
     1343    /* Something went wrong with date calculation and we ended up with a negative date. */
    13391344    if ( 0 > $since )
    1340         return __( '[Use GMT Timezone]', 'buddypress' );
     1345        return __( 'sometime', 'buddypress' );
    13411346
    13421347    /**
  • trunk/bp-core/bp-core-templatetags.php

    r2114 r2128  
    464464        return true;
    465465
    466     if ( !$is_member_page && !in_array( $bp->current_component, $bp->root_components ) )
     466    if ( is_front_page() || ( !$is_member_page && !in_array( $bp->current_component, $bp->root_components ) ) )
    467467        return true;
    468468
  • trunk/bp-core/js/admin-bar.js

    r1678 r2128  
    33        jQuery(this).addClass('sfhover');
    44    });
    5    
     5
    66    jQuery("#wp-admin-bar ul.main-nav li").mouseout( function() {
    77        jQuery(this).removeClass('sfhover');
  • trunk/bp-friends/bp-friends-templatetags.php

    r2077 r2128  
    194194    }
    195195
    196 function bp_friend_avatar_thumb() {
    197     echo bp_get_friend_avatar_thumb();
    198 }
    199     function bp_get_friend_avatar_thumb() {
    200         global $friends_template;
    201 
    202         return apply_filters( 'bp_get_friend_avatar_thumb', $friends_template->friendship->friend->avatar_thumb );
     196function bp_friend_avatar_thumb( $args = '' ) {
     197    echo bp_get_friend_avatar_thumb( $args );
     198}
     199    function bp_get_friend_avatar_thumb( $args = '' ) {
     200        global $bp, $friends_template;
     201
     202        $defaults = array(
     203            'type' => 'thumb',
     204            'width' => false,
     205            'height' => false,
     206            'class' => 'avatar',
     207            'id' => false,
     208            'alt' => __( 'Group avatar', 'buddypress' )
     209        );
     210
     211        $r = wp_parse_args( $args, $defaults );
     212        extract( $r, EXTR_SKIP );
     213
     214        return apply_filters( 'bp_get_friend_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $friends_template->friendship->friend->id, 'type' => $type, 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class ) ) );
    203215    }
    204216
  • trunk/bp-groups.php

    r2114 r2128  
    14701470        return false;
    14711471
    1472     /* If the group is not public, no recording of activity please. */
    1473     if ( 'public' != $bp->groups->current_group->status )
    1474         return false;
     1472    /* If the group is not public, hide the activity sitewide, or basically when not looking at the group feed. */
     1473    if ( 'public' == $bp->groups->current_group->status )
     1474        $hide_sitewide = false;
     1475    else
     1476        $hide_sitewide = true;
    14751477
    14761478    $defaults = array(
     
    14831485        'secondary_item_id' => false,
    14841486        'recorded_time' => time(),
    1485         'hide_sitewide' => false
     1487        'hide_sitewide' => $hide_sitewide
    14861488    );
    14871489
Note: See TracChangeset for help on using the changeset viewer.