Skip to content

Commit

Permalink
Bugfix Import
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasKrais committed Dec 19, 2017
1 parent 7e9e4a4 commit c50cbce
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
23 changes: 16 additions & 7 deletions lib/multinewsletter_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,21 @@ public function save()
if (filter_var($this->getValue('email'), FILTER_VALIDATE_EMAIL) === false) {
$this->setValue('email', '');
}
$this->setValue('createdate', $this->getValue('createdate', date('Y-m-d H:i:s')));
$this->setValue('createip', $this->getValue('createip', $_SERVER['REMOTE_ADDR']));
$this->setValue('activationdate', $this->getValue('activationdate', null));
$this->setValue('updatedate', date('Y-m-d H:i:s'));
$this->setValue('updateip', $_SERVER['REMOTE_ADDR']);

if(!isset($this->data['createdate'])) {
$this->setValue('createdate', $this->getValue('createdate', date('Y-m-d H:i:s')));
}
if(!isset($this->data['createIP'])) {
$this->setValue('createIP', $this->getValue('createip', $_SERVER['REMOTE_ADDR']));
}
if(!isset($this->data['activationdate'])) {
$this->setValue('activationdate', $this->getValue('activationdate', null));
}
if(!isset($this->data['updatedate'])) {
$this->setValue('updatedate', date('Y-m-d H:i:s'));
}
if(!isset($this->data['updateIP'])) {
$this->setValue('updateIP', $_SERVER['REMOTE_ADDR']);
}

if (MultinewsletterMailchimp::isActive()) {
$Mailchimp = MultinewsletterMailchimp::factory();
Expand Down Expand Up @@ -284,7 +293,7 @@ class MultinewsletterUserList

/**
* Stellt die Daten des Benutzers aus der Datenbank zusammen.
* @param Array $user_ids Array mit UserIds aus der Datenbank.
* @param MultinewsletterUser[] $user_ids Array mit UserIds aus der Datenbank.
*/
public function __construct($user_ids)
{
Expand Down
4 changes: 2 additions & 2 deletions package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ page:
newsletter: { title: 'translate:multinewsletter_menu_versand', icon: rex-icon rex-icon-envelope }
user: { title: 'translate:multinewsletter_menu_user', icon: rex-icon rex-icon-user }
groups: { title: 'translate:multinewsletter_menu_groups', icon: rex-icon rex-icon-category }
config: { title: 'translate:multinewsletter_menu_config', icon: rex-icon rex-icon-system }
archive: { title: 'translate:multinewsletter_menu_archive', icon: rex-icon rex-icon-backup }
import: { title: 'translate:multinewsletter_menu_import', icon: rex-icon fa-download }
config: { title: 'translate:multinewsletter_menu_config', icon: rex-icon rex-icon-system }
help:
icon: rex-icon rex-icon-help
title: 'translate:multinewsletter_menu_help'
Expand All @@ -24,7 +25,6 @@ page:
templates: { title: 'translate:multinewsletter_help_chapter_template' }
updatehinweise: { title: 'translate:multinewsletter_help_chapter_updatehinweise' }
changelog: { title: 'translate:multinewsletter_help_chapter_changelog' }
import: { title: 'translate:multinewsletter_menu_import', icon: rex-icon fa-download }

requires:
redaxo: '>=5.1.0'
Expand Down
3 changes: 2 additions & 1 deletion pages/help.changelog.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<fieldset>
<legend>MultiNewsletter Changelog</legend>
<p>3.1.1 (NEXT)</p>
<p>3.1.1</p>
<ul>
<li>Englisches Backend hinzugefügts.</li>
<li>Bugfix: Import war seit Version 3.0.8 kaputt.</li>
<li>Bugfix: Update war in Version 3.1.0 kaputt.</li>
<li>Bugfix: Aktivierungslink war ohne E-Mailadresse.</li>
<li>Bugfix: SEO42 aus Beispieltemplate entfernt.</li>
Expand Down
25 changes: 15 additions & 10 deletions pages/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,35 @@
}
// Spalte "email" muss existieren
if($fields['email'] > -1) {
$multinewsletter_list = new MultinewsletterUserList(array());
$multinewsletter_list = new MultinewsletterUserList([]);
foreach($csv_users as $csv_user) {
if(filter_var(trim($csv_user[$fields['email']]), FILTER_VALIDATE_EMAIL) !== false) {
$multinewsletter_user = MultinewsletterUser::initByMail(strtolower($csv_user[$fields['email']]));
if($multinewsletter_user === FALSE) {
$multinewsletter_user = new MultinewsletterUser(0);
$multinewsletter_user->setValue('email', filter_var(trim($csv_user[$fields['email']]), FILTER_VALIDATE_EMAIL));
}

// Sprache
$user_clang = 0;
$user_clang_id = 0;
if($fields['clang'] > -1 && key_exists($csv_user[$fields['clang_id']], rex_clang::getAll())) {
$user_clang = $csv_user[$fields['clang']];
$user_clang_id = $csv_user[$fields['clang']];
}
else if($fields['clang_id'] > -1 && key_exists($csv_user[$fields['clang_id']], rex_clang::getAll())) {
$user_clang = $csv_user[$fields['clang_id']];
$user_clang_id = $csv_user[$fields['clang_id']];
}
else {
// Standardsprache
$user_clang = rex_config::get("d2u_helper", "default_lang", rex_clang::getStartId());
$user_clang_id = rex_config::get("d2u_helper", "default_lang", rex_clang::getStartId());
}
if(filter_var($user_clang, FILTER_VALIDATE_INT) !== false) {
if(filter_var($user_clang_id, FILTER_VALIDATE_INT) !== false) {
// Falls ID der Sprache im CSV festgelegt wurde
$multinewsletter_user->clang_id = filter_var($user_clang, FILTER_VALIDATE_INT);
$multinewsletter_user->clang_id = filter_var($user_clang_id, FILTER_VALIDATE_INT);
}
else {
// Falls Name der Sprach in CSV festgelegt wurde
// Falls Name der Sprache, statt ID in CSV festgelegt wurde
foreach(rex_clang::getAll() as $clang_id => $clang_name) {
if($clang_name == $user_clang) {
if($clang_name == $user_clang_id) {
$multinewsletter_user->clang_id = $clang_id;
break;
}
Expand Down Expand Up @@ -178,7 +183,7 @@
<fieldset>
<legend><?php print rex_i18n::msg('multinewsletter_menu_import'); ?></legend>
<dl class="rex-form-group form-group">
<a href="<?php print rex_url::backendPage('multinewsletter/help', array('chapter' => 'import')); ?>">
<a href="<?php print rex_url::backendPage('multinewsletter/help', ['chapter' => 'import']); ?>">
<?php print rex_i18n::msg('multinewsletter_expl_import'); ?></a>
</dl>
<?php
Expand Down

0 comments on commit c50cbce

Please sign in to comment.