Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lang/overrides/english.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@
$_LANG['fiIdentificationPassport'] = 'Passport/ID number for Individuals';
$_LANG['fiIdentificationSocialSecurityNumber'] = 'Social Security Number for Individuals';
$_LANG['fiIdentificationBirthDate'] = 'Birthday for Foreign Private Individuals (YYYY-MM-DD)';

$_LANG['dkSoleProprietorship'] = 'Sole Proprietorship';
Comment thread
Copilot marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ShoppingCartController
{
private static ?array $inSldExtensions = null;
private const IN_NEXUS_DECLARATION_INDEX = 0;
private const DK_USER_TYPE_INDEX = 1;
private const DK_SOLE_PROPRIETORSHIP_INDEX = 2;

// .RU / .xn--p1ai field indices
private const RU_CONTACT_TYPE_INDEX = 8; // Contact Type (display only)
Expand Down Expand Up @@ -162,6 +164,11 @@ public function checkoutOutput($vars)

public function preCheckout($vars)
{
$dkError = $this->validateDkSoleProprietorshipAtCheckout($vars);
if ($dkError !== null) {
return $dkError;
}

$inNexusError = $this->validateInNexusAtCheckout($vars);
if ($inNexusError !== null) {
return $inNexusError;
Expand Down Expand Up @@ -207,6 +214,42 @@ public function preCheckout($vars)
}
}


private function validateDkSoleProprietorshipAtCheckout(array $vars): ?array
{
$domains = $vars['domains'] ?? $_SESSION['cart']['domains'] ?? [];

foreach ($domains as $domain) {
$domainName = $domain['domain'] ?? '';

if ($this->getFullTld($domainName) !== 'dk') {
continue;
}

$fields = array_values($domain['fields'] ?? []);
$soleProprietorshipChecked = ($fields[self::DK_SOLE_PROPRIETORSHIP_INDEX] ?? '') === 'on';
Comment thread
YumeChaan marked this conversation as resolved.

if (!$soleProprietorshipChecked) {
continue;
}
Comment thread
Copilot marked this conversation as resolved.
Outdated

$country = $this->getRegistrantCountryForCheckout($vars);

if ($country !== 'DK') {
Comment thread
YumeChaan marked this conversation as resolved.
continue;
}

$cartUrl = rtrim(Setting::getValue('SystemURL'), '/') . '/cart.php?a=confdomains';

return [
'error' => 'You should not tick sole proprietorship unless the registrant is a non-DK foreign company. '
. '<a href="' . $cartUrl . '">Go back to the domain configuration step</a> to correct your selection.',
];
}

return null;
}

private function validateRuContactTypeAtCheckout(array $vars): ?array
{
$domains = $vars['domains'] ?? $_SESSION['cart']['domains'] ?? [];
Expand Down Expand Up @@ -516,7 +559,103 @@ function apply() {
});
}

$(document).ready(initRuFieldVisibility);
function initDkSoleProprietorshipVisibility() {
var dkUserTypeFields = [];

$('select[name^="domainfield["]').filter(function () {
var vals = $(this).find('option').map(function () {
return $(this).val();
}).get();

return vals.indexOf('1') !== -1 && vals.indexOf('2') !== -1;
}).each(function () {
var $userType = $(this);
var $form = $userType.closest('form');

var m = ($userType.attr('name') || '').match(/^domainfield\[(\d+)\]/);
if (!m) { return; }

var n = m[1];

var $rows = $form.find('.form-group.row').filter(function () {
return $(this).find('[name^="domainfield[' + n + ']["]').length > 0;
});

var $soleRow = $rows.filter(function () {
return $(this).text().toLowerCase().indexOf('sole proprietorship') !== -1;
Comment thread
YumeChaan marked this conversation as resolved.
Outdated
}).first();

if (!$soleRow.length) { return; }

var $soleCheckbox = $soleRow.find('input[type="checkbox"]').first();
Comment thread
YumeChaan marked this conversation as resolved.
Outdated

var $error = $userType.next('.dk-user-type-error');
if (!$error.length) {
$error = $('<div class="text-danger dk-user-type-error" style="margin-top:5px;">Please select User Type.</div>');
$error.hide();
$userType.after($error);
}

function isValidUserType() {
return $userType.val() === '1' || $userType.val() === '2';
}

function showUserTypeError() {
$error.show();
$userType.focus();
}

function hideUserTypeError() {
$error.hide();
}

function apply() {
if (isValidUserType()) {
hideUserTypeError();
}

if ($userType.val() === '2') {
$soleRow.show();
} else {
$soleCheckbox.prop('checked', false);
$soleRow.hide();
}
}

$userType.off('change.dkUserType').on('change.dkUserType', apply);
apply();

dkUserTypeFields.push({
field: $userType,
isValid: isValidUserType,
showError: showUserTypeError
});
});

$('#frmConfigureDomains')
.off('submit.dkUserType')
.on('submit.dkUserType', function (e) {
var hasError = false;

$.each(dkUserTypeFields, function (_, item) {
if (!item.isValid()) {
item.showError();
hasError = true;
}
});

if (hasError) {
e.preventDefault();
e.stopImmediatePropagation();
return false;
}
});
}

$(document).ready(function () {
initRuFieldVisibility();
initDkSoleProprietorshipVisibility();
});
})(jQuery);
JS;

Expand Down
2 changes: 1 addition & 1 deletion modules/registrars/openprovider/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"require": {
"wedevelopcoffee/wpower": "2.2.*",
"viison/address-splitter": "^0.3.2",
"openprovider/rest-client-php": "v2.2.1-beta",
"openprovider/rest-client-php": "v2.2.2-beta",
"symfony/serializer": "^5.2",
"psr/log": "^1.1",
"symfony/property-access": "^5.2",
Expand Down
20 changes: 10 additions & 10 deletions modules/registrars/openprovider/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions modules/registrars/openprovider/configuration/additionalfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,25 @@ function op_addConsentField(array &$additionaldomainfields, string $tld, bool $r
"op_name" => "dkAcceptance"
);

$additionaldomainfields[".dk"][] = array(
"Name" => "User Type",
"LangVar" => "dkUserType",
"Type" => "dropdown",
"Required" => true,
"Options" => "Please select User Type,1|Individual,2|Company",
Comment thread
YumeChaan marked this conversation as resolved.
"op_location" => "customerExtensionAdditionalData",
"op_name" => "userType"
);
Comment thread
YumeChaan marked this conversation as resolved.

$additionaldomainfields[".dk"][] = array(
"Name" => "Sole Proprietorship",
"LangVar" => "dkSoleProprietorship",
"Type" => "tickbox",
"Required" => false,
"op_location" => "customerExtensionAdditionalData",
"op_name" => "soleProprietorship"
);

// .IN and all .IN SLDs

$inNexusFields = [
Expand Down
5 changes: 1 addition & 4 deletions modules/registrars/openprovider/vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
throw new RuntimeException($err);
}

require_once __DIR__ . '/composer/autoload_real.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,23 @@
*/
class InstalledVersions
{
/**
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
* @internal
*/
private static $selfDir = null;

/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;

/**
* @var bool
*/
private static $installedIsLocalDir;

/**
* @var bool|null
*/
Expand Down Expand Up @@ -309,6 +320,24 @@ public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();

// when using reload, we disable the duplicate protection to ensure that self::$installed data is
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
// so we have to assume it does not, and that may result in duplicate data being returned when listing
// all installed packages for example
self::$installedIsLocalDir = false;
}

/**
* @return string
*/
private static function getSelfDir()
{
if (self::$selfDir === null) {
self::$selfDir = strtr(__DIR__, '\\', '/');
}

return self::$selfDir;
}

/**
Expand All @@ -322,19 +351,27 @@ private static function getInstalled()
}

$installed = array();
$copiedLocalDir = false;

if (self::$canGetVendors) {
$selfDir = self::getSelfDir();
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
self::$installedByVendor[$vendorDir] = $required;
$installed[] = $required;
if (self::$installed === null && $vendorDir.'/composer' === $selfDir) {
self::$installed = $required;
self::$installedIsLocalDir = true;
}
}
if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) {
$copiedLocalDir = true;
}
}
}

Expand All @@ -350,7 +387,7 @@ private static function getInstalled()
}
}

if (self::$installed !== array()) {
if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'phpmock\\mockery\\' => array($vendorDir . '/php-mock/php-mock-mockery/classes'),
'phpmock\\integration\\' => array($vendorDir . '/php-mock/php-mock-integration/classes'),
'phpmock\\' => array($vendorDir . '/php-mock/php-mock/classes', $vendorDir . '/php-mock/php-mock/tests'),
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'),
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src', $vendorDir . '/phpdocumentor/reflection-common/src'),
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
'WeDevelopCoffee\\wPower\\' => array($vendorDir . '/wedevelopcoffee/wpower/src'),
'VIISON\\AddressSplitter\\' => array($vendorDir . '/viison/address-splitter/src'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ class ComposerStaticInit9a29979374213b4116ca45940115c24f
),
'phpDocumentor\\Reflection\\' =>
array (
0 => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src',
1 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
2 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
0 => __DIR__ . '/..' . '/phpdocumentor/reflection-docblock/src',
1 => __DIR__ . '/..' . '/phpdocumentor/type-resolver/src',
2 => __DIR__ . '/..' . '/phpdocumentor/reflection-common/src',
),
'Webmozart\\Assert\\' =>
array (
Expand Down
Loading