You are here

function mailchimp_campaign_delete_campaign in Mailchimp 7.4

Same name and namespace in other branches
  1. 8 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_delete_campaign()
  2. 7.5 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_delete_campaign()
  3. 7.2 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_delete_campaign()
  4. 7.3 modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_delete_campaign()
  5. 2.x modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_delete_campaign()

Delete a Mailchimp campaign and the local entity.

1 call to mailchimp_campaign_delete_campaign()
mailchimp_campaign_delete_form_submit in modules/mailchimp_campaign/includes/mailchimp_campaign.admin.inc
Submit handler for mailchimp_campaign_delete_list_form().

File

modules/mailchimp_campaign/mailchimp_campaign.module, line 484
Module file for mailchimp_campaign.

Code

function mailchimp_campaign_delete_campaign($cid) {

  /* @var \Mailchimp\MailchimpCampaigns $mc_campaigns */
  $mc_campaigns = mailchimp_get_api_object('MailchimpCampaigns');
  $result = NULL;

  // Delete campaign from Mailchimp.
  try {
    if (!$mc_campaigns) {
      throw new MailchimpException('Cannot delete campaign without Mailchimp API. Check API key has been entered.');
    }
    mailchimp_campaign_delete($cid);
    $mc_campaigns
      ->delete($cid);
    watchdog('mailchimp_campaign', 'Mailchimp campaign %cid was deleted.', array(
      '%cid' => $cid,
    ), WATCHDOG_INFO);
    return TRUE;
  } catch (Exception $e) {
    drupal_set_message($e
      ->getMessage(), 'error');
    watchdog('mailchimp_campaign', 'An error occurred while deleting this campaign: %message', array(
      '%message' => $e
        ->getMessage(),
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return FALSE;
}