class ZoneTemplate (View source)

Template functions

Methods

__construct(PDO $db, ConfigurationInterface $config, DnsBackendProvider|null $backendProvider = null, LoggerInterface|null $logger = null)

No description

static array
replaceWithTemplatePlaceholders(string $domain, array $record, array $options = [])

Replace domain and specific placeholders in DNS records with template placeholders

array
getListZoneTempl(int $userid)

Get a list of all available zone templates

int|null
getDefaultTemplateId()

Resolve the system-wide default zone template

bool
setDefaultTemplate(int $zone_templ_id)

Mark a template as the system-wide default. Clears is_default from all other templates so only one is flagged at a time. Personal templates (owner != 0) cannot be marked default.

bool
unsetDefaultTemplate()

Clear the system-wide default zone template flag.

bool
addZoneTempl(array $details, int $userid)

Add a zone template

static 
getZoneTemplName($db, $zone_id)

No description

static array
getZoneTemplDetails(PDO $db, int $zone_templ_id)

Get name and description of template based on template ID

bool
deleteZoneTempl(int $zone_templ_id)

Delete a zone template

static int
countZoneTemplRecords(mixed $db, int $zone_templ_id)

Count zone template records

static bool
zoneTemplIdExists(PDO $db, int $zone_templ_id)

Check if zone template exist

static array
getZoneTemplRecordFromId(PDO $db, int $id, int|null $zone_templ_id = null)

Get a zone template record from an id

static array
getZoneTemplRecords(PDO $db, int $id, int $rowstart = 0, int $rowamount = Constants::DEFAULT_MAX_ROWS, string $sortby = 'name')

Get all zone template records from a zone template id

bool
addZoneTemplRecord(int $zone_templ_id, string $name, string $type, string $content, int $ttl, int $prio)

Add a record for a zone template

bool
editZoneTemplRecord(array $record, int $zone_templ_id)

Modify zone template record

bool
deleteZoneTemplRecord(int $rid, int $zone_templ_id)

Delete a record for a zone template by a given id

bool
canUseTemplate(mixed $zone_templ_id, int $userid, bool $isAdmin)

Whether a posted template id may be applied to a zone.

bool
canCurrentUserUseTemplate(mixed $zone_templ_id)

canUseTemplate() for the logged-in user.

bool
isUserOwnerOfTemplate(int $zone_templ_id, int $userid)

No description

bool
addZoneTemplSaveAs(string $template_name, string $description, int $userid, array $records, array $options, string $domain = '')

Add a zone template from zone / another template

array
getListZoneUseTempl(int $zone_templ_id, int $userid)

Get list of all zones using template

array
getZoneAndDomainIdsByTemplate(int $zone_templ_id, int $userid)

Get id pairs for zones using a template.

array
getZonesUsingTemplate(int $zone_templ_id, int $userid)

Get detailed information about zones using a specific template

bool
editZoneTempl(array $details, int $zone_templ_id, int $user_id)

Modify zone template

bool
unlinkZoneFromTemplate(int $zone_id)

Unlink a zone from its template

array
getZonesByIds(array $zone_ids)

Get zone details by zone IDs

bool
zoneTemplNameExists(string $zone_templ_name)

Check if zone template name exists

array
getZoneTemplIdsByName(string $name)

Get zone template IDs by name

bool
zoneTemplNameAndIdExists(string $zone_templ_name, int $zone_templ_id)

Check if zone template name and id exists

string
parseTemplateValue(string $val, string $domain, string|null $recordType = null)

Parse string and substitute domain and serial

Details

__construct(PDO $db, ConfigurationInterface $config, DnsBackendProvider|null $backendProvider = null, LoggerInterface|null $logger = null)

No description

Parameters

PDO $db
ConfigurationInterface $config
DnsBackendProvider|null $backendProvider
LoggerInterface|null $logger

static array replaceWithTemplatePlaceholders(string $domain, array $record, array $options = [])

Replace domain and specific placeholders in DNS records with template placeholders

Parameters

string $domain
array $record
array $options

Return Value

array

array getListZoneTempl(int $userid)

Get a list of all available zone templates

Parameters

int $userid

User ID

Return Value

array

array of zone templates [id,name,descr]

int|null getDefaultTemplateId()

Resolve the system-wide default zone template

Resolution order:

  1. The template with is_default = 1 (global only, owner = 0)
  2. The dns.default_zone_template config setting (id or name)
  3. null (no default; the form falls back to "none")

Names that resolve to multiple templates cause the config setting to be skipped with a warning logged - operators must use the id or rename one of the duplicates.

Return Value

int|null

Template id, or null if no default is configured

bool setDefaultTemplate(int $zone_templ_id)

Mark a template as the system-wide default. Clears is_default from all other templates so only one is flagged at a time. Personal templates (owner != 0) cannot be marked default.

Parameters

int $zone_templ_id

Template id to flag default

Return Value

bool

True on success, false if the template is not global or does not exist

bool unsetDefaultTemplate()

Clear the system-wide default zone template flag.

Return Value

bool

True on success

bool addZoneTempl(array $details, int $userid)

Add a zone template

Parameters

array $details

zone template details

int $userid

User ID that owns template

Return Value

bool

true on success, false otherwise

static getZoneTemplName($db, $zone_id)

No description

Parameters

$db
$zone_id

static array getZoneTemplDetails(PDO $db, int $zone_templ_id)

Get name and description of template based on template ID

Parameters

PDO $db

Database connection

int $zone_templ_id

Zone template ID

Return Value

array

zone template details

bool deleteZoneTempl(int $zone_templ_id)

Delete a zone template

Parameters

int $zone_templ_id

Zone template ID

Return Value

bool

true on success, false otherwise

static int countZoneTemplRecords(mixed $db, int $zone_templ_id)

Count zone template records

Parameters

mixed $db
int $zone_templ_id

Zone template ID

Return Value

int

number of records

static bool zoneTemplIdExists(PDO $db, int $zone_templ_id)

Check if zone template exist

Parameters

PDO $db

Database connection

int $zone_templ_id

Zone template ID

Return Value

bool

true on success, false otherwise

static array getZoneTemplRecordFromId(PDO $db, int $id, int|null $zone_templ_id = null)

Get a zone template record from an id

Retrieve all fields of the record and send it back to the function caller.

Parameters

PDO $db

Database connection

int $id

zone template record id

int|null $zone_templ_id

restrict the lookup to this template; callers that authorised a template must pass it so a record id from another template cannot be read

Return Value

array

zone template record [id,zone_templ_id,name,type,content,ttl,prio] or an empty array if nothing is found

static array getZoneTemplRecords(PDO $db, int $id, int $rowstart = 0, int $rowamount = Constants::DEFAULT_MAX_ROWS, string $sortby = 'name')

Get all zone template records from a zone template id

Retrieve all fields of the records and send it back to the function caller.

Parameters

PDO $db

Database connection

int $id

zone template ID

int $rowstart

Starting row (default=0)

int $rowamount

Number of rows per query (default=9999)

string $sortby

Column to sort by (default='name')

Return Value

array

zone template records numerically indexed [id,zone_templd_id,name,type,content,ttl,pro] or empty array if nothing is found

bool addZoneTemplRecord(int $zone_templ_id, string $name, string $type, string $content, int $ttl, int $prio)

Add a record for a zone template

This function validates and if correct it inserts it into the database.

Parameters

int $zone_templ_id

zone template ID

string $name

name part of record

string $type

record type

string $content

record content

int $ttl TTL
int $prio Priority

Return Value

bool

true if successful, false otherwise

bool editZoneTemplRecord(array $record, int $zone_templ_id)

Modify zone template record

Edit a record for a zone template. This function validates it if correct it inserts it into the database.

Parameters

array $record

zone record array

int $zone_templ_id

template the caller is authorized to edit

Return Value

bool

true on success, false otherwise

bool deleteZoneTemplRecord(int $rid, int $zone_templ_id)

Delete a record for a zone template by a given id

Parameters

int $rid

template record id

int $zone_templ_id

template the caller is authorized to edit

Return Value

bool

true on success, false otherwise

bool canUseTemplate(mixed $zone_templ_id, int $userid, bool $isAdmin)

Whether a posted template id may be applied to a zone.

Follows the listing scope: no template, a global template (owner 0), the user's own template, or any template for an administrator.

Parameters

mixed $zone_templ_id

Posted template id ("none", "", 0 or an id)

int $userid
bool $isAdmin

Return Value

bool

bool canCurrentUserUseTemplate(mixed $zone_templ_id)

canUseTemplate() for the logged-in user.

Parameters

mixed $zone_templ_id

Return Value

bool

bool isUserOwnerOfTemplate(int $zone_templ_id, int $userid)

No description

Parameters

int $zone_templ_id
int $userid

Return Value

bool

bool addZoneTemplSaveAs(string $template_name, string $description, int $userid, array $records, array $options, string $domain = '')

Add a zone template from zone / another template

Parameters

string $template_name

template name

string $description description
int $userid

user id

array $records

array of zone records

array $options
string $domain

domain to substitute with '[ZONE]' (optional) [default=null]

Return Value

bool

true on success, false otherwise

array getListZoneUseTempl(int $zone_templ_id, int $userid)

Get list of all zones using template

Parameters

int $zone_templ_id

zone template id

int $userid

user id

Return Value

array

array of zones ids

array getZoneAndDomainIdsByTemplate(int $zone_templ_id, int $userid)

Get id pairs for zones using a template.

Returns rows of ['zone_id' => zones.id, 'domain_id' => zones.domain_id] so callers can pass the right value to PowerDNS-side operations (domain_id) and to Poweradmin-native sync tracking (zone_id). On SQL backends the result is inner-joined against the PowerDNS domains table to skip orphaned mappings whose domain_id no longer exists (those would crash later in updateZoneRecords).

Parameters

int $zone_templ_id

zone template id

int $userid

user id

Return Value

array

array getZonesUsingTemplate(int $zone_templ_id, int $userid)

Get detailed information about zones using a specific template

Parameters

int $zone_templ_id

zone template id

int $userid

user id

Return Value

array

array of zone details

bool editZoneTempl(array $details, int $zone_templ_id, int $user_id)

Modify zone template

Parameters

array $details

array of new zone template details

int $zone_templ_id

zone template id

int $user_id

User ID that is editing the template

Return Value

bool

true on success, false otherwise

bool unlinkZoneFromTemplate(int $zone_id)

Unlink a zone from its template

Parameters

int $zone_id

Zone ID to unlink

Return Value

bool

True on success, false on failure

array getZonesByIds(array $zone_ids)

Get zone details by zone IDs

Parameters

array $zone_ids

Array of zone IDs

Return Value

array

Array of zone details

bool zoneTemplNameExists(string $zone_templ_name)

Check if zone template name exists

Parameters

string $zone_templ_name

zone template name

Return Value

bool

number of matching templates

array getZoneTemplIdsByName(string $name)

Get zone template IDs by name

Returns all template IDs matching the given name. Since template names are not unique in the database, multiple IDs may be returned.

Parameters

string $name

Zone template name

Return Value

array

Array of matching template IDs

bool zoneTemplNameAndIdExists(string $zone_templ_name, int $zone_templ_id)

Check if zone template name and id exists

Parameters

string $zone_templ_name

zone template name

int $zone_templ_id

zone template id

Return Value

bool

number of matching templates

string parseTemplateValue(string $val, string $domain, string|null $recordType = null)

Parse string and substitute domain and serial

Parameters

string $val

string to parse containing tokens like '[ZONE]', '[SERIAL]', '[UNIXTIME]' or '[COUNTER]'

string $domain

domain to substitute for '[ZONE]'

string|null $recordType

record type of $val; when given it authoritatively decides SOA-timer completion. Legacy 2-arg callers fall back to a heuristic.

Return Value

string

interpolated/parsed string