Skip to:
Content

BuddyPress.org

Changeset 11557


Ignore:
Timestamp:
05/17/2017 06:57:26 PM (7 years ago)
Author:
dcavins
Message:

Update group update notifications to include slug updates.

Add cases for the group slug being updated in the code that creates the
various notifications and activity items alerting group admins that
some group information has been updated.

See #6014.

Location:
trunk
Files:
3 edited

Legend:

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

    r11447 r11557  
    190190    } elseif ( ! empty( $changed['description']['old'] ) && ! empty( $changed['description']['new'] ) ) {
    191191        $action = sprintf( __( '%1$s changed the description of the group %2$s from "%3$s" to "%4$s"', 'buddypress' ), $user_link, $group_link, esc_html( $changed['description']['old'] ), esc_html( $changed['description']['new'] ) );
     192
     193    } elseif ( ! empty( $changed['slug']['old'] ) && ! empty( $changed['slug']['new'] ) ) {
     194        $action = sprintf( __( '%1$s changed the permalink of the group %2$s.', 'buddypress' ), $user_link, $group_link );
    192195
    193196    }
     
    462465    }
    463466
    464     if ( ! isset( $old_group->name ) || ! isset( $old_group->description ) ) {
     467    if ( ! isset( $old_group->name ) || ! isset( $old_group->slug ) || ! isset( $old_group->description ) ) {
    465468        return false;
    466469    }
     
    487490            'old' => $old_group->name,
    488491            'new' => $group->name,
     492        );
     493    }
     494
     495    if ( $group->slug !== $old_group->slug ) {
     496        $changed['slug'] = array(
     497            'old' => $old_group->slug,
     498            'new' => $group->slug,
    489499        );
    490500    }
  • trunk/src/bp-groups/bp-groups-notifications.php

    r11381 r11557  
    4343                esc_html( $old_group->description ),
    4444                esc_html( $group->description )
     45            );
     46        }
     47
     48        if ( $group->slug !== $old_group->slug ) {
     49            $changed[] = sprintf(
     50                _x( '* Permalink changed from "%s" to "%s".', 'Group update email text', 'buddypress' ),
     51                esc_url( bp_get_group_permalink( $old_group ) ),
     52                esc_url( bp_get_group_permalink( $group ) )
    4553            );
    4654        }
  • trunk/tests/phpunit/testcases/groups/activity.php

    r11555 r11557  
    164164     * @group bp_groups_format_activity_action_group_details_updated
    165165     */
     166    public function test_bp_groups_format_activity_action_group_details_updated_with_updated_slug() {
     167        $old_user = get_current_user_id();
     168        $u = $this->factory->user->create();
     169        $this->set_current_user( $u );
     170
     171        $group = $this->factory->group->create_and_get();
     172        groups_edit_base_group_details( array(
     173            'group_id'       => $group->id,
     174            'name'           => $group->name,
     175            'slug'           => 'flaxen',
     176            'description'    => $group->description,
     177            'notify_members' => true,
     178        ) );
     179        $new_group_details = groups_get_group( $group->id );
     180
     181        $a = bp_activity_get( array(
     182            'component' => buddypress()->groups->id,
     183            'action' => 'group_details_updated',
     184            'item_id' => $group->id,
     185        ) );
     186
     187        $this->assertNotEmpty( $a['activities'] );
     188
     189        $expected = sprintf( __( '%s changed the permalink of the group %s.', 'buddypress' ), bp_core_get_userlink( $u ),  '<a href="' . bp_get_group_permalink( $new_group_details ) . '">' . $group->name . '</a>' );
     190        $this->assertSame( $expected, $a['activities'][0]->action );
     191
     192        $this->set_current_user( $old_user );
     193    }
     194
     195    /**
     196     * @group activity_action
     197     * @group bp_groups_format_activity_action_group_details_updated
     198     */
    166199    public function test_bp_groups_format_activity_action_group_details_updated_with_updated_name_and_description() {
    167200        $old_user = get_current_user_id();
Note: See TracChangeset for help on using the changeset viewer.