Check if serial is an integer, so we know if it's a new zone. Also, return the new zone upon saving it.

This commit is contained in:
Mark Schouten 2016-08-03 16:07:48 +02:00
parent 2cc92e6842
commit cf754d0135

View file

@ -52,7 +52,7 @@ class PdnsAPI {
unset($zonedata['url']);
unset($zonedata['rrsets']);
if ($zone['serial'] == '') {
if (gettype($zone['serial']) != 'integer') {
$api->method = 'POST';
$api->url = '/servers/localhost/zones';
$api->content = json_encode($zonedata);
@ -66,9 +66,13 @@ class PdnsAPI {
$api->call();
// Then, update the rrsets
$api->method = 'PATCH';
$api->content = json_encode(Array('rrsets' => $zone['rrsets']));
$api->call();
if (count($zone['rrsets']) > 0) {
$api->method = 'PATCH';
$api->content = json_encode(Array('rrsets' => $zone['rrsets']));
$api->call();
}
return $this->loadzone($zone['id']);
}
public function deletezone($zoneid) {