Skip to content

Commit c90a6da

Browse files
committed
Merge branch 'master' into develop
2 parents ffc52a6 + cc62c3c commit c90a6da

4 files changed

Lines changed: 21 additions & 14 deletions

File tree

dt-core/admin/menu/tabs/tab-general.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,12 @@ public function process_update_required(){
426426
$site_options['update_required']['enabled'] = isset( $_POST['triggers_enabled'] );
427427

428428
// Capture updated trigger options.
429-
if ( isset( $_POST['update_needed_triggers_options'] ) ) {
429+
if ( isset( $_POST['update_needed_triggers_options'] ) && !empty( $_POST['update_needed_triggers_options'] ) ) {
430430
// phpcs:ignore
431-
$site_options['update_required']['options'] = dt_recursive_sanitize_array( json_decode( wp_unslash( $_POST['update_needed_triggers_options'] ), true ) );
431+
$decoded_options = json_decode( wp_unslash( $_POST['update_needed_triggers_options'] ), true );
432+
if ( is_array( $decoded_options ) ) {
433+
$site_options['update_required']['options'] = dt_recursive_sanitize_array( $decoded_options );
434+
}
432435
}
433436

434437
update_option( 'dt_site_options', $site_options, true );

dt-workflows/update-required.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ protected function prepare_data( $data ) {
3333
protected function run_action() {
3434
global $wpdb;
3535
$user_locale = get_user_locale();
36-
$site_options = dt_get_option( 'dt_site_options' );
36+
$site_options = dt_get_option( 'dt_site_options' );
3737
$update_needed_settings = $site_options['update_required'];
3838
if ( $update_needed_settings['enabled'] === true ) {
3939
wp_set_current_user( 0 ); // to keep the update needed notifications from coming from a specific user.
4040
$current_user = wp_get_current_user();
4141
$current_user->add_cap( 'access_contacts' );
4242
$current_user->add_cap( 'dt_all_access_contacts' );
43-
$field_options = DT_Posts::get_post_field_settings( 'contacts' );
43+
$field_options = DT_Posts::get_post_field_settings( 'contacts' );
4444
foreach ( $update_needed_settings['options'] as $setting ) {
4545

4646
$setting_status = $setting['status'] ?? null;
@@ -49,7 +49,7 @@ protected function run_action() {
4949

5050
$deleted_flag = $field_options[ $setting_field ]['default'][ $setting_option ]['deleted'] ?? null;
5151
if ( ! ( isset( $deleted_flag ) && ( $deleted_flag === true ) ) && isset( $setting_status, $setting_field, $setting_option ) ) {
52-
$date = time() - $setting['days'] * 24 * 60 * 60; // X days in seconds
52+
$date = time() - $setting['days'] * 24 * 60 * 60; // X days in seconds
5353
$contacts_need_update = $wpdb->get_results( $wpdb->prepare( "
5454
SELECT $wpdb->posts.ID
5555
FROM $wpdb->posts
@@ -60,8 +60,10 @@ protected function run_action() {
6060
WHERE ( requires_update_field.meta_value = '' OR requires_update_field.meta_value = '0' OR requires_update_field.meta_key IS NULL )
6161
AND overall_status_field.meta_value = %s
6262
AND setting_field.meta_value = %s
63-
AND %d >= ( SELECT MAX( hist_time ) FROM $wpdb->dt_activity_log WHERE object_id = $wpdb->posts.ID and user_id != 0 && action = 'field_update' )
64-
AND NOT EXISTS ( SELECT 1 FROM $wpdb->comments WHERE comment_post_ID = $wpdb->posts.ID AND user_id != 0 )
63+
AND %d >= GREATEST(
64+
COALESCE(( SELECT MAX( hist_time ) FROM $wpdb->dt_activity_log WHERE object_id = $wpdb->posts.ID AND user_id != 0 AND action = 'field_update' ), 0),
65+
COALESCE(( SELECT MAX( UNIX_TIMESTAMP( comment_date ) ) FROM $wpdb->comments WHERE comment_post_ID = $wpdb->posts.ID AND user_id != 0 ), 0)
66+
)
6567
AND $wpdb->posts.post_type = 'contacts' AND $wpdb->posts.post_status = 'publish'
6668
GROUP BY $wpdb->posts.ID ORDER BY $wpdb->posts.post_date DESC LIMIT 0, 50",
6769
esc_sql( $setting_field ),
@@ -70,7 +72,7 @@ protected function run_action() {
7072
$date
7173
), OBJECT );
7274
foreach ( $contacts_need_update as $contact ) {
73-
$user_name = ( '@' . dt_get_assigned_name( $contact->ID, true ) . ' ' ) ?? '';
75+
$user_name = ( '@' . dt_get_assigned_name( $contact->ID, true ) . ' ' ) ?? '';
7476
$comment_html = null;
7577

7678
if ( isset( $setting['comment_translations'][$user_locale] ) && !empty( $setting['comment_translations'][$user_locale] ) ) {
@@ -104,23 +106,25 @@ protected function run_action() {
104106
$current_user->add_cap( 'update_any_groups' );
105107

106108
foreach ( $group_update_needed_settings['options'] as $setting ) {
107-
$date = time() - $setting['days'] * 24 * 60 * 60; // X days in seconds
109+
$date = time() - $setting['days'] * 24 * 60 * 60; // X days in seconds
108110
$groups_need_update = $wpdb->get_results( $wpdb->prepare( "
109111
SELECT $wpdb->posts.ID
110112
FROM $wpdb->posts
111113
LEFT JOIN $wpdb->postmeta AS requires_update_field ON ($wpdb->posts.ID = requires_update_field.post_id AND requires_update_field.meta_key = 'requires_update' )
112114
LEFT JOIN $wpdb->postmeta AS group_status_field ON ( $wpdb->posts.ID = group_status_field.post_id AND group_status_field.meta_key = 'group_status' )
113115
WHERE ( requires_update_field.meta_value = '' OR requires_update_field.meta_value = '0' OR requires_update_field.meta_value IS NULL )
114116
AND group_status_field.meta_value = %s
115-
AND %d >= ( SELECT MAX( hist_time ) FROM $wpdb->dt_activity_log WHERE object_id = $wpdb->posts.ID and user_id != 0 && action = 'field_update' )
116-
AND NOT EXISTS ( SELECT 1 FROM $wpdb->comments WHERE comment_post_ID = $wpdb->posts.ID AND user_id != 0 )
117+
AND %d >= GREATEST(
118+
COALESCE(( SELECT MAX( hist_time ) FROM $wpdb->dt_activity_log WHERE object_id = $wpdb->posts.ID AND user_id != 0 AND action = 'field_update' ), 0),
119+
COALESCE(( SELECT MAX( UNIX_TIMESTAMP( comment_date ) ) FROM $wpdb->comments WHERE comment_post_ID = $wpdb->posts.ID AND user_id != 0 ), 0)
120+
)
117121
AND $wpdb->posts.post_type = 'groups' AND $wpdb->posts.post_status = 'publish'
118122
GROUP BY $wpdb->posts.ID ORDER BY $wpdb->posts.post_date DESC LIMIT 0, 50",
119123
esc_sql( $setting['status'] ),
120124
$date
121125
), OBJECT );
122126
foreach ( $groups_need_update as $group ) {
123-
$user_name = ( '@' . dt_get_assigned_name( $group->ID, true ) . ' ' ) ?? '';
127+
$user_name = ( '@' . dt_get_assigned_name( $group->ID, true ) . ' ' ) ?? '';
124128
$comment_html = null;
125129

126130
if ( isset( $setting['comment_translations'][$user_locale] ) && !empty( $setting['comment_translations'][$user_locale] ) ) {

functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function __construct() {
103103
* Prepare variables
104104
*/
105105
$this->token = 'disciple_tools';
106-
$this->version = '1.76.2';
106+
$this->version = '1.76.3';
107107

108108
$this->theme_url = get_template_directory_uri() . '/';
109109
$this->theme_path = get_template_directory() . '/';

style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Theme Name: Disciple Tools
33
Theme URI: https://github.com/DiscipleTools/disciple-tools-theme
44
Description: Disciple.Tools is a coalition management system for disciple making movements.
55
Author URI: https://github.com/DiscipleTools
6-
Version: 1.76.2
6+
Version: 1.76.3
77
Requires at least: 4.7.0
88
License: GPL-2.0 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html

0 commit comments

Comments
 (0)