Skip to content

Commit

Permalink
some recurrence safety checks added
Browse files Browse the repository at this point in the history
  • Loading branch information
liedekef committed Jul 1, 2024
1 parent 9b02eef commit dc77f85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eme-recurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,13 @@ function eme_db_insert_recurrence( $recurrence, $event ) {
}
}
} else {
if (empty($recurrence['specific_days'])) {
return 0;
}
// get the recurrence start days
// this also ordens the days by date, so we'll update the recurrence with that too
$matching_days = eme_get_recurrence_days( $recurrence );
$recurrence['specific_days'] = join( ',', $matching_days );
$recurrence['recurrence_start_date'] = $matching_days[0];
// find the last matching day too
$last_day = $matching_days[0];
Expand Down Expand Up @@ -339,8 +344,13 @@ function eme_db_update_recurrence( $recurrence, $event, $only_change_recdates =
}
}
} else {
if (empty($recurrence['specific_days'])) {
return 0;
}
// get the recurrence start days
// this also ordens the days by date, so we'll update the recurrence with that too
$matching_days = eme_get_recurrence_days( $recurrence );
$recurrence['specific_days'] = join( ',', $matching_days );
$recurrence['recurrence_start_date'] = $matching_days[0];
// find the last matching day too
$last_day = $matching_days[0];
Expand Down
2 changes: 2 additions & 0 deletions js/eme_admin_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ jQuery(document).ready( function($) {
$('input#localized-rec-end-date').hide();
$('p#recurrence-dates-explanation').hide();
$('span#recurrence-dates-explanation-specificdates').show();
$('#localized-rec-start-date').attr('required', true);
$('#localized-rec-start-date').fdatepicker().data('fdatepicker').update('multipleDates',true);
} else {
$('div#recurrence-intervals').show();
$('input#localized-rec-end-date').show();
$('p#recurrence-dates-explanation').show();
$('span#recurrence-dates-explanation-specificdates').hide();
$('#localized-rec-start-date').attr('required', false);
$('#localized-rec-start-date').fdatepicker().data('fdatepicker').update('multipleDates',false);
// if the recurrence contained specific days before, clear those because that would not work upon save
if ($('#rec-start-date-to-submit').val().indexOf(',') !== -1) {
Expand Down

0 comments on commit dc77f85

Please sign in to comment.