[#36] Rename "double_opt_in" property to "newsletter_double_opt_in"

This commit is contained in:
Jens Schuppe 2020-08-14 10:13:51 +02:00
parent 4ff060884a
commit d3c1aabfb4
4 changed files with 11 additions and 11 deletions

View file

@ -329,7 +329,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
$this->add(
'checkbox', // field type
'double_opt_in', // field name
'newsletter_double_opt_in', // field name
E::ts('Use Double-Opt-In for newsletter'), // field label
FALSE, // is not required
array()
@ -339,7 +339,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
'select', // field type
'newsletter_groups', // field name
E::ts('Sign up for newsletter groups'), // field label
static::getNewsletterGroups($this->profile->getAttribute('double_opt_in')), // list of options
static::getNewsletterGroups($this->profile->getAttribute('newsletter_double_opt_in')), // list of options
FALSE, // is not required
array('class' => 'crm-select2 huge', 'multiple' => 'multiple')
);
@ -556,7 +556,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
$values['name'] = 'default';
}
$this->profile->setName($values['name']);
$this->profile->setAttribute('double_opt_in', isset($values['double_opt_in']));
$this->profile->setAttribute('newsletter_double_opt_in', isset($values['newsletter_double_opt_in']));
foreach ($this->profile->getData() as $element_name => $value) {
if (isset($values[$element_name])) {
$this->profile->setAttribute($element_name, $values[$element_name]);

View file

@ -221,7 +221,7 @@ class CRM_Twingle_Profile {
'membership_type_id',
'membership_type_id_recur',
'membership_postprocess_call',
'double_opt_in'
'newsletter_double_opt_in'
),
// Add payment methods.
array_keys(static::paymentInstruments()),
@ -294,7 +294,7 @@ class CRM_Twingle_Profile {
'custom_field_mapping' => NULL,
'membership_type_id' => NULL,
'membership_type_id_recur' => NULL,
'double_opt_in' => NULL,
'newsletter_double_opt_in' => NULL,
)
// Add contribution status for all payment methods.
+ array_fill_keys(array_map(function($attribute) {

View file

@ -486,8 +486,8 @@ function civicrm_api3_twingle_donation_Submit($params) {
// If usage of double opt-in is selected, use MailingEventSubscribe.create to add contact to newsletter groups
// defined in the profile
$result_values['newsletter']['double_opt_in'] = ($profile->getAttribute('double_opt_in')) ? 'true' : 'false';
if ($profile->getAttribute('double_opt_in') &&
$result_values['newsletter']['newsletter_double_opt_in'] = ($profile->getAttribute('newsletter_double_opt_in')) ? 'true' : 'false';
if ($profile->getAttribute('newsletter_double_opt_in') &&
!empty($params['newsletter']) &&
!empty($groups = $profile->getAttribute('newsletter_groups'))) {
$group_memberships = array_column(civicrm_api3('GroupContact', 'get', array (

View file

@ -209,13 +209,13 @@
<table class="form-layout-compressed">
<tr class="crm-section">
<td class="label">{$form.double_opt_in.label}</td>
<td class="content">{$form.double_opt_in.html}</td>
<td class="label">{$form.newsletter_groups.label}</td>
<td class="content">{$form.newsletter_groups.html}</td>
</tr>
<tr class="crm-section">
<td class="label">{$form.newsletter_groups.label}</td>
<td class="content">{$form.newsletter_groups.html}</td>
<td class="label">{$form.newsletter_double_opt_in.label}</td>
<td class="content">{$form.newsletter_double_opt_in.html}</td>
</tr>
<tr class="crm-section">