Skip to content

Commit

Permalink
Merge pull request #416 from SSFGizmo/11.x
Browse files Browse the repository at this point in the history
11.x
  • Loading branch information
SSFGizmo authored Jun 8, 2023
2 parents 69d120c + 69fdbcd commit 0e25cfb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
42 changes: 22 additions & 20 deletions Classes/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ public function displayImport(): array
}

// check if "email" is mapped
$error = [];
if (isset($stepCurrent) && $stepCurrent === 'startImport') {
$map = $this->indata['map'];
$error = [];
// check noMap
$newMap = ArrayUtility::removeArrayEntryByValue(array_unique($map), 'noMap');
if (empty($newMap)) {
Expand All @@ -227,6 +227,9 @@ public function displayImport(): array
}

$out = '';
if(!isset($stepCurrent)) {
$stepCurrent = '';
}
switch ($stepCurrent) {
case 'conf':
$output['conf']['show'] = true;
Expand Down Expand Up @@ -269,7 +272,7 @@ public function displayImport(): array
['val' =>'name', 'text' => 'name'],
];

$output['conf']['disableInput'] = $this->params['inputDisable'] == 1 ? true : false;
$output['conf']['disableInput'] = ($this->params['inputDisable'] ?? 0) == 1 ? true : false;

// show configuration
$output['subtitle'] = $this->getLanguageService()->getLL('mailgroup_import_header_conf');
Expand All @@ -279,10 +282,10 @@ public function displayImport(): array
$output['conf']['storageSelected'] = $this->indata['storage'] ?? '';

// remove existing option
$output['conf']['remove_existing'] = !$this->indata['remove_existing'] ? false : true;
$output['conf']['remove_existing'] = !($this->indata['remove_existing'] ?? false) ? false : true;

// first line in csv is to be ignored
$output['conf']['first_fieldname'] = !$this->indata['first_fieldname'] ? false : true;
$output['conf']['first_fieldname'] = !($this->indata['first_fieldname'] ?? false) ? false : true;

// csv separator
$output['conf']['delimiter'] = $optDelimiter;
Expand All @@ -293,13 +296,13 @@ public function displayImport(): array
$output['conf']['encapsulationSelected'] = $this->indata['encapsulation'] ?? '';

// import only valid email
$output['conf']['valid_email'] = !$this->indata['valid_email'] ? false : true;
$output['conf']['valid_email'] = !($this->indata['valid_email'] ?? false) ? false : true;

// only import distinct records
$output['conf']['remove_dublette'] = !$this->indata['remove_dublette'] ? false : true;
$output['conf']['remove_dublette'] = !($this->indata['remove_dublette'] ?? false) ? false : true;

// update the record instead renaming the new one
$output['conf']['update_unique'] = !$this->indata['update_unique'] ? false : true;
$output['conf']['update_unique'] = !($this->indata['update_unique'] ?? false) ? false : true;

// which field should be use to show uniqueness of the records
$output['conf']['record_unique'] = $optUnique;
Expand All @@ -320,7 +323,7 @@ public function displayImport(): array
$output['mapping']['remove_dublette'] = $this->indata['remove_dublette'];
$output['mapping']['update_unique'] = $this->indata['update_unique'];
$output['mapping']['record_unique'] = $this->indata['record_unique'];
$output['mapping']['all_html'] = !$this->indata['all_html'] ? false : true;
$output['mapping']['all_html'] = !($this->indata['all_html'] ?? false) ? false : true;
$output['mapping']['error'] = $error;

// show charset selector
Expand Down Expand Up @@ -386,7 +389,7 @@ public function displayImport(): array
$output['mapping']['table'][] = [
'mapping_description' => $csv_firstRow[$i],
'mapping_i' => $i,
'mapping_mappingSelected' => $this->indata['map'][$i],
'mapping_mappingSelected' => $this->indata['map'][$i] ?? '',
'mapping_value' => $exampleLines,
];
}
Expand Down Expand Up @@ -427,8 +430,8 @@ public function displayImport(): array
$output['startImport']['remove_dublette'] = $this->indata['remove_dublette'];
$output['startImport']['update_unique'] = $this->indata['update_unique'];
$output['startImport']['record_unique'] = $this->indata['record_unique'];
$output['startImport']['all_html'] = !$this->indata['all_html'] ? false : true;
$output['startImport']['add_cat'] = $this->indata['add_cat'] ? true : false;
$output['startImport']['all_html'] = !($this->indata['all_html'] ?? false) ? false : true;
$output['startImport']['add_cat'] = ($this->indata['add_cat'] ?? false) ? true : false;

$output['startImport']['error'] = $error;

Expand All @@ -454,7 +457,7 @@ public function displayImport(): array

foreach ($endOrder as $order) {
$rowsTable = [];
if (is_array($result[$order])) {
if (is_array($result[$order] ?? false)) {
foreach ($result[$order] as $v) {
$mapKeys = array_keys($v);
$rowsTable[] = [
Expand All @@ -471,12 +474,12 @@ public function displayImport(): array
}

// back button
if (is_array($this->indata['map'])) {
if (is_array($this->indata['map'] ?? false)) {
foreach ($this->indata['map'] as $fieldNr => $fieldMapped) {
$output['startImport']['hiddenMap'][] = ['name' => htmlspecialchars('CSV_IMPORT[map][' . $fieldNr . ']'), 'value' => htmlspecialchars($fieldMapped)];
}
}
if (is_array($this->indata['cat'])) {
if (is_array($this->indata['cat'] ?? false)) {
foreach ($this->indata['cat'] as $k => $catUid) {
$output['startImport']['hiddenCat'][] = ['name' => htmlspecialchars('CSV_IMPORT[cat][' . $k . ']'), 'value' => htmlspecialchars($catUid)];
}
Expand All @@ -487,8 +490,7 @@ public function displayImport(): array
default:
// show upload file form
$output['subtitle'] = $this->getLanguageService()->getLL('mailgroup_import_header_upload');

if (($this->indata['mode'] === 'file') && !(((strpos($currentFileInfo['file'], 'import') === false) ? 0 : 1) && ($currentFileInfo['realFileext'] === 'txt'))) {
if ((($this->indata['mode'] ?? '') === 'file') && !(((strpos($currentFileInfo['file'], 'import') === false) ? 0 : 1) && ($currentFileInfo['realFileext'] === 'txt'))) {
$output['upload']['current'] = true;
$file = $this->getFileById((int)$this->indata['newFileUid']);
if (is_object($file)) {
Expand All @@ -510,8 +512,8 @@ public function displayImport(): array
$output['upload']['csv'] = htmlspecialchars($this->indata['csv'] ?? '');
$output['upload']['target'] = htmlspecialchars($this->userTempFolder());
$output['upload']['target_disabled'] = GeneralUtility::_POST('importNow') ? 'disabled' : '';
$output['upload']['newFile'] = $this->indata['newFile'];
$output['upload']['newFileUid'] = $this->indata['newFileUid'];
$output['upload']['newFile'] = $this->indata['newFile'] ?? '';
$output['upload']['newFileUid'] = $this->indata['newFileUid'] ?? 0;
}

$output['title'] = $this->getLanguageService()->getLL('mailgroup_import') . BackendUtility::cshItem($this->cshTable ?? '', 'mailgroup_import');
Expand Down Expand Up @@ -726,7 +728,7 @@ public function doImport(array $csvData): array
* Hook for doImport Mail
* will be called every time a record is inserted
*/
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['doImport'])) {
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['doImport'] ?? false)) {
$hookObjectsArr = [];
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail/mod3/class.tx_directmail_recipient_list.php']['doImport'] as $classRef) {
$hookObjectsArr[] = GeneralUtility::makeInstance($classRef);
Expand Down Expand Up @@ -756,7 +758,7 @@ public function addDataArray(array &$data, $id, array $dataArray): void
if ($this->indata['all_html']) {
$data['tt_address'][$id]['module_sys_dmail_html'] = $this->indata['all_html'];
}
if (is_array($this->indata['cat']) && !in_array('cats', $this->indata['map'])) {
if (is_array($this->indata['cat'] ?? false) && !in_array('cats', $this->indata['map'])) {
foreach ($this->indata['cat'] as $k => $v) {
$data['tt_address'][$id]['module_sys_dmail_category'][$k] = $v;
}
Expand Down
31 changes: 17 additions & 14 deletions Classes/Middleware/JumpurlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
if ($this->shouldProcess()) {
$mailId = (int)$this->request->getQueryParams()['mid'];
$submittedRecipient = isset($this->request->getQueryParams()['rid']) ? (string)$this->request->getQueryParams()['rid'] : '';
$submittedAuthCode = $this->request->getQueryParams()['aC'];
$jumpurl = $this->request->getQueryParams()['jumpurl'];
$submittedAuthCode = $this->request->getQueryParams()['aC'] ?? '';
$jumpurl = $this->request->getQueryParams()['jumpurl'] ?? '';

$urlId = 0;
if (MathUtility::canBeInterpretedAsInteger($jumpurl)) {
Expand Down Expand Up @@ -179,25 +179,28 @@ protected function initDirectMailRecord(int $mailId): void
* Fetches the target url from the direct mail record
*
* @param int $targetIndex
* @return string|null
* @return string
*/
protected function getTargetUrl(int $targetIndex): ?string
protected function getTargetUrl(int $targetIndex): string
{
$targetUrl = null;
$targetUrl = '';

if (!empty($this->directMailRecord)) {
$mailContent = unserialize(
base64_decode($this->directMailRecord['mailContent']),
base64_decode((string)$this->directMailRecord['mailContent']),
['allowed_classes' => false]
);
if ($targetIndex >= 0) {
// Link (number)
$this->responseType = self::RESPONSE_TYPE_HREF;
$targetUrl = $mailContent['html']['hrefs'][$targetIndex]['absRef'];
} else {
// Link (number, plaintext)
$this->responseType = self::RESPONSE_TYPE_PLAIN;
$targetUrl = $mailContent['plain']['link_ids'][abs($targetIndex)];

if(is_array($mailContent)) {
if ($targetIndex >= 0) {
// Link (number)
$this->responseType = self::RESPONSE_TYPE_HREF;
$targetUrl = $mailContent['html']['hrefs'][$targetIndex]['absRef'];
} else {
// Link (number, plaintext)
$this->responseType = self::RESPONSE_TYPE_PLAIN;
$targetUrl = $mailContent['plain']['link_ids'][abs($targetIndex)];
}
}
$targetUrl = htmlspecialchars_decode(urldecode($targetUrl));
}
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'author_company' => 'd.k.d Internet Service GmbH',
'state' => 'stable',
'clearcacheonload' => 0,
'version' => '9.3.0',
'version' => '9.4.0',
'constraints' => [
'depends' => [
'typo3' => '11.5.0-11.99.99',
Expand Down

0 comments on commit 0e25cfb

Please sign in to comment.