You are here

function _mailchimp_get_available_lists in Mailchimp 5.2

Same name and namespace in other branches
  1. 5 mailchimp.module \_mailchimp_get_available_lists()
  2. 6.2 mailchimp.module \_mailchimp_get_available_lists()
  3. 6 mailchimp.module \_mailchimp_get_available_lists()
  4. 7 mailchimp.module \_mailchimp_get_available_lists()

Get all of the lists that the given user can subscribe to

4 calls to _mailchimp_get_available_lists()
mailchimp_form_alter in ./mailchimp.module
Implementation of hook_form_alter() . Add subscription form to registration page
mailchimp_subscribe_form in ./mailchimp.module
mailchimp_subscribe_form_submit in ./mailchimp.module
mailchimp_user in ./mailchimp.module

File

./mailchimp.module, line 758

Code

function _mailchimp_get_available_lists($user, $q = NULL) {
  $lists = array();
  if ($q || ($q = _mailchimp_get_api_object())) {
    foreach ((array) $q
      ->lists() as $list) {
      if (!empty($list)) {
        foreach ((array) $user->roles as $rid => $info) {
          if (variable_get('mailchimp_list_' . $list['id'] . '_role_' . $rid, 0)) {
            $lists[] = $list;
          }
        }
      }
    }
  }
  return $lists;
}