CRM-14807 - replacing stale PR 3450
[civicrm-core.git] / CRM / Admin / Form / ScheduleReminders.php
index 5d971f668402756dcd204de622442fae6aaf89e9..076a2f3c3c5272e94fd2b59ffdb09f89429a6ce9 100644 (file)
@@ -186,6 +186,9 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
     $this->add('select', 'end_action', ts('Repetition Condition'), $condition, TRUE);
     $this->add('select', 'end_date', ts('Date Field'), $sel4, TRUE);
 
+    $this->add('text', 'from_name', ts('From Name'));
+    $this->add('text', 'from_email', ts('From Email'));    
+
     $recipient = 'activity_contacts';
     $recipientListingOptions = array();
 
@@ -244,12 +247,21 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
    */
   static function formRule($fields) {
     $errors = array();
-    if ((array_key_exists(1, $fields['entity']) && $fields['entity'][1][0] == 0) ||
+    if ((array_key_exists(1, $fields['entity']) && $fields['entity'][1][0] === 0) ||
       (array_key_exists(2, $fields['entity']) && $fields['entity'][2][0] == 0)
     ) {
       $errors['entity'] = ts('Please select appropriate value');
     }
 
+    if (array_key_exists(1, $fields['entity']) && !is_numeric($fields['entity'][1][0])) {
+      if (count($fields['entity'][1]) > 1) {
+        $errors['entity'] = ts('You may only select one contact field per reminder');
+      }
+      elseif (!(array_key_exists(2, $fields['entity']) && $fields['entity'][2][0] > 0)) {
+        $errors['entity'] = ts('Please select whether the reminder is sent each year.');
+      }
+    }
+
     if (!empty($fields['is_active']) &&
       CRM_Utils_System::isNull($fields['subject'])
     ) {
@@ -349,7 +361,9 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
       'record_activity',
       'limit_to',
       'mode',
-      'sms_provider_id'
+      'sms_provider_id',
+      'from_name',
+      'from_email',
     );
     foreach ($keys as $key) {
       $params[$key] = CRM_Utils_Array::value($key, $values);