Ticket #5259: 5259.01.patch
File 5259.01.patch, 26.4 KB (added by , 11 years ago) |
---|
-
bp-activity/bp-activity-screens.php
function bp_activity_screen_mentions() { 129 129 } 130 130 131 131 /** 132 * Remove activity notifications when a user clicks on them.133 *134 * @since BuddyPress (1.5)135 *136 * @uses bp_core_mark_all_notifications_by_type()137 */138 function bp_activity_remove_screen_notifications() {139 bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' );140 }141 add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' );142 add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );143 add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );144 145 /**146 132 * Reset the logged-in user's new mentions data when he visits his mentions screen. 147 133 * 148 134 * @since BuddyPress (1.5) -
bp-friends/bp-friends-cache.php
function friends_clear_friend_object_cache( $friendship_id ) { 28 28 wp_cache_delete( 'friends_friend_ids_' . $friendship->friend_user_id, 'bp' ); 29 29 } 30 30 31 /**32 * Clear friend-related notifications when ?new=1.33 */34 function friends_clear_friend_notifications() {35 if ( isset( $_GET['new'] ) ) {36 bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );37 }38 }39 add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' );40 41 31 // List actions to clear object caches on 42 32 add_action( 'friends_friendship_accepted', 'friends_clear_friend_object_cache' ); 43 33 add_action( 'friends_friendship_deleted', 'friends_clear_friend_object_cache' ); -
bp-friends/bp-friends-functions.php
function friends_accept_friendship( $friendship_id ) { 118 118 if ( !$friendship->is_confirmed && BP_Friends_Friendship::accept( $friendship_id ) ) { 119 119 friends_update_friend_totals( $friendship->initiator_user_id, $friendship->friend_user_id ); 120 120 121 // Remove the friend request notice122 bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );123 124 121 // Add a friend accepted notice for the initiating user 125 122 bp_core_add_notification( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_accepted' ); 126 123 … … function friends_reject_friendship( $friendship_id ) { 170 167 171 168 if ( !$friendship->is_confirmed && BP_Friends_Friendship::reject( $friendship_id ) ) { 172 169 173 // Remove the friend request notice174 bp_core_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );175 176 170 do_action_ref_array( 'friends_friendship_rejected', array( $friendship_id, &$friendship ) ); 177 171 return true; 178 172 } … … function friends_withdraw_friendship( $initiator_userid, $friend_userid ) { 195 189 $friendship = new BP_Friends_Friendship( $friendship_id, true, false ); 196 190 197 191 if ( !$friendship->is_confirmed && BP_Friends_Friendship::withdraw( $friendship_id ) ) { 198 // Remove the friend request notice199 bp_core_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, $bp->friends->id, 'friendship_request' );200 201 192 do_action_ref_array( 'friends_friendship_whithdrawn', array( $friendship_id, &$friendship ) ); 202 193 return true; 203 194 } … … function friends_remove_data( $user_id ) { 575 566 // Remove usermeta 576 567 bp_delete_user_meta( $user_id, 'total_friend_count' ); 577 568 578 // Remove friendship requests FROM user579 bp_core_delete_notifications_from_user( $user_id, $bp->friends->id, 'friendship_request' );580 581 569 do_action( 'friends_remove_data', $user_id ); 582 570 } 583 571 add_action( 'wpmu_delete_user', 'friends_remove_data' ); -
bp-friends/bp-friends-screens.php
if ( !defined( 'ABSPATH' ) ) exit; 18 18 * Catch and process the My Friends page. 19 19 */ 20 20 function friends_screen_my_friends() { 21 22 // Delete any friendship acceptance notifications for the user when viewing a profile23 bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' );24 25 21 do_action( 'friends_screen_my_friends' ); 26 22 27 23 bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) ); … … function friends_screen_requests() { 67 63 68 64 do_action( 'friends_screen_requests' ); 69 65 70 if ( isset( $_GET['new'] ) ) {71 bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_request' );72 }73 74 66 bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) ); 75 67 } 76 68 -
bp-groups/bp-groups-functions.php
function groups_delete_group( $group_id ) { 216 216 // Remove all outstanding invites for this group 217 217 groups_delete_all_group_invites( $group_id ); 218 218 219 // Remove all notifications for any user belonging to this group220 bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->id );221 222 219 do_action( 'groups_delete_group', $group_id); 223 220 224 221 return true; … … function groups_accept_invite( $user_id, $group_id ) { 718 715 // Modify group meta 719 716 groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() ); 720 717 721 bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' );722 723 718 do_action( 'groups_accept_invite', $user_id, $group_id ); 724 719 return true; 725 720 } … … function groups_delete_invite( $user_id, $group_id ) { 737 732 738 733 $delete = BP_Groups_Member::delete_invite( $user_id, $group_id ); 739 734 740 if ( !empty( $delete ) ) { 741 bp_core_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' ); 742 } 735 do_action( 'groups_delete_invite', $user_id, $group_id, $delete ); 743 736 744 737 return $delete; 745 738 } … … function groups_remove_data_for_user( $user_id ) { 1078 1071 1079 1072 BP_Groups_Member::delete_all_for_user( $user_id ); 1080 1073 1081 bp_core_delete_notifications_from_user( $user_id, $bp->groups->id, 'new_membership_request' );1082 1083 1074 do_action( 'groups_remove_data_for_user', $user_id ); 1084 1075 } 1085 1076 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' ); -
bp-groups/bp-groups-screens.php
function groups_directory_groups_setup() { 26 26 add_action( 'bp_screens', 'groups_directory_groups_setup', 2 ); 27 27 28 28 function groups_screen_my_groups() { 29 30 $bp = buddypress();31 32 // Delete group request notifications for the user33 if ( isset( $_GET['n'] ) ) {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' );38 }39 40 29 do_action( 'groups_screen_my_groups' ); 41 30 42 31 bp_core_load_template( apply_filters( 'groups_template_my_groups', 'members/single/home' ) ); … … function groups_screen_group_invites() { 93 82 bp_core_redirect( $redirect_to ); 94 83 } 95 84 96 // Remove notifications97 bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );98 99 85 do_action( 'groups_screen_group_invites', $group_id ); 100 86 101 87 bp_core_load_template( apply_filters( 'groups_template_group_invites', 'members/single/home' ) ); … … function groups_screen_group_home() { 106 92 if ( ! bp_is_single_item() ) 107 93 return false; 108 94 109 $bp = buddypress();110 111 if ( isset( $_GET['n'] ) ) {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' );116 }117 118 95 do_action( 'groups_screen_group_home' ); 119 96 120 97 bp_core_load_template( apply_filters( 'groups_template_group_home', 'groups/single/home' ) ); … … function groups_screen_group_admin_requests() { 812 789 if ( ! bp_is_item_admin() || ( 'public' == $bp->groups->current_group->status ) ) 813 790 return false; 814 791 815 // Remove any screen notifications816 bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request' );817 818 792 $request_action = (string)bp_action_variable( 1 ); 819 793 $membership_id = (int)bp_action_variable( 2 ); 820 794 -
bp-members/bp-members-notifications.php
function bp_core_get_notifications_for_user( $user_id, $format = 'simple' ) { 105 105 return apply_filters( 'bp_core_get_notifications_for_user', $renderable, $user_id, $format ); 106 106 } 107 107 108 /** Delete ********************************************************************/108 /** Mark ****************************************************************/ 109 109 110 110 /** 111 * Delete notifications for a user by type 111 * Mark notifications for a user by type. 112 * 113 * Previously, we used to delete notifications by default, but due to changes 114 * in BuddyPress 1.9, we need to make sure notifications are marked as read 115 * instead. 116 * 117 * Plugin developers new to BuddyPress should use the notification functions 118 * located in /bp-notifications/bp-notification-functions.php instead. 112 119 * 113 * Used when clearing out notifications for a specific component when the user 114 * has visited that component. 120 * @deprecated BuddyPress (1.9) 115 121 * 116 122 * @since BuddyPress (1.0) 117 123 * @param int $user_id … … function bp_core_delete_notifications_by_type( $user_id, $component_name, $compo 126 132 return false; 127 133 } 128 134 129 return bp_notifications_ delete_notifications_by_type( $user_id, $component_name, $component_action );135 return bp_notifications_mark_notifications_by_type( $user_id, $component_name, $component_action ); 130 136 } 131 137 132 138 /** 133 * Delete notifications for an item ID 139 * Mark notifications for an item ID 140 * 141 * Previously, we used to delete notifications by default, but due to changes 142 * in BuddyPress 1.9, we need to make sure notifications are marked as read 143 * instead. 144 * 145 * Plugin developers new to BuddyPress should use the notification functions 146 * located in /bp-notifications/bp-notification-functions.php instead. 134 147 * 135 * Used when clearing out notifications for a specific component when the user 136 * has visited that component. 148 * @deprecated BuddyPress (1.9) 137 149 * 138 150 * @since BuddyPress (1.0) 139 151 * @param int $user_id … … function bp_core_delete_notifications_by_item_id( $user_id, $item_id, $component 148 160 return false; 149 161 } 150 162 151 return bp_notifications_ delete_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id );163 return bp_notifications_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id ); 152 164 } 153 165 154 166 /** 155 * Delete all notifications for by type167 * Mark all notifications by type. 156 168 * 157 * @since BuddyPress (1.0) 158 * @param int $user_id 159 * @param string $component_name 160 * @param string $component_action 161 * @return boolean True on success, false on fail 162 */ 163 function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) { 164 165 // Bail if notifications is not active 166 if ( ! bp_is_active( 'notifications' ) ) { 167 return false; 168 } 169 170 bp_notifications_delete_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id ); 171 } 172 173 /** 174 * Delete all notifications for a user 169 * Previously, we used to delete notifications by default, but due to changes 170 * in BuddyPress 1.9, we need to make sure notifications are marked as read 171 * instead. 175 172 * 176 * Used when clearing out all notifications for a user, whene deleted or spammed 173 * Plugin developers new to BuddyPress should use the notification functions 174 * located in /bp-notifications/bp-notification-functions.php instead. 175 * 176 * @deprecated BuddyPress (1.9) 177 177 * 178 178 * @since BuddyPress (1.0) 179 179 * @param int $user_id … … function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $c 181 181 * @param string $component_action 182 182 * @return boolean True on success, false on fail 183 183 */ 184 function bp_core_delete_ notifications_from_user( $user_id, $component_name, $component_action) {184 function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) { 185 185 186 186 // Bail if notifications is not active 187 187 if ( ! bp_is_active( 'notifications' ) ) { 188 188 return false; 189 189 } 190 190 191 return bp_notifications_ delete_notifications_from_user( $user_id, $component_name, $component_action);191 return bp_notifications_mark_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id ); 192 192 } 193 193 194 /** Mark **********************************************************************/194 /** Delete ********************************************************************/ 195 195 196 196 /** 197 * Delete notifications for a user by type197 * To delete notifications, please use the delete functions located in: 198 198 * 199 * Used when clearing out notifications for a specific component when the user 200 * has visited that component. 199 * /bp-notifications/bp-notifications-functions.php 201 200 * 202 * @since BuddyPress (1.9.0) 203 * @param int $user_id 204 * @param string $component_name 205 * @param string $component_action 206 * @param int $is_new 207 * @return boolean True on success, false on fail 201 * @see bp_notifications_delete_notifications_by_type() 202 * @see bp_notifications_delete_notifications_by_item_id() 203 * @see bp_notifications_delete_all_notifications_by_type() 204 * @see bp_notifications_delete_notifications_from_user() 208 205 */ 209 function bp_core_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new = false ) {210 211 // Bail if notifications is not active212 if ( ! bp_is_active( 'notifications' ) ) {213 return false;214 }215 216 return bp_notifications_mark_notifications_by_type( $user_id, $component_name, $component_action, $is_new );217 }218 206 219 207 /** 220 * Delete notifications for an item ID 221 * 222 * Used when clearing out notifications for a specific component when the user 223 * has visited that component. 208 * Delete all notifications for a user 224 209 * 225 * @since BuddyPress (1.9.0) 226 * @param int $user_id 227 * @param string $component_name 228 * @param string $component_action 229 * @param int $is_new 230 * @return boolean True on success, false on fail 231 */ 232 function bp_core_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id = false, $is_new = false ) { 233 234 // Bail if notifications is not active 235 if ( ! bp_is_active( 'notifications' ) ) { 236 return false; 237 } 238 239 return bp_notifications_mark_notifications_by_item_id( $user_id, $item_id, $component_name, $component_action, $secondary_item_id, $is_new ); 240 } 241 242 /** 243 * Mark all notifications read/unread for by type 210 * Used when clearing out all notifications for a user, whene deleted or spammed 244 211 * 245 * Used when clearing out notifications for an entire component212 * @deprecated BuddyPress (1.9) 246 213 * 247 * @since BuddyPress (1. 9.0)214 * @since BuddyPress (1.0) 248 215 * @param int $user_id 249 216 * @param string $component_name 250 217 * @param string $component_action 251 218 * @return boolean True on success, false on fail 252 219 */ 253 function bp_core_ mark_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false, $is_new = false) {220 function bp_core_delete_notifications_from_user( $user_id, $component_name, $component_action ) { 254 221 255 222 // Bail if notifications is not active 256 223 if ( ! bp_is_active( 'notifications' ) ) { 257 224 return false; 258 225 } 259 226 260 bp_notifications_mark_all_notifications_by_type( $item_id, $component_name, $component_action, $secondary_item_id, $is_new);227 return bp_notifications_delete_notifications_from_user( $user_id, $component_name, $component_action ); 261 228 } 262 229 263 /**264 * Mark all notifications read/unread from a user265 *266 * @since BuddyPress (1.9.0)267 * @param int $user_id268 * @param string $component_name269 * @param string $component_action270 * @return boolean True on success, false on fail271 */272 function bp_core_mark_notifications_from_user( $user_id, $component_name, $component_action, $is_new = false ) {273 274 // Bail if notifications is not active275 if ( ! bp_is_active( 'notifications' ) ) {276 return false;277 }278 279 return bp_notifications_mark_notifications_from_user( $user_id, $component_name, $component_action, $is_new );280 }281 230 282 231 /** Helpers *******************************************************************/ 283 232 -
bp-messages/bp-messages-template.php
function bp_has_message_threads( $args = '' ) { 184 184 if ( bp_is_current_action( 'notices' ) && !bp_current_user_can( 'bp_moderate' ) ) { 185 185 wp_redirect( bp_displayed_user_id() ); 186 186 } else { 187 if ( bp_is_current_action( 'inbox' ) ) {188 bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->messages->id, 'new_message' );189 }190 187 191 188 if ( bp_is_current_action( 'sentbox' ) ) { 192 189 $box = 'sentbox'; -
bp-notifications/bp-notifications-actions.php
function bp_notifications_action_delete() { 121 121 bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' ); 122 122 } 123 123 add_action( 'bp_actions', 'bp_notifications_action_delete' ); 124 125 126 /** BP COMPONENTS *******************************************************/ 127 128 /** 129 * Remove activity notifications when a user clicks on them. 130 * 131 * @since BuddyPress (1.5) 132 * 133 * @uses bp_notifications_mark_all_notifications_by_type() 134 */ 135 function bp_activity_remove_screen_notifications() { 136 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, 'new_at_mention' ); 137 } 138 add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' ); 139 add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' ); 140 add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' ); 141 142 /** 143 * Clear friend-related notifications when ?new=1. 144 * 145 * @since BuddyPress (1.9.0) 146 */ 147 function friends_clear_friend_notifications() { 148 if ( isset( $_GET['new'] ) ) { 149 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' ); 150 } 151 } 152 add_action( 'bp_activity_screen_my_activity', 'friends_clear_friend_notifications' ); 153 154 /** 155 * Clear any friendship acceptance notifications for the user when viewing a profile. 156 * 157 * @since BuddyPress (1.9.0) 158 */ 159 function friends_clear_friendship_accepted_notifications() { 160 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_accepted' ); 161 } 162 add_action( 'friends_screen_my_friends', 'friends_clear_friendship_accepted_notifications' ); 163 164 /** 165 * Clear any friendship request notifications for the user. 166 * 167 * @since BuddyPress (1.9.0) 168 */ 169 function friends_clear_friendship_request_notifications() { 170 if ( isset( $_GET['new'] ) ) { 171 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->friends->id, 'friendship_request' ); 172 } 173 } 174 add_action( 'friends_screen_requests', 'friends_clear_friendship_request_notifications' ); 175 176 /** 177 * Clear any friendship request notifications for the user when friendship is 178 * accepted. 179 * 180 * @since BuddyPress (1.9.0) 181 */ 182 function friends_clear_friendship_request_notifications_on_accept( $friendship_id, $initiator_user_id, $friend_user_id ) { 183 bp_notifications_mark_notifications_by_item_id( $friend_user_id, $initiator_user_id, buddypress()->friends->id, 'friendship_request' ); 184 } 185 add_action( 'friends_friendship_accepted', 'friends_clear_friendship_request_notifications_on_accept', 10, 3 ); 186 187 /** 188 * Clear any friendship request notifications for the user when friendship is 189 * rejected. 190 * 191 * @since BuddyPress (1.9.0) 192 */ 193 function friends_clear_friendship_request_notifications_on_reject( $friendship_id, $friendship ) { 194 bp_notifications_mark_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, buddypress()->friends->id, 'friendship_request' ); 195 } 196 add_action( 'friends_friendship_rejected', 'friends_clear_friendship_request_notifications_on_reject', 10, 2 ); 197 198 /** 199 * Clear any friendship request notifications for the user when friendship is 200 * rejected. 201 * 202 * @since BuddyPress (1.9.0) 203 */ 204 function friends_clear_friendship_request_notifications_on_withdraw( $friendship_id, $friendship ) { 205 bp_notifications_delete_notifications_by_item_id( $friendship->friend_user_id, $friendship->initiator_user_id, buddypress()->friends->id, 'friendship_request' ); 206 } 207 add_action( 'friends_friendship_whithdrawn', 'friends_clear_friendship_request_notifications_on_withdraw', 10, 2 ); 208 209 /** 210 * Clear any friendship request notifications by a deleted user. 211 * 212 * @since BuddyPress (1.9.0) 213 */ 214 function friends_remove_notifications_for_user( $user_id = 0 ) { 215 bp_notifications_delete_notifications_from_user( $user_id, buddypress()->friends->id, 'friendship_request' ); 216 } 217 add_action( 'friends_remove_data', 'friends_remove_notifications_for_user' ); 218 219 /** 220 * Clear any group-related notifications for the user when viewing their groups. 221 * 222 * @since BuddyPress (1.9.0) 223 */ 224 function groups_clear_my_groups_notifications() { 225 $bp = buddypress(); 226 227 // Delete group request notifications for the user 228 if ( isset( $_GET['n'] ) ) { 229 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' ); 230 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' ); 231 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' ); 232 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' ); 233 } 234 } 235 add_action( 'groups_screen_my_groups', 'groups_clear_my_groups_notifications' ); 236 237 /** 238 * Clear any group invite notifications for the user when viewing their group 239 * invites page. 240 * 241 * @since BuddyPress (1.9.0) 242 */ 243 function groups_clear_my_invites_notifications() { 244 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' ); 245 } 246 add_action( 'groups_screen_group_invites', 'groups_clear_invites_notifications' ); 247 248 /** 249 * Clear single group notifications for the user when viewing a group page. 250 * 251 * @since BuddyPress (1.9.0) 252 */ 253 function groups_clear_single_group_notifications() { 254 $bp = buddypress(); 255 256 if ( isset( $_GET['n'] ) ) { 257 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' ); 258 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' ); 259 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod' ); 260 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin' ); 261 } 262 } 263 add_action( 'groups_screen_group_home', 'groups_clear_single_group_notifications' ); 264 265 /** 266 * Clear a group's membership request notifications for the group admin. 267 * 268 * @since BuddyPress (1.9.0) 269 */ 270 function groups_clear_request_notifications() { 271 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'new_membership_request' ); 272 } 273 add_action( 'groups_group_request_managed', 'groups_clear_request_notifications' ); 274 add_action( 'groups_screen_group_admin_requests', 'groups_clear_request_notifications' ); 275 276 /** 277 * Clear a user's group invite notifications. 278 * 279 * @since BuddyPress (1.9.0) 280 */ 281 function groups_clear_group_invites_notifications( $user_id = 0, $group_id = 0, $delete = true ) { 282 bp_notifications_mark_notifications_by_item_id( $user_id, $group_id, buddypress()->groups->id, 'group_invite' ); 283 } 284 add_action( 'groups_accept_invite', 'groups_clear_group_invites_notifications', 10, 2 ); 285 add_action( 'groups_delete_invite', 'groups_clear_group_invites_notifications', 10, 3 ); 286 287 /** 288 * Clear all group notifications when a group is deleted. 289 * 290 * @since BuddyPress (1.9.0) 291 */ 292 function groups_clear_notifications_for_group( $group_id = 0 ) { 293 bp_notifications_delete_all_notifications_by_type( $group_id, buddypress()->groups->id ); 294 } 295 add_action( 'groups_delete_group', 'groups_clear_notifications_for_group' ); 296 297 /** 298 * Clear all group notifications when a user is deleted. 299 * 300 * @since BuddyPress (1.9.0) 301 */ 302 function groups_clear_notifications_for_user( $user_id = 0 ) { 303 bp_notifications_delete_notifications_from_user( $user_id, buddypress()->groups->id, 'new_membership_request' ); 304 } 305 add_action( 'groups_remove_data_for_user', 'groups_clear_notifications_for_user' ); 306 307 /** 308 * Clear notifications when user is in the PM inbox. 309 * 310 * @todo Perhaps fire this on 'messages_screen_inbox' instead? 311 */ 312 function messages_clear_notifications_on_inbox( $retval ) { 313 if ( bp_is_current_action( 'inbox' ) ) { 314 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->messages->id, 'new_message' ); 315 } 316 317 return $retval; 318 } 319 add_filter( 'bp_has_message_threads', 'messages_clear_notifications_on_inbox' ); 320 No newline at end of file