Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/14/2009 03:24:05 PM (17 years ago)
Author:
apeatling
Message:

Committing core code support for new default theme.

Removed all deprecated code since it will be released as a separate plugin for backwards compatibility if people need it.

Removed the wire and status updates components since there is no support in the theme for these. If people still want this functionality then I'm sure there is someone in the community that could spend a bit of time and release them as plugins. I'm happy to guide.

Removed a lot of template loop duplication. There are no longer site loops and user loops (e.g. bp_has_site_groups() / bp_has_groups() ). There are now bp_has_members(), bp_has_groups(), bp_has_blogs() and you can pass a "user_id" parameter into these loops to limit results to only that user or users.

Merged activity stream functions. There are no longer functions for bp_activity_get_sitewide() / bp_activity_get_for_user() / bp_activity_get_friends_activity() instead there is simply one function: bp_activity_get() and you can pass in parameters to filter on just friends, for a single user, or anything your heart desires. Actually, filtering is extremely fine grained, so I encourage devs to check out the filter functions.

Lots of other code cleanup.

The new default theme will be committed straight after this. The original default folder will be renamed to bp-classic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-templatetags.php

    r2158 r2168  
    77        var $activities;
    88        var $activity;
    9         var $activity_type;
    109
    1110        var $in_the_loop;
     
    1716        var $full_name;
    1817
    19         function bp_activity_template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden ) {
     18        function bp_activity_template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden ) {
    2019                global $bp;
    2120
    22                 $this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : 1;
     21                $this->pag_page = isset( $_REQUEST['acpage'] ) ? intval( $_REQUEST['acpage'] ) : $page;
    2322                $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page;
    24                 $this->activity_type = $type;
    2523
    2624                if ( !empty( $include ) ) {
    2725                        /* Fetch specific activity items based on ID's */
    28                         $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $page, 'per_page' => $per_page, 'sort' => $sort, 'display_comments' => $display_comments ) );
     26                        $this->activities = bp_activity_get_specific( array( 'activity_ids' => explode( ',', $include ), 'max' => $max, 'page' => $this->pag_page, 'per_page' => $this->pag_num, 'sort' => $sort, 'display_comments' => $display_comments ) );
    2927                } else {
    30                         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, 'show_hidden' => $show_hidden ) );
    32 
    33                         if ( $type == 'personal' )
    34                                 $this->activities = bp_activity_get_for_user( array( 'user_id' => $user_id, 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
    35 
    36                         if ( $type == 'friends' && ( bp_is_home() || is_site_admin() || $bp->loggedin_user->id == $user_id ) )
    37                                 $this->activities = bp_activity_get_friends_activity( $user_id, $max, false, $this->pag_num, $this->pag_page, $filter );
     28                        $this->activities = bp_activity_get( array( 'display_comments' => $display_comments, 'max' => $max, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'sort' => $sort, 'search_terms' => $search_terms, 'filter' => $filter, 'show_hidden' => $show_hidden ) );
    3829                }
    3930
     
    123114
    124115        $defaults = array(
    125                 'type' => 'sitewide',
    126116                'display_comments' => false, // false for none, stream/threaded - show comments in the stream or threaded under items
    127117                'include' => false, // pass an activity_id or string of ID's comma separated
    128118                'sort' => 'DESC', // sort DESC or ASC
     119                'page' => 1, // which page to load
    129120                'per_page' => 25, // number of items per page
    130121                'max' => false, // max number to return
     
    162153                $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id );
    163154
    164         $activities_template = new BP_Activity_Template( $type, $user_id, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );
     155        $activities_template = new BP_Activity_Template( $page, $per_page, $max, $include, $sort, $filter, $search_terms, $display_comments, $show_hidden );
    165156
    166157        return apply_filters( 'bp_has_activities', $activities_template->has_activities(), &$activities_template );
     
    352343        }
    353344
    354         if ( 'activity_comment' == $activities_template->activity->component_action )
    355                 $meta = '</span> <span class="activity-header-meta"> &middot; <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activities_template->activity->item_id . '">' . __( 'View Thread', 'buddypress' ) . '</a>';
    356         else
    357                 $meta = '</span> <span class="activity-header-meta"> &middot; <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activities_template->activity->id . '">' . __( 'Permalink', 'buddypress' ) . '</a>';
     345        if ( !bp_is_activity_permalink() ) {
     346                if ( 'activity_comment' == $activities_template->activity->component_action )
     347                        $meta = '</span> <span class="activity-header-meta"> &middot; <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activities_template->activity->item_id . '">' . __( 'View Thread', 'buddypress' ) . '</a>';
     348                else
     349                        $meta = '</span> <span class="activity-header-meta"> &middot; <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activities_template->activity->id . '">' . __( 'View Thread', 'buddypress' ) . '</a>';
     350        }
    358351
    359352        /* Add the delete link if the user has permission on this item */
    360353        if ( ( $activities_template->activity->user_id == $bp->loggedin_user->id ) || $bp->is_item_admin || is_site_admin() )
    361                  $meta .= ' &middot;' . bp_get_activity_delete_link();
     354                 $meta .= ' &middot; ' . bp_get_activity_delete_link();
    362355
    363356        $content[1] = $meta . '</span>' . $content[1];
     
    535528
    536529                return apply_filters( 'bp_get_activity_delete_link', '<a href="' . wp_nonce_url( $bp->root_domain . '/' . $bp->activity->slug . '/delete/' . $activities_template->activity->id, 'bp_activity_delete_link' ) . '" class="item-button delete-activity confirm">' . __( 'Delete', 'buddypress' ) . '</a>' );
     530        }
     531
     532function bp_activity_latest_update( $user_id = false ) {
     533        echo bp_get_activity_latest_update( $user_id );
     534}
     535        function bp_get_activity_latest_update( $user_id = false ) {
     536                global $bp;
     537
     538                if ( !$user_id )
     539                        $user_id = $bp->displayed_user->id;
     540
     541                if ( !$update = get_usermeta( $user_id, 'bp_latest_update' ) )
     542                        return false;
     543
     544                $latest_update = '&quot;' . strip_tags( bp_create_excerpt( $update['content'], 40 ) ) . '&quot;';
     545                $latest_update .= ' &middot; <a href="' . $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $update['id'] . '/"> ' . __( 'View Thread', 'buddypress' ) . '</a>';
     546
     547                return apply_filters( 'bp_get_activity_latest_update', $latest_update  );
    537548        }
    538549
Note: See TracChangeset for help on using the changeset viewer.