Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Jwineman/pi 552 advanced zone editor check #100

Merged
merged 3 commits into from
Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions src/Cpanel/ClientActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public function patchDNSRecord()
*/
public function deleteZone()
{
if(!$this->cpanelAPI->isAdvancedZoneEditEnabled()) {
return $this->api->createAPIError(Partial::ADVANCED_ZONE_EDIT_DISABLED_ERROR);
}

$path_array = explode('/', $this->request->getUrl());
$zone_tag = $path_array[1];

Expand Down
8 changes: 8 additions & 0 deletions src/Cpanel/CpanelAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,12 @@ public function get_cpanel_dns_record_name($cloudflare_dns_record_name)
//cpanel uses the trailing dot for all record names
return $cloudflare_dns_record_name . ".";
}

public function isAdvancedZoneEditEnabled() {
/* Advanced Zone Editor is required to edit DNS records for partial zone provisioning.
* https://documentation.cpanel.net/display/SDK/Guide+to+the+LiveAPI+System+-+The+cpanelfeature%28%29+Method
* Returns 1 = enabled, 0 = disabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs should be
Returns True = enable, False = disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that comment is referring to what the cPanel method itself returns, I updated the PHPDoc on the method to reflect the fact that the method returns a Boolean though.

*/
return $this->cpanel_api->cpanelfeature("zoneedit");
}
}
3 changes: 3 additions & 0 deletions src/Cpanel/HostActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function setPartialZoneSet(Partial $partialZoneSet) {
*/
public function partialZoneSet()
{
if(!$this->cpanelAPI->isAdvancedZoneEditEnabled()) {
return $this->api->createAPIError(Partial::ADVANCED_ZONE_EDIT_DISABLED_ERROR);
}
$bodyParameters = $this->request->getBody();
if (isset($bodyParameters["zone_name"])) {
if ($this->partialZoneSet->partialZoneSet("www." . $bodyParameters["zone_name"] . ".", $bodyParameters["zone_name"])) {
Expand Down
1 change: 1 addition & 0 deletions src/Cpanel/Zone/Partial.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Partial

const FORWARD_TO_SUFFIX = "cdn.cloudflare.net";
const RESOLVE_TO_PREFIX = "cloudflare-resolve-to.";
const ADVANCED_ZONE_EDIT_DISABLED_ERROR = "CloudFlare cPanel Plugin configuration issue! Please contact your hosting provider to enable \"Advanced DNS Zone Editor\"";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localization?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backends aren't localized yet


/**
* @param CpanelAPI $cpanel_api
Expand Down