Merge pull request #12206 from eileenmcnaughton/api_encoder
[civicrm-core.git] / CRM / Admin / Form / ScheduleReminders.php
index 6e56a4dfc0c129173fca59837c25a57c3470d975..612bcebff99ba3cc8370b4e72d1427b20acb435e 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
@@ -168,11 +168,10 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
     $this->add('number', 'start_action_offset', ts('When'), array('class' => 'six', 'min' => 0));
     $this->addRule('start_action_offset', ts('Value should be a positive number'), 'positiveInteger');
 
-    $isActive = ts('Send email');
+    $isActive = ts('Scheduled Reminder Active');
     $recordActivity = ts('Record activity for automated email');
     if ($providersCount) {
       $this->assign('sms', $providersCount);
-      $isActive = ts('Send email or SMS');
       $recordActivity = ts('Record activity for automated email or SMS');
       $options = CRM_Core_OptionGroup::values('msg_mode');
       $this->add('select', 'mode', ts('Send as'), $options);
@@ -335,7 +334,9 @@ 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'])) {
+      $errors['from_email'] = ts('Please enter a valid email address.');
+    }
     $recipientKind = array(
       'participant_role' => array(
         'name' => 'participant role',
@@ -350,6 +351,13 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
       $errors[$recipientKind[$fields['recipient']]['target_id']] = ts('If "Also include" or "Limit to" are selected, you must specify at least one %1', array(1 => $recipientKind[$fields['recipient']]['name']));
     }
 
+    //CRM-21523
+    if (!empty($fields['is_repeat']) &&
+      (empty($fields['repetition_frequency_interval']) || ($fields['end_frequency_interval'] == NULL))
+    ) {
+      $errors['is_repeat'] = ts('If you are enabling repetition you must indicate the frequency and ending term.');
+    }
+
     $actionSchedule = $self->parseActionSchedule($fields);
     if ($actionSchedule->mapping_id) {
       $mapping = CRM_Core_BAO_ActionSchedule::getMapping($actionSchedule->mapping_id);