DbZoneTemplateRepository
class DbZoneTemplateRepository implements ZoneTemplateRepositoryInterface (View source)
SQL persistence for zone templates in zone_templ and their records in zone_templ_records.
The zone listings join the PowerDNS tables on SQL backends; on the API backend they read the Poweradmin-native zones table only and take zone details from the backend provider.
Constants
| private DEFAULT_SOA_NAME |
Default SOA record stamped into a template that carries none. |
| private DEFAULT_SOA_CONTENT |
|
Methods
No description
List zone templates visible to the given user
WHERE condition for the templates a user may see: global ones, their own, and those shared with a group they belong to. Takes two placeholders bound to the same user id, since native MySQL prepares cannot reuse one.
Whether the template is shared with a group the user belongs to.
Groups each template is shared with, sorted by name. With a viewer, a template the viewer does not own lists only the groups the viewer belongs to.
Replace the groups a template is shared with.
Get zone template details by ID
Get the template name linked to a zone
Get all records for a zone template
Get a single zone template record by ID
Count records in a zone template
ID of the global template flagged is_default, if any
Whether a global template (owner 0) with this ID exists
Find global templates (owner 0) by name
Flag one global template as the default, clearing every other global template
Clear the system-wide default template flag
Create a new zone template with a default SOA record
Create a zone template together with its records, in one transaction
Update a zone template
Delete a zone template and all related records
Deletes every template the user owns, with its records and zone links.
The user's templates that are shared with at least one group, sorted by name.
Give the user's shared templates to another user, so the groups keep them when the owner is deleted. Runs inside the caller's transaction.
Add a record to a zone template
Update a zone template record
Delete a zone template record
Unlink a zone from its template
The template a zone is linked to.
Point a zone at a template; 0 unlinks it.
The zones.id rows of a zone. A zone shared by several owners has one row per owner, and the template sync state keys on that id.
Check if a zone template exists
Check if a zone template name already exists
Find every template ID carrying the given name
Check if user is the owner of a zone template
Get the owner ID of a zone template
Zone IDs of the zones linked to a template
Both ids of every zone linked to a template
The zones linked to a template with name, type, record count and owner details
Name and type of the given zones
Details
__construct(object $db, ConfigurationInterface|null $config = null, DnsBackendProviderInterface|null $backendProvider = null)
No description
array
listZoneTemplates(int|null $userId, bool $isUeberuser)
List zone templates visible to the given user
static string
visibleToUserSql(string $alias, string $userParam, string $groupUserParam)
WHERE condition for the templates a user may see: global ones, their own, and those shared with a group they belong to. Takes two placeholders bound to the same user id, since native MySQL prepares cannot reuse one.
bool
isSharedWithUser(int $templateId, int $userId)
Whether the template is shared with a group the user belongs to.
array
listGroupsForTemplates(array $templateIds, int|null $viewerId = null)
Groups each template is shared with, sorted by name. With a viewer, a template the viewer does not own lists only the groups the viewer belongs to.
void
replaceTemplateGroups(int $templateId, array $groupIds)
Replace the groups a template is shared with.
array|false
getZoneTemplateDetails(int $id)
Get zone template details by ID
string
getTemplateNameForZone(int|string $zoneId)
Get the template name linked to a zone
array
getZoneTemplateRecords(int $templateId, int $rowStart = 0, int $rowAmount = Constants::DEFAULT_MAX_ROWS, string $sortBy = 'name')
Get all records for a zone template
array
getZoneTemplateRecordById(int $id, int|null $templateId = null)
Get a single zone template record by ID
int
countZoneTemplateRecords(int $templateId)
Count records in a zone template
int|null
findFlaggedDefaultTemplateId()
ID of the global template flagged is_default, if any
bool
globalTemplateExists(int $id)
Whether a global template (owner 0) with this ID exists
array
findGlobalTemplateIdsByName(string $name)
Find global templates (owner 0) by name
void
flagDefaultTemplate(int $templateId)
Flag one global template as the default, clearing every other global template
void
clearDefaultTemplate()
Clear the system-wide default template flag
int
createZoneTemplate(string $name, string $description, int $owner, int $createdBy, array $groupIds = [])
Create a new zone template with a default SOA record
int
createZoneTemplateWithRecords(string $name, string $description, int $owner, int $createdBy, array $records, array $groupIds = [])
Create a zone template together with its records, in one transaction
bool
updateZoneTemplate(int $id, string $name, string $description, int|null $owner = null)
Update a zone template
bool
deleteZoneTemplate(int $id)
Delete a zone template and all related records
void
deleteZoneTemplatesOwnedBy(int $ownerId)
Deletes every template the user owns, with its records and zone links.
Runs inside the caller's transaction (used by user deletion).
array
listSharedTemplatesOwnedBy(int $ownerId)
The user's templates that are shared with at least one group, sorted by name.
void
handOverSharedTemplates(int $ownerId, int $heirId)
Give the user's shared templates to another user, so the groups keep them when the owner is deleted. Runs inside the caller's transaction.
int
addRecord(int $templateId, string $name, string $type, string $content, int $ttl, int $prio)
Add a record to a zone template
bool
updateRecord(int $id, string $name, string $type, string $content, int $ttl, int $prio)
Update a zone template record
bool
deleteRecord(int $id)
Delete a zone template record
bool
unlinkZoneFromTemplate(int $zoneId)
Unlink a zone from its template
int
getTemplateIdForZone(int $zoneId)
The template a zone is linked to.
void
assignTemplateToZone(int $zoneId, int $templateId)
Point a zone at a template; 0 unlinks it.
array
listZoneRowIds(int $zoneId)
The zones.id rows of a zone. A zone shared by several owners has one row per owner, and the template sync state keys on that id.
bool
zoneTemplateExists(int $id)
Check if a zone template exists
bool
zoneTemplateNameExists(string $name, int|null $excludeId = null)
Check if a zone template name already exists
array
findTemplateIdsByName(string $name)
Find every template ID carrying the given name
bool
isOwner(int $templateId, int $userId)
Check if user is the owner of a zone template
int|null
getOwner(int $templateId)
Get the owner ID of a zone template
array
listLinkedZoneIds(int $templateId, int|null $ownerId)
Zone IDs of the zones linked to a template
array
listLinkedZoneIdPairs(int $templateId, int|null $ownerId)
Both ids of every zone linked to a template
array
listLinkedZones(int $templateId, int|null $ownerId)
The zones linked to a template with name, type, record count and owner details
array
getZonesByIds(array $zoneIds)
Name and type of the given zones