Skip to content

Commit

Permalink
[REVERT-4398] PROD-6979 Updates related to migration to platform pro
Browse files Browse the repository at this point in the history
  • Loading branch information
bb-yudhisthir committed May 7, 2024
1 parent 71ae80e commit daeaf6f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 288 deletions.
32 changes: 0 additions & 32 deletions src/bp-activity/bp-activity-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@

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

add_filter( 'bb_is_enabled_activity_schedule_posts', 'bb_is_enabled_activity_schedule_posts_filter', 999 );

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

/**
Expand Down Expand Up @@ -3788,33 +3786,3 @@ function bb_activity_directory_set_pagination( $querystring, $object ) {

return http_build_query( $querystring );
}

/**
* Load the class to schedule the activity post.
*
* @since BuddyBoss [BBVERSION]
*/
function bb_activity_init_activity_schedule() {
BB_Activity_Schedule::instance();
}

add_action( 'bp_init', 'bb_activity_init_activity_schedule' );

/**
* Filter to check platform pro enabled for scheduled posts.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $value Schedule posts setting value.
*
* @return bool $value Filtered schedule posts setting value.
*/
function bb_is_enabled_activity_schedule_posts_filter( $value ) {

// Return false if platform pro is disabled.
if ( ! function_exists( 'bb_platform_pro' ) ) {
$value = false;
}

return $value;
}
67 changes: 3 additions & 64 deletions src/bp-activity/bp-activity-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6128,7 +6128,9 @@ function bb_activity_migration( $raw_db_version, $current_db ) {
}
}

bb_create_activity_schedule_cron_event();
if ( bp_is_active( 'activity' ) && class_exists( 'BB_Schedule_Posts' ) ) {
BB_Schedule_Posts::bb_create_activity_schedule_cron_event();
}
}

/**
Expand Down Expand Up @@ -7186,55 +7188,6 @@ function bb_is_enabled_activity_schedule_posts( $default = false ) {
return (bool) apply_filters( 'bb_is_enabled_activity_schedule_posts', (bool) bp_get_option( '_bb_enable_activity_schedule_posts', $default ) );
}

/**
* Check whether user can schedule activity or not.
*
* @since BuddyBoss [BBVERSION]
*
* @param array $args Array of Arguments.
*
* @return bool true if user can post schedule posts, otherwise false.
*/
function bb_can_user_schedule_activity( $args = array() ) {
$r = bp_parse_args(
$args,
array(
'user_id' => bp_loggedin_user_id(),
'object' => '',
'group_id' => 0,
)
);

$retval = false;
if (
bp_is_active( 'groups' ) &&
(
'group' === $r['object'] ||
bp_is_group()
) &&
bp_user_can( $r['user_id'], 'administrator' )
) {
$group_id = 'group' === $r['object'] && ! empty( $r['group_id'] ) ? $r['group_id'] : bp_get_current_group_id();
$is_admin = groups_is_user_admin( $r['user_id'], $group_id );
$is_mod = groups_is_user_mod( $r['user_id'], $group_id );
if ( $is_admin || $is_mod ) {
$retval = true;
}
} elseif ( bp_user_can( $r['user_id'], 'administrator' ) ) {
$retval = true;
}

/**
* Filters whether user can schedule activity posts.
*
* @since BuddyBoss [BBVERSION]
*
* @param bool $retval Return value for schedule post.
* @param array $args Array of Arguments.
*/
return apply_filters( 'bb_can_user_schedule_activity', $retval, $args );
}

/**
* Return the activity published status.
*
Expand All @@ -7256,17 +7209,3 @@ function bb_get_activity_published_status() {
function bb_get_activity_scheduled_status() {
return buddypress()->activity->scheduled_status;
}

/**
* Create activity schedule cron event if not exists.
*
* @since BuddyBoss [BBVERSION]
*/
function bb_create_activity_schedule_cron_event() {

if ( class_exists( 'BB_Activity_Schedule' ) ) {
if ( ! wp_next_scheduled( 'bb_activity_publish' ) ) {
wp_schedule_event( time(), 'bb_schedule_1min', 'bb_activity_publish' );
}
}
}
184 changes: 0 additions & 184 deletions src/bp-activity/classes/class-bb-activity-schedule.php

This file was deleted.

4 changes: 2 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 @@ -87,13 +87,13 @@ public function register_fields() {
// Allow scopes/tabs.
$this->add_field( '_bb_enable_activity_pinned_posts', __( 'Pinned Post', 'buddyboss' ), 'bb_admin_setting_callback_enable_activity_pinned_posts', 'intval' );

remove_filter( 'bb_is_enabled_activity_schedule_posts', 'bb_is_enabled_activity_schedule_posts_filter', 999 );
// remove_filter( 'bb_is_enabled_activity_schedule_posts', 'bb_is_enabled_activity_schedule_posts_filter', 999 );

$args = array();
$args['class'] = esc_attr( $pro_class );
$this->add_field( '_bb_enable_activity_schedule_posts', __( 'Schedule posts', 'buddyboss' ) . bb_get_pro_label_notice(), array( $this, 'bb_admin_setting_callback_enable_activity_schedule_posts' ), 'intval', $args );

add_filter( 'bb_is_enabled_activity_schedule_posts', 'bb_is_enabled_activity_schedule_posts_filter', 999 );
// add_filter( 'bb_is_enabled_activity_schedule_posts', 'bb_is_enabled_activity_schedule_posts_filter', 999 );

// Allow follow.
$this->add_field( '_bp_enable_activity_follow', __( 'Follow', 'buddyboss' ), 'bp_admin_setting_callback_enable_activity_follow', 'intval' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
?>
<script type="text/html" id="tmpl-activity-schedule-post">
<?php
if ( bp_is_active( 'activity' ) && bb_is_enabled_activity_schedule_posts() && bb_can_user_schedule_activity() ) :
if ( bp_is_active( 'activity' ) && bb_is_enabled_activity_schedule_posts() && function_exists( 'bb_can_user_schedule_activity' ) && bb_can_user_schedule_activity() ) :
?>
<# if ( false === data.edit_activity || 'scheduled' === data.activity_action_type ) { #>
<div class="bb-schedule-post_dropdown_section">
Expand Down
19 changes: 14 additions & 5 deletions src/bp-templates/bp-nouveau/includes/activity/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,13 @@ function bp_nouveau_ajax_post_update() {
)
);
}
if ( $is_scheduled && ! bb_can_user_schedule_activity() ) {
if (
$is_scheduled &&
(
! function_exists( 'bb_can_user_schedule_activity' ) ||
! bb_can_user_schedule_activity()
)
) {
wp_send_json_error(
array(
'message' => __( 'You don\'t have access to schedule the activity.', 'buddyboss' ),
Expand Down Expand Up @@ -903,10 +909,13 @@ function bp_nouveau_ajax_post_update() {

if (
$is_scheduled &&
! bb_can_user_schedule_activity(
array(
'object' => 'group',
'group_id' => $item_id,
(
! function_exists( 'bb_can_user_schedule_activity' ) ||
! bb_can_user_schedule_activity(
array(
'object' => 'group',
'group_id' => $item_id,
)
)
)
) {
Expand Down

0 comments on commit daeaf6f

Please sign in to comment.