Skip to content

Commit

Permalink
[jcalendar] remove jcalendar usage from participant_register_date on …
Browse files Browse the repository at this point in the history
…event search

This removes one more place where legacy jcalendar is used. There is actually still one left on the form (event date)
which I left out for now as it involves thinking about the fact event is a different entity & might warrant different
representation in the arrays
  • Loading branch information
eileenmcnaughton committed May 27, 2019
1 parent ae9a1b2 commit cf02d00
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 21 deletions.
10 changes: 2 additions & 8 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1559,17 +1559,12 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals
if (preg_match('/_date_relative$/', $id) ||
$id == 'event_relative' ||
$id == 'case_from_relative' ||
$id == 'case_to_relative' ||
$id == 'participant_relative'
$id == 'case_to_relative'
) {
if ($id == 'event_relative') {
$fromRange = 'event_start_date_low';
$toRange = 'event_end_date_high';
}
elseif ($id == 'participant_relative') {
$fromRange = 'participant_register_date_low';
$toRange = 'participant_register_date_high';
}
elseif ($id == 'case_from_relative') {
$fromRange = 'case_from_start_date_low';
$toRange = 'case_from_start_date_high';
Expand Down Expand Up @@ -1650,8 +1645,7 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals
elseif (preg_match('/_date_relative$/', $id) ||
$id == 'event_relative' ||
$id == 'case_from_relative' ||
$id == 'case_to_relative' ||
$id == 'participant_relative'
$id == 'case_to_relative'
) {
// Already handled in previous loop
continue;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Core/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static function formRule($fields, $files, $form) {
foreach ($form->getSearchFieldMetadata() as $entity => $spec) {
foreach ($spec as $fieldName => $fieldSpec) {
if ($fieldSpec['type'] === CRM_Utils_Type::T_DATE || $fieldSpec['type'] === (CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME)) {
if (isset($fields[$fieldName . '_high']) && isset($fields[$fieldName . '_low']) && empty($fields[$fieldName . '_relative'])) {
if (!empty($fields[$fieldName . '_high']) && !empty($fields[$fieldName . '_low']) && empty($fields[$fieldName . '_relative'])) {
if (strtotime($fields[$fieldName . '_low']) > strtotime($fields[$fieldName . '_high'])) {
$errors[$fieldName . '_low'] = ts('%1: Please check that your date range is in correct chronological order.', [1 => $fieldSpec['title']]);
}
Expand Down
12 changes: 2 additions & 10 deletions CRM/Event/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ public static function defaultReturnProperties(
public static function getSearchFieldMetadata() {
$fields = [
'participant_status_id',
'participant_register_date',
];
$metadata = civicrm_api3('Participant', 'getfields', [])['values'];
return array_intersect_key($metadata, array_flip($fields));
Expand Down Expand Up @@ -628,10 +629,7 @@ public static function buildSearchForm(&$form) {

CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);

CRM_Core_Form_Date::buildDateRange($form, 'participant', 1, '_register_date_low', '_register_date_high', ts('From'), FALSE);

$form->addElement('hidden', 'event_date_range_error');
$form->addElement('hidden', 'participant_date_range_error');
$form->addFormRule(['CRM_Event_BAO_Query', 'formRule'], $form);

$form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', [1 => '<em>%1</em>']));
Expand Down Expand Up @@ -686,7 +684,7 @@ public static function tableNames(&$tables) {
public static function formRule($fields, $files, $form) {
$errors = [];

if ((empty($fields['event_start_date_low']) || empty($fields['event_end_date_high'])) && (empty($fields['participant_register_date_low']) || empty($fields['participant_register_date_high']))) {
if ((empty($fields['event_start_date_low']) || empty($fields['event_end_date_high']))) {
return TRUE;
}
$lowDate = strtotime($fields['event_start_date_low']);
Expand All @@ -696,12 +694,6 @@ public static function formRule($fields, $files, $form) {
$errors['event_date_range_error'] = ts('Please check that your Event Date Range is in correct chronological order.');
}

$lowDate1 = strtotime($fields['participant_register_date_low']);
$highDate1 = strtotime($fields['participant_register_date_high']);

if ($lowDate1 > $highDate1) {
$errors['participant_date_range_error'] = ts('Please check that your Registration Date Range is in correct chronological order.');
}
return empty($errors) ? TRUE : $errors;
}

Expand Down
3 changes: 2 additions & 1 deletion CRM/Event/Form/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
*/
protected $searchFieldMetadata = [];


/**
* Get the default entity for the form.
*
* @return string
*/
public function getDefaultEntity() {
Expand Down
5 changes: 5 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveFifteen.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
public function upgrade_5_15_alpha1($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addTask('Fix errant deferred revenue settings', 'updateContributeSettings');
$this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [
'datepickerConversion' => [
'participant_register_date',
],
]);
}

}
2 changes: 1 addition & 1 deletion templates/CRM/Event/Form/Search/Common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{include file="CRM/Core/DateRange.tpl" fieldName="event" from='_start_date_low' to='_end_date_high' label="<label>Event Dates</label>"}
</tr>
<tr>
{include file="CRM/Core/DateRange.tpl" fieldName="participant" from='_register_date_low' to='_register_date_high' label="<label>Registration Date</label>"}
{include file="CRM/Core/DatePickerRangeWrapper.tpl" fieldName="participant_register_date" colspan="2"}
</tr>
<tr>
<td class="crm-event-form-block-participant_status"><label>{$form.participant_status_id.label}</label>
Expand Down

0 comments on commit cf02d00

Please sign in to comment.