Skip to:
Content

BuddyPress.org

Changeset 9535


Ignore:
Timestamp:
02/23/2015 04:58:04 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Groups: Clean up a section of bp-groups-template.php. See r9457.

File:
1 edited

Legend:

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

    r9515 r9535  
    39603960        global $members_template;
    39613961
    3962         if ( !isset( $members_template->member->is_friend ) )
     3962        if ( !isset( $members_template->member->is_friend ) ) {
    39633963            $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        }
    39663969
    39673970        /**
     
    40424045    global $members_template;
    40434046
    4044     if ( $members_template->total_member_count > $members_template->pag_num )
     4047    if ( $members_template->total_member_count > $members_template->pag_num ) {
    40454048        return true;
     4049    }
    40464050
    40474051    return false;
     
    40874091
    40884092        $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 );
    40924096
    40934097        /**
     
    42054209 */
    42064210function bp_user_can_create_groups() {
     4211
    42074212    // Super admin can always create groups
    4208     if ( bp_current_user_can( 'bp_moderate' ) )
     4213    if ( bp_current_user_can( 'bp_moderate' ) ) {
    42094214        return true;
     4215    }
    42104216
    42114217    // Get group creation option, default to 0 (allowed)
     
    42164222
    42174223    // Are regular users restricted?
    4218     if ( $restricted )
     4224    if ( $restricted ) {
    42194225        $can_create = false;
     4226    }
    42204227
    42214228    /**
     
    42334240    $bp = buddypress();
    42344241
    4235     if ( !is_array( $bp->groups->group_creation_steps ) )
     4242    if ( !is_array( $bp->groups->group_creation_steps ) ) {
    42364243        return false;
     4244    }
    42374245
    42384246    if ( !bp_get_groups_current_create_step() ) {
     
    42964304function bp_is_group_creation_step( $step_slug ) {
    42974305
    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' ) ) {
    43004308        return false;
     4309    }
    43014310
    43024311    $bp = buddypress();
    43034312
    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
    43054314    $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 ) {
    43074316        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
    43104321    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 ) ) {
    43124323            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 ) ) {
    43174329        return true;
     4330    }
    43184331
    43194332    return false;
     
    43234336    $bp = buddypress();
    43244337
    4325     if ( !isset( $bp->groups->completed_create_steps ) )
     4338    if ( !isset( $bp->groups->completed_create_steps ) ) {
    43264339        return false;
     4340    }
    43274341
    43284342    if ( is_array( $step_slugs ) ) {
     
    43304344
    43314345        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 ) ) {
    43334347                $found = false;
     4348            }
    43344349        }
    43354350
     
    43454360    $bp = buddypress();
    43464361
    4347     /* If this is the first group creation step, return true */
     4362    // If this is the first group creation step, return true
    43484363    $keys = array_keys( $bp->groups->group_creation_steps );
    4349     if ( array_shift( $keys ) == $step_slug )
     4364    if ( array_shift( $keys ) == $step_slug ) {
    43504365        return true;
     4366    }
    43514367
    43524368    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
    43564373    foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) {
    4357         if ( $slug == $step_slug )
     4374        if ( $slug === $step_slug ) {
    43584375            break;
     4376        }
    43594377
    43604378        $previous_steps[] = $slug;
     
    43684386}
    43694387    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;
    43764392
    43774393        /**
     
    43894405}
    43904406    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            : '';
    43974411
    43984412        /**
     
    44104424}
    44114425    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            : '';
    44184430
    44194431        /**
     
    44314443}
    44324444    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;
    44344449
    44354450        /**
     
    44404455         * @param int $enable_forum Whether or not to enable forums.
    44414456         */
    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 );
    44434458    }
    44444459
     
    44474462}
    44484463    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';
    44504468
    44514469        /**
     
    44564474         * @param string $status Status for the new group.
    44574475         */
    4458         return apply_filters( 'bp_get_new_group_status', $bp->groups->current_group->status );
     4476        return apply_filters( 'bp_get_new_group_status', $status );
    44594477    }
    44604478
     
    44654483        $bp = buddypress();
    44664484
    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' ),
    44744492            '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 );
    44794502
    44804503        /**
     
    44854508         * @param string $value HTML markup for the new group avatar.
    44864509         */
    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 );
    44884511    }
    44894512
     
    44954518
    44964519        foreach ( (array) $bp->groups->group_creation_steps as $slug => $name ) {
    4497             if ( bp_is_action_variable( $slug ) )
     4520            if ( bp_is_action_variable( $slug ) ) {
    44984521                break;
     4522            }
    44994523
    45004524            $previous_steps[] = $slug;
     
    45544578    $last_step = array_pop( $keys );
    45554579
    4556     if ( $last_step == bp_get_groups_current_create_step() )
     4580    if ( $last_step == bp_get_groups_current_create_step() ) {
    45574581        return true;
     4582    }
    45584583
    45594584    return false;
     
    45664591    $first_step = array_shift( $keys );
    45674592
    4568     if ( $first_step == bp_get_groups_current_create_step() )
     4593    if ( $first_step == bp_get_groups_current_create_step() ) {
    45694594        return true;
     4595    }
    45704596
    45714597    return false;
     
    45784604        $bp = buddypress();
    45794605
    4580         if ( !bp_is_active( 'friends' ) )
     4606        if ( !bp_is_active( 'friends' ) ) {
    45814607            return false;
     4608        }
    45824609
    45834610        $defaults = array(
     
    45894616        extract( $r, EXTR_SKIP );
    45904617
    4591         if ( empty( $group_id ) )
     4618        if ( empty( $group_id ) ) {
    45924619            $group_id = !empty( $bp->groups->new_group_id ) ? $bp->groups->new_group_id : $bp->groups->current_group->id;
     4620        }
    45934621
    45944622        if ( $friends = friends_get_friends_invite_list( bp_loggedin_user_id(), $group_id ) ) {
     
    45994627
    46004628                if ( !empty( $invites ) ) {
    4601                     if ( in_array( $friends[$i]['id'], $invites ) )
     4629                    if ( in_array( $friends[$i]['id'], $invites ) ) {
    46024630                        $checked = ' checked="checked"';
     4631                    }
    46034632                }
    46044633
     
    46074636        }
    46084637
    4609         if ( !empty( $items ) )
     4638        if ( !empty( $items ) ) {
    46104639            return implode( "\n", (array) $items );
     4640        }
    46114641
    46124642        return false;
     
    46404670 */
    46414671function 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>
    46504680
    46514681<?php
     
    47294759    }
    47304760
    4731 /************************************************************************************
    4732  * Group Avatar Template Tags
    4733  **/
     4761/** Group Avatar Template Tags ************************************************/
    47344762
    47354763/**
Note: See TracChangeset for help on using the changeset viewer.