You are here

function _campaignmonitor_is_subscribed in Campaign Monitor 5.2

Same name and namespace in other branches
  1. 5 campaignmonitor.module \_campaignmonitor_is_subscribed()
  2. 6.3 campaignmonitor.module \_campaignmonitor_is_subscribed()
  3. 6 campaignmonitor.module \_campaignmonitor_is_subscribed()
  4. 6.2 campaignmonitor.module \_campaignmonitor_is_subscribed()
2 calls to _campaignmonitor_is_subscribed()
campaignmonitor_general_form in ./campaignmonitor.module
campaignmonitor_user_form in ./campaignmonitor.module

File

./campaignmonitor.module, line 386

Code

function _campaignmonitor_is_subscribed($api_key, $list_id, $email, $show_errors = FALSE) {
  $retval = FALSE;
  $cm = new CampaignMonitor($api_key, $client_id, $campaign_id, $list_id);
  $result = $cm
    ->subscribersGetIsSubscribed($email, $list_id);
  if ($result['anyType']['Code'] != 0) {
    watchdog('campaignmonitor', 'Code - ' . $result['anyType']['Code'] . ', Message - ' . $result['anyType']['Message'], WATCHDOG_ERROR);
    $retval = FALSE;
    if ($show_errors) {
      drupal_set_message("There is an error with the newsletter server. Please try again later.", 'error');
    }
  }
  else {
    if ($result['anyType'] == 'False') {
      $retval = FALSE;
    }
    else {
      if ($result['anyType'] == 'True') {
        $retval = TRUE;
      }
    }
  }
  return $retval;
}