/**
  * Create new CjwNewsletterSubscription object
  *
  * @param integer $listContentObjectId
  * @param integer $newsletterUserId
  * @param array $outputFormatArray
  * @param unknown_type $status
  * @return object
  */
 static function create($listContentObjectId, $newsletterUserId, $outputFormatArray, $status = CjwNewsletterSubscription::STATUS_PENDING, $context = 'default')
 {
     $rows = array('created' => time(), 'list_contentobject_id' => $listContentObjectId, 'newsletter_user_id' => $newsletterUserId, 'output_format_array_string' => CjwNewsletterSubscription::arrayToString($outputFormatArray), 'creator_contentobject_id' => eZUser::currentUserID(), 'hash' => CjwNewsletterUtils::generateUniqueMd5Hash($newsletterUserId), 'remote_id' => 'cjwnl:' . $context . ':' . CjwNewsletterUtils::generateUniqueMd5Hash($newsletterUserId), 'status' => 0);
     $object = new CjwNewsletterSubscription($rows);
     // set status again so automatic status change is working
     $object->setAttribute('status', $status);
     return $object;
 }
예제 #2
0
 /**
  * create a new import set
  *
  * @param string $type import type e.g. csv
  * @param string $note personal note for import
  * @param string $dataText here you can store what you want
  * @param string $remoteId unique number to identify importset
  * @return object / false if not create
  */
 public static function create($listContentObjectId, $type = 'default', $note = '', $dataText = '', $remoteId = false)
 {
     if ($remoteId === false) {
         $remoteId = $type . ':' . CjwNewsletterUtils::generateUniqueMd5Hash($listContentObjectId);
     }
     $row = array('list_contentobject_id' => $listContentObjectId, 'type' => $type, 'created' => time(), 'creator_contentobject_id' => eZUser::currentUserID(), 'note' => $note, 'data_text' => $dataText, 'remote_id' => $remoteId);
     $newObject = new CjwNewsletterImport($row);
     return $newObject;
 }
 /**
  *
  * @param integer $editionSendId
  * @param integer $newsletterUserId
  * @param integer $outputFormatId
  * @param integer $subscriptionId
  * @return object / boolean
  */
 static function create($editionSendId, $newsletterUserId, $outputFormatId, $subscriptionId)
 {
     $existingObject = CjwNewsletterEditionSendItem::fetchBySendIdAndNewsletterUserIdAndOutputFormatId($editionSendId, $newsletterUserId, $outputFormatId);
     if (is_object($existingObject)) {
         // object exists - create no douple items
         return false;
     } else {
         $rows = array('edition_send_id' => (int) $editionSendId, 'newsletter_user_id' => (int) $newsletterUserId, 'output_format_id' => (int) $outputFormatId, 'subscription_id' => (int) $subscriptionId, 'hash' => CjwNewsletterUtils::generateUniqueMd5Hash($editionSendId . '-' . $newsletterUserId));
         $object = new CjwNewsletterEditionSendItem($rows);
         $object->setAttribute('status', CjwNewsletterEditionSendItem::STATUS_NEW);
         $object->store();
         return $object;
     }
 }
 /**
  * Create new CjwNewsletterEditionSend object
  *
  * @param CjwNewsletterEdition $editionObject
  * @return object
  */
 static function create(CjwNewsletterEdition $editionObject)
 {
     $editionContentObjectId = $editionObject->attribute('contentobject_id');
     $editionContentObjectVersion = $editionObject->attribute('contentobject_attribute_version');
     $user = eZUser::currentUser();
     $creatorId = $user->attribute('contentobject_id');
     // $outputXml = '<xml>hali hallo</xml>';
     $outputXml = $editionObject->createOutputXml();
     $listAttributeContent = $editionObject->attribute('list_attribute_content');
     $listContentObjectId = $listAttributeContent->attribute('contentobject_id');
     $outputFormatArrayString = $listAttributeContent->attribute('output_format_array_string');
     $mainSiteAccess = $listAttributeContent->attribute('main_siteaccess');
     $emailSender = $listAttributeContent->attribute('email_sender');
     $emailSenderName = $listAttributeContent->attribute('email_sender_name');
     $personalizeContent = $listAttributeContent->attribute('personalize_content');
     $rows = array('list_contentobject_id' => $listContentObjectId, 'edition_contentobject_id' => $editionContentObjectId, 'edition_contentobject_version' => $editionContentObjectVersion, 'siteaccess' => $mainSiteAccess, 'output_format_array_string' => $outputFormatArrayString, 'created' => time(), 'creator_id' => $creatorId, 'status' => CjwNewsletterEditionSend::STATUS_WAIT_FOR_PROCESS, 'output_xml' => $outputXml, 'hash' => CjwNewsletterUtils::generateUniqueMd5Hash($listContentObjectId . $editionContentObjectId . $editionContentObjectVersion), 'email_sender' => $emailSender, 'email_sender_name' => $emailSenderName, 'personalize_content' => $personalizeContent);
     $object = new CjwNewsletterEditionSend($rows);
     return $object;
 }
 /**
  * Create new CjwNewsletterEditionSend object
  *
  * @param CjwNewsletterEdition $editionObject
  * @return object
  */
 static function create(CjwNewsletterEdition $editionObject, $schedule = null)
 {
     $editionContentObjectId = $editionObject->attribute('contentobject_id');
     $editionContentObjectVersion = $editionObject->attribute('contentobject_attribute_version');
     $user = eZUser::currentUser();
     $creatorId = $user->attribute('contentobject_id');
     // $outputXml = '<xml>hali hallo</xml>';
     $outputXml = $editionObject->createOutputXml();
     $listAttributeContent = $editionObject->attribute('list_attribute_content');
     $listContentObjectId = $listAttributeContent->attribute('contentobject_id');
     $listContentObjectVersion = $listAttributeContent->attribute('contentobject_attribute_version');
     $listIsVirtual = $listAttributeContent->attribute('is_virtual');
     $outputFormatArrayString = $listAttributeContent->attribute('output_format_array_string');
     $mainSiteAccess = $listAttributeContent->attribute('main_siteaccess');
     $emailSender = $listAttributeContent->attribute('email_sender');
     $emailSenderName = $listAttributeContent->attribute('email_sender_name');
     $emailReplyTo = $listAttributeContent->attribute('email_reply_to');
     $emailReturnPath = $listAttributeContent->attribute('email_return_path');
     $personalizeContent = $listAttributeContent->attribute('personalize_content');
     $rows = array('list_contentobject_id' => $listContentObjectId, 'list_contentobject_version' => $listContentObjectVersion, 'list_is_virtual' => $listIsVirtual, 'edition_contentobject_id' => $editionContentObjectId, 'edition_contentobject_version' => $editionContentObjectVersion, 'siteaccess' => $mainSiteAccess, 'output_format_array_string' => $outputFormatArrayString, 'created' => time(), 'creator_id' => $creatorId, 'status' => CjwNewsletterEditionSend::STATUS_WAIT_FOR_SCHEDULE, 'mailqueue_process_scheduled' => is_null($schedule) ? time() : $schedule, 'output_xml' => $outputXml, 'hash' => CjwNewsletterUtils::generateUniqueMd5Hash($listContentObjectId . $editionContentObjectId . $editionContentObjectVersion), 'email_sender' => $emailSender, 'email_sender_name' => $emailSenderName, 'email_reply_to' => $emailReplyTo, 'email_return_path' => $emailReturnPath, 'personalize_content' => $personalizeContent);
     $object = new CjwNewsletterEditionSend($rows);
     return $object;
 }
                    } else {
                        // 2 - update
                        $createNewSubscription = 2;
                        $subscriptionObject = $existingSubscription;
                        $subscriptionObject->setAttribute('status', CjwNewsletterSubscription::STATUS_APPROVED);
                        $subscriptionObject->setAttribute('import_id', $importId);
                        // set new remote_id
                        $subscriptionObject->setAttribute('remote_id', 'cjwnl:csvimport:' . CjwNewsletterUtils::generateUniqueMd5Hash($newsletterUserId . $importId));
                        $subscriptionObject->store();
                    }
                } else {
                    $createNewSubscription = 1;
                    $newListSubscription = CjwNewsletterSubscription::create($listContentObjectId, $newsletterUserId, $outputFormatArray, CjwNewsletterSubscription::STATUS_APPROVED);
                    $newListSubscription->setAttribute('import_id', $importId);
                    // set new remote_id
                    $newListSubscription->setAttribute('remote_id', 'cjwnl:csvimport:' . CjwNewsletterUtils::generateUniqueMd5Hash($newsletterUserId . $importId));
                    $newListSubscription->store();
                    $subscriptionObject = $newListSubscription;
                    $newSubscriptionStatus = $subscriptionObject->attribute('status');
                }
            }
        }
        $listSubscriptionArray[$rowId] = array('subscription_object' => $subscriptionObject, 'email_ok' => $emailOk, 'user_created' => $createNewUser, 'newsletter_user_id' => $newsletterUserId, 'subscription_created' => $createNewSubscription, 'user_status_old' => $existingUserStatus, 'user_status_new' => $newUserStatus, 'subscription_status_old' => $existingSubscriptionStatus, 'subscription_status_new' => $newSubscriptionStatus);
    }
    // imported timestamp + set count for imported users + subscriptions
    $importObject->setImported();
    CjwNewsletterLog::writeNotice('subscription_list_csvimport', 'import', 'end', array('import_id' => $importObject->attribute('id'), 'current_user' => eZUser::currentUserID()));
    // store result to File
    storeImportResultToFile($importId, $listSubscriptionArray);
}
//}
예제 #7
0
 /**
  * Create new CjwNewsletterUser object
  *
  * @param string $email
  * @param string $salutation
  * @param string $firstName
  * @param string $lastName
  * @param string $eZUserId
  * @param int $status
  * @param string $context
  * @param string $customDataText1
  * @param string $customDataText2
  * @param string $customDataText3
  * @param string $customDataText4
  * @return object
  */
 static function create($email, $salutation, $firstName, $lastName, $eZUserId, $status = CjwNewsletterUser::STATUS_PENDING, $context = 'default', $customDataText1, $customDataText2, $customDataText3, $customDataText4)
 {
     $rows = array('created' => time(), 'creator_contentobject_id' => eZUser::currentUserID(), 'ez_user_id' => $eZUserId, 'email' => $email, 'first_name' => $firstName, 'last_name' => $lastName, 'salutation' => $salutation, 'hash' => CjwNewsletterUtils::generateUniqueMd5Hash($email), 'remote_id' => 'cjwnl:' . $context . ':' . CjwNewsletterUtils::generateUniqueMd5Hash($email), 'status' => $status, 'custom_data_text_1' => $customDataText1, 'custom_data_text_2' => $customDataText2, 'custom_data_text_3' => $customDataText3, 'custom_data_text_4' => $customDataText4);
     $object = new CjwNewsletterUser($rows);
     return $object;
 }
예제 #8
0
        $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);
        break;
        // text
    // text
    case 1:
        $newsletterContent .= '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>newsletter - outputformat - text</title></head><body><pre>' . $newsletterContentArray['body']['text'] . '</pre></body></html>';
        break;
    default:
        return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$debug = 0;
if ($debug == 0) {
    header("Content-type: text/html");
    echo $newsletterContent;
    eZExecution::cleanExit();
 $sendItemList = CjwNewsletterEditionSendItem::fetchListSendIdAndStatus($editionSendId, CjwNewsletterEditionSendItem::STATUS_NEW, $limit, $offset);
 $count = count($sendItemList);
 foreach ($sendItemList as $sendItem) {
     $id = $sendItem->attribute('id');
     $outputFormatId = $sendItem->attribute('output_format_id');
     // ### get newsletter user data through send_item_object
     $newsletterUserObject = $sendItem->attribute('newsletter_user_object');
     $emailReceiver = $newsletterUserObject->attribute('email');
     $emailReceiverName = $newsletterUserObject->attribute('email_name');
     // fetch html & text content of parsed outputxml from senmdobject
     // data of outputformate
     $outputStringArray = $outputFormatStringArray[$outputFormatId]['body'];
     $emailSubject = $outputFormatStringArray[$outputFormatId]['subject'];
     $outputStringArrayNew = array('html' => '', 'text' => '');
     foreach ($outputStringArray as $index => $string) {
         $outputStringArrayNew[$index] = CjwNewsletterUtils::replaceNewsletterMarkers($string, $sendObject, $newsletterUserObject);
     }
     // set x-cjwnl header
     $cjwMail->resetExtraMailHeaders();
     $cjwMail->setExtraMailHeadersByNewsletterSendItem($sendItem);
     $resultArray = $cjwMail->sendEmail($emailSender, $emailSenderName, $emailReceiver, $emailReceiverName, $emailSubject, $outputStringArrayNew);
     $sendResult = $resultArray['send_result'];
     if ($sendResult === true) {
         // emal was send
         $progressMonitor->addEntry("[SEND] {$itemCounter}/{$itemsNotSend}", "Newsletter send item {$id} processed. ");
         // wenn ok als versendet markieren
         $sendItem->setAttribute('status', CjwNewsletterEditionSendItem::STATUS_SEND);
         $sendItem->store();
     } else {
         // error execption
         $exception = $resultArray['send_result'];