Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROD-8364] Activity Filter & Sorting #4577

Open
wants to merge 77 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
636f932
[PROD-8364] Update Activity filter position
amincdev Dec 9, 2024
5d2766c
[PROD-8364] Update search filter structure
amincdev Dec 9, 2024
c82afb9
[PROD-8364] Style search filter button
amincdev Dec 9, 2024
72cf8a3
[PROD-8364] Toggle activity filter on click
amincdev Dec 9, 2024
9f1bec9
[PROD-8364] Update filter show/hide logic
amincdev Dec 9, 2024
8c03f34
[PROD-8364] Update classes for re-use
amincdev Dec 9, 2024
77d83a5
[PROD-8364] Add new filters static structure
amincdev Dec 9, 2024
e6d8531
[PROD-8364] Style Activity filter search input
amincdev Dec 10, 2024
d162e35
[PROD-8364] Style new Activity filters dropdown
amincdev Dec 10, 2024
c1fb9f3
[PROD-8364] Filter activity on new selections
amincdev Dec 10, 2024
501e4e8
[PROD-8364] Make changes to activity filters for accessibility
amincdev Dec 10, 2024
7516480
PROD-8364 Initial implementation for the activity filters and sorting…
bb-yudhisthir Dec 18, 2024
91b26cb
[PROD-8364] Make Activity Filter sorting options drag-able
amincdev Dec 19, 2024
9f72a2d
[PROD-8364] Update class
amincdev Dec 19, 2024
bc08d24
PROD-8364 update default keys and scope
bb-yudhisthir Dec 19, 2024
81f6dcf
[PROD-8364] Make changes to re-use function
amincdev Dec 19, 2024
ff10be9
Merge branch 'PROD-8364' of https://github.com/buddyboss/buddyboss-pl…
amincdev Dec 19, 2024
4c615b3
[PROD-8364] Make activity filtering options drag-able
amincdev Dec 19, 2024
b254c5a
PROD-8364 Logic updates for the filter and sorting option
bb-yudhisthir Dec 19, 2024
6b9d80e
[PROD-8364] Implement loader for activities filters
amincdev Dec 20, 2024
0752c9e
PROD-8364 Add comment sorting setting and update logic
bb-yudhisthir Dec 20, 2024
2031b7f
PROD-8364 Update for the new date column and activity sorting
bb-yudhisthir Dec 23, 2024
841442a
PROD-8364 Update logic for sorted labels
bb-yudhisthir Dec 23, 2024
8361ef0
PROD-8364 Activity search setting
bb-yudhisthir Dec 23, 2024
0cddb7b
PROD-8364 Update migration and default filter value
bb-yudhisthir Dec 24, 2024
5127262
PROD-8364 code refactor
bb-yudhisthir Dec 24, 2024
b9b5ac9
PROD-8364 condition update
bb-yudhisthir Dec 24, 2024
ad74b1e
PROD-8364 Update logic
bb-yudhisthir Dec 24, 2024
50ce846
Merge branch 'release' into PROD-8364
bb-yudhisthir Dec 24, 2024
86c360e
PROD-8364 update keys
bb-yudhisthir Dec 24, 2024
f61b1b0
[PROD-8364] Plug in new parameters to filter activity
amincdev Dec 24, 2024
def39af
[PROD-8364] Load new activity filters on main activity feed
amincdev Dec 24, 2024
dfa5a4c
[PROD-8364] Change order key to order_by for new activity filter
amincdev Dec 24, 2024
84e38c3
PROD-8364 Update date_updated on reactions
bb-yudhisthir Dec 24, 2024
4bf427d
[PROD-8364] On load sync Activity filter options label with storage key
amincdev Dec 25, 2024
9ae189f
[PROD-8364] Make Activity filters layout change for small screens
amincdev Dec 25, 2024
20784d8
[PROD-8364] Close search input only if it's empty
amincdev Dec 26, 2024
96da283
[PROD-8364] Update activity search form UI
amincdev Dec 26, 2024
2bd9564
[PROD-8364] Show loader in activity search input while loading
amincdev Dec 26, 2024
c6df84a
[PROD-8364] Remove Activity search input from screen when reset
amincdev Dec 26, 2024
8c2fa44
PROD-8364 Update logic for just-me scope from the activity directory
bb-yudhisthir Dec 26, 2024
41cd4d4
PROD-8364 Updates with the heartbeat
bb-yudhisthir Dec 30, 2024
6d1254f
PROD-8364 Update for default sorting option
bb-yudhisthir Dec 30, 2024
db7a87c
[PROD-8364] Wrap activity filters
amincdev Dec 30, 2024
35bf625
[PROD-8364] Style activity filter head and remove directory filter
amincdev Dec 30, 2024
f8e6b2d
PROD-8364 Update the logic for default filter and sorting item
bb-yudhisthir Dec 30, 2024
e82aa2e
PROD-8364 Update for the schedule activity
bb-yudhisthir Dec 31, 2024
d41d0f3
[PROD-8364] Select first filter by default and save if user selects a…
amincdev Dec 31, 2024
b287fa4
PROD-8364 update for edit activity and blog post
bb-yudhisthir Dec 31, 2024
831b8c7
[PROD-8364] Do not close activity search input form when other filter…
amincdev Dec 31, 2024
be8819d
[PROD-8364] Update activity filters loader position
amincdev Dec 31, 2024
c998f9b
[PROD-8364] Do not show Activity filter loader when searching with query
amincdev Dec 31, 2024
36939db
PROD-8364 Update for the blog post activity comments and schedule posts
bb-yudhisthir Dec 31, 2024
9b9cede
[PROD-8364] Fix directory page search form UI issue
amincdev Dec 31, 2024
e451318
[PROD-8364] Made changes to activity filters UI for mobile screen
amincdev Dec 31, 2024
c30028d
PROD-8364 keep default enabled the most recent option
bb-yudhisthir Dec 31, 2024
9f59a4f
PROD-8364 remove comment sorting settings and add settings to telemetry
bb-yudhisthir Jan 1, 2025
d0e2477
PROD-8364 logic update for multiple media, document and video activities
bb-yudhisthir Jan 1, 2025
d1a65d9
PROD-8364 Update logic for media activities
bb-yudhisthir Jan 1, 2025
7a07df4
PROD-8364 update logic for all types of medias within group activities
bb-yudhisthir Jan 1, 2025
95bb93a
PROD-8364 Update comments
bb-yudhisthir Jan 1, 2025
e1b5609
[PROD-8364] Add sorting option in group activity feed
amincdev Jan 2, 2025
1895c85
PROD-8364 Logic update for media activity
bb-yudhisthir Jan 2, 2025
b98602c
PROD-8364 Rename function
bb-yudhisthir Jan 2, 2025
ab2091c
PROD-8364 Updated condition to get parent activity object
bb-yudhisthir Jan 2, 2025
42c78cc
PROD-8364 heartbeat support for group activity page sorting
bb-yudhisthir Jan 2, 2025
ffd2cd5
[PROD-8364] Show loader in group activity search input
amincdev Jan 2, 2025
60e5c8d
PROD-8364 Remove comment sorting setting
bb-yudhisthir Jan 3, 2025
b668251
[PROD-8364] Hide input on clear activity search
amincdev Jan 3, 2025
be5aade
[PROD-8364] Show search loader on group activity page
amincdev Jan 3, 2025
7654663
[PROD-8364] Show loader and update logic to make it working on group …
amincdev Jan 7, 2025
cb471ec
[PROD-8364] Make group activity search collapsible
amincdev Jan 8, 2025
5321665
[PROD-8364] Activity filter line-height adjusted
amincdev Jan 8, 2025
755310b
PROD-8364 Timeline filters settings
bb-yudhisthir Jan 8, 2025
1bed834
[PROD-8364] Fix Activity filter styling on user timeline
amincdev Jan 8, 2025
85b4582
PROD-8364 Add search to timeline
bb-yudhisthir Jan 8, 2025
e7084e1
PROD-8364 phpcs
bb-yudhisthir Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions src/bp-activity/bp-activity-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@

add_filter( 'bp_ajax_querystring', 'bb_activity_directory_set_pagination', 20, 2 );

// Update activity date_update when any reaction.
add_filter( 'bp_activity_add_user_favorite', 'bb_activity_update_date_updated_on_reactions', 10, 2 );
add_filter( 'bp_activity_remove_user_favorite', 'bb_activity_update_date_updated_on_reactions', 10, 2 );

/** Functions *****************************************************************/

/**
Expand Down Expand Up @@ -3795,3 +3799,82 @@ function bb_activity_directory_set_pagination( $querystring, $object ) {

return http_build_query( $querystring );
}

/**
* Update date_updated on reactions.
*
* @since BuddyBoss [BBVERSION]
*
* @param int $activity_id ID of the activity item being favorited.
* @param int $user_id ID of the user doing the favoriting.
*
* @return void
*/
function bb_activity_update_date_updated_on_reactions( $activity_id, $user_id ) {
$time = bp_core_current_time();

$activity = new BP_Activity_Activity( $activity_id );
if ( 'activity_comment' === $activity->type || in_array( $activity->privacy, array( 'media', 'document', 'video' ), true ) ) {

// Check if the item_id and secondary_item_id are same.
if ( $activity->item_id === $activity->secondary_item_id && ! in_array( $activity->privacy, array( 'media', 'document', 'video' ), true ) ) {

// Update the date_updated of the parent activity item.
bb_activity_update_date_updated( $activity->item_id, $time );

// Clear the cache for the parent activity item.
bp_activity_clear_cache_for_activity( $activity );
} else {
// Get the parent activity id if the activity is a comment or the sub media, document, video activity.
$main_activity_object = bb_activity_get_comment_parent_activity_object( $activity );

// Update the date_updated of the parent activity item.
bb_activity_update_date_updated( $main_activity_object->id, $time );

// Clear the cache for the parent activity item.
bp_activity_clear_cache_for_activity( $main_activity_object );

// If individual medias activity then also get the most parent activity.
if (
(
(
in_array( $main_activity_object->privacy, array( 'media', 'document', 'video' ), true ) &&
'activity_update' === $main_activity_object->type
)
) && ! empty( $main_activity_object->secondary_item_id )
) {

// Update the date_updated of the parent activity item.
bb_activity_update_date_updated( $main_activity_object->secondary_item_id, $this->date_updated );

$intermediate_activity = new BP_Activity_Activity( $main_activity_object->secondary_item_id );
if ( ! empty( $intermediate_activity->id ) ) {

// Clear the cache for the parent activity item.
bp_activity_clear_cache_for_activity( $intermediate_activity );
unset( $intermediate_activity );
}
}

// Get the parent comment activity object.
$parent_comment_activity_object = bb_activity_get_comment_parent_comment_activity_object( $activity, $main_activity_object->id );

// Update the date_updated of the parent comment activity item.
bb_activity_update_date_updated( $parent_comment_activity_object->id, $time );

// Clear the cache for the parent activity item.
bp_activity_clear_cache_for_activity( $parent_comment_activity_object );

}
}

// Update the date_updated of the activity item.
bb_activity_update_date_updated( $activity_id, $time );

// Clear the cache for the activity item.
bp_activity_clear_cache_for_activity( $activity );

if ( class_exists( 'BuddyBoss\Performance\Cache' ) ) {
BuddyBoss\Performance\Cache::instance()->purge_by_component( 'bp_activity' );
}
}
95 changes: 94 additions & 1 deletion src/bp-activity/bp-activity-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2102,6 +2102,7 @@ function bp_activity_add( $args = '' ) {
'item_id' => false, // Optional: The ID of the specific item being recorded, e.g. a blog_id.
'secondary_item_id' => false, // Optional: A second ID used to further filter e.g. a comment_id.
'recorded_time' => bp_core_current_time(), // The GMT time that this activity was recorded.
'updated_time' => bp_core_current_time(), // The GMT time that this activity was recorded.
'hide_sitewide' => false, // Should this be hidden on the sitewide activity feed?
'is_spam' => false, // Is this activity item to be marked as spam?
'privacy' => 'public', // privacy of the activity.
Expand Down Expand Up @@ -2130,6 +2131,7 @@ function bp_activity_add( $args = '' ) {
$activity->item_id = $r['item_id'];
$activity->secondary_item_id = $r['secondary_item_id'];
$activity->date_recorded = ( empty( $r['id'] ) || $r['status'] === bb_get_activity_scheduled_status() || ( bb_get_activity_scheduled_status() === $activity->status && $r['status'] === bb_get_activity_published_status() ) ) && $r['recorded_time'] ? $r['recorded_time'] : $activity->date_recorded;
$activity->date_updated = ( empty( $r['id'] ) || $r['status'] === bb_get_activity_scheduled_status() || ( bb_get_activity_scheduled_status() === $activity->status && $r['status'] === bb_get_activity_published_status() ) ) && $r['recorded_time'] ? $r['recorded_time'] : ( $r['updated_time'] ? $r['updated_time'] : bp_core_current_time() );
$activity->hide_sitewide = $r['hide_sitewide'];
$activity->is_spam = $r['is_spam'];
$activity->privacy = $r['privacy'];
Expand Down Expand Up @@ -2223,6 +2225,7 @@ function bp_activity_post_update( $args = '' ) {
'privacy' => 'public',
'status' => bb_get_activity_published_status(),
'recorded_time' => bp_core_current_time(),
'updated_time' => bp_core_current_time(),
'error_type' => 'bool',
)
);
Expand Down Expand Up @@ -2296,6 +2299,7 @@ function bp_activity_post_update( $args = '' ) {
'item_id' => $activity->item_id,
'secondary_item_id' => $activity->secondary_item_id,
'recorded_time' => ! empty( $r['recorded_time'] ) ? $r['recorded_time'] : $activity->date_recorded,
'updated_time' => ! empty( $r['updated_time'] ) ? $r['updated_time'] : bp_core_current_time(),
'hide_sitewide' => $activity->hide_sitewide,
'is_spam' => $activity->is_spam,
'privacy' => $r['privacy'],
Expand Down Expand Up @@ -2326,6 +2330,7 @@ function bp_activity_post_update( $args = '' ) {
'hide_sitewide' => $r['hide_sitewide'],
'privacy' => $r['privacy'],
'recorded_time' => $r['recorded_time'],
'updated_time' => $r['updated_time'],
'status' => $r['status'],
'error_type' => $r['error_type'],
)
Expand Down Expand Up @@ -2560,6 +2565,8 @@ function bp_activity_post_type_update( $post = null ) {
} else {
$activity->content = $activity_summary;
}

$activity->date_updated = bp_core_current_time();
}

// Save the updated activity.
Expand Down Expand Up @@ -3205,6 +3212,7 @@ function bp_activity_get_activity_id( $args = '' ) {
'action' => false,
'content' => false,
'date_recorded' => false,
'date_updated' => false,
)
);

Expand All @@ -3228,7 +3236,8 @@ function bp_activity_get_activity_id( $args = '' ) {
$r['secondary_item_id'],
$r['action'],
$r['content'],
$r['date_recorded']
$r['date_recorded'],
$r['date_updated']
),
$r,
$args
Expand Down Expand Up @@ -3275,6 +3284,7 @@ function bp_activity_delete( $args = '' ) {
'item_id' => false,
'secondary_item_id' => false,
'date_recorded' => false,
'date_updated' => false,
'hide_sitewide' => false,
)
);
Expand Down Expand Up @@ -5549,6 +5559,7 @@ function bp_activity_get_edit_data( $activity_id = 0 ) {
'group_avatar' => $group_avatar,
'link_image_index_save' => $link_image_index_save,
'date_recorded' => $activity->date_recorded,
'date_updated' => $activity->date_updated,
'status' => $activity->status,
);

Expand Down Expand Up @@ -7398,6 +7409,88 @@ function_exists( 'bb_document_get_published_status' ) &&
}
}

/**
* Update the date_updated of an activity item.
*
* @since BuddyBoss [BBVERSION]
*
* @param int $activity_id Activity ID.
* @param string $time Time to update.
*
* @return bool True on success.
*/
function bb_activity_update_date_updated( $activity_id, $time ) {
global $wpdb;

$bp = buddypress();

$q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET date_updated = %s WHERE id = %d", $time, $activity_id ); // phpcs:ignore

if ( false === $wpdb->query( $q ) ) { // phpcs:ignore
return false;
}

return true;
}

/**
* Get parent activity id of the activity item.
*
* @since BuddyBoss [BBVERSION]
*
* @param object $activity Activity object.
*
* @return object Activity object.
*/
function bb_activity_get_comment_parent_activity_object( $activity ) {

$is_media = in_array( $activity->privacy, array( 'media', 'document', 'video' ), true );

// Loop through find the parent id until the item_id and secondary_item_id are same.
while (
$activity->item_id !== $activity->secondary_item_id &&
(
// Get medias individual activity if muliple uploaded.
( $is_media && 'groups' !== $activity->component ) ||
( ! $is_media && 'activity_comment' === $activity->type )
)
) {
$temp_activity = new BP_Activity_Activity( $activity->item_id );
if ( empty( $temp_activity->id ) ) {
unset( $temp_activity );
return $activity;
}
$activity = $temp_activity;
}

return $activity;
}

/**
* Get top level parent comment id of the activity item.
*
* @since BuddyBoss [BBVERSION]
*
* @param object $activity Activity object.
* @param int $main_activity_id Main activity ID.
*
* @return object Activity object.
*/
function bb_activity_get_comment_parent_comment_activity_object( $activity, $main_activity_id ) {

// Loop through find the id based on the secondary_item_id and having a type is activity_comment and item_id and secondary_item_id equal to $main_activity_id.
while ( $activity->secondary_item_id !== $main_activity_id || 'activity_comment' !== $activity->type ) {
$temp_activity = new BP_Activity_Activity( $activity->secondary_item_id );
if ( empty( $temp_activity->id ) ) {
unset( $temp_activity );
return $activity;
}
$activity = $temp_activity;
}

return $activity;
}

/**
* If a blog component is disabled, then display activity action for existing blog activity.
*
Expand Down
48 changes: 47 additions & 1 deletion src/bp-activity/bp-activity-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,22 @@ function bp_has_activities( $args = '' ) {
'since' => $r['since'],
);
} else {
$r['filter'] = false;

if ( 'just-me' === $scope && bp_is_activity_directory() ) {
$scope = 'just-me';
$r['user_id'] = bp_loggedin_user_id();
$r['filter'] = array(
'user_id' => $r['user_id'],
'object' => $r['object'],
'action' => $r['action'],
'primary_id' => $r['primary_id'],
'secondary_id' => $r['secondary_id'],
'offset' => $r['offset'],
'since' => $r['since'],
);
} else {
$r['filter'] = false;
}
}

// If specific activity items have been requested, override the $hide_spam
Expand Down Expand Up @@ -774,6 +789,15 @@ function bp_activity_date_recorded() {
echo bp_get_activity_date_recorded();
}

/**
* Output the date the activity was updated.
*
* @since BuddyBoss [BBVERSION]
*/
function bb_activity_date_updated() {
echo bb_get_activity_date_updated();
}

/**
* Return the date the activity was recorded.
*
Expand All @@ -796,6 +820,28 @@ function bp_get_activity_date_recorded() {
return apply_filters( 'bp_get_activity_date_recorded', $activities_template->activity->date_recorded );
}

/**
* Return the date the activity was updated.
*
* @since BuddyBoss [BBVERSION]
*
* @global object $activities_template {@link BP_Activity_Template}
*
* @return string The date the activity was updated.
*/
function bb_get_activity_date_updated() {
global $activities_template;

/**
* Filters the date the activity was updated.
*
* @since BuddyBoss [BBVERSION]
*
* @param int $date_updated The activity's date.
*/
return apply_filters( 'bb_get_activity_date_updated', $activities_template->activity->date_updated );
}

/**
* Output the display name of the member who posted the activity.
*
Expand Down
Loading
Loading