From 776a42163ad6832e19106c8f8e3d6029179763ce Mon Sep 17 00:00:00 2001 From: Samuel Vanhove Date: Sat, 25 Apr 2015 19:09:47 -0400 Subject: [PATCH] CRM-16355 - UI and database --- CRM/Admin/Form/ScheduleReminders.php | 35 +++++++++++++++++++ .../Incremental/sql/4.7.alpha1.mysql.tpl | 4 +++ .../CRM/Admin/Form/ScheduleReminders.tpl | 10 ++++++ .../CRM/Admin/Page/ScheduleReminders.hlp | 9 +++++ xml/schema/Core/ActionSchedule.xml | 14 ++++++++ 5 files changed, 72 insertions(+) diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 4e1893e1b4..bc78ea71e8 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -254,6 +254,33 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { CRM_Core_PseudoConstant::nestedGroup('Mailing'), FALSE, array('class' => 'crm-select2 huge') ); + // multilingual only options + $domain = new CRM_Core_DAO_Domain(); + $domain->find(TRUE); + $multilingual = (bool) $domain->locales; + if ($multilingual) { + $smarty = CRM_Core_Smarty::singleton(); + $smarty->assign('multilingual', $multilingual); + + $languageFilter = array(); + $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales); + $languages = CRM_Core_I18n::languages(); + foreach ($locales as $locale) { + $languageFilter[$locale] = $languages[$locale]; + } + $languageFilter['none'] = ts('Contacts with no preferred language'); + $element = $this->add('select', 'filter_contact_language', ts('Recipients language'), $languageFilter, FALSE, + array('multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => TRUE)); + + $communicationLanguage = array(); + $communicationLanguage[''] = ts('System default language'); + $communicationLanguage['auto'] = ts('Follow recipient preferred language'); + foreach ($locales as $locale) { + $communicationLanguage[$locale] = $languages[$locale]; + } + $this->add('select', 'communication_language', ts('Communication language'), $communicationLanguage); + } + CRM_Mailing_BAO_Mailing::commonCompose($this); $this->add('text', 'subject', ts('Subject'), @@ -374,6 +401,9 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $defaults['recipient'] = 'manual'; $defaults['recipient_manual_id'] = $defaults['recipient_manual']; } + if ($contactLanguage = CRM_Utils_Array::value('filter_contact_language', $defaults)) { + $defaults['filter_contact_language'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contactLanguage); + } } return $defaults; @@ -496,6 +526,11 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $params['end_date'] = 'null'; } + // multilingual options + $params['filter_contact_language'] = CRM_Utils_Array::value('filter_contact_language', $values, null); + $params['filter_contact_language'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['filter_contact_language']); + $params['communication_language'] = CRM_Utils_Array::value('communication_language', $values, null); + if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; } diff --git a/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl index d41834071b..6606d5a7f4 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl @@ -1,5 +1,9 @@ {* file to handle db changes in 4.7.alpha1 during upgrade *} +-- Add new columns for multilingual purpose +ALTER TABLE `civicrm_action_schedule` ADD COLUMN `filter_contact_language` varchar(128) DEFAULT NULL COMMENT 'Used for multilingual installation'; +ALTER TABLE `civicrm_action_schedule` ADD COLUMN `communication_language` varchar(8) DEFAULT NULL COMMENT 'Used for multilingual installation'; + -- CRM-16354 SELECT @option_group_id_wysiwyg := max(id) from civicrm_option_group where name = 'wysiwyg_editor'; diff --git a/templates/CRM/Admin/Form/ScheduleReminders.tpl b/templates/CRM/Admin/Form/ScheduleReminders.tpl index 7dd566fa56..321607fd5b 100644 --- a/templates/CRM/Admin/Form/ScheduleReminders.tpl +++ b/templates/CRM/Admin/Form/ScheduleReminders.tpl @@ -97,6 +97,16 @@ {$form.mode.label} {$form.mode.html} + {if $multilingual} + + {$form.filter_contact_language.label} + {$form.filter_contact_language.html} {help id="filter_contact_language"} + + + {$form.communication_language.label} + {$form.communication_language.html} {help id="communication_language"} + + {/if} {$form.is_active.html} {$form.is_active.label} diff --git a/templates/CRM/Admin/Page/ScheduleReminders.hlp b/templates/CRM/Admin/Page/ScheduleReminders.hlp index 8a5748ece0..a13f7b749b 100644 --- a/templates/CRM/Admin/Page/ScheduleReminders.hlp +++ b/templates/CRM/Admin/Page/ScheduleReminders.hlp @@ -41,3 +41,12 @@ {htxt id="id-from_name_email"} {ts}You can set the FROM name and email address for this reminder in these fields. If you leave these fields blank, the default FROM name and email address for your site will be used (Administer > Communications > FROM Email Addresses).{/ts} {/htxt} + +{htxt id="filter_contact_language"} + {ts}You can limt the recipient of the reminder to contact with the specified preferred language. You can also choose to add contacts that have no preferred language defined.{/ts} +{/htxt} + +{htxt id="communication_language"} + {ts}This is the language of the communication. If there are template translation or tokens, it will follow this preferrence. By default, it follows the system default language.{/ts} +{/htxt} + diff --git a/xml/schema/Core/ActionSchedule.xml b/xml/schema/Core/ActionSchedule.xml index 587f68f940..bbfbc55af6 100644 --- a/xml/schema/Core/ActionSchedule.xml +++ b/xml/schema/Core/ActionSchedule.xml @@ -332,4 +332,18 @@ Used for repeating entity 4.6 + + filter_contact_language + varchar + 128 + Used for multilingual installation + 4.7 + + + communication_language + varchar + 8 + Used for multilingual installation + 4.7 + -- 2.25.1