Database class integration.
This commit is contained in:
@@ -65,36 +65,15 @@
|
||||
}
|
||||
|
||||
//get variables used to control the order
|
||||
$order_by = check_str($_GET["order_by"]);
|
||||
$order = check_str($_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 = '';
|
||||
}
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
|
||||
//set the type
|
||||
if ($_GET['type'] == 'inbound') {
|
||||
$destination_type = 'inbound';
|
||||
}
|
||||
elseif ($_GET['type'] == 'outbound') {
|
||||
$destination_type = 'outbound';
|
||||
}
|
||||
elseif ($_GET['type'] == 'local') {
|
||||
$destination_type = 'local';
|
||||
}
|
||||
else {
|
||||
$destination_type = 'inbound';
|
||||
switch ($_GET['type']) {
|
||||
case 'inbound': $destination_type = 'inbound'; break;
|
||||
case 'outbound': $destination_type = 'outbound'; break;
|
||||
case 'local': $destination_type = 'local'; break;
|
||||
default: $destination_type = 'inbound';
|
||||
}
|
||||
|
||||
//add the search term
|
||||
@@ -115,23 +94,26 @@
|
||||
$sql_search .= ") ";
|
||||
}
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(destination_uuid) as num_rows from v_destinations ";
|
||||
$sql .= "where destination_type = :destination_type ";
|
||||
//common sql where
|
||||
$sql_where = "where destination_type = :destination_type ";
|
||||
if ($_GET['show'] == "all" && permission_exists('destination_all')) {
|
||||
//show all
|
||||
} else {
|
||||
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
}
|
||||
else {
|
||||
$sql_where .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
}
|
||||
if (isset($sql_search)) {
|
||||
$sql .= "and ".$sql_search;
|
||||
$sql_where .= "and ".$sql_search;
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
$parameters['destination_type'] = $destination_type;
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(destination_uuid) from v_destinations ";
|
||||
$sql .= $sql_where;
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
unset($parameters);
|
||||
|
||||
//prepare to page the results
|
||||
require_once "resources/paging.php";
|
||||
@@ -146,24 +128,9 @@
|
||||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list
|
||||
$sql = "select * from v_destinations ";
|
||||
$sql .= "where destination_type = :destination_type ";
|
||||
if ($_GET['show'] == "all" && permission_exists('destination_all')) {
|
||||
//show all
|
||||
} else {
|
||||
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
}
|
||||
if (isset($sql_search)) {
|
||||
$sql .= "and ".$sql_search;
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
$sql .= "and destination_type = :destination_type ";
|
||||
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
|
||||
$sql .= "limit :rows_per_page offset :offset ";
|
||||
$parameters['destination_type'] = $destination_type;
|
||||
$parameters['rows_per_page'] = $rows_per_page;
|
||||
$parameters['offset'] = $offset;
|
||||
$sql = str_replace('count(destination_uuid)', '*', $sql);
|
||||
$sql .= order_by($order_by, $order);
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$destinations = $database->select($sql, $parameters, 'all');
|
||||
unset($parameters);
|
||||
@@ -282,7 +249,7 @@
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "<tr>\n";
|
||||
if (is_array($destinations)) {
|
||||
if (is_array($destinations) && @sizeof($destinations) != 0) {
|
||||
$x = 0;
|
||||
foreach($destinations as $row) {
|
||||
$action_name = action_name($destination_array, $row['destination_app'].':'.$row['destination_data']);
|
||||
|
||||
Reference in New Issue
Block a user