use configurable recipient fields for orders and user accounts
This commit is contained in:
parent
b4ead1d4af
commit
9bc3576919
@ -20,6 +20,7 @@ use D3\LinkmobilityClient\ValueObject\Recipient;
|
||||
use OxidEsales\Eshop\Application\Model\Country;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class OrderRecipients
|
||||
{
|
||||
@ -59,9 +60,35 @@ class OrderRecipients
|
||||
*/
|
||||
public function getSmsRecipientFields(): array
|
||||
{
|
||||
return [
|
||||
'oxdelfon' => 'oxdelcountryid',
|
||||
'oxbillfon' => 'oxbillcountryid'
|
||||
];
|
||||
$customFields = $this->getSanitizedCustomFields();
|
||||
|
||||
return count($customFields) ?
|
||||
$customFields :
|
||||
[
|
||||
'oxdelfon' => 'oxdelcountryid',
|
||||
'oxbillfon' => 'oxbillcountryid'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSanitizedCustomFields() : array
|
||||
{
|
||||
$customFields = (array) Registry::getConfig()->getConfigParam('d3linkmobility_smsOrderRecipientsFields');
|
||||
array_walk($customFields, [$this, 'checkFieldExists']);
|
||||
return array_filter($customFields);
|
||||
}
|
||||
|
||||
public function checkFieldExists(&$checkPhoneFieldName, $checkCountryFieldName)
|
||||
{
|
||||
$checkCountryFieldName = trim($checkCountryFieldName);
|
||||
$checkPhoneFieldName = trim($checkPhoneFieldName);
|
||||
$allFieldNames = oxNew(Order::class)->getFieldNames();
|
||||
|
||||
array_walk($allFieldNames, function(&$value) {$value = strtolower($value);});
|
||||
|
||||
$checkPhoneFieldName = in_array(strtolower($checkPhoneFieldName), $allFieldNames) &&
|
||||
in_array(strtolower($checkCountryFieldName), $allFieldNames) ? $checkPhoneFieldName : null;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ use D3\Linkmobility4OXID\Application\Model\Exceptions\noRecipientFoundException;
|
||||
use D3\LinkmobilityClient\ValueObject\Recipient;
|
||||
use OxidEsales\Eshop\Application\Model\Country;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class UserRecipients
|
||||
{
|
||||
@ -58,10 +59,39 @@ class UserRecipients
|
||||
*/
|
||||
public function getSmsRecipientFields(): array
|
||||
{
|
||||
return [
|
||||
'oxmobfon',
|
||||
'oxfon',
|
||||
'oxprivfon'
|
||||
];
|
||||
$customFields = $this->getSanitizedCustomFields();
|
||||
|
||||
return count($customFields) ?
|
||||
$customFields :
|
||||
[
|
||||
'oxmobfon',
|
||||
'oxfon',
|
||||
'oxprivfon'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSanitizedCustomFields() : array
|
||||
{
|
||||
$customFields = (array) Registry::getConfig()->getConfigParam('d3linkmobility_smsUserRecipientsFields');
|
||||
array_walk($customFields, [$this, 'checkFieldExists']);
|
||||
return array_filter($customFields);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $checkFieldName
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function checkFieldExists(&$checkFieldName)
|
||||
{
|
||||
$checkFieldName = trim($checkFieldName);
|
||||
$allFieldNames = oxNew(User::class)->getFieldNames();
|
||||
|
||||
array_walk($allFieldNames, function(&$value) {$value = strtolower($value);});
|
||||
|
||||
$checkFieldName = in_array(strtolower($checkFieldName), $allFieldNames) ? $checkFieldName : null;
|
||||
}
|
||||
}
|
@ -20,23 +20,38 @@ $sLangName = "Deutsch";
|
||||
$aLang = [
|
||||
|
||||
//Navigation
|
||||
'charset' => 'UTF-8',
|
||||
'charset' => 'UTF-8',
|
||||
|
||||
'SHOP_MODULE_GROUP_d3linkmobility_general' => 'Grundeinstellungen',
|
||||
'SHOP_MODULE_d3linkmobility_debug' => 'Debug-Modus',
|
||||
'SHOP_MODULE_d3linkmobility_apitoken' => 'API-Token',
|
||||
'SHOP_MODULE_GROUP_d3linkmobility_general' => 'Grundeinstellungen',
|
||||
'SHOP_MODULE_d3linkmobility_debug' => 'Debug-Modus',
|
||||
'HELP_SHOP_MODULE_d3linkmobility_debug' => 'Mit aktiviertem Test-Modus wird Linkmobility die Nachrichten nicht versenden. Die Anfrage wird jedoch verarbeitet und liefert eine Systemantwort zurück.',
|
||||
'SHOP_MODULE_d3linkmobility_apitoken' => 'API-Token',
|
||||
'HELP_SHOP_MODULE_d3linkmobility_apitoken' => 'Den API-Token generieren Sie sich bitte in Ihrem Linkmobility-Konto.',
|
||||
|
||||
'D3LM_ADMIN_USER_RECIPIENT' => 'Empfängernummer',
|
||||
'D3LM_ADMIN_USER_MESSAGE' => 'Nachricht',
|
||||
'D3LM_ADMIN_SEND' => 'versenden',
|
||||
'SHOP_MODULE_GROUP_d3linkmobility_sms' => 'SMS-Versand',
|
||||
'SHOP_MODULE_d3linkmobility_smsSenderNumber' => 'Sendernummer',
|
||||
'HELP_SHOP_MODULE_d3linkmobility_smsSenderNumber' => 'Ihre Mobilfunknummer, die als Antwortziel verwendet werden kann.',
|
||||
'SHOP_MODULE_d3linkmobility_smsSenderCountry' => 'Landeskürzel',
|
||||
'HELP_SHOP_MODULE_d3linkmobility_smsSenderCountry' => 'Geben Sie hier das Landeskürzel (ISO-Alpha-2, z.B. DE, AT, FR) an, zu dem Ihre Mobilfunknummer zugeordnet ist.',
|
||||
'SHOP_MODULE_d3linkmobility_smsUserRecipientsFields'=> 'Felder des Benutzerkontos, die auf gültige Mobilfunknummern geprüft werden',
|
||||
'HELP_SHOP_MODULE_d3linkmobility_smsUserRecipientsFields' => 'Die Felder werden in dieser Reihenfolge geprüft und das erste valide Vorkommen wird zum Senden der Nachricht verwendet. Ohne (gültige) Feldangabe werden die Felder "oxmobfon", "oxfon" und "oxprivfon" geprüft.',
|
||||
'SHOP_MODULE_d3linkmobility_smsOrderRecipientsFields'=> 'Felder der Bestellung, die auf gültige Mobilfunknummern und zugehörige Länderident geprüft werden',
|
||||
'HELP_SHOP_MODULE_d3linkmobility_smsOrderRecipientsFields' => 'Die Felder werden in dieser Reihenfolge geprüft und das erste valide Vorkommen wird zum Senden der Nachricht verwendet. Ohne (gültige) Feldangabe werden die Felder "oxdelfon", und "oxbillfon" geprüft. Zum Telefonnummernfeld ist die Angabe des dazugehörigen Landesidentfeldes erforderlich. Individuelle Angaben erfolgen in diesem Format:<br><div>Telefonnummernfeld => LänderIdFeld</div><div>Bsp.: "oxdelfon => oxdelcuntryid"</div>',
|
||||
|
||||
'D3LM_EXC_MESSAGE_NO_LENGTH' => 'Die Mitteilung muss Inhalt haben',
|
||||
'D3LM_EXC_SMS_SUCC_SENT' => 'Die Mitteilung wurde erfolgreich versendet. (%1$s Nachricht(en) verwendet)',
|
||||
'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' => 'Beim Versenden der Nachricht(en) ist ein unerwarteter Fehler aufgetreten.',
|
||||
'D3LM_EXC_NO_RECIPIENT_SET' => 'Kein (verwendbarer) Empfänger gesetzt.',
|
||||
'SHOP_MODULE_GROUP_d3linkmobility_trigger' => 'Nachrichtenversand bei ...',
|
||||
'SHOP_MODULE_d3linkmobility_orderActive' => 'abgeschlossener Bestellung',
|
||||
|
||||
'D3LM_REMARK_SMS' => 'SMS-Nachr.',
|
||||
'D3LM_ADMIN_USER_RECIPIENT' => 'Empfängernummer',
|
||||
'D3LM_ADMIN_USER_MESSAGE' => 'Nachricht',
|
||||
'D3LM_ADMIN_SEND' => 'versenden',
|
||||
|
||||
'tbcluser_linkmobility' => 'SMS-Versand',
|
||||
'tbclorder_linkmobility' => 'SMS-Versand'
|
||||
'D3LM_EXC_MESSAGE_NO_LENGTH' => 'Die Mitteilung muss Inhalt haben',
|
||||
'D3LM_EXC_SMS_SUCC_SENT' => 'Die Mitteilung wurde erfolgreich versendet. (%1$s Nachricht(en) verwendet)',
|
||||
'D3LM_EXC_MESSAGE_UNEXPECTED_ERR_SEND' => 'Beim Versenden der Nachricht(en) ist ein unerwarteter Fehler aufgetreten.',
|
||||
'D3LM_EXC_NO_RECIPIENT_SET' => 'Kein (verwendbarer) Empfänger gesetzt.',
|
||||
|
||||
'D3LM_REMARK_SMS' => 'SMS-Nachr.',
|
||||
|
||||
'tbcluser_linkmobility' => 'SMS-Versand',
|
||||
'tbclorder_linkmobility' => 'SMS-Versand'
|
||||
];
|
||||
|
@ -70,19 +70,31 @@ $aModule = [
|
||||
'value' => false
|
||||
],
|
||||
[
|
||||
'group' => $sModuleId.'_general',
|
||||
'group' => $sModuleId.'_sms',
|
||||
'name' => $sModuleId.'_smsSenderNumber',
|
||||
'type' => 'str',
|
||||
'value' => false
|
||||
],
|
||||
[
|
||||
'group' => $sModuleId.'_general',
|
||||
'group' => $sModuleId.'_sms',
|
||||
'name' => $sModuleId.'_smsSenderCountry',
|
||||
'type' => 'str',
|
||||
'value' => 'DE'
|
||||
],
|
||||
[
|
||||
'group' => $sModuleId.'_order',
|
||||
'group' => $sModuleId.'_sms',
|
||||
'name' => $sModuleId.'_smsUserRecipientsFields',
|
||||
'type' => 'arr',
|
||||
'value' => [],
|
||||
],
|
||||
[
|
||||
'group' => $sModuleId.'_sms',
|
||||
'name' => $sModuleId.'_smsOrderRecipientsFields',
|
||||
'type' => 'aarr',
|
||||
'value' => [],
|
||||
],
|
||||
[
|
||||
'group' => $sModuleId.'_trigger',
|
||||
'name' => $sModuleId.'_orderActive',
|
||||
'type' => 'bool',
|
||||
'value' => false
|
||||
|
Loading…
Reference in New Issue
Block a user