Changeset 4613 for trunk/includes/extend/buddypress/group.php
- Timestamp:
- 12/21/2012 07:13:50 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/extend/buddypress/group.php
r4609 r4613 302 302 303 303 // Update the group forum setting 304 $group = new BP_Groups_Group( $group_id ); 305 $group->enable_forum = $edit_forum; 306 $group->save(); 304 $group = $this->toggle_group_forum( $group_id, $edit_forum ); 307 305 308 306 // Create a new forum … … 420 418 groups_update_groupmeta( bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id, true ); 421 419 420 // Toggle forum on 421 $this->toggle_group_forum( bp_get_new_group_id(), true ); 422 422 423 break; 423 424 case false : … … 425 426 // Forum was created but is now being undone 426 427 if ( !empty( $forum_id ) ) { 428 429 // Delete the forum 427 430 wp_delete_post( $forum_id, true ); 431 432 // Delete meta values 428 433 groups_delete_groupmeta( bp_get_new_group_id(), 'forum_id' ); 429 434 groups_delete_groupmeta( bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id ); 435 436 // Toggle forum off 437 $this->toggle_group_forum( bp_get_new_group_id(), false ); 430 438 } 431 439 … … 496 504 bbp_remove_forum_id_from_group( $group_id, $forum_id ); 497 505 bbp_remove_group_id_from_forum( $forum_id, $group_id ); 506 } 507 508 /** 509 * Toggle the enable_forum group setting on or off 510 * 511 * @since bbPress (r4612) 512 * 513 * @param int $group_id The group to toggle 514 * @param bool $enabled True for on, false for off 515 * @uses groups_get_group() To get the group to toggle 516 * @return False if group is not found, otherwise return the group 517 */ 518 public function toggle_group_forum( $group_id = 0, $enabled = false ) { 519 520 // Get the group 521 $group = groups_get_group( array( 'group_id' => $group_id ) ); 522 523 // Bail if group cannot be found 524 if ( empty( $group ) ) 525 return false; 526 527 // Set forum enabled status 528 $group->enable_forum = (int) $enabled; 529 530 // Save the group 531 $group->save(); 532 533 // Return the group 534 return $group; 498 535 } 499 536
Note: See TracChangeset
for help on using the changeset viewer.