|
10 | 10 | // http://docs.whmcs.com/Editing_Client_Area_Menus
|
11 | 11 | use WHMCS\View\Menu\Item as MenuItem;
|
12 | 12 |
|
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 | + */ |
15 | 20 | add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) {
|
16 | 21 |
|
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'); |
31 | 33 | }
|
32 | 34 |
|
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'); |
38 | 37 | }
|
39 | 38 |
|
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'); |
45 | 41 | }
|
46 | 42 | }
|
47 | 43 | });
|
48 | 44 |
|
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 | + */ |
52 | 48 | add_hook('ClientAreaPageDomainDNSManagement', 1, function (array $vars) {
|
53 | 49 |
|
54 |
| - // Map the domain id |
55 |
| - $domainid = $vars['domainid']; |
| 50 | + $domain_id = $vars['domainid']; |
| 51 | + $registrarModuleName = null; |
56 | 52 |
|
57 |
| - // If the registarModule under dnsrecords -> vars is set then assign it |
58 |
| - // Otherwise is null |
59 | 53 | if (isset($vars['dnsrecords']['vars']['registrarModule'])) {
|
60 | 54 | $registrarModuleName = $vars['dnsrecords']['vars']['registrarModule'];
|
61 |
| - } else { |
62 |
| - $registrarModuleName = null; |
63 | 55 | }
|
64 | 56 |
|
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'); |
69 | 59 | }
|
70 | 60 | });
|
71 | 61 |
|
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 | + */ |
75 | 65 | add_hook('ClientAreaPageDomainEmailForwarding', 1, function (array $vars) {
|
76 | 66 |
|
77 |
| - // Map the domain id |
78 |
| - $domainid = $vars['domainid']; |
| 67 | + $domain_id = $vars['domainid']; |
| 68 | + $registrarModuleName = null; |
79 | 69 |
|
80 |
| - // If the registarModule under dnsrecords -> vars is set then assign it |
81 |
| - // Otherwise is null |
82 | 70 | if (isset($vars['emailforwarders']['vars']['registrarModule'])) {
|
83 | 71 | $registrarModuleName = $vars['emailforwarders']['vars']['registrarModule'];
|
84 |
| - } else { |
85 |
| - $registrarModuleName = null; |
86 | 72 | }
|
87 | 73 |
|
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'); |
92 | 76 | }
|
93 | 77 | });
|
94 | 78 |
|
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 | + */ |
96 | 83 | add_hook('ClientAreaHeadOutput', 1, function (array $vars) {
|
97 | 84 | return str_replace('{WEB_ROOT}', $vars['WEB_ROOT'], '
|
98 | 85 | <script data-cfasync="false" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
|
99 | 86 | <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" /> |
102 | 89 | ');
|
103 | 90 | });
|
| 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