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

Revert "Revert "PROD-6979 : Schedule Posts Frontend"" #4399

Merged
merged 29 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2235839
Revert "Revert "PROD-6979 : Schedule Posts Frontend""
KartikSuthar May 6, 2024
3084e65
[REVERT-4398] Move Schedule post styling
amincdev May 6, 2024
71ae80e
[REVERT-4398] Move schedule post views
amincdev May 7, 2024
daeaf6f
[REVERT-4398] PROD-6979 Updates related to migration to platform pro
bb-yudhisthir May 7, 2024
9a5f1ff
[REVERT-4398] Remove open schedule posts list modal event
amincdev May 7, 2024
dba167e
[REVERT-4398] PROD-6979 migrate to platform pro
bb-yudhisthir May 8, 2024
3e33379
[REVERT-4398] Fix Check view before adding it to post form
amincdev May 8, 2024
eb22bcf
[REVERT-4398] PROD-6979 Migrate schedule posts templates to platform pro
bb-yudhisthir May 8, 2024
92fe3b8
[REVERT-4398] Move localized string variables
amincdev May 8, 2024
a9c5638
[REVERT-4398] Move schedule post related events
amincdev May 8, 2024
0e2ae5a
[REVERT-4398] PROD-6979 Platform pro validation
bb-yudhisthir May 9, 2024
ad3a1f4
[REVERT-4398] PROD-6979 Update platform pro validation
bb-yudhisthir May 9, 2024
3b23778
[REVERT-4398] PROD-6979 Update version number
bb-yudhisthir May 9, 2024
ab741cf
[REVERT-4398] PROD-6979 - Remove schedule posts related code from pla…
jitendrabanjara1991 May 9, 2024
d826078
[REVERT-4398] PROD-6979 - Remove unwanted code
jitendrabanjara1991 May 9, 2024
330ba3e
[REVERT-4398] PROD-6979 - Move some code from platform to platform pr…
jitendrabanjara1991 May 9, 2024
6e43584
[REVERT-4398] PROD-6979 Rename template name
bb-yudhisthir May 10, 2024
607f317
[REVERT-4398] Add check if schedule post is active before applying ac…
amincdev May 10, 2024
36e04da
[REVERT-4398] Update strings
amincdev May 10, 2024
c5cd205
[REVERT-4398] Update strings check
amincdev May 10, 2024
fc6a5cd
[REVERT-4398] fixed phpcbf
jitendrabanjara1991 May 10, 2024
c83e986
[REVERT-4398] PROD-6979 Update media status on clear schedule
bb-yudhisthir May 13, 2024
598cd8c
[REVERT-4398] PROD-6979 Update media, video, document status on clear…
bb-yudhisthir May 13, 2024
ed728a9
[REVERT-4398] PROD-6979 Migrate template loop code to platform pro
bb-yudhisthir May 13, 2024
a6bc0e4
[REVERT-4398] Merge branch 'release' into revert-4398-revert-4311-PRO…
KartikSuthar May 14, 2024
9deb499
[REVERT-4398] PROD-6979 add migration for adding status column
bb-yudhisthir May 14, 2024
b7c4cb6
[REVERT-4398] PROD-6979 Code refactor
bb-yudhisthir May 14, 2024
f9191c6
[REVERT-4398] PROD-6979 Code refactor
bb-yudhisthir May 14, 2024
7f1cbaf
[REVERT-4398] PROD-6753 - phpcbf fixes
KartikSuthar May 15, 2024
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
3 changes: 3 additions & 0 deletions src/bp-activity/bp-activity-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function bp_activity_clear_cache_for_activity( $activity ) {
wp_cache_delete( 'bp_video_activity_id_' . $activity->id, 'bp_video' ); // Used in get_activity_video_id().
wp_cache_delete( 'bp_video_attachment_id_' . $activity->id, 'bp_video' ); // Used in get_activity_attachment_id().
wp_cache_delete( $activity->id, 'activity_edit_data' );
wp_cache_delete( 'bb_get_activity_status_' . $activity->id, 'bp_activity' );

if ( ! empty( $activity->secondary_item_id ) ) {
wp_cache_delete( 'bp_get_child_comments_' . $activity->secondary_item_id, 'bp_activity_comments' ); // Used in BP_Activity_Activity::get_child_comments().
Expand All @@ -79,6 +80,7 @@ function bp_activity_clear_cache_for_deleted_activity( $deleted_ids ) {
wp_cache_delete( 'bp_video_activity_id_' . $deleted_id, 'bp_video' ); // Used in get_activity_video_id().
wp_cache_delete( 'bp_video_attachment_id_' . $deleted_id, 'bp_video' ); // Used in get_activity_attachment_id().
wp_cache_delete( $deleted_id, 'activity_edit_data' );
wp_cache_delete( 'bb_get_activity_status_' . $deleted_id, 'bp_activity' );
}
}
add_action( 'bp_activity_deleted_activities', 'bp_activity_clear_cache_for_deleted_activity' );
Expand All @@ -102,6 +104,7 @@ function bb_activity_clear_cache_after_deleted_activity( $activities ) {
wp_cache_delete( 'bp_video_activity_id_' . $activity->id, 'bp_video' ); // Used in get_activity_video_id().
wp_cache_delete( 'bp_video_attachment_id_' . $activity->id, 'bp_video' ); // Used in get_activity_attachment_id().
wp_cache_delete( $activity->id, 'activity_edit_data' );
wp_cache_delete( 'bb_get_activity_status_' . $activity->id, 'bp_activity' );
if ( ! empty( $activity->secondary_item_id ) ) {
wp_cache_delete( 'bp_get_child_comments_' . $activity->secondary_item_id, 'bp_activity_comments' ); // Used in BP_Activity_Activity::get_child_comments().
wp_cache_delete( $activity->secondary_item_id, 'bp_activity' );
Expand Down
33 changes: 31 additions & 2 deletions src/bp-activity/bp-activity-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ function bp_activity_at_name_send_emails( $activity ) {
return;
}

// Avoid sending notification if the activity is not published.
if ( bb_get_activity_published_status() !== $activity->status ) {
return;
}

// If our temporary variable doesn't exist, stop now.
if ( empty( buddypress()->activity->mentioned_users ) ) {
return;
Expand Down Expand Up @@ -1908,6 +1913,9 @@ function bp_activity_media_add( $media ) {

if ( $activity_id ) {

// Support for schedule activity medias only on activity.
$media->status = 'comment' !== $media->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? bb_media_get_scheduled_status() : bb_media_get_published_status();

// save media activity id in media.
$media->activity_id = $activity_id;
$media->save();
Expand All @@ -1925,6 +1933,7 @@ function bp_activity_media_add( $media ) {
if ( empty( $bp_new_activity_comment ) ) {
$media_activity = new BP_Activity_Activity( $activity_id );
$media_activity->secondary_item_id = $parent_activity_id;
$media_activity->status = 'comment' !== $media_activity->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? $_POST['activity_action_type'] : bb_get_activity_published_status();
$media_activity->save();
}

Expand All @@ -1944,6 +1953,9 @@ function bp_activity_media_add( $media ) {

// save media activity id in media.
$media->activity_id = $parent_activity_id;

// Support for schedule activity medias only on activity.
$media->status = 'comment' !== $media->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? bb_media_get_scheduled_status() : bb_media_get_published_status();
$media->save();

// save parent activity id in attachment meta.
Expand Down Expand Up @@ -1971,7 +1983,6 @@ function bp_activity_create_parent_media_activity( $media_ids ) {
}

if ( ! empty( $media_ids ) && empty( $bp_activity_post_update ) && ! isset( $_POST['edit'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing

$added_media_ids = $media_ids;
$content = false;

Expand Down Expand Up @@ -2125,6 +2136,7 @@ function bp_activity_edit_update_media( $media_ids ) {

$media_activity = new BP_Activity_Activity( $activity_id );
$media_activity->secondary_item_id = $bp_activity_post_update_id;
$media_activity->status = 'comment' !== $media_activity->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? $_POST['activity_action_type'] : bb_get_activity_published_status();
$media_activity->save();

// update activity meta to tell it is media activity.
Expand Down Expand Up @@ -2316,6 +2328,9 @@ function bp_activity_document_add( $document ) {

if ( $activity_id ) {

// Support for schedule activity documents only on activity.
$document->status = 'comment' !== $document->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? bb_document_get_scheduled_status() : bb_document_get_published_status();

// save document activity id in document.
$document->activity_id = $activity_id;
$document->save();
Expand All @@ -2333,6 +2348,7 @@ function bp_activity_document_add( $document ) {
if ( empty( $bp_new_activity_comment ) ) {
$document_activity = new BP_Activity_Activity( $activity_id );
$document_activity->secondary_item_id = $parent_activity_id;
$document_activity->status = 'comment' !== $document_activity->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? $_POST['activity_action_type'] : bb_get_activity_published_status();
$document_activity->save();
}

Expand All @@ -2352,6 +2368,9 @@ function bp_activity_document_add( $document ) {

// save document activity id in document.
$document->activity_id = $parent_activity_id;

// Support for schedule activity documents only on activity.
$document->status = 'comment' !== $document->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? bb_document_get_scheduled_status() : bb_document_get_published_status();
$document->save();

// save parent activity id in attachment meta.
Expand Down Expand Up @@ -2533,6 +2552,7 @@ function bp_activity_edit_update_document( $document_ids ) {

$document_activity = new BP_Activity_Activity( $activity_id );
$document_activity->secondary_item_id = $bp_activity_post_update_id;
$document_activity->status = 'comment' !== $document_activity->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? $_POST['activity_action_type'] : bb_get_activity_published_status();
$document_activity->save();

// update activity meta to tell it is document activity.
Expand Down Expand Up @@ -3002,6 +3022,9 @@ function bp_activity_video_add( $video ) {

if ( $activity_id ) {

// Support for schedule activity videos only on activity.
$video->status = 'comment' !== $video->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? bb_video_get_scheduled_status() : bb_video_get_published_status();

// save video activity id in video.
$video->activity_id = $activity_id;
$video->save();
Expand All @@ -3019,6 +3042,7 @@ function bp_activity_video_add( $video ) {
if ( empty( $bp_new_activity_comment ) ) {
$video_activity = new BP_Activity_Activity( $activity_id );
$video_activity->secondary_item_id = $parent_activity_id;
$video_activity->status = 'comment' !== $video_activity->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? $_POST['activity_action_type'] : bb_get_activity_published_status();
$video_activity->save();
}

Expand All @@ -3038,6 +3062,9 @@ function bp_activity_video_add( $video ) {

// save video activity id in video.
$video->activity_id = $parent_activity_id;

// Support for schedule activity videos only on activity.
$video->status = 'comment' !== $video->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? bb_video_get_scheduled_status() : bb_video_get_published_status();
$video->save();

// save parent activity id in attachment meta.
Expand Down Expand Up @@ -3220,6 +3247,7 @@ function bp_activity_edit_update_video( $video_ids ) {

$video_activity = new BP_Activity_Activity( $activity_id );
$video_activity->secondary_item_id = $bp_activity_post_update_id;
$video_activity->status = 'comment' !== $video_activity->privacy && isset( $_POST['activity_action_type'] ) && bb_get_activity_scheduled_status() === $_POST['activity_action_type'] ? $_POST['activity_action_type'] : bb_get_activity_published_status();
$video_activity->save();

// update activity meta to tell it is video activity.
Expand Down Expand Up @@ -3477,7 +3505,8 @@ function bb_activity_send_email_to_following_post( $content, $user_id, $activity
if (
empty( $activity ) ||
'activity' !== $activity->component ||
in_array( $activity->privacy, array( 'document', 'media', 'video', 'onlyme' ), true )
in_array( $activity->privacy, array( 'document', 'media', 'video', 'onlyme' ), true ) ||
bb_get_activity_published_status() !== $activity->status
) {
return;
}
Expand Down
108 changes: 85 additions & 23 deletions src/bp-activity/bp-activity-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,7 @@ function bp_activity_get( $args = '' ) {
*/
'filter' => array(),
'pin_type' => '',
'status' => bb_get_activity_published_status(),
),
'activity_get'
);
Expand Down Expand Up @@ -1949,6 +1950,7 @@ function bp_activity_get( $args = '' ) {
'count_total' => $r['count_total'],
'fields' => $r['fields'],
'pin_type' => $r['pin_type'],
'status' => $r['status'],
)
);

Expand Down Expand Up @@ -1994,6 +1996,7 @@ function bp_activity_get_specific( $args = '' ) {
'spam' => 'ham_only', // Retrieve items marked as spam.
'scope' => false, // Retrieve items marked as spam.
'update_meta_cache' => true,
'status' => bb_get_activity_published_status(),
),
'activity_get_specific'
);
Expand All @@ -2010,6 +2013,7 @@ function bp_activity_get_specific( $args = '' ) {
'spam' => $r['spam'],
'scope' => $r['scope'],
'update_meta_cache' => $r['update_meta_cache'],
'status' => $r['status'],
);

/**
Expand Down Expand Up @@ -2070,19 +2074,20 @@ function bp_activity_add( $args = '' ) {
$r = bp_parse_args(
$args,
array(
'id' => false, // Pass an existing activity ID to update an existing entry.
'action' => '', // The activity action - e.g. "Jon Doe posted an update"
'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent.
'type' => false, // The activity type e.g. activity_update, profile_updated.
'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink).
'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
'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.
'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
'id' => false, // Pass an existing activity ID to update an existing entry.
'action' => '', // The activity action - e.g. "Jon Doe posted an update"
'content' => '', // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
'component' => false, // The name/ID of the component e.g. groups, profile, mycomponent.
'type' => false, // The activity type e.g. activity_update, profile_updated.
'primary_link' => '', // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink).
'user_id' => bp_loggedin_user_id(), // Optional: The user to record the activity for, can be false if this activity is not for a user.
'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.
'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.
'status' => bb_get_activity_published_status(), // status of the activity.
'error_type' => 'bool',
),
'activity_add'
Expand All @@ -2106,11 +2111,12 @@ function bp_activity_add( $args = '' ) {
$activity->primary_link = $r['primary_link'];
$activity->item_id = $r['item_id'];
$activity->secondary_item_id = $r['secondary_item_id'];
$activity->date_recorded = empty( $r['id'] ) ? $r['recorded_time'] : $activity->date_recorded;
$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->hide_sitewide = $r['hide_sitewide'];
$activity->is_spam = $r['is_spam'];
$activity->privacy = $r['privacy'];
$activity->error_type = $r['error_type'];
$activity->status = $r['status'];
$activity->action = ! empty( $r['action'] ) ? $r['action'] : '';

$save = $activity->save();
Expand Down Expand Up @@ -2197,6 +2203,8 @@ function bp_activity_post_update( $args = '' ) {
'hide_sitewide' => false,
'type' => 'activity_update',
'privacy' => 'public',
'status' => bb_get_activity_published_status(),
'recorded_time' => bp_core_current_time(),
'error_type' => 'bool',
)
);
Expand Down Expand Up @@ -2240,7 +2248,10 @@ function bp_activity_post_update( $args = '' ) {
$activity = new BP_Activity_Activity( $r['id'] );

if ( ! empty( $activity->id ) ) {
$bp_activity_edit = true;

if ( bb_get_activity_scheduled_status() !== $activity->status ) {
$bp_activity_edit = true;
}

if ( ! bp_activity_user_can_edit( $activity ) ) {
if ( 'wp_error' === $r['error_type'] ) {
Expand All @@ -2261,19 +2272,23 @@ function bp_activity_post_update( $args = '' ) {
'user_id' => $activity->user_id,
'item_id' => $activity->item_id,
'secondary_item_id' => $activity->secondary_item_id,
'recorded_time' => $activity->date_recorded,
'recorded_time' => ! empty( $r['recorded_time'] ) ? $r['recorded_time'] : $activity->date_recorded,
'hide_sitewide' => $activity->hide_sitewide,
'is_spam' => $activity->is_spam,
'privacy' => $r['privacy'],
'status' => $r['status'],
'error_type' => $r['error_type'],
)
);

/**
* Addition from the BuddyBoss
* Add meta to ensure that this activity has been edited.
*/
bp_activity_update_meta( $activity->id, '_is_edited', bp_core_current_time() );
if ( bb_get_activity_scheduled_status() !== $activity->status ) {

/**
* Addition from the BuddyBoss
* Add meta to ensure that this activity has been edited.
*/
bp_activity_update_meta( $activity->id, '_is_edited', bp_core_current_time() );
}

}
} else {
Expand All @@ -2287,6 +2302,8 @@ function bp_activity_post_update( $args = '' ) {
'type' => $r['type'],
'hide_sitewide' => $r['hide_sitewide'],
'privacy' => $r['privacy'],
'recorded_time' => $r['recorded_time'],
'status' => $r['status'],
'error_type' => $r['error_type'],
)
);
Expand Down Expand Up @@ -4083,7 +4100,7 @@ function bp_activity_at_message_notification( $activity_id, $receiver_user_id )
$email_type = 'activity-at-message';
$group_name = '';
$message_link = bp_activity_get_permalink( $activity_id );
$poster_name = bp_core_get_user_displayname( $activity->user_id, $receiver_user_id );
$poster_name = bp_core_get_user_displayname( $activity->user_id, $receiver_user_id );

remove_filter( 'bp_get_activity_content_body', 'convert_smilies' );
remove_filter( 'bp_get_activity_content_body', 'wpautop' );
Expand Down Expand Up @@ -5457,7 +5474,6 @@ function bp_activity_get_edit_data( $activity_id = 0 ) {
if ( false === $edit_data ) {
// Get activity metas.
$activity_metas = bb_activity_get_metadata( $activity_id );

$can_edit_privacy = true;
$album_id = 0;
$folder_id = 0;
Expand Down Expand Up @@ -5508,6 +5524,8 @@ function bp_activity_get_edit_data( $activity_id = 0 ) {
'privacy' => $activity->privacy,
'group_avatar' => $group_avatar,
'link_image_index_save' => $link_image_index_save,
'date_recorded' => $activity->date_recorded,
'status' => $activity->status,
);

// Set meta data to cache.
Expand Down Expand Up @@ -7143,3 +7161,47 @@ function bb_validate_activity_privacy( $args ) {

return true;
}

/**
* Check whether activity schedule posts are enabled.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $default Optional. Fallback value if not found in the database.
* Default: false.
*
* @return bool true if activity schedule posts are enabled, otherwise false.
*/
function bb_is_enabled_activity_schedule_posts( $default = false ) {
jitendrabanjara1991 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Filters whether activity schedule posts are enabled.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $value Whether activity schedule posts are enabled.
*/
return (bool) apply_filters( 'bb_is_enabled_activity_schedule_posts', (bool) bp_get_option( '_bb_enable_activity_schedule_posts', $default ) );
}

/**
* Return the activity published status.
*
* @since BuddyBoss [BBVERSION]
*
* @return string
*/
function bb_get_activity_published_status() {
return buddypress()->activity->published_status;
}

/**
* Return the activity scheduled status.
*
* @since BuddyBoss [BBVERSION]
*
* @return string
*/
function bb_get_activity_scheduled_status() {
return buddypress()->activity->scheduled_status;
}
1 change: 1 addition & 0 deletions src/bp-activity/bp-activity-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ function bp_has_activities( $args = '' ) {
// Searching.
'search_terms' => $search_terms_default,
'update_meta_cache' => true,
'status' => bb_get_activity_published_status(),
),
'has_activities'
);
Expand Down
Loading