Changeset 11278
- Timestamp:
- 12/08/2016 02:11:17 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-notifications.php
r11091 r11278 968 968 969 969 /** 970 * Mark notifications read when a member's group membership request is granted. 971 * 972 * @since 2.8.0 973 * 974 * @param int $user_id ID of the user. 975 * @param int $group_id ID of the group. 976 */ 977 function bp_groups_accept_request_mark_notifications( $user_id, $group_id ) { 978 if ( bp_is_active( 'notifications' ) ) { 979 // First null parameter marks read for all admins. 980 bp_notifications_mark_notifications_by_item_id( null, $group_id, buddypress()->groups->id, 'new_membership_request', $user_id ); 981 } 982 } 983 add_action( 'groups_membership_accepted', 'bp_groups_accept_request_mark_notifications', 10, 2 ); 984 add_action( 'groups_membership_rejected', 'bp_groups_accept_request_mark_notifications', 10, 2 ); 985 986 /** 970 987 * Mark notifications read when a member views their group memberships. 971 988 * -
trunk/tests/phpunit/testcases/groups/notifications.php
r9819 r11278 219 219 return $value; 220 220 } 221 222 /** 223 * @group BP7375 224 */ 225 public function test_membership_request_notifications_should_be_cleared_when_request_is_accepted() { 226 $users = $this->factory->user->create_many( 3 ); 227 228 $this->add_user_to_group( $users[0], $this->group, array( 229 'is_admin' => 1, 230 ) ); 231 $this->add_user_to_group( $users[1], $this->group, array( 232 'is_admin' => 1, 233 ) ); 234 235 groups_send_membership_request( $users[2], $this->group ); 236 237 // Both admins should get a notification. 238 $get_args = array( 239 'user_id' => $users[0], 240 'item_id' => $this->group, 241 'secondary_item_id' => $users[2], 242 'component_action' => 'new_membership_request', 243 'is_new' => true, 244 ); 245 $u0_notifications = BP_Notifications_Notification::get( $get_args ); 246 $u1_notifications = BP_Notifications_Notification::get( $get_args ); 247 $this->assertNotEmpty( $u0_notifications ); 248 $this->assertNotEmpty( $u1_notifications ); 249 250 $this->assertTrue( groups_invite_user( array( 251 'user_id' => $users[2], 252 'group_id' => $this->group, 253 ) ) ); 254 255 $u0_notifications = BP_Notifications_Notification::get( $get_args ); 256 $u1_notifications = BP_Notifications_Notification::get( $get_args ); 257 $this->assertEmpty( $u0_notifications ); 258 $this->assertEmpty( $u1_notifications ); 259 } 260 221 261 }
Note: See TracChangeset
for help on using the changeset viewer.