class DbZoneRepository implements ZoneRepositoryInterface (View source)

Methods

__construct($db, $config, DnsBackendProvider|null $backendProvider = null)

No description

array
getDistinctStartingLetters(int $userId, bool $viewOthers)

No description

array|int
getReverseZones(string $permType, int $userId, string $reverseType = 'all', int $offset = 0, int $limit = 25, string $sortBy = 'name', string $sortDirection = 'ASC', bool $countOnly = false, bool $showSerial = false, bool $showTemplate = false, bool $includeHealth = true, bool $includeRecordCount = true)

Get reverse zones with efficient database-level filtering and pagination

array
getReverseZoneCounts(string $permType, int $userId)

Get all reverse zone counts in a single query (optimization)

string|null
getDomainNameById(int $zoneId)

Get domain name by ID

array
listZones(int|null $userId = null, bool $viewOthers = false, array $filters = [], int $offset = 0, int $limit = 100)

Get a complete list of zones accessible by the current user

bool
zoneExists(int $zoneId, int|null $userId = null)

Check if a zone exists and is accessible by a user

array|null
getZone(int $zoneId)

Get a zone by ID with full details

array|null
getZoneByName(string $zoneName)

Get a zone by name with full details

array
findForwardZonesByPtrRecords(array $reverseZoneIds)

Find forward zones associated with reverse zones through PTR records

bool
zoneIdExists(int $zoneId)

Check if zone exists by ID

string
getDomainType(int $zoneId)

Get domain type by zone ID

string|null
getDomainSlaveMaster(int $zoneId)

Get slave master by zone ID

string|null
getZoneComment(int $zoneId)

Get zone comment by zone ID

bool
updateZoneComment(int $zoneId, string $comment)

Update zone comment

array
getZoneOwners(int $zoneId)

Get users who own a zone

array
getOwnerIdsByZoneIds(array $zoneIds)

Direct owners of several zones in one query, for list pages.

array
getOwnedZoneIds(int $userId)

Ids of every zone the user owns directly or through a group, in the id space the zone logs and zones_groups use.

bool
addOwnerToZone(int $zoneId, int $userId)

Add owner to zone

bool
removeOwnerFromZone(int $zoneId, int $userId)

Remove owner from zone

bool
isUserZoneOwner(int $zoneId, int $userId)

Check if user is already an owner of the zone

int|null
getZoneIdByName(string $zoneName)

Get zone ID by name

array
getDomainMetadata(int $zoneId)

Get raw PowerDNS domain metadata rows for a zone.

bool
replaceDomainMetadata(int $zoneId, array $metadata)

Replace all PowerDNS domain metadata rows for a zone.

bool
deleteZone(int $zoneId)

Delete a zone by ID

bool
updateZone(int $zoneId, array $updates)

Update zone metadata

array
getAllZones(int|null $offset = null, int|null $limit = null)

Get all zones with pagination

int
getZoneCount()

Get the total number of zones

int
getZoneCountFiltered(array|null $zoneIds, int|null $userId = null, string|null $nameFilter = null)

Get count of zones filtered by zone IDs (permission-aware)

array
getAllZonesFiltered(array|null $zoneIds, int|null $userId = null, string|null $nameFilter = null, int|null $offset = null, int|null $limit = null)

Get all zones filtered by zone IDs (permission-aware)

array|null
getZoneById(int $zoneId)

Get a zone by ID

Details

__construct($db, $config, DnsBackendProvider|null $backendProvider = null)

No description

Parameters

$db
$config
DnsBackendProvider|null $backendProvider

array getDistinctStartingLetters(int $userId, bool $viewOthers)

No description

Parameters

int $userId
bool $viewOthers

Return Value

array

array|int getReverseZones(string $permType, int $userId, string $reverseType = 'all', int $offset = 0, int $limit = 25, string $sortBy = 'name', string $sortDirection = 'ASC', bool $countOnly = false, bool $showSerial = false, bool $showTemplate = false, bool $includeHealth = true, bool $includeRecordCount = true)

Get reverse zones with efficient database-level filtering and pagination

Parameters

string $permType

Permission type ('all', 'own')

int $userId

User ID (used when permType is 'own')

string $reverseType

Filter by reverse zone type ('all', 'ipv4', 'ipv6')

int $offset

Pagination offset

int $limit

Maximum number of records to return

string $sortBy

Column to sort by

string $sortDirection

Sort direction ('ASC' or 'DESC')

bool $countOnly

If true, returns only the count of matching zones

bool $showSerial
bool $showTemplate
bool $includeHealth
bool $includeRecordCount

Return Value

array|int

Array of reverse zones or count if countOnly is true

array getReverseZoneCounts(string $permType, int $userId)

Get all reverse zone counts in a single query (optimization)

Parameters

string $permType

Permission type ('all', 'own')

int $userId

User ID (used when permType is 'own')

Return Value

array

string|null getDomainNameById(int $zoneId)

Get domain name by ID

Parameters

int $zoneId

The zone ID

Return Value

string|null

The domain name or null if not found

array listZones(int|null $userId = null, bool $viewOthers = false, array $filters = [], int $offset = 0, int $limit = 100)

Get a complete list of zones accessible by the current user

Parameters

int|null $userId

Optional user ID for filtering

bool $viewOthers

Whether user can view other users' zones

array $filters

Optional filters

int $offset

Pagination offset

int $limit

Maximum number of records

Return Value

array

Array of zones

bool zoneExists(int $zoneId, int|null $userId = null)

Check if a zone exists and is accessible by a user

Parameters

int $zoneId

The zone ID

int|null $userId

Optional user ID

Return Value

bool

True if zone exists

array|null getZone(int $zoneId)

Get a zone by ID with full details

Parameters

int $zoneId

The zone ID

Return Value

array|null

The zone data or null if not found

array|null getZoneByName(string $zoneName)

Get a zone by name with full details

Parameters

string $zoneName

The zone name

Return Value

array|null

Zone data if found, null otherwise

array findForwardZonesByPtrRecords(array $reverseZoneIds)

Find forward zones associated with reverse zones through PTR records

Optimized 3-step approach instead of slow LIKE JOIN:

  1. Fetch all PTR records for reverse zones
  2. Extract domain suffixes from PTR content in PHP
  3. Look up forward zones with exact IN() match (uses indexes)

Parameters

array $reverseZoneIds

Array of reverse zone IDs

Return Value

array

Array of PTR record matches with forward zone information

bool zoneIdExists(int $zoneId)

Check if zone exists by ID

Parameters

int $zoneId

The zone ID

Return Value

bool

True if zone exists

string getDomainType(int $zoneId)

Get domain type by zone ID

Parameters

int $zoneId

The zone ID

Return Value

string

The domain type (MASTER, SLAVE, NATIVE)

string|null getDomainSlaveMaster(int $zoneId)

Get slave master by zone ID

Parameters

int $zoneId

The zone ID

Return Value

string|null

The slave master or null if not found

string|null getZoneComment(int $zoneId)

Get zone comment by zone ID

Parameters

int $zoneId

The zone ID

Return Value

string|null

The zone comment or null if not found

bool updateZoneComment(int $zoneId, string $comment)

Update zone comment

Parameters

int $zoneId

The zone ID

string $comment

The new comment

Return Value

bool

True if updated successfully

array getZoneOwners(int $zoneId)

Get users who own a zone

Parameters

int $zoneId

The zone ID

Return Value

array

Array of user information

array getOwnerIdsByZoneIds(array $zoneIds)

Direct owners of several zones in one query, for list pages.

Parameters

array $zoneIds

Return Value

array

Zone id => owner user ids; zones without a row are absent

array getOwnedZoneIds(int $userId)

Ids of every zone the user owns directly or through a group, in the id space the zone logs and zones_groups use.

Parameters

int $userId

Return Value

array

bool addOwnerToZone(int $zoneId, int $userId)

Add owner to zone

Parameters

int $zoneId

The zone ID

int $userId

The user ID

Return Value

bool

True if added successfully

bool removeOwnerFromZone(int $zoneId, int $userId)

Remove owner from zone

Parameters

int $zoneId

The zone ID

int $userId

The user ID

Return Value

bool

True if removed successfully

bool isUserZoneOwner(int $zoneId, int $userId)

Check if user is already an owner of the zone

Parameters

int $zoneId

The zone ID

int $userId

The user ID

Return Value

bool

True if user is already an owner

int|null getZoneIdByName(string $zoneName)

Get zone ID by name

Parameters

string $zoneName

The zone name

Return Value

int|null

The zone ID or null if not found

array getDomainMetadata(int $zoneId)

Get raw PowerDNS domain metadata rows for a zone.

Parameters

int $zoneId

The zone ID

Return Value

array

Array of metadata rows [['kind' => string, 'content' => string], ...]

bool replaceDomainMetadata(int $zoneId, array $metadata)

Replace all PowerDNS domain metadata rows for a zone.

Parameters

int $zoneId

The zone ID

array $metadata

Array of metadata rows [['kind' => string, 'content' => string], ...]

Return Value

bool

True if metadata was replaced successfully

bool deleteZone(int $zoneId)

Delete a zone by ID

Parameters

int $zoneId

The zone ID

Return Value

bool

True if zone was deleted successfully

bool updateZone(int $zoneId, array $updates)

Update zone metadata

Parameters

int $zoneId

The zone ID

array $updates

Array of field => value pairs to update

Return Value

bool

True if zone was updated successfully

array getAllZones(int|null $offset = null, int|null $limit = null)

Get all zones with pagination

Parameters

int|null $offset

Pagination offset

int|null $limit

Maximum number of records to return

Return Value

array

Array of zones

int getZoneCount()

Get the total number of zones

Return Value

int

Total number of zones

int getZoneCountFiltered(array|null $zoneIds, int|null $userId = null, string|null $nameFilter = null)

Get count of zones filtered by zone IDs (permission-aware)

Parameters

array|null $zoneIds

Optional array of zone IDs to filter

int|null $userId

Optional user ID filter

string|null $nameFilter

Optional name filter

Return Value

int

Number of matching zones

array getAllZonesFiltered(array|null $zoneIds, int|null $userId = null, string|null $nameFilter = null, int|null $offset = null, int|null $limit = null)

Get all zones filtered by zone IDs (permission-aware)

Parameters

array|null $zoneIds

Optional array of zone IDs to filter

int|null $userId

Optional user ID filter

string|null $nameFilter

Optional name filter

int|null $offset

Optional pagination offset

int|null $limit

Optional pagination limit

Return Value

array

Array of matching zones

array|null getZoneById(int $zoneId)

Get a zone by ID

Parameters

int $zoneId

Zone ID

Return Value

array|null

Zone data if found, null otherwise