Exemplo n.º 1
0
 * @filesource
 */
// Blacklist User by nl user id or by email
// update all nessesarry status fields to blacklisted
$module = $Params['Module'];
$templateFile = 'design:newsletter/blacklist_item_list.tpl';
require_once 'kernel/common/i18n.php';
include_once 'kernel/common/template.php';
$http = eZHTTPTool::instance();
$tpl = templateInit();
$http = eZHTTPTool::instance();
$db = eZDB::instance();
$viewParameters = array('offset' => 0, 'namefilter' => '');
$userParameters = $Params['UserParameters'];
$viewParameters = array_merge($viewParameters, $userParameters);
$limit = 10;
$limitArray = array(10, 10, 25, 50);
$limitArrayKey = eZPreferences::value('admin_blacklist_item_list_limit');
// get user limit preference
if (isset($limitArray[$limitArrayKey])) {
    $limit = $limitArray[$limitArrayKey];
}
$blacklistItemList = CjwNewsletterBlacklistItem::fetchAllBlacklistItems($limit, $viewParameters['offset']);
$blacklistItemListCount = CjwNewsletterBlacklistItem::fetchAllBlacklistItemsCount();
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('blacklist_item_list', $blacklistItemList);
$tpl->setVariable('blacklist_item_list_count', $blacklistItemListCount);
$tpl->setVariable('limit', $limit);
$Result = array();
$Result['content'] = $tpl->fetch($templateFile);
$Result['path'] = array(array('url' => 'newsletter/index', 'text' => ezi18n('cjw_newsletter/path', 'Newsletter')), array('url' => false, 'text' => ezi18n('cjw_newsletter/blacklist_item_list', 'Blacklists')));
 /**
  * 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;
     }
 }
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;
    }
}
foreach ($blackListItemArray as $blackListItem) {
    $blackListItem->remove();
}
if ($http->hasVariable('RedirectURI')) {
    $module->redirectTo(trim($http->variable('RedirectURI')));
} elseif ($http->hasSessionVariable('LastAccessesURI')) {
    $module->redirectTo($http->sessionVariable('LastAccessesURI'));
} else {
Exemplo n.º 4
0
$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;
        } else {
            $message = ezi18n('cjw_newsletter/blacklist_item_add', 'Successfully adding email address %email to blacklist', '', array('%email' => $blacklistItemObject->attribute('email')));
Exemplo n.º 5
0
 /**
  * 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);
 }