diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
index 56bb8bec6..4047df880 100644
|
|
function bp_groups_user_can_send_invites( $group_id = 0, $user_id = 0 ) { |
2438 | 2438 | return apply_filters( 'bp_groups_user_can_send_invites', $can_send_invites, $group_id, $invite_status, $user_id ); |
2439 | 2439 | } |
2440 | 2440 | |
| 2441 | /** |
| 2442 | * Are users allowed to invite users to join groups generally? |
| 2443 | * |
| 2444 | * @since 10.0.0 |
| 2445 | * |
| 2446 | * @return bool |
| 2447 | */ |
| 2448 | function bp_get_groups_invitations_allowed() { |
| 2449 | $retval = false; |
| 2450 | if ( 'nouveau' === bp_get_theme_package_id() ) { |
| 2451 | /** |
| 2452 | * In BP Nouveau, invitations are enabled if |
| 2453 | * the friends component is enabled or |
| 2454 | * invitations to all members are not disallowed. |
| 2455 | */ |
| 2456 | if ( bp_is_active( 'friends' ) || ! bp_nouveau_groups_disallow_all_members_invites() ) { |
| 2457 | $retval = true; |
| 2458 | } |
| 2459 | } else { |
| 2460 | // In BP Legacy, the friends component must be active |
| 2461 | if ( bp_is_active( 'friends' ) ) { |
| 2462 | $retval = true; |
| 2463 | } |
| 2464 | } |
| 2465 | /** |
| 2466 | * Filters whether or not group invitations are generally allowed. |
| 2467 | * |
| 2468 | * @since 10.0.0 |
| 2469 | * |
| 2470 | * @param bool $allowed Whether or not group invitations are allowed. |
| 2471 | */ |
| 2472 | return apply_filters( 'bp_get_groups_invitations_allowed', bp_is_active( 'groups', 'invitations' ) && $retval ); |
| 2473 | } |
| 2474 | |
2441 | 2475 | /** |
2442 | 2476 | * Since BuddyPress 1.0, this generated the group settings admin/member screen. |
2443 | 2477 | * As of BuddyPress 1.5 (r4489), and because this function outputs HTML, it was moved into /bp-default/groups/single/admin.php. |
diff --git src/bp-groups/classes/class-bp-groups-component.php src/bp-groups/classes/class-bp-groups-component.php
index b272b3bdb..ff76054c3 100644
|
|
class BP_Groups_Component extends BP_Component { |
116 | 116 | buddypress()->plugin_dir, |
117 | 117 | array( |
118 | 118 | 'adminbar_myaccount_order' => 70, |
119 | | 'search_query_arg' => 'groups_search', |
| 119 | 'search_query_arg' => 'groups_search', |
| 120 | 'features' => array( 'invitations' ) |
120 | 121 | ) |
121 | 122 | ); |
122 | 123 | } |
… |
… |
class BP_Groups_Component extends BP_Component { |
392 | 393 | ); |
393 | 394 | } |
394 | 395 | |
395 | | // If friends component is active, add invitations. |
396 | | if ( bp_is_active( 'friends' ) ) { |
| 396 | // If invitations are enabled, add invitations. |
| 397 | if ( bp_get_groups_invitations_allowed() ) { |
397 | 398 | $this->group_creation_steps['group-invites'] = array( |
398 | 399 | 'name' => _x( 'Invites', 'Group screen nav', 'buddypress' ), |
399 | 400 | 'position' => 30 |
… |
… |
class BP_Groups_Component extends BP_Component { |
557 | 558 | // Determine user to use. |
558 | 559 | if ( bp_displayed_user_domain() ) { |
559 | 560 | $user_domain = bp_displayed_user_domain(); |
| 561 | $user_id = bp_displayed_user_id(); |
560 | 562 | } elseif ( bp_loggedin_user_domain() ) { |
561 | 563 | $user_domain = bp_loggedin_user_domain(); |
| 564 | $user_id = bp_loggedin_user_id(); |
562 | 565 | } else { |
563 | 566 | $user_domain = false; |
| 567 | $user_id = 0; |
564 | 568 | } |
565 | 569 | |
566 | 570 | // Only grab count if we're on a user page. |
… |
… |
class BP_Groups_Component extends BP_Component { |
607 | 611 | 'item_css_id' => 'groups-my-groups' |
608 | 612 | ); |
609 | 613 | |
610 | | // Add the Group Invites nav item. |
611 | | $sub_nav[] = array( |
612 | | 'name' => __( 'Invitations', 'buddypress' ), |
613 | | 'slug' => 'invites', |
614 | | 'parent_url' => $groups_link, |
615 | | 'parent_slug' => $slug, |
616 | | 'screen_function' => 'groups_screen_group_invites', |
617 | | 'user_has_access' => $access, |
618 | | 'position' => 30 |
619 | | ); |
| 614 | if ( bp_get_groups_invitations_allowed() ) { |
| 615 | // Add the Group Invites nav item. |
| 616 | $sub_nav[] = array( |
| 617 | 'name' => __( 'Invitations', 'buddypress' ), |
| 618 | 'slug' => 'invites', |
| 619 | 'parent_url' => $groups_link, |
| 620 | 'parent_slug' => $slug, |
| 621 | 'screen_function' => 'groups_screen_group_invites', |
| 622 | 'user_has_access' => $access, |
| 623 | 'position' => 30 |
| 624 | ); |
| 625 | } |
620 | 626 | |
621 | 627 | parent::setup_nav( $main_nav, $sub_nav ); |
622 | 628 | } |
… |
… |
class BP_Groups_Component extends BP_Component { |
833 | 839 | // Setup the logged in user variables. |
834 | 840 | $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ); |
835 | 841 | |
836 | | // Pending group invites. |
837 | | $count = groups_get_invite_count_for_user(); |
838 | 842 | $title = _x( 'Groups', 'My Account Groups', 'buddypress' ); |
839 | 843 | $pending = _x( 'No Pending Invites', 'My Account Groups sub nav', 'buddypress' ); |
840 | 844 | |
841 | | if ( $count ) { |
842 | | $title = sprintf( |
843 | | /* translators: %s: Group invitation count for the current user */ |
844 | | _x( 'Groups %s', 'My Account Groups nav', 'buddypress' ), |
845 | | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
846 | | ); |
| 845 | if ( bp_get_groups_invitations_allowed() ) { |
| 846 | // Pending group invites. |
| 847 | $count = groups_get_invite_count_for_user(); |
| 848 | if ( $count ) { |
| 849 | $title = sprintf( |
| 850 | /* translators: %s: Group invitation count for the current user */ |
| 851 | _x( 'Groups %s', 'My Account Groups nav', 'buddypress' ), |
| 852 | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
| 853 | ); |
847 | 854 | |
848 | | $pending = sprintf( |
849 | | /* translators: %s: Group invitation count for the current user */ |
850 | | _x( 'Pending Invites %s', 'My Account Groups sub nav', 'buddypress' ), |
851 | | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
852 | | ); |
| 855 | $pending = sprintf( |
| 856 | /* translators: %s: Group invitation count for the current user */ |
| 857 | _x( 'Pending Invites %s', 'My Account Groups sub nav', 'buddypress' ), |
| 858 | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
| 859 | ); |
| 860 | } |
853 | 861 | } |
854 | 862 | |
855 | 863 | // Add the "My Account" sub menus. |
… |
… |
class BP_Groups_Component extends BP_Component { |
870 | 878 | ); |
871 | 879 | |
872 | 880 | // Invitations. |
873 | | $wp_admin_nav[] = array( |
874 | | 'parent' => 'my-account-' . $this->id, |
875 | | 'id' => 'my-account-' . $this->id . '-invites', |
876 | | 'title' => $pending, |
877 | | 'href' => trailingslashit( $groups_link . 'invites' ), |
878 | | 'position' => 30 |
879 | | ); |
| 881 | if ( bp_get_groups_invitations_allowed() ) { |
| 882 | $wp_admin_nav[] = array( |
| 883 | 'parent' => 'my-account-' . $this->id, |
| 884 | 'id' => 'my-account-' . $this->id . '-invites', |
| 885 | 'title' => $pending, |
| 886 | 'href' => trailingslashit( $groups_link . 'invites' ), |
| 887 | 'position' => 30 |
| 888 | ); |
| 889 | } |
880 | 890 | |
881 | 891 | // Create a Group. |
882 | 892 | if ( bp_user_can_create_groups() ) { |
diff --git src/bp-templates/bp-legacy/buddypress/groups/create.php src/bp-templates/bp-legacy/buddypress/groups/create.php
index cb85eeb71..43bfe43e9 100644
|
|
do_action( 'bp_before_create_group_page' ); ?> |
172 | 172 | |
173 | 173 | <?php endif; ?> |
174 | 174 | |
175 | | <fieldset class="group-create-invitations"> |
| 175 | <?php if ( bp_get_groups_invitations_allowed() ): ?> |
176 | 176 | |
177 | | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
| 177 | <fieldset class="group-create-invitations"> |
178 | 178 | |
179 | | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
| 179 | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
180 | 180 | |
181 | | <div class="radio"> |
| 181 | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
182 | 182 | |
183 | | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
| 183 | <div class="radio"> |
184 | 184 | |
185 | | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
| 185 | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
186 | 186 | |
187 | | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
| 187 | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
188 | 188 | |
189 | | </div> |
| 189 | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
190 | 190 | |
191 | | </fieldset> |
| 191 | </div> |
| 192 | |
| 193 | </fieldset> |
| 194 | |
| 195 | <?php endif; ?> |
192 | 196 | |
193 | 197 | <?php |
194 | 198 | |
diff --git src/bp-templates/bp-legacy/buddypress/groups/single/admin/group-settings.php src/bp-templates/bp-legacy/buddypress/groups/single/admin/group-settings.php
index 0961da5e8..1ac4fd890 100644
|
|
do_action( 'bp_before_group_settings_admin' ); ?> |
78 | 78 | |
79 | 79 | </fieldset> |
80 | 80 | |
81 | | <?php endif; ?> |
82 | 81 | |
83 | | <fieldset class="group-create-invitations"> |
| 82 | <?php if ( bp_get_groups_invitations_allowed() ): ?> |
84 | 83 | |
85 | | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
| 84 | <fieldset class="group-create-invitations"> |
86 | 85 | |
87 | | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
| 86 | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
88 | 87 | |
89 | | <div class="radio"> |
| 88 | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
90 | 89 | |
91 | | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
| 90 | <div class="radio"> |
92 | 91 | |
93 | | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
| 92 | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
94 | 93 | |
95 | | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
| 94 | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
96 | 95 | |
97 | | </div> |
| 96 | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
98 | 97 | |
99 | | </fieldset> |
| 98 | </div> |
| 99 | |
| 100 | </fieldset> |
| 101 | |
| 102 | <?php endif; ?> |
100 | 103 | |
101 | 104 | <?php |
102 | 105 | |
diff --git src/bp-templates/bp-nouveau/buddypress/groups/single/admin/group-settings.php src/bp-templates/bp-nouveau/buddypress/groups/single/admin/group-settings.php
index 6d24eafd3..f05b7c47b 100644
|
|
if ( $group_types ) : ?> |
86 | 86 | |
87 | 87 | <?php endif; ?> |
88 | 88 | |
| 89 | <?php if ( bp_get_groups_invitations_allowed() ): ?> |
| 90 | |
89 | 91 | <fieldset class="radio group-invitations"> |
90 | 92 | <legend><?php esc_html_e( 'Group Invitations', 'buddypress' ); ?></legend> |
91 | 93 | |
… |
… |
if ( $group_types ) : ?> |
108 | 110 | |
109 | 111 | </fieldset> |
110 | 112 | |
| 113 | <?php endif; ?> |
| 114 | |
111 | 115 | </div><!-- // .group-settings-selections --> |