Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/06/2016 07:55:32 AM (8 years ago)
Author:
r-a-y
Message:

Groups Admin: Better support for multiple group types.

If more than one group type is registered:

  • When editing a group, you can now set multiple group types for that group.
  • When viewing the Groups admin dashboard, all group types for a group are displayed in the "Group Type" column.

See #7210.

File:
1 edited

Legend:

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

    r11139 r11176  
    10471047    }
    10481048
    1049     $types = bp_groups_get_group_types( array(), 'objects' );
    1050     $current_type = bp_groups_get_group_type( $group->id );
     1049    $types         = bp_groups_get_group_types( array(), 'objects' );
     1050    $current_types = bp_groups_get_group_type( $group->id, false );
     1051    $backend_only  = bp_groups_get_group_types( array( 'show_in_create_screen' => false ) );
    10511052    ?>
    10521053
     
    10551056        esc_html_e( 'Select group type', 'buddypress' );
    10561057    ?></label>
    1057     <select name="bp-groups-group-type" id="bp-groups-group-type">
    1058         <option value="" <?php selected( '', $current_type ); ?>><?php /* translators: no option picked in select box */ esc_attr_e( '----', 'buddypress' ) ?></option>
     1058
     1059    <ul class="categorychecklist form-no-clear">
    10591060        <?php foreach ( $types as $type ) : ?>
    1060             <option value="<?php echo esc_attr( $type->name ) ?>" <?php selected( $type->name, $current_type ) ?>><?php echo esc_html( $type->labels['singular_name'] ) ?></option>
     1061            <li>
     1062                <label class="selectit"><input value="<?php echo esc_attr( $type->name ) ?>" name="bp-groups-group-type[]" type="checkbox" <?php checked( true, in_array( $type->name, $current_types ) ); ?>>
     1063                    <?php
     1064                        echo esc_html( $type->labels['singular_name'] );
     1065                        if ( in_array( $type->name, $backend_only ) ) {
     1066                            printf( ' <span class="description">%s</span>', esc_html__( '(Not available on the frontend)', 'buddypress' ) );
     1067                        }
     1068                    ?>
     1069
     1070                </label>
     1071            </li>
     1072
    10611073        <?php endforeach; ?>
    1062     </select>
     1074
     1075    </ul>
    10631076
    10641077    <?php
     
    10731086 */
    10741087function bp_groups_process_group_type_update( $group_id ) {
    1075     if ( ! isset( $_POST['bp-group-type-nonce'] ) || ! isset( $_POST['bp-groups-group-type'] ) ) {
     1088    if ( ! isset( $_POST['bp-group-type-nonce'] ) ) {
    10761089        return;
    10771090    }
     
    10841097    }
    10851098
    1086     // Group type string must either reference a valid group type, or be empty.
    1087     $group_type = wp_unslash( $_POST['bp-groups-group-type'] );
    1088     if ( $group_type && ! bp_groups_get_group_type_object( $group_type ) ) {
    1089         return;
    1090     }
     1099    $group_types = ! empty( $_POST['bp-groups-group-type'] ) ? wp_unslash( $_POST['bp-groups-group-type'] ) : array();
    10911100
    10921101    /*
     
    10941103     * fishy with the POST request, so we can fail silently.
    10951104     */
    1096     if ( bp_groups_set_group_type( $group_id, $group_type ) ) {
     1105    if ( bp_groups_set_group_type( $group_id, $group_types ) ) {
    10971106        // @todo Success messages can't be posted because other stuff happens on the page load.
    10981107    }
Note: See TracChangeset for help on using the changeset viewer.