diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd767a..7410012 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,15 @@ Synergy Wholesale WHMCS Domains Module ### Removed - -## 2.3.1 [Updated 30/032022] +## 2.4.0 [Updated 09/05/2022] +### Fixed +- Organisation field not displaying on Domain Contact form +- Domains not syncing their correct status when in a transfer state +- Issue where DNS and URL Forwarding would display on side menu despite not being enabled on Domain Name +- Changing DNS configuration type would display "undefined" instead of the correct name +- Fix potential issue with logging API requests + +## 2.3.1 [Updated 30/03/2022] ### Fixed - Syncing .au domains that are currently pending application or pending identity verification diff --git a/modules/registrars/synergywholesaledomains/hooks.php b/modules/registrars/synergywholesaledomains/hooks.php index 8d642cb..3627669 100644 --- a/modules/registrars/synergywholesaledomains/hooks.php +++ b/modules/registrars/synergywholesaledomains/hooks.php @@ -31,14 +31,37 @@ $menu->removeChild('Manage Private Nameservers'); } - if ($context->hasDnsManagement && !is_null($menu->getChild('Manage DNS Host Records'))) { - $menu->removeChild('Manage DNS Host Records'); - } + if ($context->status === 'Active') { + $settings = $context->getRegistrarInterface()->getSettings(); - if ($context->hasEmailForwarding && !is_null($menu->getChild('Manage Email Forwarding'))) { - $menu->removeChild('Manage Email Forwarding'); - } + $vars = [ + 'resellerID' => $settings['resellerID'], + 'apiKey' => $settings['apiKey'], + 'domainName' => $context->domain + ]; + + try { + $info = synergywholesaledomains_apiRequest('domainInfo', [], $vars); + + if ($context->hasDnsManagement && !in_array($info['dnsConfig'], [2, 4]) && !is_null($menu->getChild('Manage DNS Host Records'))) { + $menu->removeChild('Manage DNS Host Records'); + } + + if ($context->hasEmailForwarding && !in_array($info['dnsConfig'], [2]) && !is_null($menu->getChild('Manage Email Forwarding'))) { + $menu->removeChild('Manage Email Forwarding'); + } + } catch (\Exception $e) { + if (!is_null($menu->getChild('Manage DNS Host Records'))) { + $menu->removeChild('Manage DNS Host Records'); + } + if (!is_null($menu->getChild('Manage Email Forwarding'))) { + $menu->removeChild('Manage Email Forwarding'); + } + } + } + + if (preg_match('/\.au$/', $context->domain) && !is_null($menu->getChild('Registrar Lock Status'))) { $menu->removeChild('Registrar Lock Status'); } diff --git a/modules/registrars/synergywholesaledomains/js/functions.js b/modules/registrars/synergywholesaledomains/js/functions.js index 49761b6..edb669f 100644 --- a/modules/registrars/synergywholesaledomains/js/functions.js +++ b/modules/registrars/synergywholesaledomains/js/functions.js @@ -36,7 +36,7 @@ function Toast(type, css, msg) { } function formSubmitDNS() { - let type = determineDNSType(document.getElementById('option').value); + let type = determineDNSType(parseInt(document.getElementById('option').value)); let text = `Are you sure you want to change the DNS Type to ${type} ?`; if (confirm(text)) { this.form.submit() @@ -733,4 +733,4 @@ function DnsUrlPageReady(domain_id) { break; } }); -} \ No newline at end of file +} diff --git a/modules/registrars/synergywholesaledomains/synergywholesaledomains.php b/modules/registrars/synergywholesaledomains/synergywholesaledomains.php index f5f8534..7d3c9c4 100644 --- a/modules/registrars/synergywholesaledomains/synergywholesaledomains.php +++ b/modules/registrars/synergywholesaledomains/synergywholesaledomains.php @@ -107,7 +107,8 @@ function synergywholesaledomains_apiRequest($command, array $params = [], array try { $response = $client->{$command}($request); - logModuleCall(SW_MODULE_NAME, $command, $request, $response, $response, $auth); + $logResponse = is_string($response) ? $response : (array) $response; + logModuleCall(SW_MODULE_NAME, $command, $request, $logResponse, $logResponse, $auth); } catch (SoapFault $e) { logModuleCall(SW_MODULE_NAME, $command, $request, $e->getMessage(), $e->getMessage(), $auth); @@ -1048,12 +1049,30 @@ function synergywholesaledomains_TransferSync(array $params) try { $response = synergywholesaledomains_apiRequest('domainInfo', $params); } catch (\Exception $e) { + if ($e->getMessage() == 'Domain Info Failed - Unable to retrieve domain id') { + return [ + 'completed' => false, + 'failed' => true, + 'reason' => 'Domain has been marked as cancelled due to not being in your account' + ]; + } + return [ 'error' => $e->getMessage(), ]; } if (!isset($response['domain_status'])) { + if (isset($response['transfer_status']) + && isset($response['status']) + && in_array($response['status'], ['OK_TRANSFER_TIMEOUT', 'OK_TRANSFER_REJECTED', 'OK_TRANSFER_CANCELLED'])) { + // It has timed out, was cancelled, or was rejected + return [ + 'completed' => false, + 'failed' => true, + 'reason' => 'Transfer was either rejected, cancelled or timed out' + ]; + } return [ 'completed' => false, ]; @@ -1123,6 +1142,9 @@ function synergywholesaledomains_SaveContactDetails(array $params) $request["{$contactType}_suburb"] = $params['contactdetails'][$whmcs_contact]['City']; $request["{$contactType}_postcode"] = $params['contactdetails'][$whmcs_contact]['Postcode']; + if (!preg_match('/\.?uk$/', $params['tld'])) { + $request["{$contactType}_organisation"] = $params['contactdetails'][$whmcs_contact]['Organisation']; + } // Validate the country being specified if (!synergywholesaledomains_validateCountry($params['contactdetails'][$whmcs_contact]['Country'])) { return [ @@ -1196,6 +1218,7 @@ function synergywholesaledomains_GetContactDetails(array $params) 'address1' => 'Address 1', 'address2' => 'Address 2', 'address3' => 'Address 3', + 'organisation' => 'Organisation', 'suburb' => 'City', 'state' => 'State', 'country' => 'Country', @@ -1204,6 +1227,12 @@ function synergywholesaledomains_GetContactDetails(array $params) 'email' => 'Email', ]; + + if (preg_match('/\.?uk$/', $params['tld'])) { + unset($map['organisation']); + } + + $contactTypes = ['registrant']; foreach (['admin', 'billing', 'tech'] as $otherTypes) { if (isset($contacts[$otherTypes])) { @@ -1277,12 +1306,12 @@ function synergywholesaledomains_domainOptions(array $params) $errors[] = 'An error occured retrieving the domain information: ' . $e->getMessage(); } - if (isset($_REQUEST['sub']) && 'save' === $_REQUEST['sub'] && isset($_REQUEST['opt'])) { + if (isset($_REQUEST['sub']) && $_REQUEST['sub'] === 'save' && isset($_REQUEST['opt']) && empty($errors)) { switch ($_REQUEST['opt']) { case 'dnstype': $request['nameServers'] = synergywholesaledomains_helper_getNameservers($info['nameServers']); // Set nameservers to DNS hosting if selected. - if (1 == $_REQUEST['option']) { + if ($_REQUEST['option'] == 1) { $request['nameServers'] = [ 'ns1.nameserver.net.au', 'ns2.nameserver.net.au', @@ -1312,7 +1341,7 @@ function synergywholesaledomains_domainOptions(array $params) case 'resendwhoisverif': try { $response = synergywholesaledomains_apiRequest('resendVerificationEmail', $params, $request); - $vars['info'] = 'Resend WHOIS Verification Email successfull'; + $vars['info'] = 'Resend WHOIS Verification Email successful'; } catch (\Exception $e) { $errors[] = 'Resend WHOIS Verification Email failed: ' . $e->getMessage(); }