static function deleteMCEmail($emailId = array())
 {
     CRM_Mailchimp_Utils::checkDebug('Start-CRM_Mailchimp_Utils deleteMCEmail $emailId', $emailId);
     /*
     modified by mathavan@vedaconsulting.co.uk
     table name civicrm_mc_sync has no longer exist
     and dont have leid, euid, list_id informations
     so returning null to avoid the script
     */
     return NULL;
     //end
     if (empty($emailId)) {
         return NULL;
     }
     $toDelete = array();
     $listID = array();
     $email = NULL;
     $query = NULL;
     if (!empty($emailId)) {
         $emailIds = implode(',', $emailId);
         // @todo I think this code meant to include AND is_latest.
         // Looks very inefficient otherwise?
         #Mathavan@vedaconsulting.co.uk, commmenting the query, table no longer exist
         //$query = "SELECT * FROM civicrm_mc_sync WHERE email_id IN ($emailIds) ORDER BY id DESC";
     }
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
         $leidun = $dao->mc_leid;
         $euidun = $dao->mc_euid;
         $listID = $dao->mc_list_id;
         $mc_group = $dao->mc_group;
         $email_id = $dao->email_id;
         $email = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Email', $dao->email_id, 'email', 'id');
         $toDelete[$listID]['batch'][] = array('email' => $email, 'euid' => $euidun, 'leid' => $leidun);
         $params = array('email_id' => $dao->email_id, 'mc_list_id' => $listID, 'mc_group' => $mc_group, 'mc_euid' => $euidun, 'mc_leid' => $leidun, 'sync_status' => 'Removed');
         CRM_Mailchimp_BAO_MCSync::create($params);
     }
     foreach ($toDelete as $listID => $vals) {
         // sync contacts using batchunsubscribe
         $mailchimp = new Mailchimp_Lists(CRM_Mailchimp_Utils::mailchimp());
         $results = $mailchimp->batchUnsubscribe($listID, $vals['batch'], TRUE, TRUE, TRUE);
     }
     CRM_Mailchimp_Utils::checkDebug('Start-CRM_Mailchimp_Utils deleteMCEmail $emailId', $emailId);
     CRM_Mailchimp_Utils::checkDebug('Start-CRM_Mailchimp_Utils deleteMCEmail $toDelete', $toDelete);
     return $toDelete;
 }
 /**
  * Unsubscribe contacts that are subscribed at Mailchimp but not in our list.
  */
 static function syncPushRemove(CRM_Queue_TaskContext $ctx, $listID)
 {
     CRM_Mailchimp_Utils::checkDebug('Start-CRM_Mailchimp_Form_Sync syncPushRemove $listID= ', $listID);
     CRM_Mailchimp_Utils::checkDebug('Start-CRM_Mailchimp_Form_Sync syncPushRemove $ctx= ', $ctx);
     // Delete records have the same hash - these do not need an update.
     static::updatePushStats(array($listID => array('in_sync' => static::syncIdentical())));
     // Now identify those that need removing from Mailchimp.
     // @todo implement the delete option, here just the unsubscribe is implemented.
     $dao = CRM_Core_DAO::executeQuery("SELECT m.email, m.euid, m.leid\n       FROM tmp_mailchimp_push_m m\n       WHERE NOT EXISTS (\n         SELECT email FROM tmp_mailchimp_push_c c WHERE c.email = m.email\n       );");
     // Loop the $dao object to make a list of emails to unsubscribe|delete from MC
     // http://apidocs.mailchimp.com/api/2.0/lists/batch-unsubscribe.php
     $batch = array();
     $stats[$listID]['removed'] = 0;
     while ($dao->fetch()) {
         $batch[] = array('email' => $dao->email, 'euid' => $dao->euid, 'leid' => $dao->leid);
         $stats[$listID]['removed']++;
     }
     if (!$batch) {
         // Nothing to do
         return CRM_Queue_Task::TASK_SUCCESS;
     }
     // Log the batch unsubscribe details
     CRM_Core_Error::debug_var('Mailchimp batchUnsubscribe syncPushRemove $listID= ', $listID);
     CRM_Core_Error::debug_var('Mailchimp batchUnsubscribe syncPushRemove $batch= ', $batch);
     // Send Mailchimp Lists API Call: http://apidocs.mailchimp.com/api/2.0/lists/batch-unsubscribe.php
     $list = new Mailchimp_Lists(CRM_Mailchimp_Utils::mailchimp());
     $result = $list->batchUnsubscribe($listID, $batch, $delete = FALSE, $send_bye = FALSE, $send_notify = FALSE);
     CRM_Mailchimp_Utils::checkDebug('CRM_Mailchimp_Form_Sync syncPushRemove $result= ', $result);
     // @todo check errors? $result['errors'] $result['success_count']
     // Finally we can delete the emails that we just processed from the mailchimp temp table.
     CRM_Core_DAO::executeQuery("DELETE FROM tmp_mailchimp_push_m\n       WHERE NOT EXISTS (\n         SELECT email FROM tmp_mailchimp_push_c c WHERE c.email = tmp_mailchimp_push_m.email\n       );");
     static::updatePushStats($stats);
     CRM_Mailchimp_Utils::checkDebug('End-CRM_Mailchimp_Form_Sync syncPushRemove $listID= ', $listID);
     CRM_Mailchimp_Utils::checkDebug('End-CRM_Mailchimp_Form_Sync syncPushRemove $ctx= ', $ctx);
     CRM_Mailchimp_Utils::checkDebug('End-CRM_Mailchimp_Form_Sync syncPushRemove $result= ', $result);
     return CRM_Queue_Task::TASK_SUCCESS;
 }