function mailchimp_get_lists in Mailchimp 7.2
Same name and namespace in other branches
- 8 mailchimp.module \mailchimp_get_lists()
- 7.5 mailchimp.module \mailchimp_get_lists()
- 7.3 mailchimp.module \mailchimp_get_lists()
- 7.4 mailchimp.module \mailchimp_get_lists()
- 2.x mailchimp.module \mailchimp_get_lists()
Return all MailChimp lists for a given key. Lists are stored in the cache.
Parameters
array $list_ids: An array of list IDs to filter the results by.
bool $reset: Force a cache reset.
Return value
array An array of list arrays.
5 calls to mailchimp_get_lists()
- mailchimp_campaign_campaign_form in modules/
mailchimp_campaign/ mailchimp_campaign.admin.inc - Returns a form for creating a campaign.
- mailchimp_get_list in ./
mailchimp.module - Wrapper around mailchimp_get_lists() to return a single list.
- mailchimp_get_lists_by_email in ./
mailchimp.module - Returns an array of lists that the user has been a member of.
- mailchimp_lists_list_form in modules/
mailchimp_lists/ includes/ mailchimp_lists.admin.inc - Return a form for adding/editing a mailchimp list.
- mailchimp_lists_overview_page in modules/
mailchimp_lists/ includes/ mailchimp_lists.admin.inc - Administrative display showing existing lists and allowing edits/adds.
File
- ./
mailchimp.module, line 277 - Mailchimp module.
Code
function mailchimp_get_lists($list_ids = array(), $reset = FALSE) {
$cache = $reset ? NULL : cache_get('mailchimp_lists');
$lists = array();
// Return cached lists:
if ($cache) {
$lists = $cache->data;
}
else {
if ($q = mailchimp_get_api_object()) {
$result = $q
->lists(array(), 0, 100);
if ($result['total'] > 0) {
foreach ($result['data'] as $list) {
// Append mergefields:
$list['mergevars'] = $q
->listMergeVars($list['id']);
// Append interest groups:
$list['intgroups'] = $q
->listInterestGroupings($list['id']);
$lists[$list['id']] = $list;
}
}
}
uasort($lists, '_mailchimp_list_cmp');
cache_set('mailchimp_lists', $lists, 'cache', CACHE_TEMPORARY);
}
// Filter by given ids:
if (!empty($list_ids)) {
foreach ($lists as $key => $list) {
if (!in_array($key, $list_ids)) {
unset($lists[$key]);
}
}
}
return $lists;
}