Skip to:
Content

BuddyPress.org

Changeset 7530


Ignore:
Timestamp:
11/08/2013 05:20:46 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Introduce bp_core_mark_notifications_by_type() and bp_core_mark_notifications_by_item_id() and replace bp_core_delete_notifications_by_type() and bp_core_delete_notifications_by_item_id() usages.

Ensures notifications are toggled as acknowledged rather than deleted. See #5148.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-friends/bp-friends-functions.php

    r7110 r7530  
    9090
    9191        // Remove the friend request notice
    92         bp_core_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
     92        bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    9393
    9494        // Add a friend accepted notice for the initiating user
     
    134134
    135135    if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) {
     136
    136137        // Remove the friend request notice
    137         bp_core_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
     138        bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );
    138139
    139140        do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) );
  • trunk/bp-groups/bp-groups-functions.php

    r7501 r7530  
    697697 */
    698698function groups_accept_invite( $user_id, $group_id ) {
    699     global $bp;
    700699
    701700    // If the user is already a member (because BP at one point allowed two invitations to
     
    724723    groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
    725724
    726     bp_core_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
     725    bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
    727726
    728727    do_action( 'groups_accept_invite', $user_id, $group_id );
     
    740739
    741740function groups_delete_invite( $user_id, $group_id ) {
    742     global $bp;
    743741
    744742    $delete = BP_Groups_Member::delete_invite( $user_id, $group_id );
    745743
    746     if ( $delete )
    747         bp_core_delete_notifications_by_item_id( $user_id, $group_id, $bp->groups->id, 'group_invite' );
     744    if ( !empty( $delete ) ) {
     745        bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );
     746    }
    748747
    749748    return $delete;
  • trunk/bp-members/bp-members-notifications.php

    r7529 r7530  
    100100}
    101101
     102/** Delete ********************************************************************/
     103
    102104/**
    103105 * Delete notifications for a user by type
     
    163165}
    164166
     167/** Mark **********************************************************************/
     168
     169/**
     170 * Delete notifications for a user by type
     171 *
     172 * Used when clearing out notifications for a specific component when the user
     173 * has visited that component.
     174 *
     175 * @since BuddyPress (1.0)
     176 * @param int $user_id
     177 * @param string $component_name
     178 * @param string $component_action
     179 * @param int $is_new
     180 * @return boolean True on success, false on fail
     181 */
     182function bp_core_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new = false ) {
     183
     184    // Bail if notifications is not active
     185    if ( ! bp_is_active( 'notifications' ) ) {
     186        return false;
     187    }
     188
     189    return bp_notifications_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new );
     190}
     191
     192/**
     193 * Delete notifications for an item ID
     194 *
     195 * Used when clearing out notifications for a specific component when the user
     196 * has visited that component.
     197 *
     198 * @since BuddyPress (1.0)
     199 * @param int $user_id
     200 * @param string $component_name
     201 * @param string $component_action
     202 * @param int $is_new
     203 * @return boolean True on success, false on fail
     204 */
     205function bp_core_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false, $is_new = false ) {
     206
     207    // Bail if notifications is not active
     208    if ( ! bp_is_active( 'notifications' ) ) {
     209        return false;
     210    }
     211
     212    return bp_notifications_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id, $is_new );
     213}
     214
    165215/**
    166216 * Mark all notifications read/unread for by type
  • trunk/bp-messages/bp-messages-template.php

    r7439 r7530  
    186186    } else {
    187187        if ( bp_is_current_action( 'inbox' ) ) {
    188             bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->messages->id, 'new_message' );
     188            bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->messages->id, 'new_message' );
    189189        }
    190190
Note: See TracChangeset for help on using the changeset viewer.