$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);
 /**
  * Synchronous registration / deregistration for several lists with an array
  * if id_array has more elements than list_array, than is a deregistration defined
  * the difference of id_array and list_array means that these elements shouldn't
  * has subscriptions
  *
  * $subscriptionDataArr = array();
  * $subscriptionDataArr['ez_user_id']
  * $subscriptionDataArr['salutation']
  * $subscriptionDataArr['first_name'] = $http->postVariable( 'Subscription_FirstName' );
  * $subscriptionDataArr['name'] = $http->postVariable( 'Subscription_Name' );
  * $subscriptionDataArr['email'] = $http->postVariable( 'Subscription_Email' );
  *
  * $subscriptionDataArr['id_array'] = $http->postVariable( 'Subscription_IdArray' );
  * $subscriptionDataArr['list_array'] = $http->postVariable( 'Subscription_ListArray' );
  * $subscriptionDataArr['list_output_format_array'] = $http->postVariable( 'Subscription_OutputFormatArray' );
  *
  * @param array $subscriptionDataArr
  * @param $newNewsletterUserStatus status for new created nl users e.g. CjwNewsletterUser::STATUS_PENDING
  * @param $subscribeOnlyMode if true than no subscription will be removed used if subscription is done as ez_user
  * @param $context subscribe | configure | user_edit | datatype_edit | datatype_collect | csvimport from which context the function is called
  * @return array
  */
 static function createSubscriptionByArray($subscriptionDataArr, $newNewsletterUserStatus = CjwNewsletterUser::STATUS_PENDING, $subscribeOnlyMode = false, $context = 'default')
 {
     $resultArray = array();
     $resultArray['list_subscribe'] = array();
     $resultArray['list_remove'] = array();
     $resultArray['errors'] = array();
     $email = $subscriptionDataArr['email'];
     if (isset($subscriptionDataArr['salutation'])) {
         $salutation = $subscriptionDataArr['salutation'];
     } else {
         $salutation = null;
     }
     $firstName = $subscriptionDataArr['first_name'];
     $lastName = $subscriptionDataArr['last_name'];
     $eZUserId = isset($subscriptionDataArr['ez_user_id']) ? (int) $subscriptionDataArr['ez_user_id'] : 0;
     // new value form POST
     $newEzUserId = $eZUserId;
     $newEmail = $email;
     // TODO return here the nl user object for update + status
     $checkResult = CjwNewsletterUser::checkIfUserCanBeUpdated($email, $eZUserId, $updateNewEmail = true);
     switch ($checkResult) {
         // create new user
         case 40:
             break;
             // update user
         // update user
         case 41:
             break;
             // update user with new mail
         // update user with new mail
         case 42:
             break;
         case -20:
         case -1:
             if ($context == 'subscribe') {
                 eZDebug::writeDebug("checkResult[{$checkResult}] - CjwNewsletterSubscription::createSubscriptionByArray return false because email already exists");
                 // break because a newsletter user with email exists
                 return false;
             }
             break;
     }
     $idArray = $subscriptionDataArr['id_array'];
     $listArray = $subscriptionDataArr['list_array'];
     $listOutputFormatArray = $subscriptionDataArr['list_output_format_array'];
     $newsletterUserObject = CjwNewsletterUser::createUpdateNewsletterUser($email, $salutation, $firstName, $lastName, $eZUserId, (int) $newNewsletterUserStatus, $context);
     $resultArray['newsletter_user_object'] = $newsletterUserObject;
     if (is_object($newsletterUserObject) === false) {
         return $resultArray['errors'] = "Can not create new newsletter user with {$email}";
     }
     $newsletterUserId = $newsletterUserObject->attribute('id');
     // list_subscribe
     foreach ($listArray as $listId) {
         $outputFormatArray = $listOutputFormatArray[$listId];
         $status = CjwNewsletterSubscription::STATUS_PENDING;
         $dryRun = false;
         $resultArray['list_subscribe'][$listId] = CjwNewsletterSubscription::createUpdateNewsletterSubscription($listId, $newsletterUserId, $outputFormatArray, $status, $dryRun, $context);
     }
     if ($subscribeOnlyMode === false) {
         $listRemoveArray = array_diff($idArray, $listArray);
         // list_remove by user self
         foreach ($listRemoveArray as $listId) {
             $resultArray['list_remove'][$listId] = CjwNewsletterSubscription::removeSubscriptionByNewsletterUserSelf($listId, $newsletterUserId);
         }
     }
     return $resultArray;
 }
         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