Skip to:
Content

BuddyPress.org

Ticket #7382: 7382.02.patch

File 7382.02.patch, 3.7 KB (added by r-a-y, 10 years ago)
  • src/bp-groups/bp-groups-functions.php

     
    15221522        $group = groups_get_group( $group_id );
    15231523
    15241524        for ( $i = 0, $count = count( $invited_users ); $i < $count; ++$i ) {
    1525                 $member = new BP_Groups_Member( $invited_users[$i], $group_id );
     1525                $member = new BP_Groups_Member( $invited_users[$i], $group_id, false, true, array( 'populate_user_object' => false ) );
    15261526
    15271527                // Send the actual invite.
    15281528                groups_notification_group_invites( $group, $member, $user_id );
     
    16251625        if ( ! bp_is_item_admin() )
    16261626                return false;
    16271627
    1628         $member = new BP_Groups_Member( $user_id, $group_id );
     1628        $member = new BP_Groups_Member( $user_id, $group_id, false, true, array( 'populate_user_object' => false ) );
    16291629
    16301630        // Don't use this action. It's deprecated as of BuddyPress 1.6.
    16311631        do_action( 'groups_premote_member', $group_id, $user_id, $status );
  • src/bp-groups/classes/class-bp-groups-member.php

     
    135135         * Constructor method.
    136136         *
    137137         * @since 1.6.0
     138         * @since 2.8.0 Introduce $options as a parameter.
    138139         *
    139140         * @param int      $user_id  Optional. Along with $group_id, can be used to
    140141         *                           look up a membership.
     
    143144         * @param int|bool $id       Optional. The unique ID of the membership object.
    144145         * @param bool     $populate Whether to populate the properties of the
    145146         *                           located membership. Default: true.
     147         * @param array    $options  {
     148         *      An array of additional options.
     149         *      @var bool $populate_user_object If $populate is set to true, whether we should do an additional
     150         *                                      query for the BP_Core_User object in the populate() method. Default:
     151         *                                      true.
     152         * }
    146153         */
    147         public function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true ) {
     154        public function __construct( $user_id = 0, $group_id = 0, $id = false, $populate = true, $options = array() ) {
     155                // Set options.
     156                $populate_user = true;
     157                if ( isset( $options['populate_user_object'] ) && false === $options['populate_user_object'] ) {
     158                        $populate_user = false;
     159                }
    148160
    149161                // User and group are not empty, and ID is.
    150                 if ( !empty( $user_id ) && !empty( $group_id ) && empty( $id ) ) {
     162                if ( ! empty( $user_id ) && ! empty( $group_id ) && empty( $id ) ) {
    151163                        $this->user_id  = $user_id;
    152164                        $this->group_id = $group_id;
    153165
    154                         if ( !empty( $populate ) ) {
    155                                 $this->populate();
     166                        if ( ! empty( $populate ) ) {
     167                                $this->populate( $populate_user );
    156168                        }
    157169                }
    158170
    159171                // ID is not empty.
    160                 if ( !empty( $id ) ) {
     172                if ( ! empty( $id ) ) {
    161173                        $this->id = $id;
    162174
    163                         if ( !empty( $populate ) ) {
    164                                 $this->populate();
     175                        if ( ! empty( $populate ) ) {
     176                                $this->populate( $populate_user );
    165177                        }
    166178                }
    167179        }
     
    170182         * Populate the object's properties.
    171183         *
    172184         * @since 1.6.0
     185         * @since 2.8.0 Introduce $populate_user parameter.
     186         *
     187         * @param bool $populate_user Whether we should query for the BP_Core_User object. Default: true.
    173188         */
    174         public function populate() {
     189        public function populate( $populate_user = true ) {
    175190                global $wpdb;
    176191
    177192                $bp = buddypress();
     
    198213                        $this->comments      = $member->comments;
    199214                        $this->invite_sent   = (int) $member->invite_sent;
    200215
    201                         $this->user = new BP_Core_User( $this->user_id );
     216                        if ( $populate_user ) {
     217                                $this->user = new BP_Core_User( $this->user_id );
     218                        }
    202219                }
    203220        }
    204221