function __construct()
 {
     $salutationNameArray = CjwNewsletterUser::getAvailableSalutationNameArrayFromIni();
     $this->CjwNewsletterFilterType('cjwnl_salutation', ezpI18n::tr('cjw_newsletter/filtertypes', 'Salutation', 'Filtertype name'), array());
     $this->setValues(array());
     $this->setValuesAvailable(array('1' => $salutationNameArray[1], '2' => $salutationNameArray[2]));
     $this->setOperation('eq');
     $this->setOperationsAvailable(array('eq' => ezpI18n::tr('cjw_newsletter/filtertypes', 'equal', 'Filtertype condition'), 'ne' => ezpI18n::tr('cjw_newsletter/filtertypes', 'not equal', 'Filtertype condition')));
 }
 /**
  * Replaces markers in newsletter content
  * @param string $content
  * @param CjwNewsletterEditionSend $newsletterEditionSend
  * @param CjwNewsletterUser $newsletterUser
  * @return string
  */
 static function replaceNewsletterMarkers($content, CjwNewsletterEditionSend $newsletterEditionSend, CjwNewsletterUser $newsletterUser = null)
 {
     // TODO parse extra variables
     $editionSendHash = $newsletterEditionSend->attribute('hash');
     $searchArray = array('#_hash_editionsend_#');
     $replaceArray = array($editionSendHash);
     if ($newsletterUser) {
         $subscription = CjwNewsletterSubscription::fetchByListIdAndNewsletterUserId($newsletterEditionSend->attribute('list_contentobject_id'), $newsletterUser->attribute('id'));
         $newsletterUnsubscribeHash = $subscription->attribute('hash');
         $newsletterConfigureHash = $newsletterUser->attribute('hash');
         $personalizeContent = (int) $newsletterEditionSend->attribute('personalize_content');
         $searchArray = array_merge($searchArray, array('#_hash_unsubscribe_#', '#_hash_configure_#'));
         $replaceArray = array_merge($replaceArray, array($newsletterUnsubscribeHash, $newsletterConfigureHash));
         if ($personalizeContent === 1) {
             $searchArray = array_merge($searchArray, array('[[name]]', '[[salutation_name]]', '[[first_name]]', '[[last_name]]'));
             $replaceArray = array_merge($replaceArray, array($newsletterUser->attribute('name'), $newsletterUser->attribute('salutation_name'), $newsletterUser->attribute('first_name'), $newsletterUser->attribute('last_name')));
         }
     }
     return str_replace($searchArray, $replaceArray, $content);
 }
 /**
  *
  * @param unknown_type $emailSearch
  * @return array
  */
 static function fetchUserListCount($emailSearch)
 {
     $count = CjwNewsletterUser::fetchListCount($emailSearch);
     return array('result' => $count);
 }
Beispiel #4
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
Beispiel #5
0
    if ($contextCreateNewsletterUser === true && $redirectUrlStore === false) {
        $newNewsletterUserObject = CjwNewsletterUser::fetchByEmail($subscriptionDataArr['email']);
        if (is_object($newNewsletterUserObject)) {
            $redirectUrlStore = '/newsletter/user_view/' . $newNewsletterUserObject->attribute('id');
        }
    } elseif ($redirectUrlStore === false) {
        $redirectUrlStore = '/newsletter/user_list/';
    }
    // if all is ok
    $module->redirectTo($redirectUrlStore);
} elseif ($module->isCurrentAction('Cancel')) {
    if ($redirectUrlCancel === false) {
        $redirectUrlCancel = '/newsletter/user_list/';
    }
    $module->redirectTo($redirectUrlCancel);
}
//$newsletterUserObject = CjwNewsletterUser::fetch( $newsletterUserId );
$tpl->setVariable('add_subscription_for_list_id', $addSubscriptionForListId);
$tpl->setVariable('newsletter_user_subscription_array', $newsletter_user_subscription_array);
$tpl->setVariable('subscription_data_array', $subscriptionDataArr);
$tpl->setVariable('newsletter_user_id', $newsletterUserId);
$tpl->setVariable('warning_array', $warningArr);
$tpl->setVariable('message_feedback', $messageFeedback);
$tpl->setVariable('newsletter_user', $newsletterUserObject);
$tpl->setVariable('available_salutation_array', CjwNewsletterUser::getAvailableSalutationNameArrayFromIni());
$tpl->setVariable('redirect_url_action_cancel', $redirectUrlCancel);
$tpl->setVariable('redirect_url_action_store', $redirectUrlStore);
$Result = array();
//$Result[ 'ui_context' ] = 'edit';
$Result['content'] = $tpl->fetch($templateFile);
$Result['path'] = array(array('url' => false, 'text' => ezi18n('cjw_newsletter/path', 'Newsletter')), array('url' => false, 'text' => ezi18n('cjw_newsletter/user_list', 'Users')), array('url' => false, 'text' => $newsletterUserObject->attribute('name')));
 /**
  * fetch current data from contentobject for use in newsletter user object
  * @return array if success , false if user_account is not found in dataMap
  */
 private function fetchCurrentContentObjectData(&$contentObjectAttribute)
 {
     $http = eZHTTPTool::instance();
     // mapping of user data from contentobject for the newsletter user
     // the current object must be a User!!!
     $contentObject = $contentObjectAttribute->attribute('object');
     $contentObjectCurrentVersionId = (int) $contentObjectAttribute->attribute('version');
     $contentObjectIsPublished = $contentObject->attribute('is_published');
     // only for user/register  if version = 1 and published = false
     // don't fetch existing nl user because
     // otherwise you will see his registration
     $isNewObjectDraft = false;
     if ($contentObjectCurrentVersionId == 1 && $contentObjectIsPublished == false) {
         $isNewObjectDraft = true;
     }
     $dataMap = $contentObject->attribute('data_map');
     $userAccount = null;
     $subscriptionDataArr = array('ez_user_id' => 0, 'email' => '', 'salutation' => 0, 'first_name' => '', 'last_name' => '', 'id_array' => array(), 'list_array' => array());
     if (isset($dataMap['user_account'])) {
         $userAccount = $dataMap['user_account'];
     } else {
         return false;
     }
     if (isset($dataMap['salutation'])) {
         $subscriptionDataArr['salutation'] = (int) $dataMap['salutation']->content();
     }
     if (isset($dataMap['first_name'])) {
         $subscriptionDataArr['first_name'] = $dataMap['first_name']->content();
     }
     if (isset($dataMap['last_name'])) {
         $subscriptionDataArr['last_name'] = $dataMap['last_name']->content();
     }
     if (is_object($userAccount)) {
         $userAccountContent = $userAccount->content();
         // we are fetching the email directly from Post because we need this for checking
         // $subscriptionDataArr['email'] = $userAccountContent->attribute( 'email' );
         // has the value stored in db but not this from Post => onPublish has the Post value
         // only need for email
         // only in edit mode
         $base = 'ContentObjectAttribute';
         if ($http->hasPostVariable($base . "_data_user_email_" . $userAccount->attribute("id"))) {
             $subscriptionDataArr['email'] = $http->postVariable($base . "_data_user_email_" . $userAccount->attribute("id"));
         } else {
             $subscriptionDataArr['email'] = $userAccountContent->attribute('email');
         }
         $subscriptionDataArr['ez_user_id'] = (int) $userAccountContent->attribute('contentobject_id');
         // is_eabled is modified in user/register after this call
         // so we can't use this here
         //$newsletterUserDataArray['ez_user_is_enabled'] = $userAccount->attribute( 'is_enabled' );
     }
     if ($http->hasPostVariable('Subscription_IdArray')) {
         $subscriptionDataArr['id_array'] = $http->postVariable('Subscription_IdArray');
     }
     if ($http->hasPostVariable('Subscription_ListArray')) {
         $subscriptionDataArr['list_array'] = $http->postVariable('Subscription_ListArray');
     }
     foreach ($subscriptionDataArr['id_array'] as $listId) {
         if ($http->hasPostVariable("Subscription_OutputFormatArray_{$listId}")) {
             $subscriptionDataArr['list_output_format_array'][$listId] = $http->postVariable("Subscription_OutputFormatArray_{$listId}");
         } else {
             $defaultOutputFormatId = 0;
             $subscriptionDataArr['list_output_format_array'][$listId] = array($defaultOutputFormatId);
         }
     }
     if ($isNewObjectDraft === true) {
         $existingNewsletterUser = false;
     } elseif ($subscriptionDataArr['ez_user_id'] > 0) {
         $existingNewsletterUser = CjwNewsletterUser::fetchByEzUserId($subscriptionDataArr['ez_user_id']);
         if (is_object($existingNewsletterUser) === false) {
             if ($subscriptionDataArr['email'] != '') {
                 $existingNewsletterUser = CjwNewsletterUser::fetchByEmail($subscriptionDataArr['email']);
             }
         }
     } elseif ($subscriptionDataArr['email'] != '') {
         $existingNewsletterUser = CjwNewsletterUser::fetchByEmail($subscriptionDataArr['email']);
     } else {
         $existingNewsletterUser = false;
     }
     $returnArray = array('is_new_object_draft' => $isNewObjectDraft, 'subscription_data_array' => $subscriptionDataArr, 'existing_newsletter_user' => $existingNewsletterUser);
     // var_dump( $returnArray );
     return $returnArray;
 }
 /**
  * saved parsed infos from ezcMailObject into database
  *
  * @param $parsedResult
  */
 private function saveParsedInfos($parsedResult)
 {
     $this->setAttribute('email_from', $parsedResult['from']);
     $this->setAttribute('email_to', $parsedResult['to']);
     $this->setAttribute('email_subject', $parsedResult['subject']);
     $this->setAttribute('bounce_code', $parsedResult['error_code']);
     //$this->setAttribute( 'final_recipient', $parsedResult[ 'final_recipient' ] );
     $this->setAttribute('email_send_date', $this->convertEmailSendDateToTimestamp($parsedResult['email_send_date']));
     // if x-cjwnl-senditem hash was set in bounce mail than fetch some ez data
     if (isset($parsedResult['x-cjwnl-senditem'])) {
         $sendItemHash = $parsedResult['x-cjwnl-senditem'];
         // try to fetch edition send item object
         $sendItemObject = CjwNewsletterEditionSendItem::fetchByHash($sendItemHash, true);
         if (is_object($sendItemObject)) {
             $newsletterUserId = $sendItemObject->attribute('newsletter_user_id');
             $editionSendId = $sendItemObject->attribute('edition_send_id');
             $editionSendItemId = $sendItemObject->attribute('id');
             $this->setAttribute('newsletter_user_id', $newsletterUserId);
             $this->setAttribute('edition_send_id', $editionSendId);
             $this->setAttribute('edition_send_item_id', $editionSendItemId);
             if ($this->isBounce()) {
                 $sendItemObject->setBounced();
                 $newsletterUser = $sendItemObject->attribute('newsletter_user_object');
                 if (is_object($newsletterUser)) {
                     // bounce nl user
                     $isHardBounce = false;
                     $newsletterUser->setBounced($isHardBounce);
                 }
             }
         }
     } elseif (isset($parsedResult['x-cjwnl-user'])) {
         $newsletterUser = CjwNewsletterUser::fetchByHash($sendItemHash, true);
         if (is_object($sendItemObject)) {
             $newsletterUserId = $newsletterUser->attribute('id');
             $this->setAttribute('newsletter_user_id', $newsletterUserId);
             if ($this->isBounce()) {
                 // bounce nl user
                 $isHardBounce = false;
                 $newsletterUser->setBounced($isHardBounce);
             }
         }
     }
     CjwNewsletterLog::writeDebug('parse_result CjwNewsletterMailboxItem::saveParsedInfos', 'mailbox_item', $this->attribute('id'), $parsedResult);
     // item is parsed
     $this->setAttribute('processed', time());
     $this->store();
 }
Beispiel #8
0
        $subscriptionDataArray['last_name'] = trim($http->postVariable('Subscription_LastName'));
    }
    if ($http->hasPostVariable('Subscription_Salutation')) {
        $subscriptionDataArray['salutation'] = trim($http->postVariable('Subscription_Salutation'));
    }
    if ($http->hasPostVariable('Subscription_IdArray')) {
        $subscriptionDataArray['id_array'] = $http->postVariable('Subscription_IdArray');
    }
    if ($http->hasPostVariable('Subscription_ListArray')) {
        $subscriptionDataArray['list_array'] = $http->postVariable('Subscription_ListArray');
    }
    // $subscriptionDataArr['list_output_format_array'] = array();
    foreach ($subscriptionDataArray['id_array'] as $listId) {
        if ($http->hasPostVariable("Subscription_OutputFormatArray_{$listId}")) {
            $subscriptionDataArray['list_output_format_array'][$listId] = $http->postVariable("Subscription_OutputFormatArray_{$listId}");
        } else {
            $defaultOutputFormatId = 0;
            $subscriptionDataArray['list_output_format_array'][$listId] = array($defaultOutputFormatId);
        }
    }
    // TODO
    // required fields
    // update subscribe/ remove supscripions
    $subscriptionResultArray = CjwNewsletterSubscription::createSubscriptionByArray($subscriptionDataArray, CjwNewsletterUser::STATUS_PENDING, $subscribeOnlyMode = false, $context = 'configure');
    $tpl->setVariable('changes_saved', true);
}
$newsletterUser = CjwNewsletterUser::fetchByHash($Params['UserHash']);
$tpl->setVariable('newsletter_user', $newsletterUser);
$Result = array();
$Result['content'] = $tpl->fetch('design:newsletter/configure.tpl');
$Result['path'] = array(array('url' => false, 'text' => ezi18n('cjw_newsletter/configure', 'Configure newsletter settings')));
Beispiel #9
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);
//  ezuser, anonym oder per hash
$templateFile = "design:newsletter/subscribe_infomail.tpl";
$warningArr = array();
if ($module->isCurrentAction('SubscribeInfoMail')) {
    if ($module->hasActionParameter('Email')) {
        $backUrl = '/';
        if ($module->hasActionParameter('BackUrl')) {
            $backUrl = $module->actionParameter('BackUrl');
        }
        // Wenn email ok
        // Wenn user existiert zu email
        // infomail schicken
        $email = $module->actionParameter('Email');
        if (eZMail::validate($email)) {
            // ansonsten tue nix
            $newsletterUser = CjwNewsletterUser::fetchByEmail($email);
            if ($newsletterUser) {
                $sendResult = $newsletterUser->sendSubcriptionInformationMail();
            }
            // immer erfolgstemplate zeigen auch wenn email falsch ist
            $tpl->setVariable('email_input', $email);
            $tpl->setVariable('back_url_input', $backUrl);
            $templateFile = "design:newsletter/subscribe_infomail_success.tpl";
        } else {
            $warningArr[] = array('field_key' => ezi18n('cjw_newsletter/subscribe_infomail', 'email'), 'message' => ezi18n('cjw_newsletter/subscribe_infomail', 'Please input a valid e-mail address!'));
        }
    }
}
$tpl->setVariable('warning_array', $warningArr);
$Result = array();
//$Result['content'] = $tpl->fetch( "design:newsletter/subscribe.tpl" );
Beispiel #11
0
            if (count($warningArr) == 0) {
                // subscribe to all selected lists
                $subscriptionResultArray = CjwNewsletterSubscription::createSubscriptionByArray($subscriptionDataArr, CjwNewsletterUser::STATUS_PENDING, true, $context);
                $newNewsletterUser = CjwNewsletterUser::fetchByEmail($subscriptionDataArr['email']);
                $mailSendResult = $newNewsletterUser->sendSubcriptionConfirmationMail();
                $tpl->setVariable('user_email_already_exists', false);
                $tpl->setVariable('mail_send_result', $mailSendResult);
                $tpl->setVariable('newsletter_user', $newNewsletterUser);
                $tpl->setVariable('subscription_result_array', $subscriptionResultArray);
                $tpl->setVariable('back_url_input', $backUrl);
                $templateFile = 'design:newsletter/subscribe_success.tpl';
            }
        }
    }
}
if ($user) {
    $tpl->setVariable('user', $user);
}
if (isset($existingNewsletterUserObject)) {
    $tpl->setVariable('newsletter_user', $existingNewsletterUserObject);
}
$tpl->setVariable('subscription_data_array', $subscriptionDataArr);
$tpl->setVariable('warning_array', $warningArr);
$salutationArray = CjwNewsletterUser::getAvailableSalutationNameArrayFromIni();
$tpl->setVariable('available_salutation_array', $salutationArray);
// for backwardcompatibility
$tpl->setVariable('available_saluation_array', $salutationArray);
$Result = array();
//$Result['content'] = $tpl->fetch( "design:newsletter/subscribe.tpl" );
$Result['content'] = $tpl->fetch($templateFile);
$Result['path'] = array(array('url' => false, 'text' => ezi18n('cjw_newsletter/path', 'Newsletter')), array('url' => false, 'text' => ezi18n('cjw_newsletter/subscribe', 'Subscription form')));
 /**
  * used by Newletter edition preview and newsletter cronjob process
  *
  * @param CjwNewsletterUser $newsletterUser
  * @return boolean
  */
 public function setExtraMailHeadersByNewsletterUser($newsletterUser)
 {
     if ($newsletterUser instanceof CjwNewsletterUser) {
         $this->setExtraMailHeader('receiver', $newsletterUser->attribute('email'));
         $this->setExtraMailHeader('user', $newsletterUser->attribute('hash'));
     } else {
         return false;
     }
 }
 *
 * @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 cronjobs
 * @filesource
 */
// to fetch instance in Cli mode for separate logdata, cause access rights phpcli + webserver
$logInstance = CjwNewsletterLog::getInstance(true);
$message = "START: cjw_newsletter_mailqueue_create";
$cli->output($message);
// before we create the edition_send_items we will activate all nl_user with statua 20 - CjwNewlsetterUser::STATUS_PENDING_EZ_USER_REGISTER
$message = "--\n>> START: check nl users with status STATUS_PENDING_EZ_USER_REGISTER";
$cli->output($message);
$pendingNlUserObjectArray = CjwNewsletterUser::fetchUserListByStatus(CjwNewsletterUser::STATUS_PENDING_EZ_USER_REGISTER, 10000, 0, true);
$message = ">>> NlUser Objects with STATUS_PENDING_EZ_USER_REGISTER found: " . count($pendingNlUserObjectArray);
$cli->output($message);
$nlUserCounter = 1;
foreach ($pendingNlUserObjectArray as $nlUser) {
    $ezUserObject = $nlUser->attribute('ez_user');
    $nlUserId = $nlUser->attribute('id');
    $nlUserEzUserId = $nlUser->attribute('ez_user_id');
    if (is_object($ezUserObject)) {
        $ezUserIsEnabled = $ezUserObject->attribute('is_enabled');
        // if activated then confirm nl user
        if ($ezUserIsEnabled) {
            $message = "+ [{$nlUserCounter}][NL_USER][{$nlUserId}] eZUser {$nlUserEzUserId} is enabled => confirm nl user";
            $cli->output($message);
            // confirm user and all oben subscriptions
            $nlUser->confirmAll();
Beispiel #14
0
    $viewParameters = array_merge($viewParameters, $Params['UserParameters']);
}
$tpl->setVariable('view_parameters', $viewParameters);
// validate data if new user will be created
if ($module->isCurrentAction('CreateEdit')) {
    $newsletterUserId = -1;
    $msg = 'edit_new';
    $requiredSubscriptionFields = array('email');
    foreach ($requiredSubscriptionFields as $fieldName) {
        switch ($fieldName) {
            case 'email':
                if (!eZMail::validate($subscriptionDataArr['email']) || $subscriptionDataArr['email'] == '') {
                    $warningArr['email'] = array('field_key' => ezi18n('cjw_newsletter/subscription', 'Email'), 'message' => ezi18n('cjw_newsletter/subscription', 'You must provide a valid email address.'));
                } else {
                    // check if email already exists
                    $existingNewsletterUserObject = CjwNewsletterUser::fetchByEmail($subscriptionDataArr['email']);
                    if (is_object($existingNewsletterUserObject)) {
                        // If email exists redirect to user_edit
                        $newsletterUserId = $existingNewsletterUserObject->attribute('id');
                        $msg = 'edit_existing';
                        /*   $warningArr['email'] = array( 'field_key'   => ezi18n( 'cjw_newsletter/subscription', 'Email' ),
                             'message'     => ezi18n( 'cjw_newsletter/subscription', 'Email is already used by an other newsletter user.' ) );
                             */
                    }
                }
                break;
            default:
        }
    }
    // only store changes if all is ok
    if ($module->isCurrentAction('CreateEdit') && count($warningArr) == 0) {
 /**
  * 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;
     }
 }
             $userObject->setAttribute('custom_data_text_4', $customDataText4);
         }
         $userObject->setAttribute('status', CjwNewsletterUser::STATUS_CONFIRMED);
         $userObject->setAttribute('import_id', $importId);
         // set new remote_id
         if ($remote_id !== false) {
             $userObject->setAttribute('remote_id', $remote_id);
         } else {
             $userObject->setAttribute('remote_id', 'cjwnl:csvimport:' . CjwNewsletterUtils::generateUniqueMd5Hash($userObject->attribute('id')));
         }
         $userObject->store();
         $newUserStatus = $userObject->attribute('status');
     }
 } else {
     $createNewUser = 1;
     $userObject = CjwNewsletterUser::createUpdateNewsletterUser($email, $salutation, $firstName, $lastName, $eZUserId, CjwNewsletterUser::STATUS_CONFIRMED, 'default', $customDataText1, $customDataText2, $customDataText3, $customDataText4);
     $userObject->setAttribute('import_id', $importId);
     // set new remote_id
     if ($remote_id !== false) {
         $userObject->setAttribute('remote_id', $remote_id);
     } else {
         $userObject->setAttribute('remote_id', 'cjwnl:csvimport:' . CjwNewsletterUtils::generateUniqueMd5Hash($userObject->attribute('id')));
     }
     $userObject->store();
     $newUserStatus = $userObject->attribute('status');
 }
 $newsletterUserId = $userObject->attribute('id');
 $outputFormatArray = $selectedOutputFormatArray;
 // only user which are not blacklisted can get a new subscription
 if ($newsletterUserId != null && $userIsBlacklistedOrRemoved === false) {
     $existingSubscription = CjwNewsletterSubscription::fetchByListIdAndNewsletterUserId($listContentObjectId, $newsletterUserId);
 /**
  *
  * @return unknown_type
  */
 function getNewsletterUserObject()
 {
     return CjwNewsletterUser::fetch($this->attribute('newsletter_user_id'));
 }
 /**
  * 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;
     }
 }
 /**
  * check if $email and $ezUserId can update/create
  * negative value fail
  * @see CjwNewsletterSubscription::createSubscriptionByArray
  */
 public static function checkIfUserCanBeUpdated($email, $ezUserId, $updateNewEmail = false)
 {
     // TODO cache fetches
     // check if new email exists in the system
     $idNlUser = CjwNewsletterUser::fetchByEzUserId($ezUserId);
     $emailNlUser = CjwNewsletterUser::fetchByEmail($email);
     $idNlUserEmail = false;
     $idNlUserEzUserId = 0;
     $idNlUserId = 0;
     $idNlUserExists = false;
     $emailNlUserEmail = false;
     $emailNlUserEzUserId = 0;
     $emailNlUserId = 0;
     $emailNlUserExists = false;
     if (is_object($idNlUser)) {
         $idNlUserEmail = strtolower(trim($idNlUser->attribute('email')));
         $idNlUserEzUserId = $idNlUser->attribute('ez_user_id');
         $idNlUserId = $idNlUser->attribute('id');
         if ($idNlUserEzUserId > 0) {
             $idNlUserExists = true;
         }
     } else {
         if ($ezUserId > 0) {
             $idNlUserEzUserId = $ezUserId;
         }
     }
     if (is_object($emailNlUser)) {
         $emailNlUserEmail = strtolower(trim($emailNlUser->attribute('email')));
         $emailNlUserEzUserId = $emailNlUser->attribute('ez_user_id');
         $emailNlUserId = $emailNlUser->attribute('id');
         $emailNlUserExists = true;
     } else {
         $emailNlUserEmail = $email;
     }
     // new user => email + ezUserId not found in any nl user objects  => 40
     // update user => ezUserId == 0 or found + email not found + email1 == email2 => 41
     // update user with new email => ez_user_id found + email1 != email2 => 42
     $returnStatus = -1;
     $returnObject = false;
     // email is already used by an other nl_user with other ez_user_id
     if ($emailNlUserExists && $emailNlUserEmail != $idNlUserEmail && $emailNlUserEzUserId != $idNlUserEzUserId) {
         $returnStatus = -20;
     } elseif (!$idNlUserExists && !$emailNlUserExists && $emailNlUserEmail == '') {
         $returnStatus = -21;
     } elseif (!$idNlUserExists && !$emailNlUserExists && $emailNlUserEmail != '') {
         $returnStatus = 40;
     } elseif ($idNlUserExists && $emailNlUserExists && $idNlUserId == $emailNlUserId) {
         $returnStatus = 41;
     } elseif ($idNlUserExists && !$emailNlUserExists && $emailNlUserEmail != '') {
         $returnStatus = 42;
         if ($updateNewEmail === true) {
             // check if email has is not set by an other user
             // this could happend when the nl user is imported
             // check this in where the user can change the email address
             // for example in datatype validation
             $idNlUser->setAttribute('email', $emailNlUserEmail);
             $idNlUser->store();
         }
     }
     /*
              echo "ezUserId = $ezUserId <br>
     idNlUserEmail = $idNlUserEmail <br>
     idNlUserId = $idNlUserId <br>
     idNlUserEzUserId = $idNlUserEzUserId <br>
     idNlUserExists = $idNlUserExists <br><hr>
     
     email = $email<br>
     emailNlUserEmail = $emailNlUserEmail<br>
     emailNlUserId = $emailNlUserId <br>
     emailNlUserEzUserId = $emailNlUserEzUserId<br>
     emailNlUserExists = $emailNlUserExists<br>
     <hr> return stratus = $returnStatus <hr>";
     */
     //
     return $returnStatus;
 }
Beispiel #20
0
$filterArray = array();
//
// filter examples
//
//$filterArray[] = array( 'cjwnl_user.email' => array( 'OR', array( 'like', '%@%' ), array( 'like', '%abc@%' ) ) );
//$filterArray[] = array( 'cjwnl_user.email' => array( 'OR', array( 'AND', 'woldt', 'acd'  ), array( 'like', '%abc@%' ) ) );
//$filterArray[] = array( 'cjwnl_user.last_name' => array( array( 'woldt', 'acd' ) ) );
//$filterArray[] = array( 'cjwnl_user.last_name' => array( 'AND', 'woldt', 'acd'  ) );
//$filterArray[] = array( 'cjwnl_subscription.list_contentobject_id' => array(  array( 132 , 109 ) ) );
//$filterArray[] = array( 'cjwnl_subscription.status' => CjwNewsletterSubscription::STATUS_APPROVED );
//$filterArray[] = array( 'cjwnl_user.email' =>  array( 'like', '%@%.de' ) );
// get wanted user email and filter by itself
if ($http->hasVariable('SearchUserEmail')) {
    $searchUserEmail = trim($db->escapeString($http->variable('SearchUserEmail')));
    $filterArray[] = array('cjwnl_user.email' => array('like', $searchUserEmail));
}
// AND - all filter should match
// OR - 1 one the filter should be match
// AND-NOT - none of the filter should be matched
$userListSearch = CjwNewsletterUser::fetchUserListByFilter($filterArray, $limit, $offset);
$tpl->setVariable('user_list', $userListSearch);
$tpl->setVariable('user_list_count', count($userListSearch));
$viewParameters = array('offset' => 0, 'namefilter' => '');
$searchParameters = array('search_user_email' => $searchUserEmail);
$userParameters = $Params['UserParameters'];
$viewParameters = array_merge($viewParameters, $userParameters);
$viewParameters = array_merge($viewParameters, $searchParameters);
$tpl->setVariable('view_parameters', $viewParameters);
$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/user_list', 'Users')));
 /**
  * count all nl user objects which has the import_id of this object and which has status Confirmed
  * @return unknown_type
  */
 function getImportedUserCountLiveConfirmed()
 {
     return CjwNewsletterUser::fetchUserListByImportIdAndStatusCount($this->attribute('id'), CjwNewsletterUser::STATUS_CONFIRMED);
 }
 /**
  * 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;
     }
 }
         if ($firstName != '') {
             $userObject->setAttribute('first_name', $firstName);
         }
         if ($lastName != '') {
             $userObject->setAttribute('last_name', $lastName);
         }
         $userObject->setAttribute('status', CjwNewsletterUser::STATUS_CONFIRMED);
         $userObject->setAttribute('import_id', $importId);
         // set new remote_id
         $userObject->setAttribute('remote_id', 'cjwnl:csvimport:' . CjwNewsletterUtils::generateUniqueMd5Hash($userObject->attribute('id')));
         $userObject->store();
         $newUserStatus = $userObject->attribute('status');
     }
 } else {
     $createNewUser = 1;
     $userObject = CjwNewsletterUser::createUpdateNewsletterUser($email, $salutation, $firstName, $lastName, $eZUserId, CjwNewsletterUser::STATUS_CONFIRMED);
     $userObject->setAttribute('import_id', $importId);
     // set new remote_id
     $userObject->setAttribute('remote_id', 'cjwnl:csvimport:' . CjwNewsletterUtils::generateUniqueMd5Hash($userObject->attribute('id')));
     $userObject->store();
     $newUserStatus = $userObject->attribute('status');
 }
 $newsletterUserId = $userObject->attribute('id');
 $outputFormatArray = $selectedOutputFormatArray;
 // only user which are not blacklisted can get a new subscription
 if ($newsletterUserId != null && $userIsBlacklistedOrRemoved === false) {
     $existingSubscription = CjwNewsletterSubscription::fetchByListIdAndNewsletterUserId($listContentObjectId, $newsletterUserId);
     // if subscription exists do nothing
     if (is_object($existingSubscription)) {
         $existingSubscriptionStatus = $existingSubscription->attribute('status');
         // if user has removed a subscription by himself