You are here

function mailchimp_lists_overview_page in Mailchimp 7.4

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_lists/includes/mailchimp_lists.admin.inc \mailchimp_lists_overview_page()
  2. 7.2 modules/mailchimp_lists/includes/mailchimp_lists.admin.inc \mailchimp_lists_overview_page()
  3. 7.3 modules/mailchimp_lists/includes/mailchimp_lists.admin.inc \mailchimp_lists_overview_page()

Administrative display showing existing lists and allowing edits/adds.

1 string reference to 'mailchimp_lists_overview_page'
mailchimp_lists_menu in modules/mailchimp_lists/mailchimp_lists.module
Implements hook_menu().

File

modules/mailchimp_lists/includes/mailchimp_lists.admin.inc, line 11
mailchimp_lists module admin settings.

Code

function mailchimp_lists_overview_page() {
  $mc_lists = mailchimp_get_lists();
  $rows = array();
  $webhook_url = mailchimp_webhook_url();
  foreach ($mc_lists as $mc_list) {
    $webhooks = mailchimp_webhook_get($mc_list->id);
    $enabled = FALSE;
    if ($webhooks) {
      foreach ($webhooks as $webhook) {
        if ($webhook_url == $webhook->url) {
          $enabled = TRUE;
          continue;
        }
      }
    }
    if ($enabled) {

      // This is a webhook for this Mailchimp Module.
      $webhook_status = t('ENABLED') . ' (' . l(t('disable'), 'admin/config/services/mailchimp/lists/' . $mc_list->id . '/webhook/disable') . ')';
    }
    else {
      $webhook_status = t('disabled') . ' (' . l(t('enable'), 'admin/config/services/mailchimp/lists/' . $mc_list->id . '/webhook/enable') . ')';
    }
    $rows[] = array(
      l($mc_list->name, 'https://admin.mailchimp.com/lists/dashboard/overview?id=' . $mc_list->web_id, array(
        'attributes' => array(
          'target' => '_blank',
        ),
      )),
      $mc_list->stats->member_count,
      $webhook_status,
    );
  }
  $table = array(
    'header' => array(
      t('Name'),
      t('Members'),
      t('Webhook Status'),
    ),
    'rows' => $rows,
  );
  $refresh_link = l(t('Refresh lists from Mailchimp'), 'admin/config/services/mailchimp/list_cache_clear', array(
    'query' => array(
      'destination' => 'admin/config/services/mailchimp/lists',
    ),
  ));
  if (empty($mc_lists)) {
    $table['caption'] = $refresh_link;
    drupal_set_message(t('You don\'t have any lists configured in your Mailchimp account, (or you haven\'t configured your API key correctly on the Global Settings tab). Head over to !link and create some lists, then come back here and click "Refresh lists from Mailchimp"', array(
      '!link' => l(t('Mailchimp'), 'https://admin.mailchimp.com/lists/'),
    )), 'warning');
  }
  else {
    $options = t('Currently Available Mailchimp lists') . ':<i>';
    foreach ($mc_lists as $mc_list) {
      $options .= ' ' . $mc_list->name . ',';
    }
    $options = rtrim($options, ',');
    $options .= ".</i><br />" . $refresh_link;
    $table['caption'] = $options;
  }
  return theme('table', $table);
}