Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/30/2025 03:38:29 PM (2 weeks ago)
Author:
espellcaste
Message:

Misc changes to the BuddyPress Groups Activity Functions.

See #9305
See #9173

File:
1 edited

Legend:

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

    r14077 r14186  
    1818 *
    1919 * @since 1.1.0
    20  *
    21  * @return false|null False on failure.
    2220 */
    2321function groups_register_activity_actions() {
     22
     23    if ( ! bp_is_active( 'activity' ) ) {
     24        return;
     25    }
     26
    2427    $bp = buddypress();
    25 
    26     if ( ! bp_is_active( 'activity' ) ) {
    27         return false;
    28     }
    2928
    3029    bp_activity_set_action(
     
    104103 */
    105104function bp_groups_format_activity_action_created_group( $action, $activity ) {
    106     $user_link = bp_core_get_userlink( $activity->user_id );
    107 
     105    $user_link  = bp_core_get_userlink( $activity->user_id );
    108106    $group      = bp_groups_get_activity_group( $activity->item_id );
    109107    $group_link = '<a href="' . esc_url( bp_get_group_url( $group ) ) . '">' . esc_html( $group->name ) . '</a>';
     
    133131 */
    134132function bp_groups_format_activity_action_joined_group( $action, $activity ) {
    135     $user_link = bp_core_get_userlink( $activity->user_id );
    136 
     133    $user_link  = bp_core_get_userlink( $activity->user_id );
    137134    $group      = bp_groups_get_activity_group( $activity->item_id );
    138135    $group_link = '<a href="' . esc_url( bp_get_group_url( $group ) ) . '">' . esc_html( $group->name ) . '</a>';
     
    173170 */
    174171function bp_groups_format_activity_action_group_details_updated( $action, $activity ) {
    175     $user_link = bp_core_get_userlink( $activity->user_id );
    176 
     172    $user_link  = bp_core_get_userlink( $activity->user_id );
    177173    $group      = bp_groups_get_activity_group( $activity->item_id );
    178174    $group_link = '<a href="' . esc_url( bp_get_group_url( $group ) ) . '">' . esc_html( $group->name ) . '</a>';
     
    346342    }
    347343
    348     $retval = array(
     344    return array(
    349345        'relation' => 'AND',
    350346        array(
     
    368364        ),
    369365    );
    370 
    371     return $retval;
    372366}
    373367add_filter( 'bp_activity_set_groups_scope_args', 'bp_groups_filter_activity_scope', 10, 2 );
     
    407401    );
    408402
    409     $retval = array(
     403    return array(
    410404        'relation' => 'OR',
    411405
     
    481475        ),
    482476    );
    483 
    484     return $retval;
    485477}
    486478add_filter( 'bp_activity_set_favorites_scope_args', 'bp_groups_filter_activity_favorites_scope', 20, 2 );
     
    646638 * @since 6.0.0
    647639 *
    648  * @param  bool   $retval   True if item can receive comments.
    649  * @param  object $activity Activity item being checked.
     640 * @param bool   $retval   True if item can receive comments.
     641 * @param object $activity Activity item being checked.
    650642 * @return bool
    651643 */
     
    684676 * @since 3.0.0
    685677 *
    686  * @param  bool                      $retval   True if item can receive comments.
    687  * @param  null|BP_Activity_Activity $activity Null by default. Pass an activity object to check against that instead.
     678 * @param bool                      $retval   True if item can receive comments.
     679 * @param null|BP_Activity_Activity $activity Null by default. Pass an activity object to check against that instead.
    688680 * @return bool
    689681 */
     
    719711    return $retval;
    720712}
    721 add_filter( 'bp_activity_can_comment', 'bp_groups_filter_activity_can_comment', 99, 1 );
     713add_filter( 'bp_activity_can_comment', 'bp_groups_filter_activity_can_comment', 99 );
    722714
    723715/**
     
    728720 * @since 3.0.0
    729721 *
    730  * @param  bool        $retval  True if activity comment can be replied to.
    731  * @param  object|bool $comment Current activity comment object. If empty, parameter is boolean false.
     722 * @param bool        $retval  True if activity comment can be replied to.
     723 * @param object|bool $comment Current activity comment object. If empty, parameter is boolean false.
    732724 * @return bool
    733725 */
     
    753745 * @param int $user_id  ID of the user joining the group.
    754746 * @param int $group_id ID of the group.
    755  * @return false|null False on failure.
    756747 */
    757748function bp_groups_membership_accepted_add_activity( $user_id, $group_id ) {
     
    759750    // Bail if Activity is not active.
    760751    if ( ! bp_is_active( 'activity' ) ) {
    761         return false;
    762     }
    763 
    764     // Get the group so we can get it's name.
     752        return;
     753    }
     754
     755    // Get the group so we can get its name.
    765756    $group = groups_get_group( $group_id );
    766757
     
    791782 * @since 2.2.0
    792783 *
    793  * @param  int             $group_id       ID of the group.
    794  * @param  BP_Groups_Group $old_group      Group object before the details had been changed.
    795  * @param  bool            $notify_members True if the admin has opted to notify group members, otherwise false.
    796  * @return null|WP_Error|bool|int The ID of the activity on success. False on error.
     784 * @param int             $group_id       ID of the group.
     785 * @param BP_Groups_Group $old_group      Group object before the details had been changed.
     786 * @param bool            $notify_members True if the admin has opted to notify group members, otherwise false.
    797787 */
    798788function bp_groups_group_details_updated_add_activity( $group_id, $old_group, $notify_members ) {
     
    800790    // Bail if Activity is not active.
    801791    if ( ! bp_is_active( 'activity' ) ) {
    802         return false;
     792        return;
    803793    }
    804794
    805795    if ( ! isset( $old_group->name ) || ! isset( $old_group->slug ) || ! isset( $old_group->description ) ) {
    806         return false;
     796        return;
    807797    }
    808798
     
    812802    }
    813803
    814     $group = groups_get_group( array(
    815         'group_id' => $group_id,
    816     ) );
     804    $group = groups_get_group( $group_id );
    817805
    818806    /*
     
    851839
    852840    $time = bp_core_current_time();
     841
    853842    groups_update_groupmeta( $group_id, 'updated_details_' . $time, $changed );
    854843
    855844    // Record in activity streams.
    856     return groups_record_activity( array(
     845    groups_record_activity( array(
    857846        'type'          => 'group_details_updated',
    858847        'item_id'       => $group_id,
     
    861850
    862851    ) );
    863 
    864852}
    865853add_action( 'groups_details_updated', 'bp_groups_group_details_updated_add_activity', 10, 3 );
     
    880868    }
    881869}
    882 add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_activity', 10 );
     870add_action( 'groups_delete_group', 'bp_groups_delete_group_delete_all_activity' );
    883871
    884872/**
Note: See TracChangeset for help on using the changeset viewer.