Skip to content

Commit

Permalink
feat: Enable 'disabled' state management in DNS records
Browse files Browse the repository at this point in the history
  • Loading branch information
edmondas committed Dec 3, 2023
1 parent e231476 commit 95ac0a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 8 additions & 4 deletions lib/DnsRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ public function edit_record(array $record): bool
type=" . $this->db->quote($record['type'], 'text') . ",
content=" . $this->db->quote($record['content'], 'text') . ",
ttl=" . $this->db->quote($record['ttl'], 'integer') . ",
prio=" . $this->db->quote($record['prio'], 'integer') . "
prio=" . $this->db->quote($record['prio'], 'integer') . ",
disabled=" . $this->db->quote($record['disabled'], 'integer') . "
WHERE id=" . $this->db->quote($record['rid'], 'integer');
$this->db->query($query);
return true;
Expand Down Expand Up @@ -1255,7 +1256,7 @@ public static function zone_count_ng($db, $db_type, string $perm, string $letter
*/
public static function get_record_from_id($db, int $id): int|array
{
$result = $db->queryRow("SELECT id, domain_id, name, type, content, ttl, prio FROM records WHERE id=" . $db->quote($id, 'integer') . " AND type IS NOT NULL");
$result = $db->queryRow("SELECT * FROM records WHERE id=" . $db->quote($id, 'integer') . " AND type IS NOT NULL");
if ($result) {
if ($result["type"] == "" || $result["content"] == "") {
return -1;
Expand All @@ -1268,7 +1269,10 @@ public static function get_record_from_id($db, int $id): int|array
"type" => $result["type"],
"content" => $result["content"],
"ttl" => $result["ttl"],
"prio" => $result["prio"]
"prio" => $result["prio"],
"disabled" => $result["disabled"],
"ordername" => $result["ordername"],
"auth" => $result["auth"],
);
} else {
return -1;
Expand Down Expand Up @@ -1303,7 +1307,7 @@ public static function get_records_from_domain_id($db, $db_type, int $id, int $r
}
$sql_sortby = ($sortby == 'name' ? $natural_sort : $sortby . ', ' . $natural_sort);

$records = $db->query("SELECT id, domain_id, name, type, content, ttl, prio
$records = $db->query("SELECT *
FROM records
WHERE domain_id=" . $db->quote($id, 'integer') . " AND type IS NOT NULL
ORDER BY type = 'SOA' DESC, type = 'NS' DESC," . $sql_sortby);
Expand Down
10 changes: 7 additions & 3 deletions templates/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ <h5 class="mb-3">{% trans %}Edit zone{% endtrans %} "{{ zone_name_to_display }}"
<th><a href="edit.php?id={{ zone_id }}&record_sort_by=ttl">{% trans %}TTL{% endtrans %}</a>
{% if record_sort_by == 'ttl' %}<i class="bi bi-arrow-down"></i>{% endif %}
</th>
<th>{% trans %}Disabled{% endtrans %}</th>
<th>&nbsp;</th>
</tr>
{% for r in records %}
Expand All @@ -69,6 +70,7 @@ <h5 class="mb-3">{% trans %}Edit zone{% endtrans %} "{{ zone_name_to_display }}"
<td>{{ r['content'] }}</td>
<td>&nbsp;</td>
<td class="col-sm-1">{{ r['ttl'] }}</td>
<td>&nbsp;</td>
{% else %}
<td class="col-sm-2"><input class="form-control form-control-sm" type="text"
name="record[{{ r['id'] }}][name]" value="{{ r['name'] }}"></td>
Expand Down Expand Up @@ -97,6 +99,9 @@ <h5 class="mb-3">{% trans %}Edit zone{% endtrans %} "{{ zone_name_to_display }}"
<td class="col-sm-1"><input class="form-control form-control-sm" type="text"
min="0" max="2147483647" pattern="[0-9]*" name="record[{{ r['id'] }}][ttl]"
value="{{ r['ttl'] }}"></td>
<td>
<input class="form-check-input" type="checkbox" name="record[{{ r['id'] }}][disabled]" {% if r['disabled'] == 1 %}checked{% endif %}>
</td>
{% endif %}

{% if domain_type == "SLAVE" or perm_edit == "none" or (perm_edit == "own" or perm_edit ==
Expand Down Expand Up @@ -125,10 +130,9 @@ <h5 class="mb-3">{% trans %}Edit zone{% endtrans %} "{{ zone_name_to_display }}"
<tr>
<td>
</td>
<td colspan="4"><textarea class="form-control form-control-sm" rows="5" cols="80" name="comment">{{ zone_comment }}</textarea>
<td colspan="6"><textarea class="form-control form-control-sm" rows="5" cols="80" name="comment">{{ zone_comment }}</textarea>
</td>
<td></td>
<td>
<td colspan="2">
<a class="btn btn-outline-primary btn-sm" href="edit_comment.php?id={{ zone_id }}">
<i class="bi bi-pencil-square"></i> {% trans %}Edit comment{% endtrans %}</a>
</td>
Expand Down

0 comments on commit 95ac0a2

Please sign in to comment.