Skip to:
Content

BuddyPress.org

Changeset 3633


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

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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity.php

    r3620 r3633  
    203203
    204204function bp_activity_screen_notification_settings() {
    205         global $bp;
    206        
    207         ?>
    208        
     205        global $bp;
     206
     207        $mention = get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true );
     208        if ( !$mention )
     209                $mention = 'yes';
     210
     211        $reply = get_user_meta( $bp->displayed_user->id, 'notification_activity_new_reply', true );
     212        if ( !$reply )
     213                $reply = 'yes';
     214?>
    209215        <table class="notification-settings zebra" id="activity-notification-settings">
    210216                <thead>
     
    221227                                <td></td>
    222228                                <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( $bp->displayed_user->id, $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login ) ) ?></td>
    223                                 <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ) ) { ?>checked="checked" <?php } ?>/></td>
    224                                 <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_activity_new_mention', true ) ) { ?>checked="checked" <?php } ?>/></td>
     229                                <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php checked( $mention, 'yes', true ) ?>/></td>
     230                                <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php checked( $mention, 'no', true ) ?>/></td>
    225231                        </tr>
    226232                        <tr id="activity-notification-settings-replies">
    227233                                <td></td>
    228234                                <td><?php _e( "A member replies to an update or comment you've posted", 'buddypress' ) ?></td>
    229                                 <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_user_meta( $bp->loggedin_user->id, 'notification_activity_new_reply', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_activity_new_reply', true ) ) { ?>checked="checked" <?php } ?>/></td>
    230                                 <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_activity_new_reply', true ) ) { ?>checked="checked" <?php } ?>/></td>
     235                                <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php checked( $reply, 'yes', true ) ?>/></td>
     236                                <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php checked( $reply, 'no', true ) ?>/></td>
    231237                        </tr>
    232238
  • 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
  • trunk/bp-groups.php

    r3627 r3633  
    948948
    949949function groups_screen_notification_settings() {
    950         global $bp;
    951        
    952         ?>
    953        
     950        global $bp;
     951
     952        $group_invite = get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true );
     953        if ( !$group_invite )
     954                $group_invite = 'yes';
     955
     956        $group_update = get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true );
     957        if ( !$group_update )
     958                $group_update = 'yes';
     959
     960        $group_promo = get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true );
     961        if ( !$group_promo )
     962                $group_promo = 'yes';
     963
     964        $group_request = get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true );
     965        if ( !$group_request )
     966                $group_request = 'yes';
     967?>
    954968        <table class="notification-settings zebra" id="groups-notification-settings">
    955969                <thead>
     
    966980                                <td></td>
    967981                                <td><?php _e( 'A member invites you to join a group', 'buddypress' ) ?></td>
    968                                 <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true ) ) { ?>checked="checked" <?php } ?>/></td>
    969                                 <td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_groups_invite', true ) ) { ?>checked="checked" <?php } ?>/></td>
     982                                <td class="yes"><input type="radio" name="notifications[notification_groups_invite]" value="yes" <?php checked( $group_invite, 'yes', true ) ?>/></td>
     983                                <td class="no"><input type="radio" name="notifications[notification_groups_invite]" value="no" <?php checked( $group_invite, 'no', true ) ?>/></td>
    970984                        </tr>
    971985                        <tr id="groups-notification-settings-info-updated">
    972986                                <td></td>
    973987                                <td><?php _e( 'Group information is updated', 'buddypress' ) ?></td>
    974                                 <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true ) ) { ?>checked="checked" <?php } ?>/></td>
    975                                 <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_groups_group_updated', true ) ) { ?>checked="checked" <?php } ?>/></td>
     988                                <td class="yes"><input type="radio" name="notifications[notification_groups_group_updated]" value="yes" <?php checked( $group_update, 'yes', true ) ?>/></td>
     989                                <td class="no"><input type="radio" name="notifications[notification_groups_group_updated]" value="no" <?php checked( $group_update, 'no', true ) ?>/></td>
    976990                        </tr>
    977991                        <tr id="groups-notification-settings-promoted">
    978992                                <td></td>
    979993                                <td><?php _e( 'You are promoted to a group administrator or moderator', 'buddypress' ) ?></td>
    980                                 <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true ) ) { ?>checked="checked" <?php } ?>/></td>
    981                                 <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_groups_admin_promotion', true ) ) { ?>checked="checked" <?php } ?>/></td>
     994                                <td class="yes"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="yes" <?php checked( $group_promo, 'yes', true ) ?>/></td>
     995                                <td class="no"><input type="radio" name="notifications[notification_groups_admin_promotion]" value="no" <?php checked( $group_promo, 'no', true ) ?>/></td>
    982996                        </tr>
    983997                        <tr id="groups-notification-settings-request">
    984998                                <td></td>
    985999                                <td><?php _e( 'A member requests to join a private group for which you are an admin', 'buddypress' ) ?></td>
    986                                 <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php if ( !get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true ) || 'yes' == get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true ) ) { ?>checked="checked" <?php } ?>/></td>
    987                                 <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_groups_membership_request', true ) ) { ?>checked="checked" <?php } ?>/></td>
     1000                                <td class="yes"><input type="radio" name="notifications[notification_groups_membership_request]" value="yes" <?php checked( $group_request, 'yes', true ) ?>/></td>
     1001                                <td class="no"><input type="radio" name="notifications[notification_groups_membership_request]" value="no" <?php checked( $group_request, 'no', true ) ?>/></td>
    9881002                        </tr>
    9891003
  • 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.