Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/05/2012 06:17:43 AM (13 years ago)
Author:
johnjamesjacoby
Message:

First pass at rearranging settings and forums settings screens to accommodate bbPress 2.x migration:

  • Simplify and move old bb-config.php file write logic into Settings screen
  • Introduce new functions for checking what possible mode the Forums screen is in
  • Deprecate old forum admin code for now, will probably be removed later
  • Deprecate $bp->bbconfig setting and use bp_get_option() instead
  • Clean up the Settings screen and add dedicated groups for Profiles and Forums
  • See #3598
  • More to do
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/admin/bp-core-settings.php

    r5883 r5885  
    1616 * @since BuddyPress (r2786)
    1717 */
    18 function bp_admin_setting_callback_main_section() {
    19 ?>
    20 
    21     <p><?php _e( 'Main community settings for enabling features and setting time limits', 'buddypress' ); ?></p>
    22 
    23 <?php
    24 }
     18function bp_admin_setting_callback_main_section() { }
     19
     20/**
     21 * Throttle setting field
     22 *
     23 * @since BuddyPress (r2737)
     24 *
     25 * @uses bp_form_option() To output the option value
     26 */
     27function bp_admin_setting_callback_admin_bar() {
     28?>
     29
     30    <input id="hide-loggedout-adminbar" name="hide-loggedout-adminbar" type="checkbox" value="1" <?php checked( !bp_hide_loggedout_adminbar( false ) ); ?> />
     31    <label for="hide-loggedout-adminbar"><?php _e( 'Show the admin bar for logged out users', 'buddypress' ); ?></label>
     32
     33<?php
     34}
     35
     36/**
     37 * Allow subscriptions setting field
     38 *
     39 * @since BuddyPress (r2737)
     40 *
     41 * @uses checked() To display the checked attribute
     42 */
     43function bp_admin_setting_callback_account_deletion() {
     44?>
     45
     46    <input id="bp-disable-account-deletion" name="bp-disable-account-deletion" type="checkbox" value="1" <?php checked( !bp_disable_account_deletion( true ) ); ?> />
     47    <label for="bp-disable-account-deletion"><?php _e( 'Allow registered members to delete their own accounts', 'buddypress' ); ?></label>
     48
     49<?php
     50}
     51
     52/**
     53 * Use the WordPress editor setting field
     54 *
     55 * @since BuddyPress (r3586)
     56 *
     57 * @uses checked() To display the checked attribute
     58 */
     59function bp_admin_setting_callback_use_wp_editor() {
     60?>
     61
     62    <input id="_bp_use_wp_editor" name="_bp_use_wp_editor" type="checkbox" id="_bp_use_wp_editor" value="1" <?php checked( bp_use_wp_editor( true ) ); ?> />
     63    <label for="_bp_use_wp_editor"><?php _e( 'Use the fancy WordPress editor to create and edit topics and replies', 'buddypress' ); ?></label>
     64
     65<?php
     66}
     67
     68/** Activity *******************************************************************/
     69
     70/**
     71 * Groups settings section description for the settings page
     72 *
     73 * @since BuddyPress (1.6)
     74 */
     75function bp_admin_setting_callback_activity_section() { }
     76
     77/**
     78 * Allow Akismet setting field
     79 *
     80 * @since BuddyPress (r3575)
     81 *
     82 * @uses checked() To display the checked attribute
     83 */
     84function bp_admin_setting_callback_activity_akismet() {
     85?>
     86
     87    <input id="_bp_enable_akismet" name="_bp_enable_akismet" type="checkbox" value="1" <?php checked( bp_is_akismet_active( true ) ); ?> />
     88    <label for="_bp_enable_akismet"><?php _e( 'Allow Akismet to scan for activity stream spam', 'buddypress' ); ?></label>
     89
     90<?php
     91}
     92
     93/** XProfile ******************************************************************/
     94
     95/**
     96 * Profile settings section description for the settings page
     97 *
     98 * @since BuddyPress (1.0)
     99 */
     100function bp_admin_setting_callback_xprofile_section() { }
    25101
    26102/**
     
    41117
    42118/**
    43  * Throttle setting field
    44  *
    45  * @since BuddyPress (r2737)
    46  *
    47  * @uses bp_form_option() To output the option value
    48  */
    49 function bp_admin_setting_callback_admin_bar() {
    50 ?>
    51 
    52     <input id="hide-loggedout-adminbar" name="hide-loggedout-adminbar" type="checkbox" value="1" <?php checked( !bp_hide_loggedout_adminbar( false ) ); ?> />
    53     <label for="hide-loggedout-adminbar"><?php _e( 'Show the admin bar for guest/anonymous users', 'buddypress' ); ?></label>
    54 
    55 <?php
    56 }
    57 
    58 /**
    59119 * Allow favorites setting field
    60120 *
     
    67127
    68128    <input id="bp-disable-avatar-uploads" name="bp-disable-avatar-uploads" type="checkbox" value="1" <?php checked( !bp_disable_avatar_uploads( true ) ); ?> />
    69     <label for="bp-disable-avatar-uploads"><?php _e( 'Allow members to upload avatars', 'buddypress' ); ?></label>
    70 
    71 <?php
    72 }
    73 
    74 /**
    75  * Allow subscriptions setting field
    76  *
    77  * @since BuddyPress (r2737)
    78  *
    79  * @uses checked() To display the checked attribute
    80  */
    81 function bp_admin_setting_callback_account_deletion() {
    82 ?>
    83 
    84     <input id="bp-disable-account-deletion" name="bp-disable-account-deletion" type="checkbox" value="1" <?php checked( !bp_disable_account_deletion( true ) ); ?> />
    85     <label for="bp-disable-account-deletion"><?php _e( 'Allow members to delete their own accounts', 'buddypress' ); ?></label>
    86 
    87 <?php
    88 }
    89 
    90 /**
    91  * Use the WordPress editor setting field
    92  *
    93  * @since BuddyPress (r3586)
    94  *
    95  * @uses checked() To display the checked attribute
    96  */
    97 function bp_admin_setting_callback_use_wp_editor() {
    98 ?>
    99 
    100     <input id="_bp_use_wp_editor" name="_bp_use_wp_editor" type="checkbox" id="_bp_use_wp_editor" value="1" <?php checked( bp_use_wp_editor( true ) ); ?> />
    101     <label for="_bp_use_wp_editor"><?php _e( 'Use the fancy WordPress editor to create and edit topics and replies', 'buddypress' ); ?></label>
    102 
    103 <?php
    104 }
    105 
    106 /** Activity *******************************************************************/
     129    <label for="bp-disable-avatar-uploads"><?php _e( 'Allow registered members to upload avatars', 'buddypress' ); ?></label>
     130
     131<?php
     132}
     133
     134/** Groups Section ************************************************************/
    107135
    108136/**
     
    111139 * @since BuddyPress (1.6)
    112140 */
    113 function bp_admin_setting_callback_activity_section() {
    114 ?>
    115 
    116     <p><?php _e( 'Settings for the Actvity component', 'buddypress' ); ?></p>
    117 
    118 <?php
    119 }
    120 
    121 /**
    122  * Allow Akismet setting field
    123  *
    124  * @since BuddyPress (r3575)
    125  *
    126  * @uses checked() To display the checked attribute
    127  */
    128 function bp_admin_setting_callback_activity_akismet() {
    129 ?>
    130 
    131     <input id="_bp_enable_akismet" name="_bp_enable_akismet" type="checkbox" value="1" <?php checked( bp_is_akismet_active( true ) ); ?> />
    132     <label for="_bp_enable_akismet"><?php _e( 'Allow Akismet to scan for activity stream spam', 'buddypress' ); ?></label>
    133 
    134 <?php
    135 }
    136 
    137 /** Groups Section ************************************************************/
    138 
    139 /**
    140  * Groups settings section description for the settings page
    141  *
    142  * @since BuddyPress (1.6)
    143  */
    144 function bp_admin_setting_callback_groups_section() {
    145 ?>
    146 
    147     <p><?php _e( 'Settings for the Groups component', 'buddypress' ); ?></p>
    148 
    149 <?php
    150 }
     141function bp_admin_setting_callback_groups_section() { }
    151142
    152143/**
     
    167158}
    168159
     160/** Forums Section ************************************************************/
     161
     162/**
     163 * Forums settings section description for the settings page
     164 *
     165 * @since BuddyPress (1.6)
     166 */
     167function bp_admin_setting_callback_bbpress_section() { }
     168
     169/**
     170 * Allow topic and reply revisions
     171 *
     172 * @since BuddyPress (1.6)
     173 * @uses checked() To display the checked attribute
     174 * @uses bp_get_option() To get the config location
     175 * @uses bp_form_option() To get the sanitized form option
     176 */
     177function bp_admin_setting_callback_bbpress_configuration() {
     178
     179    $config_location = bp_get_option( 'bb-config-location' );
     180    $file_exists     = (bool) ( file_exists( $config_location ) || is_file( $config_location ) ); ?>
     181
     182    <input name="bb-config-location" type="text" id="bb-config-location" value="<?php bp_form_option( 'bb-config-location', '' ); ?>" class="medium-text" style="width: 300px;" />
     183
     184    <?php if ( false === $file_exists ) : ?>
     185
     186        <a class="button" href="<?php bp_admin_url( 'admin.php?page=bb-forums-setup&repair=1' ); ?>" title="<?php _e( 'Attempt to save a new config file.', 'buddypress' ); ?>"><?php _e( 'Repair', 'buddypress' ) ?></a>
     187        <span class="attention"><?php _e( 'File does not exist', 'buddypress' ); ?></span>
     188
     189    <?php endif; ?>
     190
     191    <p class="description"><?php _e( 'Absolute path to your bbPress configuration file.', 'buddypress' ); ?></p>
     192
     193<?php
     194}
     195
    169196/** Settings Page *************************************************************/
    170197
     
    180207function bp_core_admin_settings() {
    181208    global $wp_settings_fields;
    182    
    183     // We're saving our own options, until the WP Settings API is updated to work with Multisite
    184     $form_action = add_query_arg( 'page', 'bp-settings', bp_core_do_network_admin() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) );
    185209
    186210    if ( !empty( $_POST['submit'] ) ) {
    187211        check_admin_referer( 'buddypress-options' );
    188        
     212
    189213        // Because many settings are saved with checkboxes, and thus will have no values
    190214        // in the $_POST array when unchecked, we loop through the registered settings
     
    193217                foreach( $settings as $setting_name => $setting ) {
    194218                    $value = isset( $_POST[$setting_name] ) ? $_POST[$setting_name] : '';
    195                    
     219
    196220                    bp_update_option( $setting_name, $value );
    197221                }
    198222            }
    199223        }
    200        
     224
    201225        // Some legacy options are not registered with the Settings API
    202226        $legacy_options = array(
     
    207231            'bp_restrict_group_creation'
    208232        );
    209        
     233
    210234        foreach( $legacy_options as $legacy_option ) {
    211235            // Note: Each of these options is represented by its opposite in the UI
     
    216240        }
    217241    }
    218 ?>
     242   
     243    // We're saving our own options, until the WP Settings API is updated to work with Multisite
     244    $form_action = add_query_arg( 'page', 'bp-settings', bp_core_do_network_admin() ? network_admin_url( 'admin.php' ) : admin_url( 'admin.php' ) ); ?>
    219245
    220246    <div class="wrap">
     
    368394        /** bbPress Core ******************************************************/
    369395
    370         if ( defined( 'BBP_VERSION' ) ) {
     396        if ( bp_forums_is_bbpress_active() ) {
    371397
    372398            // Forum archive slug
Note: See TracChangeset for help on using the changeset viewer.