Skip to:
Content

BuddyPress.org

Changeset 3955


Ignore:
Timestamp:
01/27/2011 09:15:35 PM (15 years ago)
Author:
johnjamesjacoby
Message:

First pass at replacing the 'Admin Options' menus for users and groups. Include additional functionality for moderating registered components and their associated data. Also introduce cap checks for allowing non-super-admins to have moderator abilities. Does not include action handlers, this is a first pass at getting the UI in place. Also adds button class to a few rogue links in the groups component.

Location:
trunk
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-functions.php

    r3917 r3955  
    723723}
    724724
    725 /********************************************************************************
    726  * Caching
    727  *
    728  * Caching functions handle the clearing of cached objects and pages on specific
    729  * actions throughout BuddyPress.
    730  */
    731 
    732 /**
    733  * REQUIRES WP-SUPER-CACHE
    734  *
    735  * When wp-super-cache is installed this function will clear cached pages
    736  * so that success/error messages are not cached, or time sensitive content.
    737  *
    738  * @package BuddyPress Core
    739  */
    740 function bp_core_clear_cache() {
    741         global $cache_path, $cache_filename;
    742 
    743         if ( function_exists( 'prune_super_cache' ) ) {
    744                 do_action( 'bp_core_clear_cache' );
    745 
    746                 return prune_super_cache( $cache_path, true );
    747         }
    748 }
    749 
    750 /**
    751  * Add's 'bp' to global group of network wide cachable objects
    752  *
    753  * @package BuddyPress Core
    754  */
    755 function bp_core_add_global_group() {
    756         wp_cache_init();
    757 
    758         if ( function_exists( 'wp_cache_add_global_groups' ) )
    759                 wp_cache_add_global_groups( array( 'bp' ) );
    760 }
    761 add_action( 'bp_loaded', 'bp_core_add_global_group' );
    762 
    763 /**
    764  * Clears all cached objects for a user, or a user is part of.
    765  *
    766  * @package BuddyPress Core
    767  */
    768 function bp_core_clear_user_object_cache( $user_id ) {
    769         wp_cache_delete( 'bp_user_' . $user_id, 'bp' );
    770 }
    771 
    772 // List actions to clear super cached pages on, if super cache is installed
    773 add_action( 'wp_login',              'bp_core_clear_cache' );
    774 add_action( 'bp_core_render_notice', 'bp_core_clear_cache' );
    775 
    776725?>
  • trunk/bp-core/bp-core-loader.php

    r3947 r3955  
    22
    33// Require all of the BuddyPress core libraries
    4 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php'  );
    5 require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php'  );
     4require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-cache.php'  );
    65require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-hooks.php'  );
    76require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-cssjs.php'  );
     
    1312require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-buddybar.php'  );
    1413require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-catchuri.php'  );
     14require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-component.php'  );
     15require_once( BP_PLUGIN_DIR . '/bp-core/bp-core-functions.php'  );
    1516
    1617// Load deprecated functions
  • trunk/bp-groups/bp-groups-functions.php

    r3917 r3955  
    77 * true or false on success or failure.
    88 */
    9 
    10 function groups_setup_adminbar_menu() {
    11         global $bp;
    12 
    13         if ( empty( $bp->groups->current_group ) )
    14                 return false;
    15 
    16         // Don't show this menu to non site admins or if you're viewing your own profile
    17         if ( !is_super_admin() )
    18                 return false; ?>
    19 
    20         <li id="bp-adminbar-adminoptions-menu">
    21                 <a href=""><?php _e( 'Admin Options', 'buddypress' ) ?></a>
    22 
    23                 <ul>
    24                         <li><a class="confirm" href="<?php echo wp_nonce_url( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/delete-group/', 'groups_delete_group' ) ?>&amp;delete-group-button=1&amp;delete-group-understand=1"><?php _e( "Delete Group", 'buddypress' ) ?></a></li>
    25 
    26                         <?php do_action( 'groups_adminbar_menu_items' ) ?>
    27 
    28                 </ul>
    29         </li>
    30 
    31         <?php
    32 }
    33 add_action( 'bp_adminbar_menus', 'groups_setup_adminbar_menu', 20 );
    349
    3510function groups_get_group( $args = '' ) {
  • trunk/bp-groups/bp-groups-loader.php

    r3917 r3955  
    4242                        'activity',
    4343                        'template',
     44                        'buddybar',
    4445                        'functions'
    4546                );
     
    229230                parent::_setup_nav( $main_nav, $sub_nav );
    230231
    231                 if ( bp_is_groups_component() ) {
    232                         if ( bp_is_single_item() ) {
    233 
    234                                 // Add 'Groups' to the main navigation
    235                                 $main_nav = array(
    236                                         'name'                => __( 'Groups', 'buddypress' ),
    237                                         'slug'                => $this->root_slug,
    238                                         'position'            => -1, // Do not show in BuddyBar
    239                                         'screen_function'     => 'groups_screen_group_home',
    240                                         'default_subnav_slug' => 'home',
    241                                         'item_css_id'         => $this->id
    242                                 );
    243 
    244                                 $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug );
    245 
    246                                 // Add the "Home" subnav item, as this will always be present
     232                if ( bp_is_groups_component() && bp_is_single_item() ) {
     233
     234                        // Add 'Groups' to the main navigation
     235                        $main_nav = array(
     236                                'name'                => __( 'Groups', 'buddypress' ),
     237                                'slug'                => $this->root_slug,
     238                                'position'            => -1, // Do not show in BuddyBar
     239                                'screen_function'     => 'groups_screen_group_home',
     240                                'default_subnav_slug' => 'home',
     241                                'item_css_id'         => $this->id
     242                        );
     243
     244                        $group_link = trailingslashit( $bp->root_domain . '/' . $this->root_slug . '/' . $this->current_group->slug );
     245
     246                        // Add the "Home" subnav item, as this will always be present
     247                        $sub_nav[] = array(
     248                                'name'            => __( 'Home', 'buddypress' ),
     249                                'slug'            => 'home',
     250                                'parent_url'      => $group_link,
     251                                'parent_slug'     => $this->root_slug,
     252                                'screen_function' => 'groups_screen_group_home',
     253                                'position'        => 10,
     254                                'item_css_id'     => 'home'
     255                        );
     256
     257                        // If the user is a group mod or more, then show the group admin nav item
     258                        if ( bp_is_item_admin() || bp_is_item_mod() ) {
    247259                                $sub_nav[] = array(
    248                                         'name'            => __( 'Home', 'buddypress' ),
    249                                         'slug'            => 'home',
     260                                        'name'            => __( 'Admin', 'buddypress' ),
     261                                        'slug'            => 'admin',
    250262                                        'parent_url'      => $group_link,
    251263                                        'parent_slug'     => $this->root_slug,
    252                                         'screen_function' => 'groups_screen_group_home',
    253                                         'position'        => 10,
    254                                         'item_css_id'     => 'home'
     264                                        'screen_function' => 'groups_screen_group_admin',
     265                                        'position'        => 20,
     266                                        'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ),
     267                                        'item_css_id'     => 'admin'
    255268                                );
    256 
    257                                 // If the user is a group mod or more, then show the group admin nav item
    258                                 if ( bp_is_item_admin() || bp_is_item_mod() ) {
     269                        }
     270
     271                        // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
     272                        if ( is_user_logged_in() &&
     273                                 !is_super_admin() &&
     274                                 !$this->current_group->is_user_member &&
     275                                 !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) &&
     276                                 $this->current_group->status == 'private'
     277                                ) {
     278                                $sub_nav[] = array(
     279                                        'name'               => __( 'Request Membership', 'buddypress' ),
     280                                        'slug'               => 'request-membership',
     281                                        'parent_url'         => $group_link,
     282                                        'parent_slug'        => $this->root_slug,
     283                                        'screen_function'    => 'groups_screen_group_request_membership',
     284                                        'position'           => 30
     285                                );
     286                        }
     287
     288                        // Forums are enabled and turned on
     289                        if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
     290                                $sub_nav[] = array(
     291                                        'name'            => __( 'Forum', 'buddypress' ),
     292                                        'slug'            => 'forum',
     293                                        'parent_url'      => $group_link,
     294                                        'parent_slug'     => $this->root_slug,
     295                                        'screen_function' => 'groups_screen_group_forum',
     296                                        'position'        => 40,
     297                                        'user_has_access' => $this->current_group->user_has_access,
     298                                        'item_css_id'     => 'forums'
     299                                );
     300                        }
     301
     302                        $sub_nav[] = array(
     303                                'name'            => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
     304                                'slug'            => 'members',
     305                                'parent_url'      => $group_link,
     306                                'parent_slug'     => $this->root_slug,
     307                                'screen_function' => 'groups_screen_group_members',
     308                                'position'        => 60,
     309                                'user_has_access' => $this->current_group->user_has_access,
     310                                'item_css_id'     => 'members'
     311                        );
     312
     313                        if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) {
     314                                if ( bp_is_active( 'friends' ) ) {
    259315                                        $sub_nav[] = array(
    260                                                 'name'            => __( 'Admin', 'buddypress' ),
    261                                                 'slug'            => 'admin',
     316                                                'name'            => __( 'Send Invites', 'buddypress' ),
     317                                                'slug'            => 'send-invites',
    262318                                                'parent_url'      => $group_link,
    263319                                                'parent_slug'     => $this->root_slug,
    264                                                 'screen_function' => 'groups_screen_group_admin',
    265                                                 'position'        => 20,
    266                                                 'user_has_access' => ( $bp->is_item_admin + (int)$bp->is_item_mod ),
    267                                                 'item_css_id'     => 'admin'
     320                                                'screen_function' => 'groups_screen_group_invite',
     321                                                'item_css_id'     => 'invite',
     322                                                'position'        => 70,
     323                                                'user_has_access' => $this->current_group->user_has_access
    268324                                        );
    269325                                }
    270 
    271                                 // If this is a private group, and the user is not a member, show a "Request Membership" nav item.
    272                                 if ( is_user_logged_in() &&
    273                                          !is_super_admin() &&
    274                                          !$this->current_group->is_user_member &&
    275                                          !groups_check_for_membership_request( $bp->loggedin_user->id, $this->current_group->id ) &&
    276                                          $this->current_group->status == 'private'
    277                                         ) {
    278                                         $sub_nav[] = array(
    279                                                 'name'               => __( 'Request Membership', 'buddypress' ),
    280                                                 'slug'               => 'request-membership',
    281                                                 'parent_url'         => $group_link,
    282                                                 'parent_slug'        => $this->root_slug,
    283                                                 'screen_function'    => 'groups_screen_group_request_membership',
    284                                                 'position'           => 30
    285                                         );
    286                                 }
    287 
    288                                 // Forums are enabled and turned on
    289                                 if ( $this->current_group->enable_forum && bp_is_active( 'forums' ) ) {
    290                                         $sub_nav[] = array(
    291                                                 'name'            => __( 'Forum', 'buddypress' ),
    292                                                 'slug'            => 'forum',
    293                                                 'parent_url'      => $group_link,
    294                                                 'parent_slug'     => $this->root_slug,
    295                                                 'screen_function' => 'groups_screen_group_forum',
    296                                                 'position'        => 40,
    297                                                 'user_has_access' => $this->current_group->user_has_access,
    298                                                 'item_css_id'     => 'forums'
    299                                         );
    300                                 }
    301 
    302                                 $sub_nav[] = array(
    303                                         'name'            => sprintf( __( 'Members (%s)', 'buddypress' ), number_format( $this->current_group->total_member_count ) ),
    304                                         'slug'            => 'members',
    305                                         'parent_url'      => $group_link,
    306                                         'parent_slug'     => $this->root_slug,
    307                                         'screen_function' => 'groups_screen_group_members',
    308                                         'position'        => 60,
    309                                         'user_has_access' => $this->current_group->user_has_access,
    310                                         'item_css_id'     => 'members'
    311                                 );
    312 
    313                                 if ( is_user_logged_in() && groups_is_user_member( $bp->loggedin_user->id, $this->current_group->id ) ) {
    314                                         if ( bp_is_active( 'friends' ) ) {
    315                                                 $sub_nav[] = array(
    316                                                         'name'            => __( 'Send Invites', 'buddypress' ),
    317                                                         'slug'            => 'send-invites',
    318                                                         'parent_url'      => $group_link,
    319                                                         'parent_slug'     => $this->root_slug,
    320                                                         'screen_function' => 'groups_screen_group_invite',
    321                                                         'item_css_id'     => 'invite',
    322                                                         'position'        => 70,
    323                                                         'user_has_access' => $this->current_group->user_has_access
    324                                                 );
    325                                         }
    326                                 }
    327 
    328                                 parent::_setup_nav( $main_nav, $sub_nav );
    329                         }
     326                        }
     327
     328                        parent::_setup_nav( $main_nav, $sub_nav );
    330329                }
    331330
  • trunk/bp-groups/bp-groups-screens.php

    r3917 r3955  
    571571                        return false;
    572572
    573                 if ( isset( $bp->action_variables[1] ) && isset( $bp->action_variables[2] ) && $bp->action_variables[3] ) {
     573                if ( isset( $bp->action_variables[1] ) && isset( $bp->action_variables[2] ) && isset( $bp->action_variables[3] ) ) {
    574574                        if ( 'promote' == $bp->action_variables[1] && ( 'mod' == $bp->action_variables[2] || 'admin' == $bp->action_variables[2] ) && is_numeric( $bp->action_variables[3] ) ) {
    575575                                $user_id = $bp->action_variables[3];
  • trunk/bp-groups/bp-groups-template.php

    r3929 r3955  
    797797        global $groups_template;
    798798
    799         if ( !$group )
     799        if ( empty( $group ) )
    800800                $group =& $groups_template->group;
    801801
    802         $admins = groups_get_group_admins( $group->id );
    803 ?>
    804         <?php if ( $admins ) { ?>
    805                 <ul id="admins-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
     802
     803        if ( $admins = groups_get_group_admins( $group->id ) ) : ?>
     804
     805                <ul id="admins-list" class="item-list<?php if ( !empty( $admin_list ) ) : ?> single-line<?php endif; ?>">
     806
    806807                <?php foreach ( (array)$admins as $admin ) { ?>
    807                         <?php if ( $admin_list ) { ?>
     808
     809                        <?php if ( !empty( $admin_list ) ) : ?>
     810
    808811                        <li>
     812
    809813                                <?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30, 'alt' => __( 'Profile picture of %s', 'buddypress' ) ) ) ?>
    810                                 <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?>  <span class="small"> &mdash; <a class="confirm admin-demote-to-member" href="<?php bp_group_member_demote_link($admin->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a></span></h5>
     814
     815                                <h5>
     816
     817                                        <?php echo bp_core_get_userlink( $admin->user_id ); ?>
     818
     819                                        <span class="small">
     820                                                <a class="button confirm admin-demote-to-member" href="<?php bp_group_member_demote_link($admin->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a>
     821                                        </span>
     822                                </h5>
    811823                        </li>
    812                         <?php } else { ?>
     824
     825                        <?php else : ?>
     826
    813827                        <li>
     828
    814829                                <?php echo bp_core_fetch_avatar( array( 'item_id' => $admin->user_id, 'type' => 'thumb', 'alt' => __( 'Profile picture of %s', 'buddypress' ) ) ) ?>
     830
    815831                                <h5><?php echo bp_core_get_userlink( $admin->user_id ) ?></h5>
    816                                 <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
     832                                <span class="activity">
     833                                        <?php echo bp_core_get_last_activity( strtotime( $admin->date_modified ), __( 'joined %s ago', 'buddypress') ); ?>
     834                                </span>
    817835
    818836                                <?php if ( bp_is_active( 'friends' ) ) : ?>
     837
    819838                                        <div class="action">
    820                                                 <?php bp_add_friend_button( $admin->user_id ) ?>
     839
     840                                                <?php bp_add_friend_button( $admin->user_id ); ?>
     841
    821842                                        </div>
     843
    822844                                <?php endif; ?>
     845
    823846                        </li>
    824                         <?php } ?>
    825                 <?php } ?>
     847
     848                        <?php endif;
     849                } ?>
     850
    826851                </ul>
    827         <?php } else { ?>
     852
     853        <?php else : ?>
     854
    828855                <div id="message" class="info">
    829856                        <p><?php _e( 'This group has no administrators', 'buddypress' ); ?></p>
    830857                </div>
    831         <?php }
     858
     859        <?php endif;
    832860}
    833861
     
    835863        global $groups_template, $group_mods;
    836864
    837         if ( !$group )
     865        if ( empty( $group ) )
    838866                $group =& $groups_template->group;
    839867
    840         $group_mods = groups_get_group_mods( $group->id );
    841         ?>
    842                 <?php if ( $group_mods ) { ?>
    843                         <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
    844                         <?php foreach ( (array)$group_mods as $mod ) { ?>
    845                                 <?php if ( $admin_list ) { ?>
    846                                 <li>
    847                                         <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30, 'alt' => __( 'Profile picture of %s', 'buddypress' ) ) ) ?>
    848                                         <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?>  <span class="small"> &mdash; <a href="<?php bp_group_member_promote_admin_link( array( 'user_id' => $mod->user_id ) ) ?>" class="confirm mod-promote-to-admin" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a> | <a class="confirm mod-demote-to-member" href="<?php bp_group_member_demote_link($mod->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a></span></h5>
    849                                 </li>
    850                                 <?php } else { ?>
    851                                 <li>
    852                                         <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb', 'alt' => __( 'Profile picture of %s', 'buddypress' ) ) ) ?>
    853                                         <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5>
    854                                         <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
    855 
    856                                         <?php if ( bp_is_active( 'friends' ) ) : ?>
    857                                                 <div class="action">
    858                                                         <?php bp_add_friend_button( $mod->user_id ) ?>
    859                                                 </div>
    860                                         <?php endif; ?>
    861                                 </li>
    862                                 <?php } ?>
     868        if ( $group_mods = groups_get_group_mods( $group->id ) ) { ?>
     869
     870                <ul id="mods-list" class="item-list<?php if ( $admin_list ) { ?> single-line<?php } ?>">
     871
     872                <?php foreach ( (array)$group_mods as $mod ) { ?>
     873
     874                        <?php if ( !empty( $admin_list ) ) { ?>
     875
     876                        <li>
     877
     878                                <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb', 'width' => 30, 'height' => 30, 'alt' => __( 'Profile picture of %s', 'buddypress' ) ) ) ?>
     879
     880                                <h5>
     881                                        <?php echo bp_core_get_userlink( $mod->user_id ); ?>
     882
     883                                        <span class="small">
     884                                                <a href="<?php bp_group_member_promote_admin_link( array( 'user_id' => $mod->user_id ) ) ?>" class="button confirm mod-promote-to-admin" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a>
     885                                                <a class="button confirm mod-demote-to-member" href="<?php bp_group_member_demote_link($mod->user_id) ?>"><?php _e( 'Demote to Member', 'buddypress' ) ?></a>
     886                                        </span>
     887                                </h5>
     888                        </li>
     889
     890                        <?php } else { ?>
     891
     892                        <li>
     893
     894                                <?php echo bp_core_fetch_avatar( array( 'item_id' => $mod->user_id, 'type' => 'thumb', 'alt' => __( 'Profile picture of %s', 'buddypress' ) ) ) ?>
     895
     896                                <h5><?php echo bp_core_get_userlink( $mod->user_id ) ?></h5>
     897
     898                                <span class="activity"><?php echo bp_core_get_last_activity( strtotime( $mod->date_modified ), __( 'joined %s ago', 'buddypress') ); ?></span>
     899
     900                                <?php if ( bp_is_active( 'friends' ) ) : ?>
     901
     902                                        <div class="action">
     903                                                <?php bp_add_friend_button( $mod->user_id ) ?>
     904                                        </div>
     905
     906                                <?php endif; ?>
     907
     908                        </li>
     909
    863910                        <?php } ?>
    864                         </ul>
    865                 <?php } else { ?>
    866                         <div id="message" class="info">
    867                                 <p><?php _e( 'This group has no moderators', 'buddypress' ); ?></p>
    868                         </div>
    869                 <?php }
     911                <?php } ?>
     912
     913                </ul>
     914
     915        <?php } else { ?>
     916
     917                <div id="message" class="info">
     918                        <p><?php _e( 'This group has no moderators', 'buddypress' ); ?></p>
     919                </div>
     920
     921        <?php }
    870922}
    871923
     
    24272479                return apply_filters( 'bp_get_current_group_name', $name );
    24282480        }
     2481
     2482function bp_groups_action_link( $action = '', $query_args = '', $nonce = false ) {
     2483        echo bp_get_groups_action_link( $action, $query_args, $nonce );
     2484}
     2485        function bp_get_groups_action_link( $action = '', $query_args = '', $nonce = false ) {
     2486                global $bp;
     2487
     2488                // Must be displayed user
     2489                if ( empty( $bp->groups->current_group->id ) )
     2490                        return;
     2491
     2492                // Append $action to $url if there is no $type
     2493                if ( !empty( $action ) )
     2494                        $url = $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $bp->groups->current_group->slug . '/' . $action;
     2495                else
     2496                        $url = $bp->root_domain . '/' . $bp->groups->root_slug . '/' . $bp->groups->current_group->slug;
     2497
     2498                // Add a slash at the end of our user url
     2499                $url = trailingslashit( $url );
     2500
     2501                // Add possible query arg
     2502                if ( !empty( $query_args ) && is_array( $query_args ) )
     2503                        $url = add_query_arg( $query_args, $url );
     2504
     2505                // To nonce, or not to nonce...
     2506                if ( true === $nonce )
     2507                        $url = wp_nonce_url( $url );
     2508                elseif ( is_string( $nonce ) )
     2509                        $url = wp_nonce_url( $url, $nonce );
     2510
     2511                // Return the url, if there is one
     2512                if ( !empty( $url ) )
     2513                        return $url;
     2514        }
    24292515?>
  • trunk/bp-members/bp-members-buddybar.php

    r3952 r3955  
    7979add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
    8080
     81/**
     82 * Adds an admin bar menu to any profile page providing site moderator actions
     83 * that allow capable users to clean up a users account.
     84 *
     85 * @package BuddyPress XProfile
     86 * @global $bp BuddyPress
     87 */
     88function bp_members_adminbar_admin_menu() {
     89        global $bp;
     90
     91        // Only show if viewing a user
     92        if ( !$bp->displayed_user->id )
     93                return false;
     94
     95        // Don't show this menu to non site admins or if you're viewing your own profile
     96        if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
     97                return false; ?>
     98
     99        <li id="bp-adminbar-adminoptions-menu">
     100                <a href=""><?php _e( 'User Admin', 'buddypress' ) ?></a>
     101
     102                <ul>
     103                        <li>
     104                                <a href="<?php echo trailingslashit( $bp->displayed_user->domain . $bp->profile->slug ); ?>"><?php _e( 'Account Status', 'buddypress' ); ?></a>
     105                                <ul>
     106
     107                                        <?php if ( !bp_core_is_user_spammer( $bp->displayed_user->id ) ) : ?>
     108
     109                                                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/mark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php printf( __( "Mark %s as Spam", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ); ?></a></li>
     110
     111                                        <?php else : ?>
     112
     113                                                <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/unmark-spammer/', 'mark-unmark-spammer' ) ?>" class="confirm"><?php _e( "Not a Spammer", 'buddypress' ) ?></a></li>
     114
     115                                        <?php endif; ?>
     116
     117                                        <li><a href="<?php echo wp_nonce_url( $bp->displayed_user->domain . 'admin/delete-user/', 'delete-user' ) ?>" class="confirm"><?php printf( __( "Delete %s's Account", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ); ?></a></li>
     118                                </ul>
     119                        </li>
     120
     121                        <?php if ( bp_is_active( 'activity' ) ) : ?>
     122
     123                                <li>
     124                                        <a href="<?php bp_members_component_link( 'activity' ); ?>"><?php _e( 'Activity', 'buddypress' ); ?></a>
     125                                        <ul>
     126                                                <li><a href="<?php bp_members_component_link( 'activity', 'admin', array( 'clear' => 'all' ), true ); ?>" class="confirm"><?php printf( __( "Delete %s's Activity", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     127                                        </ul>
     128                                </li>
     129
     130                        <?php endif; ?>
     131
     132                        <?php if ( bp_is_active( 'xprofile' ) ) : ?>
     133
     134                                <li>
     135                                        <a href="<?php bp_members_component_link( 'profile' ); ?>"><?php _e( 'Profile', 'buddypress' ); ?></a>
     136                                        <ul>
     137                                                <li><a href="<?php bp_members_component_link( 'profile', 'edit' ); ?>"><?php printf( __( "Edit %s's Profile", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     138                                                <li><a href="<?php bp_members_component_link( 'profile', 'change-avatar' ); ?>"><?php printf( __( "Edit %s's Avatar", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     139                                        </ul>
     140                                </li>
     141
     142                        <?php endif; ?>
     143
     144                        <?php if ( bp_is_active( 'messages' ) ) : ?>
     145
     146                                <li>
     147                                        <a href="<?php bp_members_component_link( 'messages' ); ?>"><?php _e( 'Messages', 'buddypress' ); ?></a>
     148                                        <ul>
     149                                                <li><a href="<?php bp_members_component_link( 'messages', 'admin', array( 'clear' => 'inbox' ), true ); ?>" class="confirm"><?php printf( __( "Empty %s's Inbox", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     150                                                <li><a href="<?php bp_members_component_link( 'messages', 'admin', array( 'clear' => 'sentbox' ), true ); ?>" class="confirm"><?php printf( __( "Empty %s's Sentbox", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     151                                                <li><a href="<?php bp_members_component_link( 'messages', 'admin', array( 'clear' => 'all' ), true ); ?>" class="confirm"><?php printf( __( "Empty All %s's Messages", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     152                                        </ul>
     153                                </li>
     154
     155                        <?php endif; ?>
     156
     157                        <?php if ( bp_is_active( 'friends' ) ) : ?>
     158
     159                                <li>
     160                                        <a href="<?php echo trailingslashit( $bp->displayed_user->domain . $bp->friends->slug ); ?>"><?php _e( 'Friends', 'buddypress' ); ?></a>
     161                                        <ul>
     162                                                <li><a href="<?php bp_members_component_link( 'friends', 'admin', array( 'clear' => 'friendships' ), true ); ?>" class="confirm"><?php printf( __( "Remove %s's Friendships", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     163                                                <li><a href="<?php bp_members_component_link( 'friends', 'admin', array( 'clear' => 'requests' ), true ); ?>" class="confirm"><?php printf( __( "Clear %s's Friend Requests", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     164                                        </ul>
     165                                </li>
     166
     167                        <?php endif; ?>
     168
     169                        <?php if ( bp_is_active( 'groups' ) ) : ?>
     170
     171                                <li>
     172                                        <a href="<?php bp_members_component_link( 'groups' ); ?>"><?php _e( 'Groups', 'buddypress' ); ?></a>
     173                                        <ul>
     174                                                <li><a href="<?php bp_members_component_link( 'groups', 'admin', array( 'clear' => 'memberships' ), true ); ?>" class="confirm"><?php printf( __( "Remove %s From Groups", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     175                                                <li><a href="<?php bp_members_component_link( 'groups', 'admin', array( 'clear' => 'invites' ), true ); ?>" class="confirm"><?php printf( __( "Clear %s's Group Invites", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     176                                        </ul>
     177                                </li>
     178
     179                        <?php endif; ?>
     180
     181                        <?php if ( bp_is_active( 'forums' ) ) : ?>
     182
     183                                <li>
     184                                        <a href="<?php bp_members_component_link( 'forums' ); ?>"><?php _e( 'Forums', 'buddypress' ); ?></a>
     185                                        <ul>
     186                                                <li><a href="<?php bp_members_component_link( 'forums', 'admin', array( 'clear' => 'topics' ), true ); ?>" class="confirm"><?php printf( __( "Delete %s's Topics", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     187                                                <li><a href="<?php bp_members_component_link( 'forums', 'admin', array( 'clear' => 'replies' ), true ); ?>" class="confirm"><?php printf( __( "Delete %s's Replies", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     188                                                <li><a href="<?php bp_members_component_link( 'forums', 'admin', array( 'clear' => 'all' ), true ); ?>" class="confirm"><?php printf( __( "Delete All %s's Posts", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     189                                        </ul>
     190                                </li>
     191
     192                        <?php endif; ?>
     193
     194                        <?php if ( bp_is_active( 'settings' ) ) : ?>
     195
     196                                <li>
     197                                        <a href="<?php bp_members_component_link( 'settings' ); ?>"><?php _e( 'Settings', 'buddypress' ); ?></a>
     198                                        <ul>
     199                                                <li><a href="<?php bp_members_component_link( 'settings', 'general' ); ?>"><?php printf( __( "Edit %s's Settings", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     200                                                <li><a href="<?php bp_members_component_link( 'settings', 'notifications' ); ?>"><?php printf( __( "Edit %s's Notifications", 'buddypress' ), esc_attr( $bp->displayed_user->fullname ) ) ?></a></li>
     201                                        </ul>
     202                                </li>
     203
     204                        <?php endif; ?>
     205
     206                        <?php do_action( 'bp_members_adminbar_admin_menu' ) ?>
     207
     208                </ul>
     209        </li>
     210
     211        <?php
     212}
     213add_action( 'bp_adminbar_menus', 'bp_members_adminbar_admin_menu', 20 );
     214
    81215?>
  • trunk/bp-members/bp-members-functions.php

    r3917 r3955  
    626626                return true;
    627627
    628         if ( is_super_admin() )
     628        if ( is_super_admin() || current_user_can( 'edit_users' ) )
    629629                return true;
    630630
  • trunk/bp-members/bp-members-template.php

    r3930 r3955  
    984984add_action( 'bp_head', 'bp_members_activity_feed' );
    985985
     986
     987function bp_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) {
     988        echo bp_get_members_component_link( $component, $action, $query_args, $nonce );
     989}
     990        function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) {
     991                global $bp;
     992
     993                // Must be displayed user
     994                if ( empty( $bp->displayed_user->id ) )
     995                        return;
     996
     997                // Append $action to $url if there is no $type
     998                if ( !empty( $action ) )
     999                        $url = $bp->displayed_user->domain . $bp->{$component}->slug . '/' . $action;
     1000                else
     1001                        $url = $bp->displayed_user->domain . $bp->{$component}->slug;
     1002
     1003                // Add a slash at the end of our user url
     1004                $url = trailingslashit( $url );
     1005
     1006                // Add possible query arg
     1007                if ( !empty( $query_args ) && is_array( $query_args ) )
     1008                        $url = add_query_arg( $query_args, $url );
     1009
     1010                // To nonce, or not to nonce...
     1011                if ( true === $nonce )
     1012                        $url = wp_nonce_url( $url );
     1013                elseif ( is_string( $nonce ) )
     1014                        $url = wp_nonce_url( $url, $nonce );
     1015
     1016                // Return the url, if there is one
     1017                if ( !empty( $url ) )
     1018                        return $url;
     1019        }
     1020
    9861021?>
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r3847 r3955  
    338338                echo '<span class="activity">' . esc_attr( $user->last_active ) . '</span>';
    339339                echo '<div class="action">
    340                                 <a class="remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
     340                                <a class="button remove" href="' . wp_nonce_url( $bp->loggedin_user->domain . $bp->groups->slug . '/' . $_POST['group_id'] . '/invites/remove/' . $user->id, 'groups_invite_uninvite_user' ) . '" id="uid-' . esc_attr( $user->id ) . '">' . __( 'Remove Invite', 'buddypress' ) . '</a>
    341341                          </div>';
    342342                echo '</li>';
  • trunk/bp-themes/bp-default/_inc/css/default.css

    r3912 r3955  
    657657        font-weight: normal;
    658658        font-size: 11px;
     659        float: right;
    659660}
    660661
  • trunk/bp-themes/bp-default/groups/single/admin.php

    r3878 r3955  
    195195                                                        <?php if ( bp_get_group_member_is_banned() ) _e( '(banned)', 'buddypress'); ?>
    196196
    197                                                         <span class="small"> -
     197                                                        <span class="small">
    198198
    199199                                                        <?php if ( bp_get_group_member_is_banned() ) : ?>
    200200
    201                                                                 <a href="<?php bp_group_member_unban_link() ?>" class="confirm member-unban" title="<?php _e( 'Unban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a>
     201                                                                <a href="<?php bp_group_member_unban_link() ?>" class="button confirm member-unban" title="<?php _e( 'Unban this member', 'buddypress' ) ?>"><?php _e( 'Remove Ban', 'buddypress' ); ?></a>
    202202
    203203                                                        <?php else : ?>
    204204
    205                                                                 <a href="<?php bp_group_member_ban_link() ?>" class="confirm member-ban" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick &amp; Ban', 'buddypress' ); ?></a>
    206                                                                 | <a href="<?php bp_group_member_promote_mod_link() ?>" class="confirm member-promote-to-mod" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a>
    207                                                                 | <a href="<?php bp_group_member_promote_admin_link() ?>" class="confirm member-promote-to-admin" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a>
     205                                                                <a href="<?php bp_group_member_ban_link() ?>" class="button confirm member-ban" title="<?php _e( 'Kick and ban this member', 'buddypress' ); ?>"><?php _e( 'Kick &amp; Ban', 'buddypress' ); ?></a>
     206                                                                <a href="<?php bp_group_member_promote_mod_link() ?>" class="button confirm member-promote-to-mod" title="<?php _e( 'Promote to Mod', 'buddypress' ); ?>"><?php _e( 'Promote to Mod', 'buddypress' ); ?></a>
     207                                                                <a href="<?php bp_group_member_promote_admin_link() ?>" class="button confirm member-promote-to-admin" title="<?php _e( 'Promote to Admin', 'buddypress' ); ?>"><?php _e( 'Promote to Admin', 'buddypress' ); ?></a>
    208208
    209209                                                        <?php endif; ?>
    210210
    211                                                                 | <a href="<?php bp_group_member_remove_link() ?>" class="confirm" title="<?php _e( 'Remove this member', 'buddypress' ); ?>"><?php _e( 'Remove from group', 'buddypress' ); ?></a>
     211                                                                <a href="<?php bp_group_member_remove_link() ?>" class="button confirm" title="<?php _e( 'Remove this member', 'buddypress' ); ?>"><?php _e( 'Remove from group', 'buddypress' ); ?></a>
    212212
    213213                                                                <?php do_action( 'bp_group_manage_members_admin_item' ); ?>
  • trunk/bp-themes/bp-default/groups/single/send-invites.php

    r3771 r3955  
    4040
    4141                                                <div class="action">
    42                                                         <a class="remove" href="<?php bp_group_invite_user_remove_invite_url() ?>" id="<?php bp_group_invite_item_id() ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
     42                                                        <a class="button remove" href="<?php bp_group_invite_user_remove_invite_url() ?>" id="<?php bp_group_invite_item_id() ?>"><?php _e( 'Remove Invite', 'buddypress' ) ?></a>
    4343
    4444                                                        <?php do_action( 'bp_group_send_invites_item_action' ) ?>
  • trunk/bp-xprofile/bp-xprofile-buddybar.php

    r3949 r3955  
    7575        <?php
    7676}
    77 add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 );
     77//add_action( 'bp_adminbar_menus', 'xprofile_setup_adminbar_menu', 20 );
    7878
    7979?>
Note: See TracChangeset for help on using the changeset viewer.