ZoneTemplate
class ZoneTemplate (View source)
Template functions
Methods
No description
Replace domain and specific placeholders in DNS records with template placeholders
Get a list of all available zone templates
Resolve the system-wide default zone template
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.
Clear the system-wide default zone template flag.
Add a zone template
No description
Get name and description of template based on template ID
Delete a zone template
Count zone template records
Get a zone template record from an id
Get all zone template records from a zone template id
Add a record for a zone template
Modify zone template record
Delete a record for a zone template by a given id
Whether a posted template id may be applied to a zone.
canUseTemplate() for the logged-in user.
No description
Add a zone template from zone / another template
Get list of all zones using template
Get id pairs for zones using a template.
Get detailed information about zones using a specific template
Modify zone template
Unlink a zone from its template
Get zone details by zone IDs
Check if zone template name exists
Get zone template IDs by name
Check if zone template name and id exists
Parse string and substitute domain and serial
Details
__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
Resolution order:
- The template with
is_default = 1(global only,owner = 0) - The
dns.default_zone_templateconfig setting (id or name) - 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.
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
Retrieve all fields of the record and send it back to the function caller.
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.
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.
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.
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.
Follows the listing scope: no template, a global template (owner 0), the user's own template, or any template for an administrator.
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.
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).
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
Returns all template IDs matching the given name. Since template names are not unique in the database, multiple IDs may be returned.
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