Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/20/2014 03:33:49 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Member Admin:

  • Allow admins to edit other admins.
  • Allow admins to edit their own profiles.
  • Replace our custom tabbed UL/LI interface with WordPress core H2 navigation (and update admin.css accordingly.)

See #5623.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-admin.php

    r8318 r8432  
    318318                } ?>
    319319
    320                 <ul id="profile-nav" class="nav-tab-wrapper">
     320                <h2 id="profile-nav" class="nav-tab-wrapper">
    321321                        <?php
    322322                        /**
     
    326326                         */
    327327                        ?>
    328                         <?php if ( current_user_can( 'edit_user' ) ) :?>
    329                                 <li class="nav-tab<?php echo esc_attr( $wp_active ); ?>"><a href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'Profile', 'buddypress' ); ?></a></li>
    330                         <?php endif ;?>
    331                         <li class="nav-tab<?php echo esc_attr( $bp_active ); ?>"><a href="<?php echo esc_url( $community_url );?>"><?php _e( 'Extended Profile', 'buddypress' ); ?></a></li>
    332 
    333                         <?php do_action( 'bp_members_admin_profile_nav', $active, $user ); ?>
    334                 </ul>
     328                        <?php if ( current_user_can( 'edit_user' ) ) : ?>
     329                                <a class="nav-tab<?php echo esc_attr( $wp_active ); ?>" href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'Profile', 'buddypress' ); ?></a>
     330                        <?php endif; ?>
     331                        <a class="nav-tab<?php echo esc_attr( $bp_active ); ?>" href="<?php echo esc_url( $community_url );?>"><?php _e( 'Extended Profile', 'buddypress' ); ?></a>
     332                </h2>
    335333
    336334                <?php
     
    351349                if ( ! $user_id = intval( $_GET['user_id'] ) ) {
    352350                        wp_die( __( 'No users were found', 'buddypress' ) );
    353                 }
    354 
    355                 // only edit others profile
    356                 if ( get_current_user_id() == $user_id ) {
    357                         bp_core_redirect( get_edit_user_link( $user_id ) );
    358351                }
    359352
     
    632625                                <div id="misc-publishing-actions">
    633626                                        <?php
     627
     628                                        // Get the spam status once here to compare against below
     629                                        $is_spammer = bp_is_user_spammer( $user->ID );
     630
    634631                                        /**
    635                                          * In configs where BuddyPress is not network activated, regular admins
    636                                          * cannot mark a user as a spammer on front end. This prevent them to do
    637                                          * it in backend.
     632                                         * In configs where BuddyPress is not network activated,
     633                                         * regular admins cannot mark a user as a spammer on front
     634                                         * end. This prevent them to do it in backend.
     635                                         *
     636                                         * Also prevent admins from marking themselves or other
     637                                         * admins as spammers.
    638638                                         */
    639                                         ?>
    640                                         <?php if ( empty( $this->subsite_activated ) || ( ! empty( $this->subsite_activated ) && current_user_can( 'manage_network_users' ) ) ) : ?>
     639                                        if ( ( get_current_user_id() !== $user->ID ) && ( ! in_array( $user->user_login, get_super_admins() ) ) &&  empty( $this->subsite_activated ) || ( ! empty( $this->subsite_activated ) && current_user_can( 'manage_network_users' ) ) ) : ?>
    641640                                                <div class="misc-pub-section" id="comment-status-radio">
    642                                                         <label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( bp_is_user_spammer( $user->ID ), false ); ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></label><br />
    643                                                         <label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( bp_is_user_spammer( $user->ID ), true ); ?>><?php esc_html_e( 'Spammer', 'buddypress' ); ?></label>
     641                                                        <label class="approved"><input type="radio" name="user_status" value="ham" <?php checked( $is_spammer, false ); ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></label><br />
     642                                                        <label class="spam"><input type="radio" name="user_status" value="spam" <?php checked( $is_spammer, true ); ?>><?php esc_html_e( 'Spammer', 'buddypress' ); ?></label>
    644643                                                </div>
    645644                                        <?php endif ;?>
     
    737736         */
    738737        public function row_actions( $actions = '', $user = null ) {
    739                 // only edit others profile
    740                 if ( get_current_user_id() == $user->ID ) {
    741                         return $actions;
    742                 }
    743 
    744                 // Prevent a regular admin to edit a super admin
    745                 if( in_array( $user->user_login, get_super_admins() ) ) {
    746                         return $actions;
    747                 }
    748738
    749739                $edit_profile = add_query_arg( array(
     
    752742                ), $this->edit_profile_url );
    753743
    754                 $edit_profile_link = '<a href="' . esc_url( $edit_profile ) . '">' . esc_html__( 'Extended Profile', 'buddypress' ) . '</a>';
     744                $edit_profile_link = sprintf( '<a href="%1$s">%2$s</a>',  esc_url( $edit_profile ), esc_html__( 'Extended', 'buddypress' ) );
    755745
    756746                /**
Note: See TracChangeset for help on using the changeset viewer.