Skip to:
Content

BuddyPress.org

Changeset 3633 for trunk/bp-friends.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-friends.php

    r3620 r3633  
    108108
    109109function friends_screen_notification_settings() {
    110     global $bp;
    111    
    112     ?>
    113    
     110    global $bp;
     111
     112    $send_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true );
     113    if ( !$send_requests )
     114        $send_requests = 'yes';
     115
     116    $accept_requests = get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true );
     117    if ( !$accept_requests )
     118        $accept_requests = 'yes';
     119?>
    114120    <table class="notification-settings zebra" id="friends-notification-settings">
    115121        <thead>
     
    126132                <td></td>
    127133                <td><?php _e( 'A member sends you a friendship request', 'buddypress' ) ?></td>
    128                 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) ) { ?>checked="checked" <?php } ?>/></td>
    129                 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php if ( get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_request', true ) == 'no' ) { ?>checked="checked" <?php } ?>/></td>
     134                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" value="yes" <?php checked( $send_requests, 'yes', true ) ?>/></td>
     135                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" value="no" <?php checked( $send_requests, 'no', true ) ?>/></td>
    130136            </tr>
    131137            <tr id="friends-notification-settings-accepted">
    132138                <td></td>
    133139                <td><?php _e( 'A member accepts your friendship request', 'buddypress' ) ?></td>
    134                 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td>
    135                 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) ) { ?>checked="checked" <?php } ?>/></td>
     140                <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="yes" <?php checked( $accept_requests, 'yes', true ) ?>/></td>
     141                <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" value="no" <?php checked( $accept_requests, 'no', true ) ?>/></td>
    136142            </tr>
    137143
Note: See TracChangeset for help on using the changeset viewer.