Skip to:
Content

BuddyPress.org

Ticket #2579: 2579.01.patch

File 2579.01.patch, 9.8 KB (added by r-a-y, 13 years ago)
  • buddypress/bp-activity/bp-activity-actions.php

     
    2424                return false;
    2525
    2626        // Get the activity details
    27         $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->action_variables[0] ) );
     27        $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->action_variables[0], 'show_hidden' => true ) );
    2828
    2929        // Redirect to root if activity does not exist
    3030        if ( !$activity = $activity['activities'][0] )
    3131                bp_core_redirect( bp_get_root_domain() );
    3232
    33         // Do not redirect at default
    34         $redirect = false;
     33        // Default redirect is to /members/[username]/id/
     34        $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id . '/';
    3535
    3636        // Redirect based on the type of activity
    3737        if ( bp_is_active( 'groups' ) && $activity->component == $bp->groups->id ) {
    3838
    39                 // Activity is a user update
    40                 if ( !empty( $activity->user_id ) ) {
    41                         $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id . '/';
    42 
    43                 // Activity is something else
    44                 } else {
    45 
    46                         // Set redirect to group activity stream
    47                         if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
    48                                 $redirect = bp_get_group_permalink( $group ) . $bp->activity->slug . '/' . $activity->id . '/';
    49                         }
     39                // Set redirect to group activity stream
     40                if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
     41                        $redirect = bp_get_group_permalink( $group ) . $bp->activity->slug . '/' . $activity->id . '/';
    5042                }
    51 
    52         // Set redirect to users' activity stream
    53         } else {
    54                 $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . $bp->activity->slug . '/' . $activity->id;
    5543        }
    5644
    57         // Allow redirect to be filtered
     45        // Allow redirect to be filtered, return false to redirect to root
    5846        if ( !$redirect = apply_filters( 'bp_activity_permalink_redirect_url', $redirect, &$activity ) )
    5947                bp_core_redirect( bp_get_root_domain() );
    6048
  • buddypress/bp-activity/bp-activity-screens.php

     
    7474        // No displayed user or not viewing activity component
    7575        if ( !bp_is_activity_component() )
    7676                return false;
    77        
    78         if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) ) 
    79                 return false; 
    80        
     77
     78        if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) )
     79                return false;
     80
    8181        // Get the activity details
    82         $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action() ) );
     82        $activity = bp_activity_get_specific( array( 'activity_ids' => bp_current_action(), 'show_hidden' => true ) );
    8383
    8484        if ( !$activity = $activity['activities'][0] )
    8585                bp_core_redirect( bp_get_root_domain() );
    8686
    87         // Default access is true
    88         $has_access = true;
    89 
    90         // If activity is from a group, do an extra cap check
    91         if ( isset( $bp->groups->id ) && $activity->component == $bp->groups->id ) {
    92 
    93                 // Activity is from a group, but groups is currently disabled
    94                 if ( !bp_is_active( 'groups') )
    95                         bp_core_redirect( bp_get_root_domain() );
    96 
    97                 // Check to see if the group is not public, if so, check the
    98                 // user has access to see this activity
    99                 if ( $group = groups_get_group( array( 'group_id' => $activity->item_id ) ) ) {
    100 
    101                         // Group is not public
    102                         if ( 'public' != $group->status ) {
    103 
    104                                 // User is not a member of group
    105                                 if ( !groups_is_user_member( $bp->loggedin_user->id, $group->id ) ) {
    106                                         $has_access = false;
    107                                 }
    108                         }
    109                 }
    110         }
    111 
    112         // Allow access to be filtered
    113         $has_access = apply_filters( 'bp_activity_permalink_access', $has_access, &$activity );
     87        // Default access is true; allow access to be filtered
     88        $has_access = apply_filters( 'bp_activity_permalink_access', true, &$activity );
    11489
    11590        // Allow additional code execution
    11691        do_action( 'bp_activity_screen_single_activity_permalink', $activity, $has_access );
  • buddypress/bp-core/bp-core-template.php

     
    3434                        $the_index = $bp->current_item;
    3535                }
    3636        }
    37        
     37
    3838        // Loop through each navigation item
    3939        foreach ( (array)$bp->bp_options_nav[$the_index] as $subnav_item ) {
    4040                if ( !$subnav_item['user_has_access'] )
     
    242242        // Displayed user
    243243        } elseif ( !empty( $bp->displayed_user->fullname ) && !is_404() ) {
    244244                // translators: "displayed user's name | canonicalised component name"
    245                 $title = strip_tags( sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->displayed_user->fullname, ucwords( bp_current_component() ) ) ); 
     245                $title = strip_tags( sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->displayed_user->fullname, ucwords( bp_current_component() ) ) );
    246246
    247247        // A single group
    248248        } elseif ( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {
     
    964964        if ( bp_is_current_component( 'activity' ) && is_numeric( $bp->current_action ) )
    965965                return true;
    966966
    967         return false;
     967        if ( bp_group_is_activity_permalink() )
     968                return true;
     969
     970        return apply_filters( 'bp_is_single_activity', false );
    968971}
    969972
    970973/** User **********************************************************************/
  • buddypress/bp-groups/bp-groups-screens.php

     
    437437
    438438        $bp->is_single_item = true;
    439439
    440         bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) );
     440        // Get the activity details
     441        $activity = bp_activity_get_specific( array( 'activity_ids' => $bp->action_variables[0], 'show_hidden' => true ) );
     442
     443        // If no activities, redirect to root
     444        if ( !$activity = $activity['activities'][0] )
     445                bp_core_redirect( bp_get_root_domain() );
     446
     447        // If activity isn't from the current group, redirect to root
     448        if ( $activity->item_id != $bp->groups->current_group->id )
     449                bp_core_redirect( bp_get_root_domain() );
     450
     451        // Grab group access status; allow access to be filtered
     452        $has_access = apply_filters( 'bp_group_activity_permalink_access', $bp->groups->current_group->user_has_access, &$activity );
     453
     454        // Allow additional code execution
     455        do_action( 'bp_group_screen_single_activity_permalink', $activity, $has_access );
     456
     457        // Access is specifically disallowed
     458        if ( false === $has_access ) {
     459
     460                // User feedback
     461                bp_core_add_message( __( 'You do not have access to this activity.', 'buddypress' ), 'error' );
     462
     463                // Redirect based on logged in status
     464                is_user_logged_in() ?
     465                        bp_core_redirect( $bp->loggedin_user->domain ) :
     466                        bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . bp_get_group_permalink( $bp->groups->current_group ) . $bp->activity->slug . '/' . $activity->id . '/' ) );
     467        }
     468
     469        bp_core_load_template( apply_filters( 'groups_template_group_activity_permalink', 'groups/single/activity/permalink' ) );
    441470}
    442471add_action( 'bp_screens', 'groups_screen_group_activity_permalink' );
    443472
  • buddypress/bp-groups/bp-groups-template.php

     
    625625        return true;
    626626}
    627627
     628function bp_group_activity_id() {
     629        echo bp_group_get_activity_id();
     630}
     631        function bp_group_get_activity_id() {
     632                global $bp;
     633
     634                if ( bp_group_is_activity_permalink() ) {
     635                        if ( $id = $bp->action_variables[0] )
     636                                return $id;
     637                }
     638
     639                return false;
     640        }
     641
    628642function bp_groups_pagination_links() {
    629643        echo bp_get_groups_pagination_links();
    630644}
     
    14521466        var $total_group_count;
    14531467
    14541468        function bp_groups_group_members_template( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude ) {
    1455                 $this->__construct( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude );     
     1469                $this->__construct( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude );
    14561470        }
    1457        
     1471
    14581472        function __construct( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude ) {
    14591473                global $bp;
    14601474
     
    21742188        function bp_groups_membership_requests_template( $group_id, $per_page, $max ) {
    21752189                $this->__construct( $group_id, $per_page, $max );
    21762190        }
    2177        
    2178        
     2191
     2192
    21792193        function __construct( $group_id, $per_page, $max ) {
    2180                
     2194
    21812195                global $bp;
    21822196
    21832197                $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1;
     
    23482362        var $total_invite_count;
    23492363
    23502364        function bp_groups_invite_template( $user_id, $group_id ) {
    2351                 $this->__construct( $user_id, $group_id ); 
     2365                $this->__construct( $user_id, $group_id );
    23522366        }
    2353                
     2367
    23542368        function __construct( $user_id, $group_id ) {
    23552369
    23562370                global $bp;
    2357                
     2371
    23582372                $this->invites = groups_get_invites_for_group( $user_id, $group_id );
    23592373                $this->invite_count = count( $this->invites );
    23602374
  • buddypress/bp-themes/bp-default/groups/single/activity/permalink.php

     
     1<?php get_header( 'buddypress' ) ?>
     2
     3<div class="activity no-ajax" role="main">
     4        <?php if ( bp_has_activities( 'display_comments=threaded&show_hidden=true&include=' . bp_group_get_activity_id() ) ) : ?>
     5
     6                <ul id="activity-stream" class="activity-list item-list">
     7                <?php while ( bp_activities() ) : bp_the_activity(); ?>
     8
     9                        <?php locate_template( array( 'activity/entry.php' ), true ) ?>
     10
     11                <?php endwhile; ?>
     12                </ul>
     13
     14        <?php endif; ?>
     15</div>
     16
     17<?php get_footer( 'buddypress' ) ?>
     18 No newline at end of file