Changeset 9463 for trunk/src/bp-groups/bp-groups-template.php
- Timestamp:
- 02/09/2015 10:00:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r9462 r9463 3071 3071 3072 3072 class 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; 3084 3084 3085 3085 /** … … 3103 3103 * } 3104 3104 */ 3105 function __construct( $args = array() ) {3105 public function __construct( $args = array() ) { 3106 3106 3107 3107 // Backward compatibility with old method of passing arguments … … 3137 3137 ) ); 3138 3138 3139 // @todo No3140 extract( $r );3141 3142 3139 $this->pag_arg = sanitize_key( $r['page_arg'] ); 3143 3140 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] ); … … 3149 3146 */ 3150 3147 $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() ) ) { 3152 3149 $current_group = groups_get_group( array( 'group_id' => $r['group_id'] ) ); 3153 3150 } … … 3164 3161 $members_args['per_page'] = $this->pag_num; 3165 3162 3163 // Get group members for this loop 3166 3164 $this->members = groups_get_group_members( $members_args ); 3167 3165 3168 if ( !$max || $max >= (int) $this->members['count'] )3166 if ( empty( $r['max'] ) || ( $r['max'] >= (int) $this->members['count'] ) ) { 3169 3167 $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 3173 3173 $this->members = $this->members['members']; 3174 3174 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 ); 3180 3177 } else { 3181 $this->member_count = count($this->members);3178 $this->member_count = (int) $r['max']; 3182 3179 } 3183 3180 … … 3191 3188 'mid_size' => 1, 3192 3189 '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 ) ) { 3198 3195 return true; 3196 } 3199 3197 3200 3198 return false; 3201 3199 } 3202 3200 3203 function next_member() {3201 public function next_member() { 3204 3202 $this->current_member++; 3205 $this->member = $this->members[ $this->current_member];3203 $this->member = $this->members[ $this->current_member ]; 3206 3204 3207 3205 return $this->member; 3208 3206 } 3209 3207 3210 function rewind_members() {3208 public function rewind_members() { 3211 3209 $this->current_member = -1; 3212 3210 if ( $this->member_count > 0 ) { … … 3215 3213 } 3216 3214 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 ) { 3219 3218 return true; 3220 } elseif ( $t his->current_member + 1== $this->member_count ) {3221 do_action( 'loop_end');3219 } elseif ( $tick == $this->member_count ) { 3220 do_action( 'loop_end' ); 3222 3221 // Do some cleaning up after the loop 3223 3222 $this->rewind_members(); … … 3228 3227 } 3229 3228 3230 function the_member() { 3231 3229 public function the_member() { 3232 3230 $this->in_the_loop = true; 3233 3231 $this->member = $this->next_member(); 3234 3232 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 } 3237 3237 } 3238 3238 } … … 4117 4117 } 4118 4118 4119 4120 /************************************************************************************ 4121 * Membership Requests Template Tags 4122 **/ 4119 /** Group Membership Requests *************************************************/ 4123 4120 4124 4121 class 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; 4136 4133 4137 4134 /** … … 4147 4144 * } 4148 4145 */ 4149 function __construct( $args = array() ) {4146 public function __construct( $args = array() ) { 4150 4147 4151 4148 // Backward compatibility with old method of passing arguments … … 4202 4199 } 4203 4200 4204 if ( !$r['max'] || $r['max'] >= (int) $mquery->total_users )4201 if ( empty( $r['max'] ) || ( $r['max'] >= (int) $mquery->total_users ) ) { 4205 4202 $this->total_request_count = (int) $mquery->total_users; 4206 else4203 } else { 4207 4204 $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 ); 4214 4209 } else { 4215 $this->request_count = count($this->requests);4210 $this->request_count = (int) $r['max']; 4216 4211 } 4217 4212 … … 4228 4223 } 4229 4224 4230 function has_requests() {4231 if ( $this->request_count )4225 public function has_requests() { 4226 if ( ! empty( $this->request_count ) ) { 4232 4227 return true; 4228 } 4233 4229 4234 4230 return false; 4235 4231 } 4236 4232 4237 function next_request() {4233 public function next_request() { 4238 4234 $this->current_request++; 4239 $this->request = $this->requests[ $this->current_request];4235 $this->request = $this->requests[ $this->current_request ]; 4240 4236 4241 4237 return $this->request; 4242 4238 } 4243 4239 4244 function rewind_requests() {4240 public function rewind_requests() { 4245 4241 $this->current_request = -1; 4246 4242 4247 if ( $this->request_count > 0 ) 4243 if ( $this->request_count > 0 ) { 4248 4244 $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 ) { 4253 4251 return true; 4254 } elseif ( $t his->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' ); 4256 4254 // Do some cleaning up after the loop 4257 4255 $this->rewind_requests(); … … 4262 4260 } 4263 4261 4264 function the_request() {4262 public function the_request() { 4265 4263 $this->in_the_loop = true; 4266 4264 $this->request = $this->next_request(); 4267 4265 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 } 4270 4270 } 4271 4271 } … … 4401 4401 } 4402 4402 4403 /************************************************************************************ 4404 * Invite Friends Template Tags 4405 **/ 4403 /** Group Invitations *********************************************************/ 4406 4404 4407 4405 class 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; 4419 4417 4420 4418 public function __construct( $args = array() ) { … … 4455 4453 'inviter_id' => $r['user_id'], 4456 4454 ) ); 4457 $this->invite_data = $iquery->results; 4458 4455 4456 $this->invite_data = $iquery->results; 4459 4457 $this->total_invite_count = $iquery->total_users; 4460 $this->invites 4458 $this->invites = array_values( wp_list_pluck( $this->invite_data, 'ID' ) ); 4461 4459 $this->invite_count = count( $this->invites ); 4462 4460 … … 4479 4477 } 4480 4478 4481 function has_invites() {4482 if ( $this->invite_count )4479 public function has_invites() { 4480 if ( ! empty( $this->invite_count ) ) { 4483 4481 return true; 4482 } 4484 4483 4485 4484 return false; 4486 4485 } 4487 4486 4488 function next_invite() {4487 public function next_invite() { 4489 4488 $this->current_invite++; 4490 $this->invite = $this->invites[ $this->current_invite];4489 $this->invite = $this->invites[ $this->current_invite ]; 4491 4490 4492 4491 return $this->invite; 4493 4492 } 4494 4493 4495 function rewind_invites() {4494 public function rewind_invites() { 4496 4495 $this->current_invite = -1; 4497 if ( $this->invite_count > 0 ) 4496 if ( $this->invite_count > 0 ) { 4498 4497 $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 ) { 4503 4504 return true; 4504 } elseif ( $t his->current_invite + 1== $this->invite_count ) {4505 do_action( 'loop_end');4505 } elseif ( $tick == $this->invite_count ) { 4506 do_action( 'loop_end' ); 4506 4507 // Do some cleaning up after the loop 4507 4508 $this->rewind_invites(); … … 4512 4513 } 4513 4514 4514 function the_invite() {4515 public function the_invite() { 4515 4516 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 ]; 4521 4523 4522 4524 // This method previously populated the user object with … … 4527 4529 } 4528 4530 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 ) ) ); 4530 4532 $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 ) ) ); 4531 4533 $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 ) ); … … 4546 4548 $this->invite->user->total_blogs = null; 4547 4549 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 } 4552 4557 } 4553 4558 }
Note: See TracChangeset
for help on using the changeset viewer.