You are here

function _campaignmonitor_get_list_detail in Campaign Monitor 6.3

Get detailed information about a campaign mointor list.

@staticvar array $lists

Parameters

string $api_key:

string $list_id:

boolean $reset:

Return value

array with detailed list information.

3 calls to _campaignmonitor_get_list_detail()
campaignmonitor_admin_settings_form in includes/campaignmonitor.admin.inc
Menu callback that creates the administartion settings form.
_campaignmonitor_add_subscriber in ./campaignmonitor.module
Subscribe a user to a newsletter list, by e-mail, name and custom fields.
_campaignmonitor_remove_subscriber in ./campaignmonitor.module
Remove user form a newsletter list identified by e-mail and list ID.

File

./campaignmonitor.module, line 781
Module that plugs in Campaign Monitor functionality to your Drupal web site. For Campaign Monitor information see: http://www.campaignmonitor.com/

Code

function _campaignmonitor_get_list_detail($api_key, $list_id, $reset = FALSE) {
  $get_data = FALSE;
  static $data;
  if (!isset($data) || !isset($data[$list_id]) || $reset) {
    if (!$reset && ($cache = cache_get('campaignmonitor_list_detail')) && !empty($cache->data)) {
      $data = $cache->data;
      if (!isset($data[$list_id])) {

        // Cache found, but no information about current list.
        $get_data = TRUE;
      }
    }
    else {

      // No cache found.
      $data = array();
      $get_data = TRUE;
    }
  }

  // Data was not found in the cache, so aske campaign monitor for it.
  if ($get_data) {
    $cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id);
    $result = $cm
      ->listGetDetail($list_id);
    if (empty($result) || $result['anyType']['Code'] != 0) {
      if (empty($result)) {
        watchdog('campaignmonitor', 'There was a problem with the connection to Campaign Monitor.');
      }
      else {
        watchdog('campaignmonitor', 'Get List Detail: Code - %code, Message - %message', array(
          '%code' => $result['anyType']['Code'],
          '%message' => $result['anyType']['Message'],
        ));
      }
      drupal_set_message(CM_ERROR, 'error', FALSE);
    }
    else {

      // Save list details in the cache.
      $data[$list_id] = $result['anyType'];
      cache_set('campaignmonitor_list_detail', $data);
    }
  }
  return $data[$list_id];
}