Skip to content

Commit

Permalink
Merge branch 'release' into PROD-7043
Browse files Browse the repository at this point in the history
* release: (40 commits)
Update: Grunt
Update: Grunt string-replace
Update: Version name update
grunt
Added change log
pulled api changes
PROD-7433 - Typo fixed
PROD-7433 - Grunt
PROD-7433 - Update schedule allowed value null to disabled. Fixed - When setting disable, In feed - select group and add content and keep data as draft. Once you open draft feed again the scheduled icon still was there.
PROD-7433 - Only validate for schedule post
PROD-7433 - Allow read more for schedule post
PROD-7433 - 	Fixed - Check for non admin member to delete scheduled post which they scheduled when they have permission to moderate.
PROD-7433 - Remove error log
PROD-7433 - Fixed - delete scheduled activity issue for group
PROD-7433 - Code refactor and run grunt
PROD-7433 - Fixed - undefined error
PROD-7433 - Fixed - validate delete schedule post for group. - Like some one has org/mode and they added schedule post but after some time they change role from org to member, not they try to delete schedule post then they not allow to delete
PROD-7433 - Fixed - Schedule button icon issue
PROD-7433 - Read more content issue
PROD-7433 - Code refactor - Allow hide/show schedule form for admin/group organiser. If loggedin with admin and setting disable then schedule icon should be visible for admin - If non admin user, setting is enable for schedule button, and in news feed page, he select some group where they have org/mode, then schedule icon should be visible
...
  • Loading branch information
jitendrabanjara1991 committed May 27, 2024
2 parents 45d09b4 + 69e3357 commit e93fadc
Show file tree
Hide file tree
Showing 17 changed files with 491 additions and 275 deletions.
2 changes: 1 addition & 1 deletion bp-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: The BuddyBoss Platform adds community features to WordPress. Member Profiles, Activity Feeds, Direct Messaging, Notifications, and more!
* Author: BuddyBoss
* Author URI: https://buddyboss.com/
* Version: 2.6.10
* Version: 2.6.11
* Text Domain: buddyboss
* Domain Path: /bp-languages/
* License: GPLv2 or later (license.txt)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
},
"license": "GPL-2.0-or-later",
"version": "3.1.0",
"BBVersion": "2.6.10"
"BBVersion": "2.6.11"
}
10 changes: 10 additions & 0 deletions src/bp-activity/classes/class-bp-rest-activity-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ public function get_items( $request ) {
$args['pin_type'] = bb_activity_pin_type( $args );
}

if ( bb_get_activity_scheduled_status() === $args['status'] ) {
if ( ! isset( $request['user_id'] ) ) {
$args['filter']['user_id'] = bp_loggedin_user_id();
}
if ( ! empty( $args['group_id'] ) ) {
$args['filter']['object'] = 'groups';
} else {
$args['filter']['object'] = 'activity';
}
}
/**
* Filter the query arguments for the request.
*
Expand Down
2 changes: 1 addition & 1 deletion src/bp-core/admin/bp-core-admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,7 @@ function_exists( 'bb_platform_pro' ) &&
esc_html__( 'BuddyBoss Platform Pro', 'buddyboss' ),
esc_html__( 'to unlock', 'buddyboss' )
);
} elseif( ! function_exists( 'bb_platform_pro' ) ) {
} elseif( ! function_exists( 'bb_platform_pro' ) || ! bbp_pro_is_license_valid() ) {
$bb_pro_notice = sprintf(
'<br/><span class="bb-head-notice"> %1$s <a target="_blank" href="https://www.buddyboss.com/platform/">%2$s</a> %3$s</span>',
esc_html__( 'Install', 'buddyboss' ),
Expand Down
5 changes: 3 additions & 2 deletions src/bp-core/admin/settings/bp-admin-setting-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,11 @@ public function bb_admin_activity_comments_settings_tutorial() {
* @since BuddyBoss 2.6.10
*/
public function bb_admin_setting_callback_enable_activity_schedule_posts() {
$val = function_exists( 'bb_is_enabled_activity_schedule_posts_filter' ) ? bb_is_enabled_activity_schedule_posts_filter() : false;
$notice = bb_get_pro_label_notice( 'schedule_posts' );
?>
<input id="bb_enable_activity_schedule_posts" name="<?php echo empty( $notice ) ? '_bb_enable_activity_schedule_posts' : ''; ?>" type="checkbox" value="1" <?php echo empty( $notice ) ? checked( bb_is_enabled_activity_schedule_posts(), true, false ) : ''; ?> />
<label for="bb_enable_activity_schedule_posts"><?php esc_html_e( 'Allow site owners and moderators to schedule their posts', 'buddyboss' ); ?></label>
<input id="bb_enable_activity_schedule_posts" name="<?php echo empty( $notice ) ? '_bb_enable_activity_schedule_posts' : ''; ?>" type="checkbox" value="1" <?php echo empty( $notice ) ? checked( $val, true, false ) : ''; ?> />
<label for="bb_enable_activity_schedule_posts"><?php esc_html_e( 'Allow Group Organizers and Moderators to schedule their posts', 'buddyboss' ); ?></label>
<?php
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/bp-core/bp-core-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,9 @@ function bp_create_excerpt( $text, $length = 225, $options = array() ) {
}

// If the link in plain text
$truncate = mb_substr( $truncate, 0, $last_space );
if ( false !== $last_space ) {
$truncate = mb_substr( $truncate, 0, $last_space );
}
}
$truncate .= $ending;

Expand Down
4 changes: 2 additions & 2 deletions src/bp-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: The BuddyBoss Platform adds community features to WordPress. Member Profiles, Activity Feeds, Direct Messaging, Notifications, and more!
* Author: BuddyBoss
* Author URI: https://buddyboss.com/
* Version: 2.6.10
* Version: 2.6.11
* Text Domain: buddyboss
* Domain Path: /languages/
* License: GPLv2 or later (license.txt)
Expand All @@ -24,7 +24,7 @@
}

if ( ! defined( 'BP_PLATFORM_VERSION' ) ) {
define( 'BP_PLATFORM_VERSION', '2.6.10' );
define( 'BP_PLATFORM_VERSION', '2.6.11' );
}

if ( ! defined( 'BP_PLATFORM_API' ) ) {
Expand Down
10 changes: 10 additions & 0 deletions src/bp-performance/classes/integrations/class-bb-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public function set_up() {

// When change the member display name.
'update_option_bp-display-name-format' => 3,

// When change the schedule post.
'update_option__bb_enable_activity_schedule_posts' => 0,
);

$this->purge_single_events( $purge_single_events );
Expand Down Expand Up @@ -672,4 +675,11 @@ public function event_update_option_bp_video_group_video_support( $old_value, $v
public function event_update_option_bp_display_name_format( $old_value, $value, $option ) {
$this->purge_cache_on_change_default_group_images_settings();
}

/**
* When changed schedule post setting from the Settings -> Activity.
*/
public function event_update_option__bb_enable_activity_schedule_posts() {
Cache::instance()->purge_by_component( 'bp-groups' );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<span class="bp-item-name">{{data.name}}</span>

<span class="bb-radio-style privacy-radio <# if ( data.selected ) { #>selected<# } #>">
<input type="radio" id="bp-item-opt-{{data.id}}" class="bp-activity-object__radio" name="group-privacy" data-title="{{data.name}}" data-id="{{data.id}}" value="opt-value-{{data.id}}" <# if ( data.selected ) { #> checked <# } #>><span></span>
<input type="radio" id="bp-item-opt-{{data.id}}" class="bp-activity-object__radio" name="group-privacy" data-title="{{data.name}}" data-id="{{data.id}}" <# if ( data.allow_schedule ) { #> data-allow-schedule-post="{{data.allow_schedule}}" <# } #> value="opt-value-{{data.id}}" <# if ( data.selected ) { #> checked <# } #>><span></span>
</span>
</label>
</script>
75 changes: 58 additions & 17 deletions src/bp-templates/bp-nouveau/includes/activity/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,19 @@ function bp_nouveau_ajax_get_single_activity_content() {
wp_send_json_error( $response );
}

$activity_array = bp_activity_get_specific(
array(
'activity_ids' => $_POST['id'],
'display_comments' => 'stream',
)
$args = array(
'activity_ids' => $_POST['id'],
'display_comments' => 'stream',
);

// Check scheduled status.
$post_status = filter_input( INPUT_POST, 'status', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
if ( ! empty( $post_status ) && sanitize_text_field( wp_unslash( $post_status ) ) === bb_get_activity_scheduled_status() ) {
$args['status'] = $post_status;
}

$activity_array = bp_activity_get_specific( $args );

if ( empty( $activity_array['activities'][0] ) ) {
wp_send_json_error( $response );
}
Expand Down Expand Up @@ -818,23 +824,37 @@ function bp_nouveau_ajax_post_update() {
// Combine date and time.
$activity_datetime = $activity_schedule_date_raw . ' ' . $activity_schedule_time_24hr;

// Convert to MySQL datetime format
// Convert to MySQL datetime format.
$schedule_date_time = get_gmt_from_date( $activity_datetime );

// Get current GMT timestamp.
$current_timestamp = gmdate('U');
$current_timestamp = gmdate( 'U' );

// Add 1 hour to the timestamp (in seconds)
// Add 1 hour to the timestamp (in seconds).
$next_hour_timestamp = $current_timestamp + 3600;
$scheduled_timestamp = strtotime( $schedule_date_time );

if ( empty( $activity_id ) && $scheduled_timestamp < $next_hour_timestamp ) {
wp_send_json_error(
array(
'message' => __( 'Please set a minimum schedule time for at least 1 hour later.', 'buddyboss' ),
)
);
} elseif( ! empty( $activity_id ) ) {
// Add 3 months to the timestamp (in seconds).
$three_months_ago_timestamp = strtotime( '+3 months', $current_timestamp );
$scheduled_timestamp = strtotime( $schedule_date_time );
if ( empty( $activity_id ) ) {
// Check if the scheduled date is within the next hour.
if ( $scheduled_timestamp < $next_hour_timestamp ) {
wp_send_json_error(
array(
'message' => __( 'Please set a minimum schedule time for at least 1 hour later.', 'buddyboss' ),
)
);
}

// Check if the scheduled date is more than three months ago.
if ( $scheduled_timestamp > $three_months_ago_timestamp ) {
wp_send_json_error(
array(
'message' => __( 'Please set a schedule date between next three months.', 'buddyboss' ),
)
);
}
} elseif ( ! empty( $activity_id ) ) {

// Check if the scheduled time is changed.
$obj_activity = new BP_Activity_Activity( $activity_id );
Expand Down Expand Up @@ -921,7 +941,7 @@ function bp_nouveau_ajax_post_update() {
) {
wp_send_json_error(
array(
'message' => __( 'You don\'t have permission to schedule activity in perticular group.', 'buddyboss' ),
'message' => __( 'You don\'t have permission to schedule activity in particular group.', 'buddyboss' ),
)
);
}
Expand Down Expand Up @@ -1629,6 +1649,27 @@ function bb_nouveau_ajax_delete_scheduled_activity() {
wp_send_json_error( $response );
}

if (
(
// Check for non admin member to delete scheduled post which they scheduled when they have permission to moderate.
! bp_current_user_can( 'bp_moderate' ) && 'groups' !== $activity->component
) ||
(
// If Groups allow to schedule post then check user can delete schedule post or not;
'groups' === $activity->component && bp_is_active( 'groups' ) && bb_is_enabled_activity_schedule_posts_filter()
)
) {
$is_admin = groups_is_user_admin( $activity->user_id, $activity->item_id );
$is_mod = groups_is_user_mod( $activity->user_id, $activity->item_id );
if ( ! $is_admin && ! $is_mod ) {
wp_send_json_error(
array(
'feedback' => __( 'You don\'t have permission to delete scheduled activity.', 'buddyboss' ),
)
);
}
}

do_action( 'bb_activity_before_action_delete_scheduled_activity', $activity->id, $activity->user_id );

if (
Expand Down
35 changes: 26 additions & 9 deletions src/bp-templates/bp-nouveau/includes/groups/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,22 +450,28 @@ function bp_nouveau_groups_invites_custom_message( $message = '' ) {
* Format a Group for a json reply
*
* @since BuddyPress 3.0.0
*
* @param object $item The group object
*
* @return array $args The group data.
*/
function bp_nouveau_prepare_group_for_js( $item ) {
if ( empty( $item->id ) ) {
return array();
}

$item_avatar_url = bp_disable_group_avatar_uploads() ? '' : bp_core_fetch_avatar( array(
'item_id' => $item->id,
'object' => 'group',
'type' => 'thumb',
'width' => 100,
'height' => 100,
'html' => false
) );
$item_avatar_url = bp_disable_group_avatar_uploads() ? '' : bp_core_fetch_avatar(
array(
'item_id' => $item->id,
'object' => 'group',
'type' => 'thumb',
'width' => 100,
'height' => 100,
'html' => false,
)
);

return array(
$args = array(
'id' => $item->id,
'name' => bp_get_group_name( $item ),
'avatar_url' => $item_avatar_url,
Expand All @@ -475,6 +481,17 @@ function bp_nouveau_prepare_group_for_js( $item ) {
'group_document' => ( bp_is_active( 'document' ) && bp_is_group_document_support_enabled() && bb_document_user_can_upload( bp_loggedin_user_id(), $item->id ) ),
'group_video' => ( bp_is_active( 'video' ) && bp_is_group_video_support_enabled() && bb_video_user_can_upload( bp_loggedin_user_id(), $item->id ) ),
);

$val = function_exists( 'bb_is_enabled_activity_schedule_posts_filter' ) ? bb_is_enabled_activity_schedule_posts_filter() : false;
if ( $val ) {
$is_admin = groups_is_user_admin( bp_loggedin_user_id(), $item->id );
$is_mod = groups_is_user_mod( bp_loggedin_user_id(), $item->id );
if ( $is_admin || $is_mod ) {
$args['allow_schedule'] = 'enabled';
}
}

return $args;
}

/**
Expand Down
Loading

0 comments on commit e93fadc

Please sign in to comment.