/**
  * create / update subscription
  * return newsletter_user_object
  *
  * @param integer $listContentObjectId
  * @param integer $newsletterUserId
  * @param array $outputFormatArray
  * @param integer $status
  * @param integer $dryRun if true changes will be not stored to db usefull for test runs @see user_edit
  * @return object
  */
 static function createUpdateNewsletterSubscription($listContentObjectId, $newsletterUserId, $outputFormatArray, $status = CjwNewsletterSubscription::STATUS_PENDING, $dryRun = false, $context = 'default')
 {
     $existingSubscriptionObject = CjwNewsletterSubscription::fetchByListIdAndNewsletterUserId($listContentObjectId, $newsletterUserId);
     $newsletterUser = CjwNewsletterUser::fetch($newsletterUserId);
     // if nl user status is confirmed set all nl subscription with status pending to confirmed
     if (is_object($newsletterUser) && (int) $newsletterUser->attribute('status') == CjwNewsletterUser::STATUS_CONFIRMED && $status == CjwNewsletterSubscription::STATUS_PENDING) {
         $status = CjwNewsletterSubscription::STATUS_CONFIRMED;
     }
     // update existing
     if (is_object($existingSubscriptionObject)) {
         $existingSubscriptionObject->setAttribute('output_format_array_string', CjwNewsletterSubscription::arrayToString($outputFormatArray));
         if ($context == 'configure') {
             // if nl list autoapprove is disabled + admin has approved the nl subscription
             // + the nl subscription should be get status approved when update confirmstatus,
             if ($existingSubscriptionObject->attribute('status') == CjwNewsletterSubscription::STATUS_APPROVED) {
                 // set confirmed timestamp if emty - could be possible if admin has approved subscription before user has confirm his email address
                 if ($existingSubscriptionObject->attribute('confirmed') == 0) {
                     $existingSubscriptionObject->setAttribute('confirmed', time());
                 }
                 // else nothing
             } else {
                 $existingSubscriptionObject->setAttribute('status', $status);
             }
         } else {
             $existingSubscriptionObject->setAttribute('status', $status);
         }
         if ($dryRun === false) {
             $existingSubscriptionObject->sync();
         }
         return $existingSubscriptionObject;
     } else {
         $object = CjwNewsletterSubscription::create($listContentObjectId, $newsletterUserId, $outputFormatArray, $status, $context);
         if ($dryRun === false) {
             $object->store();
         }
         return $object;
     }
 }
 /**
  * Fetches the newsletter object the blacklist object is attached to
  *
  * @return CjwNewsletterUser
  */
 function getNewsletterUserObject()
 {
     if ($this->attribute('newsletter_user_id') != 0) {
         $user = CjwNewsletterUser::fetch($this->attribute('newsletter_user_id'));
         return $user;
     } else {
         return false;
     }
 }
Esempio n. 3
0
 *
 * @copyright Copyright (C) 2007-2012 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
 */
require_once 'kernel/common/i18n.php';
include_once 'kernel/common/template.php';
$module = $Params['Module'];
$http = eZHTTPTool::instance();
$tpl = templateInit();
$templateFile = 'design:newsletter/user_remove.tpl';
$newsLetterUserId = (int) $Params['NewsletterUserId'];
$newsletterUserObject = CjwNewsletterUser::fetch($newsLetterUserId);
if (!is_object($newsletterUserObject)) {
    return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$redirectUrlCancel = '/newsletter/user_view/' . $newsletterUserObject->attribute('id');
if ($http->hasVariable('RedirectUrlActionCancel')) {
    $redirectUrlCancel = $http->variable('RedirectUrlActionCancel');
}
$redirectUrlRemove = '/newsletter/user_list/';
if ($http->hasVariable('RedirectUrlActionRemove')) {
    $redirectUrlRemove = $http->variable('RedirectUrlActionRemove');
}
// show an overview of all things we will be delete
/*
- all subscriptions
- user data
 /**
  *
  * @return unknown_type
  */
 function getNewsletterUserObject()
 {
     return CjwNewsletterUser::fetch($this->attribute('newsletter_user_id'));
 }
 /**
  * creates a virtual subscriptioobejct
  * for a userId and editionSendId
  * @param int $newsletterUserId
  * @param int $editionSendId
  * @return false or CjwNewsletterSubscriptionVirtual object
  */
 static function createByUserIdAndEditionSendId($newsletterUserId, $editionSendId)
 {
     $newsletterUserRow = CjwNewsletterUser::fetch($newsletterUserId, false);
     if (!is_array($newsletterUserRow)) {
         return false;
     }
     $editionSendObject = CjwNewsletterEditionSend::fetch($editionSendId);
     if (is_object($editionSendObject)) {
         $subcriptionVirtualObject = self::createFromUserRow($newsletterUserRow, $editionSendObject->attribute('list_contentobject_id'), true);
         return $subcriptionVirtualObject;
     } else {
         return false;
     }
 }
Esempio n. 6
0
 */
include_once 'kernel/common/template.php';
$module = $Params["Module"];
$http = eZHTTPTool::instance();
$editionSendHash = $Params['EditionSendHash'];
$outputFormatId = 0;
$subscriptionHash = false;
$newsletterUser = null;
if ($Params['OutputFormatId']) {
    $outputFormatId = (int) $Params['OutputFormatId'];
}
if ($Params['SubscriptionHash']) {
    $subscriptionHash = $Params['SubscriptionHash'];
    $subscription = CjwNewsletterSubscription::fetchByHash($subscriptionHash);
    if ($subscription) {
        $newsletterUser = CjwNewsletterUser::fetch($subscription->attribute('newsletter_user_id'));
    }
}
$editionSendObject = CjwNewsletterEditionSend::fetchByHash($editionSendHash);
if (!is_object($editionSendObject)) {
    return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$newsletterDataArray = $editionSendObject->getParsedOutputXml();
$newsletterContent = false;
if (isset($newsletterDataArray[$outputFormatId])) {
    $newsletterContentArray = $newsletterDataArray[$outputFormatId];
}
switch ($outputFormatId) {
    // html
    case 0:
        $newsletterContent = CjwNewsletterUtils::replaceNewsletterMarkers($newsletterContentArray['body']['html'], $editionSendObject, $newsletterUser);