Skip to content

Commit

Permalink
fix: sorting by selected column in template records
Browse files Browse the repository at this point in the history
  • Loading branch information
edmondas committed Dec 2, 2023
1 parent 911ac98 commit 992e946
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions lib/ZoneTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ public static function get_zone_templ_records($db, int $id, int $rowstart = 0, i
{
$db->setLimit($rowamount, $rowstart);

$allowedSortColumns = ['name', 'type', 'content', 'priority', 'ttl'];
$sortby = in_array($sortby, $allowedSortColumns) ? $sortby : 'name';

$stmt = $db->prepare("SELECT id FROM zone_templ_records WHERE zone_templ_id = :id ORDER BY " . $sortby);
$stmt->execute([':id' => $id]);

Expand Down
15 changes: 5 additions & 10 deletions templates/edit_zone_templ.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@ <h5 class="mb-3">{% trans %}Edit zone template{% endtrans %} "{{templ_details['n
<form method="post" action="">
<table class="table table-striped table-hover table-sm">
<tr>
<th><a href="edit_zone_templ.php?id=" {{zone_templ_id}}&amp;record_sort_by=name">{% trans %}Name{% endtrans
%}</a></th>
<th><a href="edit_zone_templ.php?id=" {{zone_templ_id}}&amp;record_sort_by=type">{% trans %}Type{% endtrans
%}</a></th>
<th><a href="edit_zone_templ.php?id=" {{zone_templ_id}}&amp;record_sort_by=content">{% trans %}Content{%
endtrans %}</a></th>
<th><a href="edit_zone_templ.php?id=" {{zone_templ_id}}&amp;record_sort_by=prio">{% trans %}Priority{%
endtrans %}</a>
<th><a href="edit_zone_templ.php?id={{zone_templ_id}}&amp;record_sort_by=name">{% trans %}Name{% endtrans %}</a></th>
<th><a href="edit_zone_templ.php?id={{zone_templ_id}}&amp;record_sort_by=type">{% trans %}Type{% endtrans %}</a></th>
<th><a href="edit_zone_templ.php?id={{zone_templ_id}}&amp;record_sort_by=content">{% trans %}Content{% endtrans %}</a></th>
<th><a href="edit_zone_templ.php?id={{zone_templ_id}}&amp;record_sort_by=prio">{% trans %}Priority{% endtrans %}</a>
</th>
<th><a href="edit_zone_templ.php?id=" {{zone_templ_id}}&amp;record_sort_by=ttl">{% trans %}TTL{% endtrans
%}</a></th>
<th><a href="edit_zone_templ.php?id={{zone_templ_id}}&amp;record_sort_by=ttl">{% trans %}TTL{% endtrans %}</a></th>
<th>&nbsp;</th>
</tr>
{% for record in records %}
Expand Down

0 comments on commit 992e946

Please sign in to comment.