Skip to:
Content

BuddyPress.org

Changeset 5903


Ignore:
Timestamp:
03/11/2012 03:54:27 PM (13 years ago)
Author:
boonebgorges
Message:

Improvements to link construction and filters in the Groups component:

  • Fixes arguments being passed to bp_groups_get_total_groups_sql filter
  • Passes additional arguments to various group link filters
  • Sweeps through link concatenation in the groups component, to ensure that bp_get_group_permalink is used wherever possible (allowing for centralized filters in plugins)
  • Corrects some inline documentation
  • Fixes the permissions logic in bp_groups_adminbar_admin_menu(), so that super admins and group admins are able to see the group-specific dropdown when using the BuddyBar
  • Fixes #4071. Props travel-junkie
Location:
trunk/bp-groups
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-buddybar.php

    r5689 r5903  
    2424        return false;
    2525
    26     // Don't show this menu to non site admins or if you're viewing your own profile
    27     if ( !current_user_can( 'edit_users' ) || !bp_current_user_can( 'bp_moderate' ) || ( bp_is_item_admin() && ! bp_is_item_mod() ) )
     26    // Only group admins and site admins can see this menu
     27    if ( !current_user_can( 'edit_users' ) && !bp_current_user_can( 'bp_moderate' ) && !bp_is_item_admin() )
    2828        return false; ?>
    2929
  • trunk/bp-groups/bp-groups-classes.php

    r5729 r5903  
    385385
    386386        // Get total group results
    387         $total_groups_sql = apply_filters( 'bp_groups_get_total_groups_sql', join( ' ', (array) $t_sql ), $t_sql );
     387        $total_groups_sql = apply_filters( 'bp_groups_get_total_groups_sql', $t_sql, $total_sql );
    388388        $total_groups     = $wpdb->get_var( $total_groups_sql );
    389389
  • trunk/bp-groups/bp-groups-loader.php

    r5895 r5903  
    327327            );
    328328
    329             $group_link = trailingslashit( bp_get_root_domain() . '/' . $this->root_slug . '/' . $this->current_group->slug );
     329            $group_link = bp_get_group_permalink( $this->current_group );
    330330
    331331            // Add the "Home" subnav item, as this will always be present
  • trunk/bp-groups/bp-groups-template.php

    r5893 r5903  
    446446            $group =& $groups_template->group;
    447447
    448         return apply_filters( 'bp_get_group_permalink', bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/' );
     448        return apply_filters( 'bp_get_group_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/' ) );
    449449    }
    450450
     
    458458            $group =& $groups_template->group;
    459459
    460         return apply_filters( 'bp_get_group_admin_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin' ) );
     460        return apply_filters( 'bp_get_group_admin_permalink', trailingslashit( bp_get_group_permalink( $group ) . '/admin' ) );
    461461    }
    462462
     
    12671267    if ( bp_is_item_admin() || bp_is_item_mod() ) : ?>
    12681268
    1269         <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/edit-details' ) ?>"><?php _e( 'Details', 'buddypress' ); ?></a></li>
     1269        <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/edit-details' ) ?>"><?php _e( 'Details', 'buddypress' ); ?></a></li>
    12701270
    12711271    <?php endif; ?>
     
    12741274            return false; ?>
    12751275
    1276     <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/group-settings' ) ?>"><?php _e( 'Settings', 'buddypress' ); ?></a></li>
     1276    <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-settings' ) ?>"><?php _e( 'Settings', 'buddypress' ); ?></a></li>
    12771277
    12781278    <?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) ) : ?>
    12791279
    1280         <li<?php if ( 'group-avatar'   == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/group-avatar' ) ?>"><?php _e( 'Avatar', 'buddypress' ); ?></a></li>
     1280        <li<?php if ( 'group-avatar'   == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-avatar' ) ?>"><?php _e( 'Avatar', 'buddypress' ); ?></a></li>
    12811281
    12821282    <?php endif; ?>
    12831283
    1284     <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/manage-members' ) ?>"><?php _e( 'Members', 'buddypress' ); ?></a></li>
     1284    <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members' ) ?>"><?php _e( 'Members', 'buddypress' ); ?></a></li>
    12851285
    12861286    <?php if ( $groups_template->group->status == 'private' ) : ?>
    12871287
    1288         <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/membership-requests' ) ?>"><?php _e( 'Requests', 'buddypress' ); ?></a></li>
     1288        <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/membership-requests' ) ?>"><?php _e( 'Requests', 'buddypress' ); ?></a></li>
    12891289
    12901290    <?php endif; ?>
     
    12921292    <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
    12931293
    1294     <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group->slug . '/admin/delete-group' ) ?>"><?php _e( 'Delete', 'buddypress' ); ?></a></li>
     1294    <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/delete-group' ) ?>"><?php _e( 'Delete', 'buddypress' ); ?></a></li>
    12951295
    12961296<?php
     
    16641664}
    16651665    function bp_get_total_group_count_for_user( $user_id = 0 ) {
    1666         return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ) );
     1666        return apply_filters( 'bp_get_total_group_count_for_user', groups_total_groups_for_user( $user_id ), $user_id );
    16671667    }
    16681668
     
    28292829        global $bp;
    28302830
    2831         // Must be displayed user
     2831        // Must be a group
    28322832        if ( empty( $bp->groups->current_group->id ) )
    28332833            return;
    28342834
    2835         // Append $action to $url if there is no $type
     2835        // Append $action to $url if provided
    28362836        if ( !empty( $action ) )
    2837             $url = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/' . $action;
     2837            $url = bp_get_group_permalink( groups_get_current_group() ) . $action;
    28382838        else
    2839             $url = bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug;
     2839            $url = bp_get_group_permalink( groups_get_current_group() );
    28402840
    28412841        // Add a slash at the end of our user url
Note: See TracChangeset for help on using the changeset viewer.