diff --git a/classes/cjwnewslettercsvparser.php b/classes/cjwnewslettercsvparser.php index 1f03960..6d21d25 100644 --- a/classes/cjwnewslettercsvparser.php +++ b/classes/cjwnewslettercsvparser.php @@ -53,22 +53,27 @@ function __construct( $csvFileName, $delimiter = ';' , $firstRowIsLabel = true, { $firstRowTmp = fgetcsv( $fp, 1000, $delimiter ); $c++; + $firstRow = array(); + foreach ( $csvFieldMappingArray as $key => $item ) + { + $firstRow[array_search($item, $firstRowTmp)] = $item; + } } // Loop file while ( ( $row = fgetcsv( $fp, 1000, $delimiter )) !== FALSE ) { - for ( $i=0; $i < count( $firstRow ); $i++ ) + foreach ( $firstRow as $key => $item ) { - if ( array_key_exists( $i, $row ) ) + if ( array_key_exists( $key, $row ) ) { if ( $utf8Encode !== FALSE ) { - $rowArray[ $c ] [ $firstRow[$i] ] = utf8_encode( $row[ $i ] ); + $rowArray[ $c ] [ $item ] = utf8_encode( $row[ $key ] ); } else { - $rowArray[ $c ] [ $firstRow[$i] ] = $row[ $i ]; + $rowArray[ $c ] [ $item ] = $row[ $key ]; } } } diff --git a/design/admin2/templates/cjw_newsletter_list_children.tpl b/design/admin2/templates/cjw_newsletter_list_children.tpl index ba0be9b..bf17e7c 100644 --- a/design/admin2/templates/cjw_newsletter_list_children.tpl +++ b/design/admin2/templates/cjw_newsletter_list_children.tpl @@ -176,6 +176,15 @@ edition_node_list_count = $children_count show_actions_colum = true()} +
+ {include name = 'Navigator' + uri = 'design:navigator/google.tpl' + page_uri = $node.url_alias + item_count = $children_count + view_parameters = $view_parameters + item_limit = $number_of_items} +
+ {def $viewmode_newsletter=true()} {* Else: there are no children. *} diff --git a/design/standard/templates/newsletter/subscription_list.tpl b/design/standard/templates/newsletter/subscription_list.tpl index 5512e90..417f96f 100644 --- a/design/standard/templates/newsletter/subscription_list.tpl +++ b/design/standard/templates/newsletter/subscription_list.tpl @@ -126,7 +126,7 @@ -
+
diff --git a/design/standard/templates/newsletter/subscription_list_csvexport.tpl b/design/standard/templates/newsletter/subscription_list_csvexport.tpl index d0936f3..12969e0 100644 --- a/design/standard/templates/newsletter/subscription_list_csvexport.tpl +++ b/design/standard/templates/newsletter/subscription_list_csvexport.tpl @@ -6,7 +6,7 @@
-
+
{* DESIGN: Header START *} diff --git a/design/standard/templates/newsletter/subscription_list_csvimport.tpl b/design/standard/templates/newsletter/subscription_list_csvimport.tpl index 8feffe4..2909bd6 100644 --- a/design/standard/templates/newsletter/subscription_list_csvimport.tpl +++ b/design/standard/templates/newsletter/subscription_list_csvimport.tpl @@ -285,6 +285,9 @@ list all blacklist items {'Email ok'|i18n( 'cjw_newsletter/subscription_list_csvimport' )} + + {'Statut'|i18n( 'cjw_newsletter/subscription_list_csvimport' )} + {'Nl user created'|i18n( 'cjw_newsletter/subscription_list_csvimport' )} @@ -367,6 +370,23 @@ list all blacklist items {$email_ok|wash()} {/if} + + {if $data_set.s_status|eq( '1' )} + {'Created'|i18n( 'cjw_newsletter/subscription_list_csvimport' )} + {elseif $data_set.s_status|eq( '2' )} + {'Updated'|i18n( 'cjw_newsletter/subscription_list_csvimport' )} + {elseif $data_set.s_status|eq( '0' )} + {'Pending'|i18n( 'cjw_newsletter/subscription_list_csvimport' )} + {elseif $data_set.s_status|eq( 3 )} + {'Removed by user'|i18n( 'cjw_newsletter/subscription/status' )} + {elseif $data_set.s_status|eq( 4 )} + {'Removed by admin'|i18n( 'cjw_newsletter/subscription/status' )} + {elseif $data_set.s_status|eq( 8 )} + {'Blacklisted'|i18n( 'cjw_newsletter/subscription/status' ) + {else} + {$user_created|wash()} + {/if} + {if $user_created|eq( '1' )} {'created'|i18n( 'cjw_newsletter/subscription_list_csvimport' )} @@ -461,4 +481,4 @@ list all blacklist items
-
\ No newline at end of file + diff --git a/modules/newsletter/module.php b/modules/newsletter/module.php index 8df6071..84f2575 100644 --- a/modules/newsletter/module.php +++ b/modules/newsletter/module.php @@ -164,6 +164,7 @@ 'script' => 'subscription_list_csvexport.php', 'functions' => array( 'subscription_list_csvexport' ), 'default_navigation_part' => 'eznewsletternavigationpart', + 'unordered_params' => array( 'status' => "Status" ), 'params' => array( 'NodeId' ) ); diff --git a/modules/newsletter/subscription_list_csvexport.php b/modules/newsletter/subscription_list_csvexport.php index dae515e..3036ce5 100644 --- a/modules/newsletter/subscription_list_csvexport.php +++ b/modules/newsletter/subscription_list_csvexport.php @@ -16,6 +16,8 @@ include_once( 'kernel/common/template.php' ); $module = $Params['Module']; +$Status = getStatusFromString($Params['Status']); + $http = eZHTTPTool::instance(); $nodeId = (int) $Params['NodeId']; @@ -73,7 +75,7 @@ * CSV Preview */ // preview for csv data export, fetch data with limit -$arrPreviewCsvData = getDataForCsv( $listContentObjectId, 10, $module ); +$arrPreviewCsvData = getDataForCsv( $listContentObjectId, 10, $module, $Status ); // create csv string for preview @@ -110,7 +112,7 @@ * Export */ // fetch data - $arrCsvData = getDataForCsv( $listContentObjectId, 0, $module ); + $arrCsvData = getDataForCsv( $listContentObjectId, 0, $module, $Status ); if ( $arrCsvData !== FALSE ) { @@ -142,6 +144,7 @@ $tpl = eZTemplate::factory(); $tpl->setVariable( 'view_parameters', $viewParameters ); +$tpl->setVariable( 'status', getStatusFromInt($Status) ); $tpl->setVariable( 'list_node', $listNode ); $tpl->setVariable( 'csv_delimiter', $delimiter ); $tpl->setVariable( 'arr_tables', $arrTables ); @@ -175,7 +178,7 @@ * @param integer $listContentObjectId * @return array with data */ -function getDataForCsv( $listContentObjectId, $limit = 0, $module = false ) +function getDataForCsv( $listContentObjectId, $limit = 0, $module = false, $Status = -1 ) { if ( isset( $listContentObjectId ) ) { @@ -210,10 +213,15 @@ function getDataForCsv( $listContentObjectId, $limit = 0, $module = false ) s.output_format_array_string FROM cjwnl_subscription s, cjwnl_user u - WHERE s.list_contentobject_id=$listContentObjectId - AND s.newsletter_user_id=u.id - $qryLimit"; + WHERE s.list_contentobject_id=$listContentObjectId"; + + if($Status != -1) + { + $qryGetData .= " AND s.status=$Status"; + } + $qryGetData .= " AND s.newsletter_user_id=u.id + $qryLimit"; // execute query $resQryGetData = $db->arrayQuery( $qryGetData ); @@ -235,4 +243,74 @@ function getDataForCsv( $listContentObjectId, $limit = 0, $module = false ) } } } -?> + +/** + * get status code from string + * + * @param string + * @return int + */ +function getStatusFromString($Status) +{ + if(!empty($Status)) { + switch ($Status) { + case 'pending': + return CjwNewsletterSubscription::STATUS_PENDING; + break; + case 'confirmed': + return CjwNewsletterSubscription::STATUS_CONFIRMED; + break; + case 'approved': + return CjwNewsletterSubscription::STATUS_APPROVED; + break; + case 'bounced': + return CjwNewsletterSubscription::STATUS_BOUNCED_HARD; + break; + case 'removed': + return CjwNewsletterSubscription::STATUS_REMOVED_SELF; + break; + case 'blacklisted': + return CjwNewsletterSubscription::STATUS_BLACKLISTED; + break; + default: + return null; + break; + } + } +} + +/** + * get string from status code + * + * @param integer + * @return string + */ +function getStatusFromInt($Status) +{ + if($Status>=0) { + switch ($Status) { + case CjwNewsletterSubscription::STATUS_PENDING: + return 'pending'; + break; + case CjwNewsletterSubscription::STATUS_CONFIRMED: + return 'confirmed'; + break; + case CjwNewsletterSubscription::STATUS_APPROVED: + return 'approved'; + break; + case CjwNewsletterSubscription::STATUS_BOUNCED_HARD: + return 'bounced'; + break; + case CjwNewsletterSubscription::STATUS_REMOVED_SELF: + return 'removed'; + break; + case CjwNewsletterSubscription::STATUS_BLACKLISTED: + return 'blacklisted'; + break; + default: + return ""; + break; + } + } +} +?> \ No newline at end of file diff --git a/modules/newsletter/subscription_list_csvimport.php b/modules/newsletter/subscription_list_csvimport.php index 897d2a0..741457a 100644 --- a/modules/newsletter/subscription_list_csvimport.php +++ b/modules/newsletter/subscription_list_csvimport.php @@ -59,7 +59,8 @@ $csvFieldMappingArray = array( 'email' => '', 'first_name' => '', 'last_name' => '', - 'salutation' => '' ); + 'salutation' => '', + 's_status' => ''); if ( $cjwNewsletterIni->hasVariable( 'NewsletterCsvImportSettings', 'CsvFieldMappingArray' ) ) { @@ -266,6 +267,10 @@ $customDataText4 = ''; if( isset( $item[ 'custom_data_text_4' ] ) ) $customDataText4 = $item[ 'custom_data_text_4' ]; + + $s_status = ''; + if ( isset( $item[ 's_status' ] ) ) + $s_status = $item[ 's_status' ]; $eZUserId = false; $newsletterUserId = 0; @@ -377,7 +382,14 @@ if ( $customDataText4 != '' ) $userObject->setAttribute( 'custom_data_text_4', $customDataText4 ); - $userObject->setAttribute( 'status', CjwNewsletterUser::STATUS_CONFIRMED ); + if ( $s_status == '4' ) + { + $userObject->setAttribute( 'status', CjwNewsletterUser::STATUS_REMOVED_ADMIN); + } else + { + $userObject->setAttribute( 'status', CjwNewsletterUser::STATUS_CONFIRMED); + } + $userObject->setAttribute( 'import_id', $importId ); // set new remote_id @@ -443,8 +455,15 @@ // 2 - update $createNewSubscription = 2; $subscriptionObject = $existingSubscription; - - $subscriptionObject->setAttribute( 'status', CjwNewsletterSubscription::STATUS_APPROVED ); + + if ( $s_status == '4' ) + { + $subscriptionObject->setAttribute( 'status', CjwNewsletterSubscription::STATUS_REMOVED_ADMIN ); + } + else + { + $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 ) ); @@ -460,6 +479,12 @@ $newsletterUserId, $outputFormatArray, CjwNewsletterSubscription::STATUS_APPROVED ); + + if ( $s_status == '4' ) + { + $newListSubscription->setAttribute( 'status', CjwNewsletterSubscription::STATUS_REMOVED_ADMIN ); + } + $newListSubscription->setAttribute( 'import_id', $importId ); // set new remote_id $newListSubscription->setAttribute( 'remote_id', 'cjwnl:csvimport:'. CjwNewsletterUtils::generateUniqueMd5Hash( $newsletterUserId . $importId ) ); diff --git a/settings/cjw_newsletter.ini b/settings/cjw_newsletter.ini index 9a39dd8..8647e49 100644 --- a/settings/cjw_newsletter.ini +++ b/settings/cjw_newsletter.ini @@ -122,7 +122,7 @@ AvailableFilterTypeClassArray[]=CjwNewsletterFilterTypeEmail # , ; \t | DefaultCsvDelimiter=; # true or false -DefaultFirstRowIsLabel=false +DefaultFirstRowIsLabel=true # true or false DefaultUtf8Encode=true