[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Groups: Single group "Manage > Settings" screen handler 4 * 5 * @package BuddyPress 6 * @subpackage GroupsScreens 7 * @since 3.0.0 8 */ 9 10 /** 11 * Handle the display of a group's admin/group-settings page. 12 * 13 * @since 1.0.0 14 */ 15 function groups_screen_group_admin_settings() { 16 17 if ( 'group-settings' != bp_get_group_current_admin_tab() ) 18 return false; 19 20 if ( ! bp_is_item_admin() ) 21 return false; 22 23 $bp = buddypress(); 24 25 // If the edit form has been submitted, save the edited details. 26 if ( isset( $_POST['save'] ) ) { 27 $enable_forum = ( isset($_POST['group-show-forum'] ) ) ? 1 : 0; 28 29 // Checked against a list of allowed statuses for security. 30 /** This filter is documented in bp-groups/bp-groups-admin.php */ 31 $allowed_status = apply_filters( 'groups_allowed_status', array( 'public', 'private', 'hidden' ) ); 32 $status = ( in_array( $_POST['group-status'], (array) $allowed_status ) ) ? $_POST['group-status'] : 'public'; 33 34 // Checked against a list of allowed statuses for security. 35 /** This filter is documented in bp-groups/bp-groups-admin.php */ 36 $allowed_invite_status = apply_filters( 'groups_allowed_invite_status', array( 'members', 'mods', 'admins' ) ); 37 $invite_status = isset( $_POST['group-invite-status'] ) && in_array( $_POST['group-invite-status'], (array) $allowed_invite_status ) ? $_POST['group-invite-status'] : 'members'; 38 39 // Check the nonce. 40 if ( !check_admin_referer( 'groups_edit_group_settings' ) ) 41 return false; 42 43 $group_id = bp_get_current_group_id(); 44 45 /* 46 * Save group types. 47 * 48 * Ensure we keep types that have 'show_in_create_screen' set to false. 49 */ 50 $current_types = bp_groups_get_group_type( $group_id, false ); 51 $current_types = array_intersect( bp_groups_get_group_types( array( 'show_in_create_screen' => false ) ), (array) $current_types ); 52 if ( isset( $_POST['group-types'] ) ) { 53 $current_types = array_merge( $current_types, $_POST['group-types'] ); 54 55 // Set group types. 56 bp_groups_set_group_type( $group_id, $current_types ); 57 58 // No group types checked, so this means we want to wipe out all group types. 59 } else { 60 /* 61 * Passing a blank string will wipe out all types for the group. 62 * 63 * Ensure we keep types that have 'show_in_create_screen' set to false. 64 */ 65 $current_types = empty( $current_types ) ? '' : $current_types; 66 67 // Set group types. 68 bp_groups_set_group_type( $group_id, $current_types ); 69 } 70 71 if ( ! groups_edit_group_settings( $group_id, $enable_forum, $status, $invite_status ) ) { 72 bp_core_add_message( __( 'There was an error updating group settings. Please try again.', 'buddypress' ), 'error' ); 73 } else { 74 bp_core_add_message( __( 'Group settings were successfully updated.', 'buddypress' ) ); 75 } 76 77 /** 78 * Fires before the redirect if a group settings has been edited and saved. 79 * 80 * @since 1.0.0 81 * 82 * @param int $id ID of the group that was edited. 83 */ 84 do_action( 'groups_group_settings_edited', $bp->groups->current_group->id ); 85 86 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/group-settings/' ); 87 } 88 89 /** 90 * Fires before the loading of the group admin/group-settings page template. 91 * 92 * @since 1.0.0 93 * 94 * @param int $id ID of the group that is being displayed. 95 */ 96 do_action( 'groups_screen_group_admin_settings', $bp->groups->current_group->id ); 97 98 /** 99 * Filters the template to load for a group's admin/group-settings page. 100 * 101 * @since 1.0.0 102 * 103 * @param string $value Path to a group's admin/group-settings template. 104 */ 105 bp_core_load_template( apply_filters( 'groups_template_group_admin_settings', 'groups/single/home' ) ); 106 } 107 add_action( 'bp_screens', 'groups_screen_group_admin_settings' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Nov 21 01:00:57 2024 | Cross-referenced by PHPXref 0.7.1 |