diff --git a/sites/all/modules/patched/mailchimp/mailchimp.module b/sites/all/modules/patched/mailchimp/mailchimp.module index d47d7ee..e876f05 100644 --- a/sites/all/modules/patched/mailchimp/mailchimp.module +++ b/sites/all/modules/patched/mailchimp/mailchimp.module @@ -275,7 +275,13 @@ function mailchimp_get_api_object() { * An array of list arrays. */ function mailchimp_get_lists($list_ids = array(), $reset = FALSE) { - $cache = $reset ? NULL : cache_get('mailchimp_lists'); + $cid = 'mailchimp_lists'; + if (module_exists('domain')) { + $current_domain = domain_get_domain(); + $cid .= ':'.$current_domain['machine_name']; + } + + $cache = $reset ? NULL : cache_get($cid); $lists = array(); // Return cached lists: if ($cache) { @@ -299,7 +305,7 @@ function mailchimp_get_lists($list_ids = array(), $reset = FALSE) { } uasort($lists, '_mailchimp_list_cmp'); - cache_set('mailchimp_lists', $lists, 'cache', CACHE_TEMPORARY); + cache_set($cid, $lists, 'cache', CACHE_TEMPORARY); } // Filter by given ids: diff --git a/sites/all/modules/patched/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.module b/sites/all/modules/patched/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.module index e5b6ffd..b9efb8a 100644 --- a/sites/all/modules/patched/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.module +++ b/sites/all/modules/patched/mailchimp/modules/mailchimp_campaign/mailchimp_campaign.module @@ -305,7 +305,13 @@ function mailchimp_campaign_delete_campaign($cid) { * @return array(). */ function mailchimp_campaign_get_templates($template_id = NULL, $reset = FALSE) { - $cache = $reset ? NULL : cache_get('mailchimp_templates'); + $cid = 'mailchimp_templates'; + // domain specific templates + if (module_exists('domain')) { + $current_domain = domain_get_domain(); + $cid .= ':'.$current_domain['machine_name']; + } + $cache = $reset ? NULL : cache_get($cid); $templates = array(); // return cached lists if ($cache) { @@ -329,7 +335,7 @@ function mailchimp_campaign_get_templates($template_id = NULL, $reset = FALSE) { } } - cache_set('mailchimp_templates', $templates, 'cache', CACHE_TEMPORARY); + cache_set($cid, $templates, 'cache', CACHE_TEMPORARY); } if (isset($template_id)) { diff --git a/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/includes/mailchimp_lists.admin.inc b/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/includes/mailchimp_lists.admin.inc index 61bed91..4b42199 100644 --- a/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/includes/mailchimp_lists.admin.inc +++ b/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/includes/mailchimp_lists.admin.inc @@ -12,6 +12,14 @@ function mailchimp_lists_overview_page() { $lists = mailchimp_lists_load_multiple(); $rows = array(); $roles = user_roles(); + if (module_exists('domain')) { + $current_domain = domain_get_domain(); + foreach ($lists as $key => $list) { + if ($list->domain_id != $current_domain['domain_id']) { + unset($lists[$key]); + } + } + } foreach ($lists as $list) { $mc_list = mailchimp_get_list($list->mc_list_id); $actions = array( @@ -71,6 +79,13 @@ function mailchimp_lists_overview_page() { */ function mailchimp_lists_refresh_page() { cache_clear_all('mailchimp_lists', 'cache'); + $cid = 'mailchimp_lists'; + if (module_exists('domain')) { + $current_domain = domain_get_domain(); + $cid .= ':'.$current_domain['machine_name']; + } + + cache_clear_all($cid, 'cache'); drupal_set_message(t('Mailchimp Lists refreshed'), 'status'); // Return render array. return array( @@ -140,7 +155,7 @@ function mailchimp_lists_list_form($form, &$form_state, MailchimpList $list = NU '#type' => 'fieldset', '#title' => t('Form & Subscribe Block Options'), ); - + $lists = mailchimp_get_lists(); $options = array('' => t('-- Select --')); foreach ($lists as $mc_list) { @@ -514,6 +529,11 @@ function mailchimp_lists_list_form_submit($form, &$form_state) { 'required' => $form_state['values']['required'], ); + if (module_exists('domain')) { + $current_domain = domain_get_domain(); + $list->domain_id = $current_domain['domain_id']; + } + if ($ret = mailchimp_lists_save($list)) { drupal_set_message(t('List @name has been saved.', array('@name' => $list->label))); diff --git a/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/mailchimp_lists.install b/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/mailchimp_lists.install index aa85e59..7b6cb2e 100644 --- a/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/mailchimp_lists.install +++ b/sites/all/modules/patched/mailchimp/modules/mailchimp_lists/mailchimp_lists.install @@ -34,6 +34,13 @@ function mailchimp_lists_schema() { 'length' => 32, 'description' => 'The MailChimp list id associated with this list.', ), + 'domain_id' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Domain numeric id.', + ), 'label' => array( 'type' => 'varchar', 'length' => 32, @@ -424,3 +431,41 @@ function mailchimp_lists_update_7206() { db_drop_field('mailchimp_lists', 'updated'); drupal_get_schema('mailchimp_lists', TRUE); } + +/** + * Add domain_id field. + */ +function mailchimp_lists_update_7207() { + + // Add the domain_id field. + if (!db_field_exists('mailchimp_lists', 'domain_id')) { + db_add_field('mailchimp_lists', 'domain_id', array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'Domain numeric id.', + )); + } + + // Add current lists to default domain + if (module_exists('domain')) { + $domain_default_id = domain_default_id(); + // Generate a machine name for existing lists. + $lists = db_select('mailchimp_lists', 'm') + ->fields('m') + ->execute() + ->fetchAll(); + + foreach ($lists as $list) { + $list->name = strtolower(str_replace(' ', '_', $list->label)); + db_update('mailchimp_lists') + ->fields(array('domain_id' => $domain_default_id)) + ->condition('id', $list->id) + ->execute(); + } + + } + + cache_clear_all(); +}