diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php
index bf321c4..a1933b3 100644
|
|
function groups_leave_group( $group_id, $user_id = 0 ) { |
400 | 400 | function groups_join_group( $group_id, $user_id = 0 ) { |
401 | 401 | global $bp; |
402 | 402 | |
403 | | if ( empty( $user_id ) ) |
| 403 | if ( empty( $user_id ) ) { |
404 | 404 | $user_id = bp_loggedin_user_id(); |
| 405 | } |
405 | 406 | |
406 | 407 | // Check if the user has an outstanding invite. If so, delete it. |
407 | | if ( groups_check_user_has_invite( $user_id, $group_id ) ) |
| 408 | if ( groups_check_user_has_invite( $user_id, $group_id ) ) { |
408 | 409 | groups_delete_invite( $user_id, $group_id ); |
| 410 | } |
409 | 411 | |
410 | 412 | // Check if the user has an outstanding request. If so, delete it. |
411 | | if ( groups_check_for_membership_request( $user_id, $group_id ) ) |
| 413 | if ( groups_check_for_membership_request( $user_id, $group_id ) ) { |
412 | 414 | groups_delete_membership_request( null, $user_id, $group_id ); |
| 415 | } |
413 | 416 | |
414 | 417 | // User is already a member, just return true |
415 | | if ( groups_is_user_member( $user_id, $group_id ) ) |
| 418 | if ( groups_is_user_member( $user_id, $group_id ) ) { |
416 | 419 | return true; |
| 420 | } |
417 | 421 | |
418 | 422 | $new_member = new BP_Groups_Member; |
419 | 423 | $new_member->group_id = $group_id; |
… |
… |
function groups_join_group( $group_id, $user_id = 0 ) { |
424 | 428 | $new_member->date_modified = bp_core_current_time(); |
425 | 429 | $new_member->is_confirmed = 1; |
426 | 430 | |
427 | | if ( !$new_member->save() ) |
| 431 | if ( !$new_member->save() ) { |
428 | 432 | return false; |
| 433 | } |
429 | 434 | |
430 | | if ( !isset( $bp->groups->current_group ) || !$bp->groups->current_group || $group_id != $bp->groups->current_group->id ) |
| 435 | if ( !isset( $bp->groups->current_group ) || !$bp->groups->current_group || $group_id != $bp->groups->current_group->id ) { |
431 | 436 | $group = groups_get_group( array( 'group_id' => $group_id ) ); |
432 | | else |
| 437 | } else { |
433 | 438 | $group = $bp->groups->current_group; |
| 439 | } |
434 | 440 | |
435 | 441 | // Record this in activity streams |
436 | 442 | groups_record_activity( array( |
… |
… |
function groups_remove_member( $user_id, $group_id ) { |
1217 | 1223 | function groups_send_membership_request( $requesting_user_id, $group_id ) { |
1218 | 1224 | |
1219 | 1225 | // Prevent duplicate requests |
1220 | | if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) ) |
| 1226 | if ( groups_check_for_membership_request( $requesting_user_id, $group_id ) ) { |
1221 | 1227 | return false; |
| 1228 | } |
1222 | 1229 | |
1223 | 1230 | // Check if the user is already a member or is banned |
1224 | | if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) ) |
| 1231 | if ( groups_is_user_member( $requesting_user_id, $group_id ) || groups_is_user_banned( $requesting_user_id, $group_id ) ) { |
1225 | 1232 | return false; |
| 1233 | } |
1226 | 1234 | |
1227 | 1235 | // Check if the user is already invited - if so, simply accept invite |
1228 | 1236 | if ( groups_check_user_has_invite( $requesting_user_id, $group_id ) ) { |
… |
… |
function groups_reject_membership_request( $membership_id, $user_id = 0, $group_ |
1323 | 1331 | * @return bool True on success, false on failure. |
1324 | 1332 | */ |
1325 | 1333 | function groups_delete_membership_request( $membership_id, $user_id = 0, $group_id = 0 ) { |
1326 | | if ( !empty( $user_id ) && !empty( $group_id ) ) |
| 1334 | if ( ! empty( $user_id ) && ! empty( $group_id ) ) { |
1327 | 1335 | $membership = new BP_Groups_Member( $user_id, $group_id ); |
1328 | | else |
| 1336 | } else { |
1329 | 1337 | $membership = new BP_Groups_Member( false, false, $membership_id ); |
| 1338 | } |
1330 | 1339 | |
1331 | | if ( !BP_Groups_Member::delete_request( $membership->user_id, $membership->group_id ) ) |
| 1340 | if ( ! BP_Groups_Member::delete_request( $membership->user_id, $membership->group_id ) ) { |
1332 | 1341 | return false; |
| 1342 | } |
1333 | 1343 | |
1334 | 1344 | return $membership; |
1335 | 1345 | } |