Skip to content
Snippets Groups Projects
Commit 00fffafc authored by xenophyle's avatar xenophyle
Browse files

Issue #3391752 by xenophyle, bdimaggio: Interests are not updated

parent a746b591
No related branches found
No related tags found
3 merge requests!60Issue #3391752: Interests are not updated,!353.x - Merge Oauth work into 3.x after that work has beeb merged into 2.x,!25Issue #2951089 by thomscode, Guietc: WSOD - Proxy issue
......@@ -253,28 +253,59 @@ function _mailchimp_lists_subscription_has_changed(MailchimpListsSubscription $i
// old settings from Mailchimp. This means the only possible change is in our
// interest group settings, so we only analyze those:
else {
// Current member info:
$member_info = mailchimp_get_memberinfo($settings['mc_list_id'], $email);
if (isset($member_info->merge_fields->GROUPINGS)) {
foreach ($member_info->merge_fields->GROUPINGS as $grouping) {
if (!isset($choices['interest_groups'][$grouping['id']])) {
return TRUE;
// Current member info interests exist, whether selected or not:
if (!empty($member_info->interests)) {
foreach ($member_info->interests as $interest_id => $subscribed) {
// Current interest is selected on MC:
if ($subscribed) {
// If no interests are selected in the form, subscription has changed.
if (empty($choices['interest_groups'])) {
return TRUE;
}
else {
// Subscription has changed if interest is not selected in form.
$selected = FALSE;
foreach ($choices['interest_groups'] as $group_id => $group) {
if (!is_array($group)) {
// Standardize formatting of choices:
$choices['interest_groups'][$group_id] = [$choices['interest_groups'][$group_id] => $choices['interest_groups'][$group_id]];
}
// Current interest is selected in form:
if (isset($group[$interest_id]) && $group[$interest_id]) {
// Found it!
$selected = TRUE;
break;
}
}
if (!$selected) {
return TRUE;
}
}
}
// If current interest is not subscribed on MC, check if it is selected
// in the form.
else {
if (!is_array($choices['interest_groups'][$grouping['id']])) {
// Standardize formatting of choices:
$choices['interest_groups'][$grouping['id']] = [$choices['interest_groups'][$grouping['id']] => $choices['interest_groups'][$grouping['id']]];
}
foreach ($choices['interest_groups'] as $group_id => $group) {
if (!is_array($group)) {
// Standardize formatting of choices:
$choices['interest_groups'][$group_id] = [$choices['interest_groups'][$group_id] => $choices['interest_groups'][$group_id]];
}
foreach ($grouping['groups'] as $group) {
$selected = isset($choices['interest_groups'][$grouping['id']][$group['name']]) && $choices['interest_groups'][$grouping['id']][$group['name']];
if (($group['interested'] && !$selected) || (!$group['interested'] && $selected)) {
// Current interest is selected in form:
if (isset($group[$interest_id]) && $group[$interest_id]) {
return TRUE;
}
}
}
}
}
// Current member info has no interests selected but form submission does.
elseif (!empty($choices['interest_groups'])) {
return TRUE;
}
}
// No changes detected.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment