Skip to:
Content

BuddyPress.org

Changeset 7537


Ignore:
Timestamp:
11/08/2013 07:53:56 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Use the correct function and update methods for marking user notifications as read. See #5148.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-screens.php

    r7529 r7537  
    137137 */
    138138function bp_activity_remove_screen_notifications() {
    139     bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );
     139    bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );
    140140}
    141141add_action( 'bp_activity_screen_my_activity',               'bp_activity_remove_screen_notifications' );
  • trunk/bp-friends/bp-friends-cache.php

    r7529 r7537  
    2525function friends_clear_friend_notifications() {
    2626    if ( isset( $_GET['new'] ) ) {
    27         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
     27        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
    2828    }
    2929}
  • trunk/bp-friends/bp-friends-screens.php

    r7529 r7537  
    1818
    1919    // Delete any friendship acceptance notifications for the user when viewing a profile
    20     bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
     20    bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );
    2121
    2222    do_action( 'friends_screen_my_friends' );
     
    6363
    6464    if ( isset( $_GET['new'] ) ) {
    65         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_request' );
     65        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_request' );
    6666    }
    6767
  • trunk/bp-groups/bp-groups-screens.php

    r7529 r7537  
    3232    // Delete group request notifications for the user
    3333    if ( isset( $_GET['n'] ) ) {
    34         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
    35         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
    36         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod'      );
    37         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin'    );
     34        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
     35        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
     36        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod'      );
     37        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin'    );
    3838    }
    3939
     
    9595
    9696    // Remove notifications
    97     bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
     97    bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
    9898
    9999    do_action( 'groups_screen_group_invites', $group_id );
     
    110110
    111111    if ( isset( $_GET['n'] ) ) {
    112         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
    113         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
    114         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod'      );
    115         bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin'    );
     112        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
     113        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
     114        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod'      );
     115        bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin'    );
    116116    }
    117117
     
    814814
    815815    // Remove any screen notifications
    816     bp_core_mark_all_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request' );
     816    bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request' );
    817817
    818818    $request_action = (string)bp_action_variable( 1 );
  • trunk/bp-notifications/bp-notifications-functions.php

    r7536 r7537  
    307307 */
    308308function bp_notifications_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new = false ) {
    309     return BP_Notifications_Notification::delete( array(
    310         'user_id'          => $user_id,
    311         'component_name'   => $component_name,
    312         'component_action' => $component_action,
    313         'is_new'           => $is_new,
    314     ) );
     309    return BP_Notifications_Notification::update(
     310        array(
     311            'is_new' => $is_new
     312        ),
     313        array(
     314            'user_id'          => $user_id,
     315            'component_name'   => $component_name,
     316            'component_action' => $component_action
     317        )
     318    );
    315319}
    316320
     
    332336 */
    333337function bp_notifications_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false, $is_new = false ) {
    334     return BP_Notifications_Notification::delete( array(
    335         'user_id'           => $user_id,
    336         'item_id'           => $item_id,
    337         'secondary_item_id' => $secondary_item_id,
    338         'component_name'    => $component_name,
    339         'component_action'  => $component_action,
    340         'is_new'            => $is_new,
    341     ) );
     338    return BP_Notifications_Notification::update(
     339        array(
     340            'is_new' => $is_new
     341        ),
     342        array(
     343            'user_id'           => $user_id,
     344            'item_id'           => $item_id,
     345            'secondary_item_id' => $secondary_item_id,
     346            'component_name'    => $component_name,
     347            'component_action'  => $component_action
     348        )
     349    );
    342350}
    343351
     
    358366 */
    359367function bp_notifications_mark_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false, $is_new = false ) {
    360     return BP_Notifications_Notification::delete( array(
    361         'item_id'           => $item_id,
    362         'secondary_item_id' => $secondary_item_id,
    363         'component_name'    => $component_name,
    364         'component_action'  => $component_action,
    365         'is_new'            => $is_new,
    366     ) );
     368    return BP_Notifications_Notification::update(
     369        array(
     370            'is_new' => $is_new
     371        ),
     372        array(
     373            'item_id'           => $item_id,
     374            'secondary_item_id' => $secondary_item_id,
     375            'component_name'    => $component_name,
     376            'component_action'  => $component_action
     377        )
     378    );
    367379}
    368380
     
    386398 */
    387399function bp_notifications_mark_notifications_from_user( $user_id, $component_name, $component_action, $is_new = false ) {
    388     return BP_Notifications_Notification::delete( array(
    389         'item_id'          => $user_id,
    390         'component_name'   => $component_name,
    391         'component_action' => $component_action,
    392         'is_new'           => $is_new,
    393     ) );
     400    return BP_Notifications_Notification::_update(
     401        array(
     402            'is_new' => $is_new
     403        ),
     404        array(
     405            'item_id'          => $user_id,
     406            'component_name'   => $component_name,
     407            'component_action' => $component_action
     408        )
     409    );
    394410}
    395411
Note: See TracChangeset for help on using the changeset viewer.