/** * Check if given email is on blacklist * * @param string $email * @return boolean */ static function isEmailOnBlacklist($email) { $object = CjwNewsletterBlacklistItem::fetchByEmail($email); if (is_object($object)) { return true; } else { return false; } }
* * @copyright Copyright (C) 2007-2010 CJW Network - Coolscreen.de, JAC Systeme GmbH, Webmanufaktur. All rights reserved. * @license http://ez.no/licenses/gnu_gpl GNU GPL v2 * @version //autogentag// * @package cjw_newsletter * @subpackage modules * @filesource */ $module = $Params['Module']; require_once 'kernel/common/i18n.php'; $http = eZHTTPTool::instance(); $blackListItemArray = array(); $deleteIDArray = $http->hasVariable('BlacklistIDArray') ? $http->variable('BlacklistIDArray') : array(); $email = $http->hasVariable('Email') ? trim($http->variable('Email')) : ''; if ($email) { $itemByEmail = CjwNewsletterBlacklistItem::fetchByEmail($email); if (!is_object($itemByEmail)) { eZDebug::writeError("Given email ({$email}) isn't blacklisted", 'newsletter/blacklist_item_remove'); return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel'); } $blackListItemArray[] = $itemByEmail; } if ($deleteIDArray) { foreach ($deleteIDArray as $id) { $itemByID = CjwNewsletterBlacklistItem::fetch($id); if (!is_object($itemByID)) { eZDebug::writeError("Given id ({$id}) isn't blacklisted", 'newsletter/blacklist_item_remove'); return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel'); } $blackListItemArray[] = $itemByID; }
$tpl = templateInit(); $isBlacklistDone = false; $email = false; $note = ''; if ($http->hasVariable('Email')) { $email = trim($http->variable('Email')); } if ($http->hasVariable('Note')) { $note = trim($http->variable('Note')); } // if email is ok than create a new blacklist item // email to lowercase $message = ''; $blacklistItemObject = false; if ($email != '') { $existingBlacklistItemObject = CjwNewsletterBlacklistItem::fetchByEmail($email); if (!is_object($existingBlacklistItemObject)) { $blacklistItemObject = CjwNewsletterBlacklistItem::create($email, $note); } else { $blacklistItemObject = $existingBlacklistItemObject; } } // if AddButton was pushed than store new data if ($http->hasVariable('AddButton')) { if (is_object($blacklistItemObject)) { $newsletterUserObject = $blacklistItemObject->attribute('newsletter_user_object'); // $newsletterUserObject->setBlacklisted(); $blacklistItemObject->store(); if (is_object($newsletterUserObject)) { $message = ezi18n('cjw_newsletter/blacklist_item_add', 'Successfully adding newsletter user %nl_user_id with email %email to blacklist', '', array('%nl_user_id' => $newsletterUserObject->attribute('id'), '%email' => $newsletterUserObject->attribute('email'))); $isBlacklistDone = true;
/** * remove the current newlsetter user and all depending nl subscriptions * @see kernel/classes/eZPersistentObject#remove($conditions, $extraConditions) */ function remove($conditions = null, $extraConditions = null) { // remove subscriptions $currentNewsletterSubscriptionObjects = $this->attribute('subscription_array'); CjwNewsletterLog::writeNotice('CjwNewsletterUser::remove', 'user', 'remove', array('nl_user' => $this->attribute('id'), 'subscription_count' => count($currentNewsletterSubscriptionObjects), 'subscriptions_to_remove' => implode('|', array_keys($currentNewsletterSubscriptionObjects)), 'modifier' => eZUser::currentUserID())); foreach ($currentNewsletterSubscriptionObjects as $subscription) { $subscription->remove(); } $blackListItem = CjwNewsletterBlacklistItem::fetchByEmail($this->attribute('email')); if (is_object($blackListItem)) { $blackListItem->setAttribute('newsletter_user_id', 0); $blackListItem->store(); } parent::remove($conditions, $extraConditions); }