Skip to:
Content

BuddyPress.org

Changeset 9463


Ignore:
Timestamp:
02/09/2015 10:00:09 PM (5 years ago)
Author:
johnjamesjacoby
Message:

Explicit visibility for group template classes. See r7277, #5108.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-template.php

    r9462 r9463  
    30713071
    30723072class BP_Groups_Group_Members_Template {
    3073     var $current_member = -1;
    3074     var $member_count;
    3075     var $members;
    3076     var $member;
    3077 
    3078     var $in_the_loop;
    3079 
    3080     var $pag_page;
    3081     var $pag_num;
    3082     var $pag_links;
    3083     var $total_group_count;
     3073    public $current_member = -1;
     3074    public $member_count;
     3075    public $members;
     3076    public $member;
     3077
     3078    public $in_the_loop;
     3079
     3080    public $pag_page;
     3081    public $pag_num;
     3082    public $pag_links;
     3083    public $total_group_count;
    30843084
    30853085    /**
     
    31033103     * }
    31043104     */
    3105     function __construct( $args = array() ) {
     3105    public function __construct( $args = array() ) {
    31063106
    31073107        // Backward compatibility with old method of passing arguments
     
    31373137        ) );
    31383138
    3139         // @todo No
    3140         extract( $r );
    3141 
    31423139        $this->pag_arg  = sanitize_key( $r['page_arg'] );
    31433140        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page']     );
     
    31493146         */
    31503147        $current_group = groups_get_current_group();
    3151         if ( ! $current_group || $current_group && $current_group->id !== bp_get_current_group_id() ) {
     3148        if ( empty( $current_group ) || ( $current_group && $current_group->id !== bp_get_current_group_id() ) ) {
    31523149            $current_group = groups_get_group( array( 'group_id' => $r['group_id'] ) );
    31533150        }
     
    31643161        $members_args['per_page'] = $this->pag_num;
    31653162
     3163        // Get group members for this loop
    31663164        $this->members = groups_get_group_members( $members_args );
    31673165
    3168         if ( !$max || $max >= (int) $this->members['count'] )
     3166        if ( empty( $r['max'] ) || ( $r['max'] >= (int) $this->members['count'] ) ) {
    31693167            $this->total_member_count = (int) $this->members['count'];
    3170         else
    3171             $this->total_member_count = (int) $max;
    3172 
     3168        } else {
     3169            $this->total_member_count = (int) $r['max'];
     3170        }
     3171
     3172        // Reset members array for subsequent looping
    31733173        $this->members = $this->members['members'];
    31743174
    3175         if ( $max ) {
    3176             if ( $max >= count($this->members) )
    3177                 $this->member_count = count($this->members);
    3178             else
    3179                 $this->member_count = (int) $max;
     3175        if ( empty( $r['max'] ) || ( $r['max'] >= count( $this->members ) ) ) {
     3176            $this->member_count = (int) count( $this->members );
    31803177        } else {
    3181             $this->member_count = count($this->members);
     3178            $this->member_count = (int) $r['max'];
    31823179        }
    31833180
     
    31913188            'mid_size'  => 1,
    31923189            'add_args'  => array(),
    3193         ));
    3194     }
    3195 
    3196     function has_members() {
    3197         if ( $this->member_count )
     3190        ) );
     3191    }
     3192
     3193    public function has_members() {
     3194        if ( ! empty( $this->member_count ) ) {
    31983195            return true;
     3196        }
    31993197
    32003198        return false;
    32013199    }
    32023200
    3203     function next_member() {
     3201    public function next_member() {
    32043202        $this->current_member++;
    3205         $this->member = $this->members[$this->current_member];
     3203        $this->member = $this->members[ $this->current_member ];
    32063204
    32073205        return $this->member;
    32083206    }
    32093207
    3210     function rewind_members() {
     3208    public function rewind_members() {
    32113209        $this->current_member = -1;
    32123210        if ( $this->member_count > 0 ) {
     
    32153213    }
    32163214
    3217     function members() {
    3218         if ( $this->current_member + 1 < $this->member_count ) {
     3215    public function members() {
     3216        $tick = intval( $this->current_member + 1 );
     3217        if ( $tick < $this->member_count ) {
    32193218            return true;
    3220         } elseif ( $this->current_member + 1 == $this->member_count ) {
    3221             do_action('loop_end');
     3219        } elseif ( $tick == $this->member_count ) {
     3220            do_action( 'loop_end' );
    32223221            // Do some cleaning up after the loop
    32233222            $this->rewind_members();
     
    32283227    }
    32293228
    3230     function the_member() {
    3231 
     3229    public function the_member() {
    32323230        $this->in_the_loop = true;
    32333231        $this->member      = $this->next_member();
    32343232
    3235         if ( 0 == $this->current_member ) // loop has just started
    3236             do_action('loop_start');
     3233        // loop has just started
     3234        if ( 0 == $this->current_member ) {
     3235            do_action( 'loop_start' );
     3236        }
    32373237    }
    32383238}
     
    41174117}
    41184118
    4119 
    4120 /************************************************************************************
    4121  * Membership Requests Template Tags
    4122  **/
     4119/** Group Membership Requests *************************************************/
    41234120
    41244121class BP_Groups_Membership_Requests_Template {
    4125     var $current_request = -1;
    4126     var $request_count;
    4127     var $requests;
    4128     var $request;
    4129 
    4130     var $in_the_loop;
    4131 
    4132     var $pag_page;
    4133     var $pag_num;
    4134     var $pag_links;
    4135     var $total_request_count;
     4122    public $current_request = -1;
     4123    public $request_count;
     4124    public $requests;
     4125    public $request;
     4126
     4127    public $in_the_loop;
     4128
     4129    public $pag_page;
     4130    public $pag_num;
     4131    public $pag_links;
     4132    public $total_request_count;
    41364133
    41374134    /**
     
    41474144     * }
    41484145     */
    4149     function __construct( $args = array() ) {
     4146    public function __construct( $args = array() ) {
    41504147
    41514148        // Backward compatibility with old method of passing arguments
     
    42024199        }
    42034200
    4204         if ( !$r['max'] || $r['max'] >= (int) $mquery->total_users )
     4201        if ( empty( $r['max'] ) || ( $r['max'] >= (int) $mquery->total_users ) ) {
    42054202            $this->total_request_count = (int) $mquery->total_users;
    4206         else
     4203        } else {
    42074204            $this->total_request_count = (int) $r['max'];
    4208 
    4209         if ( $r['max'] ) {
    4210             if ( $r['max'] >= count($this->requests) )
    4211                 $this->request_count = count($this->requests);
    4212             else
    4213                 $this->request_count = (int) $r['max'];
     4205        }
     4206
     4207        if ( empty( $r['max'] ) || ( $r['max'] >= count( $this->requests ) ) ) {
     4208            $this->request_count = count( $this->requests );
    42144209        } else {
    4215             $this->request_count = count($this->requests);
     4210            $this->request_count = (int) $r['max'];
    42164211        }
    42174212
     
    42284223    }
    42294224
    4230     function has_requests() {
    4231         if ( $this->request_count )
     4225    public function has_requests() {
     4226        if ( ! empty( $this->request_count ) ) {
    42324227            return true;
     4228        }
    42334229
    42344230        return false;
    42354231    }
    42364232
    4237     function next_request() {
     4233    public function next_request() {
    42384234        $this->current_request++;
    4239         $this->request = $this->requests[$this->current_request];
     4235        $this->request = $this->requests[ $this->current_request ];
    42404236
    42414237        return $this->request;
    42424238    }
    42434239
    4244     function rewind_requests() {
     4240    public function rewind_requests() {
    42454241        $this->current_request = -1;
    42464242
    4247         if ( $this->request_count > 0 )
     4243        if ( $this->request_count > 0 ) {
    42484244            $this->request = $this->requests[0];
    4249     }
    4250 
    4251     function requests() {
    4252         if ( $this->current_request + 1 < $this->request_count ) {
     4245        }
     4246    }
     4247
     4248    public function requests() {
     4249        $tick = intval( $this->current_request + 1 );
     4250        if ( $tick < $this->request_count ) {
    42534251            return true;
    4254         } elseif ( $this->current_request + 1 == $this->request_count ) {
    4255             do_action('group_request_loop_end');
     4252        } elseif ( $tick == $this->request_count ) {
     4253            do_action( 'group_request_loop_end' );
    42564254            // Do some cleaning up after the loop
    42574255            $this->rewind_requests();
     
    42624260    }
    42634261
    4264     function the_request() {
     4262    public function the_request() {
    42654263        $this->in_the_loop = true;
    42664264        $this->request     = $this->next_request();
    42674265
    4268         if ( 0 == $this->current_request ) // loop has just started
    4269             do_action('group_request_loop_start');
     4266        // loop has just started
     4267        if ( 0 == $this->current_request ) {
     4268            do_action( 'group_request_loop_start' );
     4269        }
    42704270    }
    42714271}
     
    44014401    }
    44024402
    4403 /************************************************************************************
    4404  * Invite Friends Template Tags
    4405  **/
     4403/** Group Invitations *********************************************************/
    44064404
    44074405class BP_Groups_Invite_Template {
    4408     var $current_invite = -1;
    4409     var $invite_count;
    4410     var $invites;
    4411     var $invite;
    4412 
    4413     var $in_the_loop;
    4414 
    4415     var $pag_page;
    4416     var $pag_num;
    4417     var $pag_links;
    4418     var $total_invite_count;
     4406    public $current_invite = -1;
     4407    public $invite_count;
     4408    public $invites;
     4409    public $invite;
     4410
     4411    public $in_the_loop;
     4412
     4413    public $pag_page;
     4414    public $pag_num;
     4415    public $pag_links;
     4416    public $total_invite_count;
    44194417
    44204418    public function __construct( $args = array() ) {
     
    44554453            'inviter_id'   => $r['user_id'],
    44564454        ) );
    4457         $this->invite_data = $iquery->results;
    4458 
     4455
     4456        $this->invite_data        = $iquery->results;
    44594457        $this->total_invite_count = $iquery->total_users;
    4460         $this->invites        = array_values( wp_list_pluck( $this->invite_data, 'ID' ) );
     4458        $this->invites            = array_values( wp_list_pluck( $this->invite_data, 'ID' ) );
    44614459        $this->invite_count       = count( $this->invites );
    44624460
     
    44794477    }
    44804478
    4481     function has_invites() {
    4482         if ( $this->invite_count )
     4479    public function has_invites() {
     4480        if ( ! empty( $this->invite_count ) ) {
    44834481            return true;
     4482        }
    44844483
    44854484        return false;
    44864485    }
    44874486
    4488     function next_invite() {
     4487    public function next_invite() {
    44894488        $this->current_invite++;
    4490         $this->invite = $this->invites[$this->current_invite];
     4489        $this->invite = $this->invites[ $this->current_invite ];
    44914490
    44924491        return $this->invite;
    44934492    }
    44944493
    4495     function rewind_invites() {
     4494    public function rewind_invites() {
    44964495        $this->current_invite = -1;
    4497         if ( $this->invite_count > 0 )
     4496        if ( $this->invite_count > 0 ) {
    44984497            $this->invite = $this->invites[0];
    4499     }
    4500 
    4501     function invites() {
    4502         if ( $this->current_invite + 1 < $this->invite_count ) {
     4498        }
     4499    }
     4500
     4501    public function invites() {
     4502        $tick = intval( $this->current_invite + 1 );
     4503        if ( $tick < $this->invite_count ) {
    45034504            return true;
    4504         } elseif ( $this->current_invite + 1 == $this->invite_count ) {
    4505             do_action('loop_end');
     4505        } elseif ( $tick == $this->invite_count ) {
     4506            do_action( 'loop_end' );
    45064507            // Do some cleaning up after the loop
    45074508            $this->rewind_invites();
     
    45124513    }
    45134514
    4514     function the_invite() {
     4515    public function the_invite() {
    45154516        global $group_id;
    4516         $this->in_the_loop      = true;
    4517         $user_id                = $this->next_invite();
    4518 
    4519         $this->invite           = new stdClass;
    4520         $this->invite->user     = $this->invite_data[ $user_id ];
     4517
     4518        $this->in_the_loop  = true;
     4519        $user_id            = $this->next_invite();
     4520
     4521        $this->invite       = new stdClass;
     4522        $this->invite->user = $this->invite_data[ $user_id ];
    45214523
    45224524        // This method previously populated the user object with
     
    45274529        }
    45284530
    4529         $this->invite->user->avatar       = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->invite->user->fullname ) ) );
     4531        $this->invite->user->avatar       = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'full',  'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->invite->user->fullname ) ) );
    45304532        $this->invite->user->avatar_thumb = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->invite->user->fullname ) ) );
    45314533        $this->invite->user->avatar_mini  = bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile photo of %s', 'buddypress' ), $this->invite->user->fullname ), 'width' => 30, 'height' => 30 ) );
     
    45464548        $this->invite->user->total_blogs = null;
    45474549
    4548         $this->invite->group_id = $group_id; // Global'ed in bp_group_has_invites()
    4549 
    4550         if ( 0 == $this->current_invite ) // loop has just started
    4551             do_action('loop_start');
     4550        // Global'ed in bp_group_has_invites()
     4551        $this->invite->group_id = $group_id;
     4552
     4553        // loop has just started
     4554        if ( 0 == $this->current_invite ) {
     4555            do_action( 'loop_start' );
     4556        }
    45524557    }
    45534558}
Note: See TracChangeset for help on using the changeset viewer.