Skip to content

Commit 91550b6

Browse files
committed
RT-16779 cleanup/improvements to implementation
1 parent b3e04b1 commit 91550b6

11 files changed

Lines changed: 43 additions & 36 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ We also provide widgets for you to use on your admin homepage:
3939
Please check the latest [Releases](https://github.com/realtimeregister/whmcs-domains/releases) and Download files
4040

4141
### Suggestions, Bugs, Issues, New Features
42-
You are of course welcome to send us requests for new features, suggestions, issues or any possible bugs found
43-
[Submission form](https://github.com/realtimeregister/whmcs-domains/issues/new/choose)
42+
You are of course more than welcome to send us requests for new features, suggestions, issues or any possible bugs found
43+
[via Github issues](https://github.com/realtimeregister/whmcs-domains/issues/new).
4444

4545
### WIKI
4646
Check out our [WIKI](https://github.com/realtimeregister/whmcs-domains/wiki) for manuals and description of all features.

modules/registrars/realtimeregister/composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/registrars/realtimeregister/lang/dutch.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
$_LANG['rtr']['public_key'] = 'Publieke sleutel';
6666

6767
$_LANG['rtr']['date'] = 'Datum';
68+
$_LANG['rtr']['type'] = 'Soort';
6869
$_LANG['rtr']['action'] = 'Actie';
6970
$_LANG['rtr']['status'] = 'Status';
7071

modules/registrars/realtimeregister/lang/english.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
$_LANG['rtr']['public_key'] = 'Public key';
7272

7373
$_LANG['rtr']['date'] = 'Date';
74+
$_LANG['rtr']['type'] = 'Type';
7475
$_LANG['rtr']['action'] = 'Action';
7576
$_LANG['rtr']['status'] = 'Status';
7677

modules/registrars/realtimeregister/realtimeregister.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,14 @@ function realtimeregister_GetDomainSuggestions($params)
203203
return App::dispatch(\RealtimeRegisterDomains\Actions\Domains\DomainSuggestions::class, $params);
204204
}
205205

206-
function realtimeregister_GetDNS($params)
207-
{
208-
return App::dispatch(\RealtimeRegisterDomains\Actions\Domains\GetDns::class, $params);
209-
}
210-
211-
function realtimeregister_SaveDNS($params)
212-
{
213-
return App::dispatch(\RealtimeRegisterDomains\Actions\Domains\SaveDns::class, $params);
206+
if (App::registrarConfig()->hasDnsSupport()) {
207+
function realtimeregister_GetDNS($params)
208+
{
209+
return App::dispatch(\RealtimeRegisterDomains\Actions\Domains\GetDns::class, $params);
210+
}
211+
212+
function realtimeregister_SaveDNS($params)
213+
{
214+
return App::dispatch(\RealtimeRegisterDomains\Actions\Domains\SaveDns::class, $params);
215+
}
214216
}

modules/registrars/realtimeregister/src/Actions/Domains/SaveDns.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
class SaveDns extends Action
1515
{
16+
private ZoneServiceEnum $serviceType;
17+
1618
public function __invoke(Request $request): array
1719
{
18-
if ($request->params['dnsmanagement'] === true && App::registrarConfig()->hasDnsSupport()) {
20+
if ($request->params['dnsmanagement'] === true && App::registrarConfig()->hasDnsSupport() === true) {
21+
$this->serviceType = ZoneServiceEnum::from(App::registrarConfig()->get('dns_support'));
1922
$domain = $this->domainInfo($request);
2023
$zone = App::client()->domains->get($domain->domainName)->zone;
2124
return $this->processUpdate($zone, $domain, $_POST['soa'], $_POST['dns-items']);
@@ -50,7 +53,7 @@ private function processUpdate(?Zone $zone, DomainDetails $domain, array $soaDat
5053
$dnsRecords[$k]['name'] = $domain->domainName;
5154
}
5255

53-
if (!in_array('ttl', $data)) {
56+
if (!array_key_exists('ttl', $data)) {
5457
$dnsRecords[$k]['ttl'] = 3600;
5558
}
5659
}
@@ -67,28 +70,22 @@ private function processUpdate(?Zone $zone, DomainDetails $domain, array $soaDat
6770
'ttl' => (int)$soaData['ttl'],
6871
'records' => DomainZoneRecordCollection::fromArray($dnsRecords)
6972
];
70-
7173
if (!$zone) {
7274
App::client()->dnszones->create(
7375
name: $domain->domainName,
74-
service: App::registrarConfig()->get('dns_support') === 'basic' ? ZoneServiceEnum::BASIC
75-
: ZoneServiceEnum::PREMIUM,
76+
service: $this->serviceType,
7677
hostMaster: $soaData['hostmaster'],
7778
refresh: (int)$soaData['refresh'],
7879
retry: (int)$soaData['retry'],
7980
expire: (int)$soaData['expire'],
8081
records: DomainZoneRecordCollection::fromArray($dnsRecords),
8182
);
82-
8383
// Enable the just created zone, and thus, enable it to the domain
8484
App::client()->domains->update(
8585
domainName: $domain->domainName,
8686
zone: Zone::fromArray(
8787
[
88-
'service' => App::registrarConfig()->get(
89-
'dns_support'
90-
) === 'basic' ? ZoneServiceEnum::BASIC->value : ZoneServiceEnum::PREMIUM->value,
91-
'managed' => true
88+
'service' => $this->serviceType->value,
9289
]
9390
)
9491
);

modules/registrars/realtimeregister/src/Assets/Tpl/admin/processes_log.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
<tbody>
66
<tr>
77
<th>{$LANG.rtr.date}</th>
8+
<th>{$LANG.rtr.type}</th>
89
<th>{$LANG.rtr.action}</th>
910
<th>{$LANG.rtr.status}</th>
1011
</tr>
1112
{if $processes}
1213
{foreach from=$processes item=process}
1314
<tr class="clickable-row" data-href="{$process.link}">
1415
<td class="nowrap">{$process.createdDate|date_format:"l Y-m-d H:i:s"}</td>
16+
<td>{$process.type}</td>
1517
<td>{$process.action}</td>
1618
<td>{$process.status}</td>
1719
</tr>

modules/registrars/realtimeregister/src/ConfigArray.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace RealtimeRegisterDomains;
44

55
use Illuminate\Database\Capsule\Manager as Capsule;
6+
use RealtimeRegister\Domain\Enum\ZoneServiceEnum;
67

78
class ConfigArray
89
{
@@ -168,7 +169,11 @@ public function __invoke(): array
168169
'dns_support' => [
169170
'FriendlyName' => 'DNS support',
170171
'Type' => 'dropdown',
171-
'Options' => ['none', 'basic', 'premium'],
172+
'Options' => [
173+
'none',
174+
ZoneServiceEnum::BASIC->value => ZoneServiceEnum::BASIC->value,
175+
ZoneServiceEnum::PREMIUM->value => ZoneServiceEnum::PREMIUM->value,
176+
],
172177
'Default' => 'none',
173178
'Description' => 'Enable DNS support from Realtime Register. The option <strong>Premium</strong> ' .
174179
'will yield <b>1 payed zone per domain</b>. The price of the DNS support can be set in the ' .

modules/registrars/realtimeregister/src/Entities/RegistrarConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function apiKey(): ?string
3434

3535
public function hasDnsSupport(): bool
3636
{
37-
$dnsSupport = $this->get('dns_support', 'none');
38-
if ($dnsSupport === 'none') {
37+
$dnsSupport = $this->get('dns_support', '');
38+
if ($dnsSupport === '') {
3939
return false;
4040
}
4141
return true;

modules/registrars/realtimeregister/src/Hooks/AdminClientDomainsTabFields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __invoke(DataObject $vars): array
3939
$processes = array_map(
4040
fn($process) => [...$process, 'link' => App::portalUrl() . '/app/process/' . $process['id']],
4141
App::client()->processes->export([
42-
'fields' => 'createdDate,action,status,id',
42+
'fields' => 'createdDate,type,action,status,id',
4343
'order' => '-createdDate',
4444
'identifier:eq' => $domainName
4545
])

0 commit comments

Comments
 (0)