From 1c4d4fb795f6836cdcc153b17a5803b3c270732a Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 27 Sep 2018 15:35:10 +1000 Subject: [PATCH] dev/core#410 Ensure that Email related fields in Scheduled Reminders are not required when creating an SMS reminder and ensure that SMS Text Message field is required when creating an SMS reminder --- CRM/Admin/Form/ScheduleReminders.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 1067dad2c5..152d5ae185 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -319,17 +319,24 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $errors['entity'] = ts('Please select appropriate value'); } + $mode = CRM_Utils_Array::value('mode', $fields, FALSE); if (!empty($fields['is_active']) && - CRM_Utils_System::isNull($fields['subject']) + CRM_Utils_System::isNull($fields['subject']) && (!$mode || $mode != 'SMS') ) { $errors['subject'] = ts('Subject is a required field.'); } if (!empty($fields['is_active']) && - CRM_Utils_System::isNull(trim(strip_tags($fields['html_message']))) + CRM_Utils_System::isNull(trim(strip_tags($fields['html_message']))) && (!$mode || $mode != 'SMS') ) { $errors['html_message'] = ts('The HTML message is a required field.'); } + if (!empty($mode) && ($mode == 'SMS' || $mode == 'User_Preference') && !empty($fields['is_active']) && + CRM_Utils_System::isNull(trim(strip_tags($fields['sms_text_message']))) + ) { + $errors['sms_text_message'] = ts('The SMS message is a required field.'); + } + if (empty($self->getContext()) && CRM_Utils_System::isNull(CRM_Utils_Array::value(1, $fields['entity']))) { $errors['entity'] = ts('Please select entity value'); } @@ -339,7 +346,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $errors['absolute_date'] = ts('Absolute date cannot be earlier than the current time.'); } } - if (!CRM_Utils_Rule::email($fields['from_email'])) { + if (!CRM_Utils_Rule::email($fields['from_email']) && (!$mode || $mode != 'SMS')) { $errors['from_email'] = ts('Please enter a valid email address.'); } $recipientKind = array( -- 2.25.1