Skip to content

Commit 5be452d

Browse files
author
Cameron Hall
authored
Fixed #8: Registrar lock is no longer shown for .au domains (#13)
1 parent 8a3dd14 commit 5be452d

File tree

2 files changed

+64
-55
lines changed

2 files changed

+64
-55
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Synergy Wholesale WHMCS Domains Module
1515
### Removed
1616
-
1717

18+
## 2.1.4 [Updated 20/04/2020]
19+
20+
### Fixed
21+
- Fixed Registrar Lock option displaying for .au domain names. Fixes [#8](https://github.com/SynergyWholesale/WHMCS-Domains-Module/issues/8)
22+
1823
## 2.1.3 [Updated 16/04/2020]
1924

2025
### Fixed

modules/registrars/synergywholesaledomains/hooks.php

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -10,94 +10,98 @@
1010
// http://docs.whmcs.com/Editing_Client_Area_Menus
1111
use WHMCS\View\Menu\Item as MenuItem;
1212

13-
// We use this hook to override the WHMCS default manage private nameservers page
14-
// As well as email forwarding and dns modification pages as well
13+
/**
14+
* We have our own custom ones, so remove the default;
15+
* - Manage Private Nameservers
16+
* - Manage DNS Host Records
17+
* - Manage Email Forwarding
18+
* - Registrar Lock Status (for unsupported TLDs)
19+
*/
1520
add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) {
1621

17-
// Get the domain being visited and grab the id of it
18-
// http://docs.whmcs.com/classes/classes/WHMCS.Domain.Domain.html
19-
$domain = Menu::context('domain');
20-
$hasEmailForwarding = $domain->hasEmailForwarding;
21-
$hasDNSManagement = $domain->hasDnsManagement;
22-
$hasIdProtection = $domain->hasIdProtection;
23-
$registrarModuleName = $domain->registrarModuleName;
24-
25-
// Make sure the domain belongs to the Synergy Wholesale Domains module before we go forth
26-
// and hide the default pages
27-
if ("synergywholesaledomains" == $registrarModuleName) {
28-
// If the Manage Private Nameservers page is defined, rid ourselves of it
29-
if (!is_null($primarySidebar->getChild('Domain Details Management')) && !is_null($primarySidebar->getChild('Domain Details Management')->getChild('Manage Private Nameservers'))) {
30-
$primarySidebar->getChild('Domain Details Management')->removeChild('Manage Private Nameservers');
22+
$context = Menu::context('domain');
23+
$menu = $primarySidebar->getChild('Domain Details Management');
24+
25+
// Make sure the domain belongs to the Synergy Wholesale Domains module
26+
if (!is_null($menu) && 'synergywholesaledomains' === $context->registrarModuleName) {
27+
if (!is_null($menu->getChild('Manage Private Nameservers'))) {
28+
$menu->removeChild('Manage Private Nameservers');
29+
}
30+
31+
if ($context->hasDnsManagement && !is_null($menu->getChild('Manage DNS Host Records'))) {
32+
$menu->removeChild('Manage DNS Host Records');
3133
}
3234

33-
// If we can find the user has dns management addon enabled, we hide WHMCS default page
34-
if ($hasDNSManagement) {
35-
if (!is_null($primarySidebar->getChild('Domain Details Management')) && !is_null($primarySidebar->getChild('Domain Details Management')->getChild('Manage DNS Host Records'))) {
36-
$primarySidebar->getChild('Domain Details Management')->removeChild('Manage DNS Host Records');
37-
}
35+
if ($context->hasEmailForwarding && !is_null($menu->getChild('Manage Email Forwarding'))) {
36+
$menu->removeChild('Manage Email Forwarding');
3837
}
3938

40-
// If we can find the user has email forwarding addon enabled, we hide the WHMCS default page
41-
if ($hasEmailForwarding) {
42-
if (!is_null($primarySidebar->getChild('Domain Details Management')) && !is_null($primarySidebar->getChild('Domain Details Management')->getChild('Manage Email Forwarding'))) {
43-
$primarySidebar->getChild('Domain Details Management')->removeChild('Manage Email Forwarding');
44-
}
39+
if (preg_match('/\.au$/', $context->domain) && !is_null($menu->getChild('Registrar Lock Status'))) {
40+
$menu->removeChild('Registrar Lock Status');
4541
}
4642
}
4743
});
4844

49-
// We use this hook to override the WHMCS default domain dns management page
50-
// We want to go to our custom page, as long as the registrarModuleName is set and
51-
// is pointing to our custom module
45+
/**
46+
* Override the DNS Management page to link to our custom one
47+
*/
5248
add_hook('ClientAreaPageDomainDNSManagement', 1, function (array $vars) {
5349

54-
// Map the domain id
55-
$domainid = $vars['domainid'];
50+
$domain_id = $vars['domainid'];
51+
$registrarModuleName = null;
5652

57-
// If the registarModule under dnsrecords -> vars is set then assign it
58-
// Otherwise is null
5953
if (isset($vars['dnsrecords']['vars']['registrarModule'])) {
6054
$registrarModuleName = $vars['dnsrecords']['vars']['registrarModule'];
61-
} else {
62-
$registrarModuleName = null;
6355
}
6456

65-
// If the registrarModuleName is not null and equals synergywholesaledomains
66-
if (!is_null($registrarModuleName) && "synergywholesaledomains" == $registrarModuleName) {
67-
// Redirect to our custom page
68-
header("Location: clientarea.php?action=domaindetails&id=" . $domainid . "&modop=custom&a=manageDNSURLForwarding");
57+
if ('synergywholesaledomains' === $registrarModuleName) {
58+
header('Location: clientarea.php?action=domaindetails&id=' . $domain_id . '&modop=custom&a=manageDNSURLForwarding');
6959
}
7060
});
7161

72-
// We use this hook to override the WHMCS default domain email forwarding page
73-
// We want to go to our custom page, as long as the registrarModuleName is set and
74-
// is pointing to our custom module
62+
/**
63+
* Override the Email Forwarding page to link to our custom one
64+
*/
7565
add_hook('ClientAreaPageDomainEmailForwarding', 1, function (array $vars) {
7666

77-
// Map the domain id
78-
$domainid = $vars['domainid'];
67+
$domain_id = $vars['domainid'];
68+
$registrarModuleName = null;
7969

80-
// If the registarModule under dnsrecords -> vars is set then assign it
81-
// Otherwise is null
8270
if (isset($vars['emailforwarders']['vars']['registrarModule'])) {
8371
$registrarModuleName = $vars['emailforwarders']['vars']['registrarModule'];
84-
} else {
85-
$registrarModuleName = null;
8672
}
8773

88-
// If the registrarModuleName is not null and equals synergywholesaledomains
89-
if (!is_null($registrarModuleName) && "synergywholesaledomains" == $registrarModuleName) {
90-
// Redirect to our custom page
91-
header("Location: clientarea.php?action=domaindetails&id=" . $domainid . "&modop=custom&a=manageEmailForwarding");
74+
if ('synergywholesaledomains' === $registrarModuleName) {
75+
header('Location: clientarea.php?action=domaindetails&id=' . $domain_id . '&modop=custom&a=manageEmailForwarding');
9276
}
9377
});
9478

95-
// https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-specific-JavaScripts-
79+
/**
80+
* We've had reports of things not working/loading properly when they're using Cloudflare Rocket Loader, so let's add an exemption.
81+
* @see https://support.cloudflare.com/hc/en-us/articles/200169436-How-can-I-have-Rocket-Loader-ignore-specific-JavaScripts-
82+
*/
9683
add_hook('ClientAreaHeadOutput', 1, function (array $vars) {
9784
return str_replace('{WEB_ROOT}', $vars['WEB_ROOT'], '
9885
<script data-cfasync="false" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
9986
<link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet" />
100-
<script data-cfasync="false" src="{WEB_ROOT}/modules/registrars/synergywholesaledomains/js/functions.min.js?v=2.1.2"></script>
101-
<link rel="stylesheet" type="text/css" href="{WEB_ROOT}/modules/registrars/synergywholesaledomains/css/synergywholesaledomains.min.css?v=2.1.2" />
87+
<script data-cfasync="false" src="{WEB_ROOT}/modules/registrars/synergywholesaledomains/js/functions.min.js?v=2.1.3"></script>
88+
<link rel="stylesheet" type="text/css" href="{WEB_ROOT}/modules/registrars/synergywholesaledomains/css/synergywholesaledomains.min.css?v=2.1.3" />
10289
');
10390
});
91+
92+
93+
/*
94+
* Remove the "Domain Currently Unlocked!" error message on the domain overview for TLDs that don't support registrar lock (such as .au)
95+
*/
96+
add_hook('ClientAreaPageDomainDetails', 1, function (array $vars) {
97+
98+
$menu = Menu::context('domain');
99+
100+
if (preg_match('/\.au$/', $menu->domain) && 'synergywholesaledomains' === $menu->registrar) {
101+
// Required to hide the error message
102+
$vars['managementoptions']['locking'] = false;
103+
$vars['lockstatus'] = false;
104+
105+
return $vars;
106+
}
107+
});

0 commit comments

Comments
 (0)