Changeset 9535
- Timestamp:
- 02/23/2015 04:58:04 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r9515 r9535 3960 3960 global $members_template; 3961 3961 3962 if ( !isset( $members_template->member->is_friend ) ) 3962 if ( !isset( $members_template->member->is_friend ) ) { 3963 3963 $friend_status = 'not_friends'; 3964 else 3965 $friend_status = ( 0 == $members_template->member->is_friend ) ? 'pending' : 'is_friend'; 3964 } else { 3965 $friend_status = ( 0 == $members_template->member->is_friend ) 3966 ? 'pending' 3967 : 'is_friend'; 3968 } 3966 3969 3967 3970 /** … … 4042 4045 global $members_template; 4043 4046 4044 if ( $members_template->total_member_count > $members_template->pag_num ) 4047 if ( $members_template->total_member_count > $members_template->pag_num ) { 4045 4048 return true; 4049 } 4046 4050 4047 4051 return false; … … 4087 4091 4088 4092 $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1; 4089 $from_num = bp_core_number_format( $start_num );4090 $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );4091 $total = bp_core_number_format( $members_template->total_member_count );4093 $from_num = bp_core_number_format( $start_num ); 4094 $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) ); 4095 $total = bp_core_number_format( $members_template->total_member_count ); 4092 4096 4093 4097 /** … … 4205 4209 */ 4206 4210 function bp_user_can_create_groups() { 4211 4207 4212 // Super admin can always create groups 4208 if ( bp_current_user_can( 'bp_moderate' ) ) 4213 if ( bp_current_user_can( 'bp_moderate' ) ) { 4209 4214 return true; 4215 } 4210 4216 4211 4217 // Get group creation option, default to 0 (allowed) … … 4216 4222 4217 4223 // Are regular users restricted? 4218 if ( $restricted ) 4224 if ( $restricted ) { 4219 4225 $can_create = false; 4226 } 4220 4227 4221 4228 /** … … 4233 4240 $bp = buddypress(); 4234 4241 4235 if ( !is_array( $bp->groups->group_creation_steps ) ) 4242 if ( !is_array( $bp->groups->group_creation_steps ) ) { 4236 4243 return false; 4244 } 4237 4245 4238 4246 if ( !bp_get_groups_current_create_step() ) { … … 4296 4304 function bp_is_group_creation_step( $step_slug ) { 4297 4305 4298 / * Make sure we are in the groups component */4299 if ( ! bp_is_groups_component() || !bp_is_current_action( 'create' ) )4306 // Make sure we are in the groups component 4307 if ( ! bp_is_groups_component() || ! bp_is_current_action( 'create' ) ) { 4300 4308 return false; 4309 } 4301 4310 4302 4311 $bp = buddypress(); 4303 4312 4304 / * If this the first step, we can just accept and return true */4313 // If this the first step, we can just accept and return true 4305 4314 $keys = array_keys( $bp->groups->group_creation_steps ); 4306 if ( !bp_action_variable( 1 ) && array_shift( $keys ) == $step_slug ) 4315 if ( !bp_action_variable( 1 ) && array_shift( $keys ) == $step_slug ) { 4307 4316 return true; 4308 4309 /* Before allowing a user to see a group creation step we must make sure previous steps are completed */ 4317 } 4318 4319 // Before allowing a user to see a group creation step we must make sure 4320 // previous steps are completed 4310 4321 if ( !bp_is_first_group_creation_step() ) { 4311 if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) ) 4322 if ( !bp_are_previous_group_creation_steps_complete( $step_slug ) ) { 4312 4323 return false; 4313 } 4314 4315 /* Check the current step against the step parameter */ 4316 if ( bp_is_action_variable( $step_slug ) ) 4324 } 4325 } 4326 4327 // Check the current step against the step parameter 4328 if ( bp_is_action_variable( $step_slug ) ) { 4317 4329 return true; 4330 } 4318 4331 4319 4332 return false; … … 4323 4336 $bp = buddypress(); 4324 4337 4325 if ( !isset( $bp->groups->completed_create_steps ) ) 4338 if ( !isset( $bp->groups->completed_create_steps ) ) { 4326 4339 return false; 4340 } 4327 4341 4328 4342 if ( is_array( $step_slugs ) ) { … … 4330 4344 4331 4345 foreach ( (array) $step_slugs as $step_slug ) { 4332 if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) ) 4346 if ( !in_array( $step_slug, $bp->groups->completed_create_steps ) ) { 4333 4347 $found = false; 4348 } 4334 4349 } 4335 4350 … … 4345 4360 $bp = buddypress(); 4346 4361 4347 / * If this is the first group creation step, return true */4362 // If this is the first group creation step, return true 4348 4363 $keys = array_keys( $bp->groups->group_creation_steps ); 4349 if ( array_shift( $keys ) == $step_slug ) 4364 if ( array_shift( $keys ) == $step_slug ) { 4350 4365 return true; 4366 } 4351 4367 4352 4368 reset( $bp->groups->group_creation_steps ); 4353 unset( $previous_steps ); 4354 4355 /* Get previous steps */ 4369 4370 $previous_steps = array(); 4371 4372 // Get previous steps 4356 4373 foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) { 4357 if ( $slug == $step_slug )4374 if ( $slug === $step_slug ) { 4358 4375 break; 4376 } 4359 4377 4360 4378 $previous_steps[] = $slug; … … 4368 4386 } 4369 4387 function bp_get_new_group_id() { 4370 $bp = buddypress(); 4371 4372 if ( isset( $bp->groups->new_group_id ) ) 4373 $new_group_id = $bp->groups->new_group_id; 4374 else 4375 $new_group_id = 0; 4388 $bp = buddypress(); 4389 $new_group_id = isset( $bp->groups->new_group_id ) 4390 ? $bp->groups->new_group_id 4391 : 0; 4376 4392 4377 4393 /** … … 4389 4405 } 4390 4406 function bp_get_new_group_name() { 4391 $bp = buddypress(); 4392 4393 if ( isset( $bp->groups->current_group->name ) ) 4394 $name = $bp->groups->current_group->name; 4395 else 4396 $name = ''; 4407 $bp = buddypress(); 4408 $name = isset( $bp->groups->current_group->name ) 4409 ? $bp->groups->current_group->name 4410 : ''; 4397 4411 4398 4412 /** … … 4410 4424 } 4411 4425 function bp_get_new_group_description() { 4412 $bp = buddypress(); 4413 4414 if ( isset( $bp->groups->current_group->description ) ) 4415 $description = $bp->groups->current_group->description; 4416 else 4417 $description = ''; 4426 $bp = buddypress(); 4427 $description = isset( $bp->groups->current_group->description ) 4428 ? $bp->groups->current_group->description 4429 : ''; 4418 4430 4419 4431 /** … … 4431 4443 } 4432 4444 function bp_get_new_group_enable_forum() { 4433 $bp = buddypress(); 4445 $bp = buddypress(); 4446 $forum = isset( $bp->groups->current_group->enable_forum ) 4447 ? $bp->groups->current_group->enable_forum 4448 : false; 4434 4449 4435 4450 /** … … 4440 4455 * @param int $enable_forum Whether or not to enable forums. 4441 4456 */ 4442 return (int) apply_filters( 'bp_get_new_group_enable_forum', $ bp->groups->current_group->enable_forum );4457 return (int) apply_filters( 'bp_get_new_group_enable_forum', $forum ); 4443 4458 } 4444 4459 … … 4447 4462 } 4448 4463 function bp_get_new_group_status() { 4449 $bp = buddypress(); 4464 $bp = buddypress(); 4465 $status = isset( $bp->groups->current_group->status ) 4466 ? $bp->groups->current_group->status 4467 : 'public'; 4450 4468 4451 4469 /** … … 4456 4474 * @param string $status Status for the new group. 4457 4475 */ 4458 return apply_filters( 'bp_get_new_group_status', $ bp->groups->current_group->status );4476 return apply_filters( 'bp_get_new_group_status', $status ); 4459 4477 } 4460 4478 … … 4465 4483 $bp = buddypress(); 4466 4484 4467 $ defaults =array(4468 'type' => 'full',4469 'width' => false,4470 'height' => false,4471 'class' => 'avatar',4472 'id' => 'avatar-crop-preview',4473 'alt' => __( 'Group avatar', 'buddypress' ),4485 $r = wp_parse_args( $args, array( 4486 'type' => 'full', 4487 'width' => false, 4488 'height' => false, 4489 'class' => 'avatar', 4490 'id' => 'avatar-crop-preview', 4491 'alt' => __( 'Group avatar', 'buddypress' ), 4474 4492 'no_grav' => false 4475 ); 4476 4477 $r = wp_parse_args( $args, $defaults ); 4478 extract( $r, EXTR_SKIP ); 4493 ) ); 4494 4495 $r = array_merge( $r, array( 4496 'item_id' => $bp->groups->current_group->id, 4497 'object' => 'group', 4498 'avatar_dir' => 'group-avatars', 4499 ) ); 4500 4501 $avatar = bp_core_fetch_avatar( $r ); 4479 4502 4480 4503 /** … … 4485 4508 * @param string $value HTML markup for the new group avatar. 4486 4509 */ 4487 return apply_filters( 'bp_get_new_group_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->groups->current_group->id, 'object' => 'group', 'type' => $type, 'avatar_dir' => 'group-avatars', 'alt' => $alt, 'width' => $width, 'height' => $height, 'class' => $class, 'no_grav' => $no_grav ) ));4510 return apply_filters( 'bp_get_new_group_avatar', $avatar, $r, $args ); 4488 4511 } 4489 4512 … … 4495 4518 4496 4519 foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) { 4497 if ( bp_is_action_variable( $slug ) ) 4520 if ( bp_is_action_variable( $slug ) ) { 4498 4521 break; 4522 } 4499 4523 4500 4524 $previous_steps[] = $slug; … … 4554 4578 $last_step = array_pop( $keys ); 4555 4579 4556 if ( $last_step == bp_get_groups_current_create_step() ) 4580 if ( $last_step == bp_get_groups_current_create_step() ) { 4557 4581 return true; 4582 } 4558 4583 4559 4584 return false; … … 4566 4591 $first_step = array_shift( $keys ); 4567 4592 4568 if ( $first_step == bp_get_groups_current_create_step() ) 4593 if ( $first_step == bp_get_groups_current_create_step() ) { 4569 4594 return true; 4595 } 4570 4596 4571 4597 return false; … … 4578 4604 $bp = buddypress(); 4579 4605 4580 if ( !bp_is_active( 'friends' ) ) 4606 if ( !bp_is_active( 'friends' ) ) { 4581 4607 return false; 4608 } 4582 4609 4583 4610 $defaults = array( … … 4589 4616 extract( $r, EXTR_SKIP ); 4590 4617 4591 if ( empty( $group_id ) ) 4618 if ( empty( $group_id ) ) { 4592 4619 $group_id = !empty( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id; 4620 } 4593 4621 4594 4622 if ( $friends = friends_get_friends_invite_list( bp_loggedin_user_id(), $group_id ) ) { … … 4599 4627 4600 4628 if ( !empty( $invites ) ) { 4601 if ( in_array( $friends[$i]['id'], $invites ) ) 4629 if ( in_array( $friends[$i]['id'], $invites ) ) { 4602 4630 $checked = ' checked="checked"'; 4631 } 4603 4632 } 4604 4633 … … 4607 4636 } 4608 4637 4609 if ( !empty( $items ) ) 4638 if ( !empty( $items ) ) { 4610 4639 return implode( "\n", (array) $items ); 4640 } 4611 4641 4612 4642 return false; … … 4640 4670 */ 4641 4671 function bp_groups_header_tabs() { 4642 $ bp = buddypress(); ?>4643 4644 <li<?php if ( !bp_action_variable( 0 ) || bp_is_action_variable( 'recently-active', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/recently-active' ) ?>"><?php _e( 'Recently Active', 'buddypress' )?></a></li>4645 <li<?php if ( bp_is_action_variable( 'recently-joined', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/recently-joined' ) ?>"><?php _e( 'Recently Joined', 'buddypress' )?></a></li>4646 <li<?php if ( bp_is_action_variable( 'most-popular', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/most-popular' ) ?>"><?php _e( 'Most Popular', 'buddypress' )?></a></li>4647 <li<?php if ( bp_is_action_variable( 'admin-of', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/admin-of' ) ?>"><?php _e( 'Administrator Of', 'buddypress' )?></a></li>4648 <li<?php if ( bp_is_action_variable( 'mod-of', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/mod-of' ) ?>"><?php _e( 'Moderator Of', 'buddypress' )?></a></li>4649 <li<?php if ( bp_is_action_variable( 'alphabetically' ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_displayed_user_domain() . bp_get_groups_slug() . '/my-groups/alphabetically' ) ?>"><?php _e( 'Alphabetically', 'buddypress' )?></a></li>4672 $user_groups = bp_displayed_user_domain() . bp_get_groups_slug(); ?> 4673 4674 <li<?php if ( !bp_action_variable( 0 ) || bp_is_action_variable( 'recently-active', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $user_groups . '/my-groups/recently-active' ); ?>"><?php _e( 'Recently Active', 'buddypress' ); ?></a></li> 4675 <li<?php if ( bp_is_action_variable( 'recently-joined', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $user_groups . '/my-groups/recently-joined' ); ?>"><?php _e( 'Recently Joined', 'buddypress' ); ?></a></li> 4676 <li<?php if ( bp_is_action_variable( 'most-popular', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $user_groups . '/my-groups/most-popular' ); ?>"><?php _e( 'Most Popular', 'buddypress' ); ?></a></li> 4677 <li<?php if ( bp_is_action_variable( 'admin-of', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $user_groups . '/my-groups/admin-of' ); ?>"><?php _e( 'Administrator Of', 'buddypress' ); ?></a></li> 4678 <li<?php if ( bp_is_action_variable( 'mod-of', 0 ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $user_groups . '/my-groups/mod-of' ); ?>"><?php _e( 'Moderator Of', 'buddypress' ); ?></a></li> 4679 <li<?php if ( bp_is_action_variable( 'alphabetically' ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( $user_groups . '/my-groups/alphabetically' ); ?>"><?php _e( 'Alphabetically', 'buddypress' ); ?></a></li> 4650 4680 4651 4681 <?php … … 4729 4759 } 4730 4760 4731 /************************************************************************************ 4732 * Group Avatar Template Tags 4733 **/ 4761 /** Group Avatar Template Tags ************************************************/ 4734 4762 4735 4763 /**
Note: See TracChangeset
for help on using the changeset viewer.