Skip to:
Content

BuddyPress.org

Ticket #4677: 4677.2.patch

File 4677.2.patch, 8.3 KB (added by xgz, 9 years ago)

Adding options on / off loading avatar in the group and on / off the display on the pages.

  • wp-content/plugins/buddypress/bp-core/admin/bp-core-admin-settings.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    182182<?php
    183183}
    184184
     185/**
     186 * Allow group to upload avatars field
     187 *
     188 * @since BuddyPress (1.6)
     189 *
     190 * @uses checked() To display the checked attribute
     191 */
     192function bp_admin_setting_callback_group_avatar_uploads() {
     193?>
     194        <input id="bp-disable-group-avatar-uploads" name="bp-disable-group-avatar-uploads" type="checkbox" value="1" <?php checked( !bp_disable_group_avatar_uploads( false ) ); ?> />
     195        <label for="bp-disable-group-avatar-uploads"><?php _e( 'Enable Group Profile Photos', 'buddypress' ); ?></label>
     196<?php
     197}
     198
    185199/** Forums Section ************************************************************/
    186200
    187201/**
     
    284298                $legacy_options = array(
    285299                        'bp-disable-account-deletion',
    286300                        'bp-disable-avatar-uploads',
     301            'bp-disable-group-avatar-uploads',
    287302                        'bp_disable_blogforum_comments',
    288303                        'bp-disable-profile-sync',
    289304                        'bp_restrict_group_creation',
  • wp-content/plugins/buddypress/bp-groups/bp-groups-template.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    860860
    861861                // Bail if avatars are turned off
    862862                // @todo Should we maybe still filter this?
    863                 if ( ! buddypress()->avatar->show_avatars ) {
     863        // @todo ! buddypress()->avatar->show_avatars If this is a test user profile avatars why is it here for group avatar?
     864                if (  bp_disable_group_avatar_uploads() ) {
    864865                        return false;
    865866                }
    866867
  • wp-content/plugins/buddypress/bp-core/bp-core-admin.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    358358                        // Allow subscriptions setting
    359359                        add_settings_field( 'bp_restrict_group_creation', __( 'Group Creation',   'buddypress' ), 'bp_admin_setting_callback_group_creation',   'buddypress', 'bp_groups' );
    360360                        register_setting  ( 'buddypress',         'bp_restrict_group_creation',   'intval'                                                                                );
     361
     362            // Allow avatar uploads for group
     363            add_settings_field( 'bp-disable-group-avatar-uploads', __( 'Group Avatar Uploads', 'buddypress' ), 'bp_admin_setting_callback_group_avatar_uploads', 'buddypress', 'bp_groups' );
     364            register_setting( 'buddypress', 'bp-disable-group-avatar-uploads', 'intval' );
    361365                }
    362366
    363367                /** Forums ************************************************************/
  • wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress-functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    7777         */
    7878        protected function setup_actions() {
    7979
     80        add_filter( 'bp_activity_allowed_tags', array( $this, 'set_allowed_tags_secondary_avatar' ) );
    8081                // Template Output
    8182                add_filter( 'bp_get_activity_action_pre_meta', array( $this, 'secondary_avatars' ), 10, 2 );
    8283
     
    434435        }
    435436
    436437        /**
     438     * @param array $activity_allowedtags
     439     * @package BuddyPress Theme
     440     * @return array
     441     */
     442    public function set_allowed_tags_secondary_avatar($activity_allowedtags)
     443    {
     444        $activity_allowedtags['br'] = array();
     445        return $activity_allowedtags;
     446    }
     447
     448        /**
    437449         * Add secondary avatar image to this activity stream's record, if supported.
    438450         *
    439451         * @since BuddyPress (1.7)
     
    446458        function secondary_avatars( $action, $activity ) {
    447459                switch ( $activity->component ) {
    448460                        case 'groups' :
     461                $secondary_avatar = bp_get_activity_secondary_avatar();
     462                                if ( !$secondary_avatar || ( $secondary_avatar && bp_disable_group_avatar_uploads() ) ) {
     463                        $secondary_avatar = '<br>';
     464                                }
     465
     466                $reverse_content = strrev( $action );
     467                $position        = strpos( $reverse_content, 'a<' );
     468                $action          = substr_replace( $action, $secondary_avatar, -$position - 2, 0 );
     469
     470                                break;
     471
    449472                        case 'friends' :
    450473                                // Only insert avatar if one exists
    451474                                if ( $secondary_avatar = bp_get_activity_secondary_avatar() ) {
  • wp-content/plugins/buddypress/bp-core/bp-core-options.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    5555                // Avatar uploads
    5656                'bp-disable-avatar-uploads'       => false,
    5757
     58                // Group Profile Photos
     59                'bp-disable-group-avatar-uploads' => false,
     60
    5861                // Allow users to delete their own accounts
    5962                'bp-disable-account-deletion'     => false,
    6063
     
    551554         * @param bool $value Whether or not members are able to upload their own avatars.
    552555         */
    553556        return (bool) apply_filters( 'bp_disable_avatar_uploads', (bool) bp_get_option( 'bp-disable-avatar-uploads', $default ) );
     557}
     558
     559/**
     560 * @since BuddyPress (1.6.0)
     561 *
     562 * @uses bp_get_option() To get the avatar uploads option for group.
     563 *
     564 * @param bool $default Optional. Fallback value if not found in the database.
     565 *        Default: true.
     566 * @return bool True if group avatar uploads are disabled, otherwise false.
     567 */
     568function bp_disable_group_avatar_uploads( $default = false ) {
     569
     570    /**
     571     * Filters whether or not members are able to upload their groups avatars.
     572     *
     573     * @since BuddyPress (1.6.0)
     574     *
     575     * @param bool $value Whether or not members are able to upload their groups avatars.
     576     */
     577        return (bool) apply_filters( 'bp_disable_group_avatar_uploads', (bool) bp_get_option( 'bp-disable-group-avatar-uploads', $default ) );
    554578}
    555579
    556580/**
  • wp-content/plugins/buddypress/bp-groups/bp-groups-screens.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    906906                return false;
    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() )
    910910                return false;
    911911
    912912        $bp = buddypress();
  • wp-content/plugins/buddypress/bp-groups/bp-groups-loader.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    573573                                        'position'        => 10,
    574574                                ), $default_params );
    575575
    576                                 if ( ! (int) bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) {
     576                                if ( !bp_disable_group_avatar_uploads() ) {
    577577                                        $sub_nav[] = array_merge( array(
    578578                                                'name'        => __( 'Photo', 'buddypress' ),
    579579                                                'slug'        => 'group-avatar',