Skip to:
Content

BuddyPress.org

Ticket #1150: 1150.003.diff

File 1150.003.diff, 4.1 KB (added by cnorris23, 12 years ago)

for 1.2 branch

  • bp-themes/bp-default/groups/index.php

     
    44                <div class="padder">
    55
    66                <form action="" method="post" id="groups-directory-form" class="dir-form">
    7                         <h3><?php _e( 'Groups Directory', 'buddypress' ) ?><?php if ( is_user_logged_in() ) : ?> &nbsp;<a class="button" href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG . '/create/' ?>"><?php _e( 'Create a Group', 'buddypress' ) ?></a><?php endif; ?></h3>
     7                        <h3><?php _e( 'Groups Directory', 'buddypress' ); ?><?php if ( is_user_logged_in() && bp_user_can_create_groups() ) : ?> &nbsp;<a class="button" href="<?php echo trailingslashit( bp_get_root_domain() . '/' . BP_GROUPS_SLUG . '/create' ); ?>"><?php _e( 'Create a Group', 'buddypress' ); ?></a><?php endif; ?></h3>
    88
    99                        <?php do_action( 'bp_before_directory_groups_content' ) ?>
    1010
     
    1212                                <?php bp_directory_groups_search_form() ?>
    1313                        </div><!-- #group-dir-search -->
    1414
     15                        <?php do_action( 'template_notices' ); ?>
     16
    1517                        <div class="item-list-tabs">
    1618                                <ul>
    1719                                        <li class="selected" id="groups-all"><a href="<?php echo bp_get_root_domain() . '/' . BP_GROUPS_SLUG ?>"><?php printf( __( 'All Groups (%s)', 'buddypress' ), bp_get_total_group_count() ) ?></a></li>
  • bp-core/bp-core-admin.php

     
    114114                                        </td>
    115115                                </tr>
    116116
     117                                <?php if ( bp_is_active( 'groups' ) ) : ?>
     118
     119                                        <tr>
     120                                                <th scope="row"><?php _e( 'Restrict group creation to Site Admins?', 'buddypress' ) ?>:</th>
     121                                                        <td>
     122                                                                <input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php checked( '1', get_site_option( 'bp_restrict_group_creation', '0' ) ); ?>id="bp-restrict-group-creation" value="1" /> <?php _e( 'Yes', 'buddypress' ) ?> &nbsp;
     123                                                                <input type="radio" name="bp-admin[bp_restrict_group_creation]"<?php checked( '0', get_site_option( 'bp_restrict_group_creation', '0' ) ); ?>id="bp-restrict-group-creation" value="0" /> <?php _e( 'No', 'buddypress' ) ?>
     124                                                        </td>
     125                                        </tr>
     126
     127                                <?php endif; ?>
     128
    117129                                <?php do_action( 'bp_core_admin_screen_fields' ) ?>
     130
    118131                        </tbody>
    119132                        </table>
    120133
  • bp-groups.php

     
    10411041        if ( !is_user_logged_in() )
    10421042                return false;
    10431043
     1044        if ( !bp_user_can_create_groups() ) {
     1045                bp_core_add_message( __( 'Sorry, you are not allowed to create groups.', 'buddypress' ), 'error' );
     1046                bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->groups->slug ) );
     1047        }
     1048
    10441049        /* Make sure creation steps are in the right order */
    10451050        groups_action_sort_creation_steps();
    10461051
  • bp-groups/bp-groups-templatetags.php

     
    15551555 * Group Creation Process Template Tags
    15561556 **/
    15571557
     1558/**
     1559 * Determine if the current logged in user can create groups.
     1560 *
     1561 * @since BuddyPress {unknown}
     1562 *
     1563 * @uses apply_filters() To call 'bp_user_can_create_groups'.
     1564 * @uses get_site_option() To retrieve value of 'bp_restrict_group_creation'. Defaults to 0.
     1565 * @uses is_super_admin() To determine if current user if super admin.
     1566 *
     1567 * @return bool True if user can create groups. False otherwise.
     1568 */
     1569function bp_user_can_create_groups() {
     1570        // Bail early if super admin
     1571        if ( is_super_admin() )
     1572                return true;
     1573
     1574        // Get group creation option, default to 0 (allowed)
     1575        $restricted = (int) get_site_option( 'bp_restrict_group_creation', 0 );
     1576
     1577        // Allow by default
     1578        $can_create = true;
     1579
     1580        // Are regular users restricted?
     1581        if ( $restricted )
     1582                $can_create = false;
     1583
     1584        return apply_filters( 'bp_user_can_create_groups', $can_create );
     1585}
     1586
    15581587function bp_group_creation_tabs() {
    15591588        global $bp;
    15601589