Merge pull request #4217 from AlexanderDCrane/patch-465
Update call_block.php
This commit is contained in:
commit
f9c8f53cf9
|
|
@ -50,6 +50,21 @@ require_once "resources/require.php";
|
||||||
$order_by = $_GET["order_by"];
|
$order_by = $_GET["order_by"];
|
||||||
$order = $_GET["order"];
|
$order = $_GET["order"];
|
||||||
|
|
||||||
|
//validate order by
|
||||||
|
if (strlen($order_by) > 0) {
|
||||||
|
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by);
|
||||||
|
}
|
||||||
|
|
||||||
|
//validate the order
|
||||||
|
switch ($order) {
|
||||||
|
case 'asc':
|
||||||
|
break;
|
||||||
|
case 'desc':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$order = '';
|
||||||
|
}
|
||||||
|
|
||||||
//show the content
|
//show the content
|
||||||
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
|
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
|
||||||
echo " <tr>\n";
|
echo " <tr>\n";
|
||||||
|
|
@ -65,19 +80,11 @@ require_once "resources/require.php";
|
||||||
|
|
||||||
//prepare to page the results
|
//prepare to page the results
|
||||||
$sql = "select count(*) as num_rows from v_call_block ";
|
$sql = "select count(*) as num_rows from v_call_block ";
|
||||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
$prep_statement = $db->prepare($sql);
|
$database = new database;
|
||||||
if ($prep_statement) {
|
$num_rows = $database->select($sql, $parameters, 'column');
|
||||||
$prep_statement->execute();
|
//unset($parameters);
|
||||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
||||||
if ($row['num_rows'] > 0) {
|
|
||||||
$num_rows = $row['num_rows'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$num_rows = '0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//prepare to page the results
|
//prepare to page the results
|
||||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||||
|
|
@ -89,18 +96,17 @@ require_once "resources/require.php";
|
||||||
|
|
||||||
//get the list
|
//get the list
|
||||||
$sql = "select * from v_call_block ";
|
$sql = "select * from v_call_block ";
|
||||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
if (strlen($order_by)> 0) {
|
if (strlen($order_by) > 0) {
|
||||||
$sql .= "order by $order_by $order ";
|
$sql .= "order by $order_by $order ";
|
||||||
} else {
|
} else {
|
||||||
$sql .= "order by call_block_number asc ";
|
$sql .= "order by call_block_number asc ";
|
||||||
}
|
}
|
||||||
$sql .= " limit $rows_per_page offset $offset ";
|
$sql .= "limit :rows_per_page offset :offset ";
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$database = new database;
|
||||||
$prep_statement->execute();
|
$parameters['rows_per_page'] = $rows_per_page;
|
||||||
$result = $prep_statement->fetchAll();
|
$parameters['offset'] = $offset;
|
||||||
$result_count = count($result);
|
$result = $database->select($sql, $parameters, 'all');
|
||||||
unset ($prep_statement, $sql);
|
|
||||||
|
|
||||||
//table headers
|
//table headers
|
||||||
$c = 0;
|
$c = 0;
|
||||||
|
|
@ -122,7 +128,7 @@ require_once "resources/require.php";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|
||||||
//show the results
|
//show the results
|
||||||
if ($result_count > 0) {
|
if (is_array($result)) {
|
||||||
foreach($result as $row) {
|
foreach($result as $row) {
|
||||||
$tr_link = (permission_exists('call_block_edit')) ? "href='call_block_edit.php?id=".$row['call_block_uuid']."'" : null;
|
$tr_link = (permission_exists('call_block_edit')) ? "href='call_block_edit.php?id=".$row['call_block_uuid']."'" : null;
|
||||||
echo "<tr ".$tr_link.">\n";
|
echo "<tr ".$tr_link.">\n";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue