Skip to:
Content

BuddyPress.org

Changeset 3633 for trunk/bp-messages.php


Ignore:
Timestamp:
12/31/2010 06:05:34 PM (14 years ago)
Author:
djpaul
Message:

Cleanup code in notification settings, and don't reinvent the wheel. Fixes #2987, props wpmuguru

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages.php

    r3620 r3633  
    168168
    169169function messages_screen_notification_settings() {
    170     global $bp;
    171    
    172     ?>
    173    
     170    global $bp;
     171
     172    $new_messages = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true );
     173    if ( !$new_messages )
     174        $new_messages = 'yes';
     175
     176    $new_notices = get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true );
     177    if ( !$new_notices )
     178        $new_notices = 'yes';
     179?>
    174180    <table class="notification-settings zebra" id="messages-notification-settings">
    175181        <thead>
     
    186192                <td></td>
    187193                <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td>
    188                 <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td>
    189                 <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_messages_new_message', true ) ) { ?>checked="checked" <?php } ?>/></td>
     194                <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" value="yes" <?php checked( $new_messages, 'yes', true ) ?>/></td>
     195                <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" value="no" <?php checked( $new_messages, 'no', true ) ?>/></td>
    190196            </tr>
    191197            <tr id="messages-notification-settings-new-site-notice">
    192198                <td></td>
    193199                <td><?php _e( 'A new site notice is posted', 'buddypress' ) ?></td>
    194                 <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td>
    195                 <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_messages_new_notice', true ) ) { ?>checked="checked" <?php } ?>/></td>
     200                <td class="yes"><input type="radio" name="notifications[notification_messages_new_notice]" value="yes" <?php checked( $new_notices, 'yes', true ) ?>/></td>
     201                <td class="no"><input type="radio" name="notifications[notification_messages_new_notice]" value="no" <?php checked( $new_notices, 'no', true ) ?>/></td>
    196202            </tr>
    197203
Note: See TracChangeset for help on using the changeset viewer.