Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/27/2011 09:15:35 PM (14 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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?>
Note: See TracChangeset for help on using the changeset viewer.