Skip to:
Content

BuddyPress.org

Ticket #5367: 5367.required.diff

File 5367.required.diff, 4.2 KB (added by imath, 11 years ago)
  • bp-members/bp-members-admin.php

     
    122122                $this->signups_page = '';
    123123                $this->users_url    = bp_get_admin_url( 'users.php' );
    124124                $this->users_screen = bp_core_do_network_admin() ? 'users-network' : 'users';
     125
     126                // Specific config: BuddyPress is not network activated
     127                $this->subsite_activated = (bool) is_multisite() && ! bp_is_network_activated() && bp_is_root_blog();
    125128        }
    126129
    127130        /**
     
    298301                } ?>
    299302
    300303                <ul id="profile-nav" class="nav-tab-wrapper">
    301                         <li class="nav-tab<?php echo esc_attr( $wp_active ); ?>"><a href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'WordPress Profile', 'buddypress' ); ?></a></li>
     304                        <?php
     305                        /**
     306                         * In configs where BuddyPress is not network activated, as regular
     307                         * admins do not have the capacity to edit other users, we must add
     308                         * this check.
     309                         */
     310                        ?>
     311                        <?php if ( current_user_can( 'edit_user' ) ) :?>
     312                                <li class="nav-tab<?php echo esc_attr( $wp_active ); ?>"><a href="<?php echo esc_url( $wordpress_url );?>"><?php _e( 'WordPress Profile', 'buddypress' ); ?></a></li>
     313                        <?php endif ;?>
    302314                        <li class="nav-tab<?php echo esc_attr( $bp_active ); ?>"><a href="<?php echo esc_url( $community_url );?>"><?php _e( 'Community Profile', 'buddypress' ); ?></a></li>
    303315
    304316                        <?php do_action( 'bp_members_admin_profile_nav', $active, $user ); ?>
     
    609621                                </div><!-- #minor-publishing-actions -->
    610622
    611623                                <div id="misc-publishing-actions">
    612                                         <div class="misc-pub-section" id="comment-status-radio">
    613                                                 <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 />
    614                                                 <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>
    615                                         </div>
     624                                        <?php
     625                                        /**
     626                                         * In configs where BuddyPress is not network activated, regular admins
     627                                         * cannot mark a user as a spammer on front end.
     628                                         */
     629                                        ?>
     630                                        <?php if ( empty( $this->subsite_activated ) || ( ! empty( $this->subsite_activated ) && current_user_can( 'manage_network_users' ) ) ) : ?>
     631                                                <div class="misc-pub-section" id="comment-status-radio">
     632                                                        <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 />
     633                                                        <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>
     634                                                </div>
     635                                        <?php endif ;?>
    616636
    617637                                        <div class="misc-pub-section curtime misc-pub-section-last">
    618638                                                <?php
     
    709729                        return $actions;
    710730                }
    711731
     732                // Prevent a regular admin to edit a super admin
     733                if( in_array( $user->user_login, get_super_admins() ) ) {
     734                        return $actions;
     735                }
     736
    712737                $edit_profile = add_query_arg( array(
    713738                        'user_id'         => $user->ID,
    714739                        'wp_http_referer' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
    715740                ), $this->edit_profile_url );
    716741
    717                 $edit_action = $actions['edit'];
    718                 unset( $actions['edit'] );
     742                $edit_profile_link = '<a href="' . esc_url( $edit_profile ) . '">' . esc_html__( 'Profile', 'buddypress' ) . '</a>';
    719743
    720                 $new_edit_actions = array(
    721                         'edit'         => $edit_action,
    722                         'edit-profile' => '<a href="' . esc_url( $edit_profile ) . '">' . esc_html__( 'Profile', 'buddypress' ) . '</a>'
    723                 );
     744                /**
     745                 * If BuddyPress is not network activated the regular admin
     746                 * cannot edit users. We need to first check the edit action
     747                 * is available
     748                 */
     749                if ( ! empty( $actions['edit'] ) ) {
     750                        $edit_action = $actions['edit'];
     751                        unset( $actions['edit'] );
     752 
     753                        $new_edit_actions = array(
     754                                'edit'         => $edit_action,
     755                                'edit-profile' => $edit_profile_link,
     756                        );
     757                } else {
     758                        $new_edit_actions = array( 'edit-profile' => $edit_profile_link );
     759                }
    724760
    725761                return array_merge( $new_edit_actions, $actions );
    726762        }