Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/25/2018 05:08:27 PM (7 years ago)
Author:
r-a-y
Message:

Groups: Ensure 'last_activity' meta is updated when the Activity component is disabled.

In r11924, the bp-groups-activity.php file is loaded only if the Activity
component is disabled.

However, the groups_update_last_activity() function was in this file.
This function is needed to set the last_activity group meta entry. To
ensure the last_activity group meta entry is always updated, this commit
moves the groups_update_last_activity() function over to
bp-groups-functions.php.

Anti-props r-a-y.

See #7870 (trunk).

File:
1 edited

Legend:

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

    r11922 r12124  
    604604    return true;
    605605}
     606
     607/**
     608 * Update the last_activity meta value for a given group.
     609 *
     610 * @since 1.0.0
     611 *
     612 * @param int $group_id Optional. The ID of the group whose last_activity is
     613 *                      being updated. Default: the current group's ID.
     614 * @return false|null False on failure.
     615 */
     616function groups_update_last_activity( $group_id = 0 ) {
     617
     618    if ( empty( $group_id ) ) {
     619        $group_id = buddypress()->groups->current_group->id;
     620    }
     621
     622    if ( empty( $group_id ) ) {
     623        return false;
     624    }
     625
     626    groups_update_groupmeta( $group_id, 'last_activity', bp_core_current_time() );
     627}
     628add_action( 'groups_join_group',           'groups_update_last_activity' );
     629add_action( 'groups_leave_group',          'groups_update_last_activity' );
     630add_action( 'groups_created_group',        'groups_update_last_activity' );
    606631
    607632/** General Group Functions ***************************************************/
Note: See TracChangeset for help on using the changeset viewer.