/** * Batch Subscription to MailChimp Lists * * @author Ruchi Kothari * @return bool "true" on Success, "false" otherwise * @throws SWIFT_Exception If the Class is not Loaded */ public function Subscribe() { if (!$this->GetIsClassLoaded()) { throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED); return false; } $_SWIFT_UserSyncManagerObject = new SWIFT_UserSyncManager(); $_subscriptionResult = $_SWIFT_UserSyncManagerObject->BatchSubscribe(); $_errorString = ""; if (isset($_subscriptionResult['error'])) { $_errorString .= $_subscriptionResult['error']; } else { if (isset($_subscriptionResult['lists'])) { foreach ($_subscriptionResult['lists'] as $_list) { foreach ($_list['errors'] as $_error) { $_errorString .= $_error['email'] . ' failed'; $_errorString .= ' Code: ' . $_error['code']; $_errorString .= ' Message: ' . $_error['message']; } } } } if (!empty($_errorString)) { $_errorString = $this->Language->Get('mc_error') . $_errorString; SWIFT_Loader::LoadLibrary('ErrorLog:ErrorLog'); SWIFT_ErrorLog::Create(SWIFT_ErrorLog::TYPE_GENERAL, $_errorString); } return true; }
/** * Log errors from mailchimp results * * @author Ruchi Kothari * * @param array $_mailchimpResult Result recieved from MailChimp after performing various operations * * @return bool "true" on Success, "false" otherwise * @throws SWIFT_Exception If class is not loaded */ private function LogError($_mailchimpResult) { if (!$this->GetIsClassLoaded()) { throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED); return false; } if (!_is_array($_mailchimpResult)) { return true; } $_errorString = ''; foreach ($_mailchimpResult as $_list) { if (!empty($_list['errors'])) { $_errorString .= "*****" . $_list['name'] . " Error***** :"; foreach ($_list['errors'] as $_error) { $_errorString .= ' Message: ' . $_error['message'] . SWIFT_CRLF; $_errorString .= ' Code: ' . $_error['code']; } } } if (!empty($_errorString)) { $_errorString = $this->Language->Get('mc_error') . $_errorString; // SWIFT_Loader::LoadLibrary('ErrorLog:ErrorLog'); SWIFT_ErrorLog::Create(SWIFT_ErrorLog::TYPE_GENERAL, $_errorString); } return true; }