Skip to:
Content

BuddyPress.org

Changeset 9828


Ignore:
Timestamp:
05/02/2015 01:01:03 AM (9 years ago)
Author:
boonebgorges
Message:

Allow group avatars to be disabled.

Props xgz, boonebgorges, imath, hnla.
Fixes #4677.

Location:
trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r9824 r9828  
    16071607        switch ( $activities_template->activity->component ) {
    16081608            case 'groups' :
     1609                if ( bp_disable_group_avatar_uploads() ) {
     1610                    return false;
     1611                }
     1612
    16091613                $object  = 'group';
    16101614                $item_id = $activities_template->activity->item_id;
  • trunk/src/bp-core/admin/bp-core-admin-settings.php

    r9819 r9828  
    180180    <p class="description"><?php _e( 'Administrators can always create groups, regardless of this setting.', 'buddypress' ); ?></p>
    181181
     182<?php
     183}
     184
     185/**
     186 * 'Enable group avatars' field markup.
     187 *
     188 * @since BuddyPress (2.3.0)
     189 */
     190function bp_admin_setting_callback_group_avatar_uploads() {
     191?>
     192    <input id="bp-disable-group-avatar-uploads" name="bp-disable-group-avatar-uploads" type="checkbox" value="1" <?php checked( ! bp_disable_group_avatar_uploads() ); ?> />
     193    <label for="bp-disable-group-avatar-uploads"><?php _e( 'Allow customizable avatars for groups', 'buddypress' ); ?></label>
    182194<?php
    183195}
     
    281293        }
    282294
    283         // Some legacy options are not registered with the Settings API
     295        // Some legacy options are not registered with the Settings API, or are reversed in the UI.
    284296        $legacy_options = array(
    285297            'bp-disable-account-deletion',
    286298            'bp-disable-avatar-uploads',
     299            'bp-disable-group-avatar-uploads',
    287300            'bp_disable_blogforum_comments',
    288301            'bp-disable-profile-sync',
  • trunk/src/bp-core/bp-core-admin.php

    r9819 r9828  
    338338            add_settings_section( 'bp_xprofile', _x( 'Profile Settings', 'BuddyPress setting tab', 'buddypress' ), 'bp_admin_setting_callback_xprofile_section', 'buddypress' );
    339339
    340             $avatar_setting = 'bp_xprofile';
     340            add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_avatar_uploads', 'buddypress', 'bp_xprofile' );
     341            register_setting( 'buddypress', 'bp-disable-avatar-uploads', 'intval' );
    341342
    342343            // Profile sync setting
     
    352353            add_settings_section( 'bp_groups',        __( 'Groups Settings',  'buddypress' ), 'bp_admin_setting_callback_groups_section',   'buddypress'              );
    353354
    354             if ( empty( $avatar_setting ) ) {
    355                 $avatar_setting = 'bp_groups';
    356             }
    357 
    358355            // Allow subscriptions setting
    359356            add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation',   'buddypress' ), 'bp_admin_setting_callback_group_creation',   'buddypress', 'bp_groups' );
    360357            register_setting  ( 'buddypress',         'bp_restrict_group_creation',   'intval'                                                                                );
     358
     359            // Allow group avatars.
     360            add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Photo Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
     361            register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
    361362        }
    362363
     
    393394                register_setting  ( 'buddypress',         '_bp_enable_akismet',   'intval'                                                                                  );
    394395            }
    395         }
    396 
    397         /** Avatar upload for users or groups ************************************/
    398 
    399         if ( ! empty( $avatar_setting ) ) {
    400             // Allow avatar uploads
    401             add_settings_field( 'bp-disable-avatar-uploads', __( 'Profile Photo Uploads',   'buddypress' ), 'bp_admin_setting_callback_avatar_uploads',   'buddypress', $avatar_setting );
    402             register_setting  ( 'buddypress',         'bp-disable-avatar-uploads',   'intval'                                                                                    );
    403396        }
    404397    }
  • trunk/src/bp-core/bp-core-avatars.php

    r9827 r9828  
    18141814        // Group creation
    18151815        if ( bp_is_group_create() && bp_is_group_creation_step( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
    1816             $retval = ! bp_core_get_root_option( 'bp-disable-avatar-uploads' );
     1816            $retval = ! bp_disable_group_avatar_uploads();
    18171817
    18181818        // Group Manage
    18191819        } elseif ( bp_is_group_admin_page() && bp_is_group_admin_screen( 'group-avatar' ) && 'crop-image' !== bp_get_avatar_admin_step() ) {
    1820             $retval = ! bp_core_get_root_option( 'bp-disable-avatar-uploads' );
     1820            $retval = ! bp_disable_group_avatar_uploads();
    18211821        }
    18221822    }
  • trunk/src/bp-core/bp-core-options.php

    r9819 r9828  
    5555        // Avatar uploads
    5656        'bp-disable-avatar-uploads'       => false,
     57
     58        // Group Profile Photos
     59        'bp-disable-group-avatar-uploads' => false,
    5760
    5861        // Allow users to delete their own accounts
     
    582585
    583586/**
     587 * Are group avatars disabled?
     588 *
     589 * For backward compatibility, this option falls back on the value of 'bp-disable-avatar-uploads' when no value is
     590 * found in the database.
     591 *
     592 * @since BuddyPress (2.3.0)
     593 *
     594 * @param bool $default Optional. Fallback value if not found in the database.
     595 *                      Defaults to the value of `bp_disable_avatar_uploads()`.
     596 * @return bool True if group avatar uploads are disabled, otherwise false.
     597 */
     598function bp_disable_group_avatar_uploads( $default = null ) {
     599    $disabled = bp_get_option( 'bp-disable-group-avatar-uploads', '' );
     600
     601    if ( '' === $disabled ) {
     602        if ( is_null( $default ) ) {
     603            $disabled = bp_disable_avatar_uploads();
     604        } else {
     605            $disabled = $default;
     606        }
     607    }
     608
     609    /**
     610     * Filters whether or not members are able to upload group avatars.
     611     *
     612     * @since BuddyPress (2.3.0)
     613     *
     614     * @param bool $disabled Whether or not members are able to upload their groups avatars.
     615     * @param bool $default  Default value passed to the function.
     616     */
     617    return (bool) apply_filters( 'bp_disable_group_avatar_uploads', $disabled, $default );
     618}
     619
     620/**
    584621 * Are members able to delete their own accounts?
    585622 *
  • trunk/src/bp-groups/bp-groups-loader.php

    r9819 r9828  
    299299
    300300        // If avatar uploads are not disabled, add avatar option
    301         $disabled_avatar_uploads = (int) bp_core_get_root_option( 'bp-disable-avatar-uploads' );
     301        $disabled_avatar_uploads = (int) bp_disable_group_avatar_uploads();
    302302        if ( ! $disabled_avatar_uploads && $bp->avatar->show_avatars ) {
    303303            $this->group_creation_steps['group-avatar'] = array(
     
    575575                ), $default_params );
    576576
    577                 if ( ! (int) bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) {
     577                if ( ! bp_disable_group_avatar_uploads() && buddypress()->avatar->show_avatars ) {
    578578                    $sub_nav[] = array_merge( array(
    579579                        'name'        => __( 'Photo', 'buddypress' ),
  • trunk/src/bp-groups/bp-groups-screens.php

    r9819 r9828  
    907907
    908908    // If the logged-in user doesn't have permission or if avatar uploads are disabled, then stop here
    909     if ( ! bp_is_item_admin() || (int) bp_get_option( 'bp-disable-avatar-uploads' ) || ! buddypress()->avatar->show_avatars )
     909    if ( ! bp_is_item_admin() || bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars )
    910910        return false;
    911911
  • trunk/src/bp-groups/bp-groups-template.php

    r9819 r9828  
    710710        }
    711711
     712        // Whether a group avatar will appear.
     713        if ( bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars ) {
     714            $classes[] = 'group-no-avatar';
     715        } else {
     716            $classes[] = 'group-has-avatar';
     717        }
     718
    712719        /**
    713720         * Filters classes that will be applied to row class of the current group in the loop.
     
    859866        global $groups_template;
    860867
    861         // Bail if avatars are turned off
    862         // @todo Should we maybe still filter this?
    863         if ( ! buddypress()->avatar->show_avatars ) {
     868        // Bail if avatars are turned off.
     869        if ( bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars ) {
    864870            return false;
    865871        }
  • trunk/src/bp-templates/bp-legacy/buddypress/groups/groups-loop.php

    r9819 r9828  
    5353
    5454        <li <?php bp_group_class(); ?>>
    55             <div class="item-avatar">
    56                 <a href="<?php bp_group_permalink(); ?>"><?php bp_group_avatar( 'type=thumb&width=50&height=50' ); ?></a>
    57             </div>
     55            <?php if ( ! bp_disable_group_avatar_uploads() ) : ?>
     56                <div class="item-avatar">
     57                    <a href="<?php bp_group_permalink(); ?>"><?php bp_group_avatar( 'type=thumb&width=50&height=50' ); ?></a>
     58                </div>
     59            <?php endif; ?>
    5860
    5961            <div class="item">
  • trunk/src/bp-templates/bp-legacy/buddypress/groups/single/group-header.php

    r9819 r9828  
    5151</div><!-- #item-actions -->
    5252
    53 <div id="item-header-avatar">
    54     <a href="<?php bp_group_permalink(); ?>" title="<?php bp_group_name(); ?>">
     53<?php if ( ! bp_disable_group_avatar_uploads() ) : ?>
     54    <div id="item-header-avatar">
     55        <a href="<?php bp_group_permalink(); ?>" title="<?php bp_group_name(); ?>">
    5556
    56         <?php bp_group_avatar(); ?>
     57            <?php bp_group_avatar(); ?>
    5758
    58     </a>
    59 </div><!-- #item-header-avatar -->
     59        </a>
     60    </div><!-- #item-header-avatar -->
     61<?php endif; ?>
    6062
    6163<div id="item-header-content">
  • trunk/src/bp-templates/bp-legacy/buddypress/members/single/groups/invites.php

    r9819 r9828  
    1515
    1616            <li>
    17                 <div class="item-avatar">
    18                     <a href="<?php bp_group_permalink(); ?>"><?php bp_group_avatar( 'type=thumb&width=50&height=50' ); ?></a>
    19                 </div>
     17                <?php if ( ! bp_disable_group_avatar_uploads() ) : ?>
     18                    <div class="item-avatar">
     19                        <a href="<?php bp_group_permalink(); ?>"><?php bp_group_avatar( 'type=thumb&width=50&height=50' ); ?></a>
     20                    </div>
     21                <?php endif; ?>
    2022
    2123                <h4><a href="<?php bp_group_permalink(); ?>"><?php bp_group_name(); ?></a><span class="small"> - <?php printf( _nx( '%d member', '%d members', bp_get_group_total_members( false ),'Group member count', 'buddypress' ), bp_get_group_total_members( false )  ); ?></span></h4>
  • trunk/src/bp-templates/bp-legacy/css/buddypress.css

    r9819 r9828  
    12821282    width: 50%;
    12831283}
     1284#buddypress ul.item-list li.group-no-avatar div.item-desc {
     1285    margin-left: 0;
     1286}
    12841287#buddypress ul.item-list li div.action {
    12851288    position: absolute;
Note: See TracChangeset for help on using the changeset viewer.