Skip to:
Content

BuddyPress.org

Changeset 9668


Ignore:
Timestamp:
03/31/2015 11:29:11 PM (5 years ago)
Author:
johnjamesjacoby
Message:

XProfile: Improvemets to bp-xprofile-admin.php

  • Introduce xprofile_admin_screen() for outputting the root admin screen content
  • Add brackets to conditional statements
  • Add @todo regarding feedback message (kvetch)

See #6318.

File:
1 edited

Legend:

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

    r9639 r9668  
    2222function xprofile_add_admin_menu() {
    2323
    24     if ( !bp_current_user_can( 'bp_moderate' ) )
     24    // Bail if current user cannot moderate community
     25    if ( ! bp_current_user_can( 'bp_moderate' ) ) {
    2526        return false;
     27    }
    2628
    2729    add_users_page( _x( 'Profile Fields', 'xProfile admin page title', 'buddypress' ), _x( 'Profile Fields', 'Admin Users menu', 'buddypress' ), 'manage_options', 'bp-profile-setup', 'xprofile_admin' );
     
    3739    $type = preg_replace( '|[^a-z]|i', '', $type );
    3840
     41    if ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'add_field' == $_GET['mode'] ) {
     42        xprofile_admin_manage_field( $_GET['group_id'] );
     43
     44    } elseif ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && isset( $_GET['field_id'] ) && 'edit_field' == $_GET['mode'] ) {
     45        xprofile_admin_manage_field( $_GET['group_id'], $_GET['field_id'] );
     46
     47    } elseif ( isset( $_GET['mode'] ) && isset( $_GET['field_id'] ) && 'delete_field' == $_GET['mode'] ) {
     48        xprofile_admin_delete_field( $_GET['field_id'], 'field');
     49
     50    } elseif ( isset( $_GET['mode'] ) && isset( $_GET['option_id'] ) && 'delete_option' == $_GET['mode'] ) {
     51        xprofile_admin_delete_field( $_GET['option_id'], 'option' );
     52
     53    } elseif ( isset( $_GET['mode'] ) && 'add_group' == $_GET['mode'] ) {
     54        xprofile_admin_manage_group();
     55
     56    } elseif ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'delete_group' == $_GET['mode'] ) {
     57        xprofile_admin_delete_group( $_GET['group_id'] );
     58
     59    } elseif ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'edit_group' == $_GET['mode'] ) {
     60        xprofile_admin_manage_group( $_GET['group_id'] );
     61
     62    } else {
     63        xprofile_admin_screen( $message );
     64    }
     65}
     66
     67/**
     68 * Output the main XProfile management screen
     69 *
     70 * @since BuddyPress (2.3.0)
     71 *
     72 * @todo Improve error message output
     73 */
     74function xprofile_admin_screen( $message = '' ) {
     75
     76    // Get all of the profile groups & fields
    3977    $groups = bp_xprofile_get_groups( array(
    4078        'fetch_fields' => true
    41     ) );
    42 
    43     if ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'add_field' == $_GET['mode'] )
    44         xprofile_admin_manage_field( $_GET['group_id'] );
    45 
    46     elseif ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && isset( $_GET['field_id'] ) && 'edit_field' == $_GET['mode'] )
    47         xprofile_admin_manage_field( $_GET['group_id'], $_GET['field_id'] );
    48 
    49     elseif ( isset( $_GET['mode'] ) && isset( $_GET['field_id'] ) && 'delete_field' == $_GET['mode'] )
    50         xprofile_admin_delete_field( $_GET['field_id'], 'field');
    51 
    52     elseif ( isset( $_GET['mode'] ) && isset( $_GET['option_id'] ) && 'delete_option' == $_GET['mode'] )
    53         xprofile_admin_delete_field( $_GET['option_id'], 'option' );
    54 
    55     elseif ( isset( $_GET['mode'] ) && 'add_group' == $_GET['mode'] )
    56         xprofile_admin_manage_group();
    57 
    58     elseif ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'delete_group' == $_GET['mode'] )
    59         xprofile_admin_delete_group( $_GET['group_id'] );
    60 
    61     elseif ( isset( $_GET['mode'] ) && isset( $_GET['group_id'] ) && 'edit_group' == $_GET['mode'] )
    62         xprofile_admin_manage_group( $_GET['group_id'] );
    63 
    64     else { ?>
     79    ) ); ?>
    6580
    6681    <div class="wrap">
     
    203218
    204219<?php
    205     }
    206220}
    207221
     
    226240                $type    = 'success';
    227241
    228                 if ( 1 == $group_id )
     242                if ( 1 == $group_id ) {
    229243                    bp_update_option( 'bp-xprofile-base-group-name', $group->name );
     244                }
    230245
    231246                /**
     
    297312            $field->type        = wp_filter_kses( $_POST['fieldtype'] );
    298313
    299             if ( !empty( $_POST["sort_order_{$field->type}"] ) )
     314            if ( !empty( $_POST["sort_order_{$field->type}"] ) ) {
    300315                $field->order_by = wp_filter_kses( $_POST["sort_order_{$field->type}"] );
     316            }
    301317
    302318            $field->field_order = $wpdb->get_var( $wpdb->prepare( "SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id ) );
     
    322338                $type = 'success';
    323339
    324                 if ( 1 == $field_id )
     340                if ( 1 == $field_id ) {
    325341                    bp_update_option( 'bp-xprofile-fullname-field-name', $field->name );
     342                }
    326343
    327344                if ( !empty( $_POST['default-visibility'] ) ) {
     
    402419    check_admin_referer( 'bp_reorder_fields', '_wpnonce_reorder_fields' );
    403420
    404     if ( empty( $_POST['field_order'] ) )
     421    if ( empty( $_POST['field_order'] ) ) {
    405422        return false;
     423    }
    406424
    407425    parse_str( $_POST['field_order'], $order );
     
    423441    check_admin_referer( 'bp_reorder_groups', '_wpnonce_reorder_groups' );
    424442
    425     if ( empty( $_POST['group_order'] ) )
     443    if ( empty( $_POST['group_order'] ) ) {
    426444        return false;
     445    }
    427446
    428447    parse_str( $_POST['group_order'], $order );
Note: See TracChangeset for help on using the changeset viewer.