From 3c12bd79b595cf03b7c36847f973b50965ec774a Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 9 Aug 2022 12:02:06 +0200 Subject: [PATCH] check for missing recipients --- .../d3linkmobility_ordermanager_action.php | 15 +++++++++------ .../de/d3_linkmobility_ordermanager_lang.php | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Application/Model/Actions/d3linkmobility_ordermanager_action.php b/src/Application/Model/Actions/d3linkmobility_ordermanager_action.php index 355da72..0c70a47 100644 --- a/src/Application/Model/Actions/d3linkmobility_ordermanager_action.php +++ b/src/Application/Model/Actions/d3linkmobility_ordermanager_action.php @@ -67,6 +67,8 @@ class d3linkmobility_ordermanager_action extends d3ordermanager_action_abstract return 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_NOVALIDTPL'; } elseif ($this->hasRequiredValuesCmsSource(false)) { return 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_NOVALIDCMS'; + } elseif ($this->hasRequiredValuesRecipient(false)) { + return 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_NORECIPIENT'; } else { return 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_UNDEFINED'; } @@ -132,7 +134,7 @@ class d3linkmobility_ordermanager_action extends d3ordermanager_action_abstract ( $this->hasRequiredValuesTplSource(true) || $this->hasRequiredValuesCmsSource(true) - ) && $this->hasRequiredValuesRecipient(); + ) && $this->hasRequiredValuesRecipient(true); } /** @@ -204,16 +206,17 @@ class d3linkmobility_ordermanager_action extends d3ordermanager_action_abstract /** * @return bool */ - protected function hasRequiredValuesRecipient(): bool + protected function hasRequiredValuesRecipient(bool $blExpected): bool { $toCust = (bool) $this->getManager()->getValue('blLinkMobilityMessageToCustomer'); $toCustom = (bool) $this->getManager()->getValue('blLinkMobilityMessageToCustom'); $toCustomAddress = (string) $this->getManager()->getValue('sLinkMobilityMessageToCustomAddress'); - return $toCust || ( - $toCustom && - (bool) strlen(trim($toCustomAddress)) - ); + if ($blExpected === true) { + return $toCust || ( $toCustom && (bool) strlen( trim( $toCustomAddress ) ) === true ); + } else { + return !($toCust || ( $toCustom && (bool) strlen( trim( $toCustomAddress ) ) === true )); + } } /** diff --git a/src/Application/views/admin/de/d3_linkmobility_ordermanager_lang.php b/src/Application/views/admin/de/d3_linkmobility_ordermanager_lang.php index 80ffc65..6e6a8b9 100644 --- a/src/Application/views/admin/de/d3_linkmobility_ordermanager_lang.php +++ b/src/Application/views/admin/de/d3_linkmobility_ordermanager_lang.php @@ -47,6 +47,7 @@ $aLang = [ 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_NOVALIDSOURCE' => 'keine gültige Inhaltsquelle gesetzt', 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_NOVALIDTPL' => 'keine gültigen Templatedaten gesetzt', 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_NOVALIDCMS' => 'kein gültiger CMS-Eintrag gesetzt', + 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_NORECIPIENT' => 'kein gültiger Empfänger gesetzt', 'D3_ORDERMANAGER_ACTION_LINKMOBILITYMESSAGE_ERR_UNDEFINED' => 'unbekannter Fehler', 'D3_ORDERMANAGER_JOBDESC_SENDLMMESSAGE' => 'sende SMS via LinkMobility an %s',