Database class integration.

This commit is contained in:
Nate
2019-07-04 09:01:28 -06:00
parent be2e3ab2e4
commit a052e80b7b
4 changed files with 157 additions and 165 deletions
+21 -20
View File
@@ -43,9 +43,9 @@
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (is_uuid($_REQUEST["id"])) {
$action = "update"; $action = "update";
$call_recording_uuid = check_str($_REQUEST["id"]); $call_recording_uuid = $_REQUEST["id"];
} }
else { else {
$action = "add"; $action = "add";
@@ -53,13 +53,13 @@
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (is_array($_POST)) { if (is_array($_POST)) {
$call_recording_name = check_str($_POST["call_recording_name"]); $call_recording_name = $_POST["call_recording_name"];
$call_recording_path = check_str($_POST["call_recording_path"]); $call_recording_path = $_POST["call_recording_path"];
$call_recording_length = check_str($_POST["call_recording_length"]); $call_recording_length = $_POST["call_recording_length"];
$call_recording_date = check_str($_POST["call_recording_date"]); $call_recording_date = $_POST["call_recording_date"];
$call_direction = check_str($_POST["call_direction"]); $call_direction = $_POST["call_direction"];
$call_recording_description = check_str($_POST["call_recording_description"]); $call_recording_description = $_POST["call_recording_description"];
$call_recording_base64 = check_str($_POST["call_recording_base64"]); $call_recording_base64 = $_POST["call_recording_base64"];
} }
//process the user data and save it to the database //process the user data and save it to the database
@@ -67,7 +67,7 @@
//get the uuid from the POST //get the uuid from the POST
if ($action == "update") { if ($action == "update") {
$call_recording_uuid = check_str($_POST["call_recording_uuid"]); $call_recording_uuid = $_POST["call_recording_uuid"];
} }
//check for all required data //check for all required data
@@ -96,7 +96,7 @@
$_POST["domain_uuid"] = $_SESSION["domain_uuid"]; $_POST["domain_uuid"] = $_SESSION["domain_uuid"];
//add the call_recording_uuid //add the call_recording_uuid
if (strlen($_POST["call_recording_uuid"]) == 0) { if (!is_uuid($_POST["call_recording_uuid"])) {
$call_recording_uuid = uuid(); $call_recording_uuid = uuid();
$_POST["call_recording_uuid"] = $call_recording_uuid; $_POST["call_recording_uuid"] = $call_recording_uuid;
} }
@@ -134,15 +134,16 @@
} //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form //pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") { if (is_array($_GET) && $_POST["persistformvar"] != "true" && is_uuid($_GET["id"])) {
$call_recording_uuid = check_str($_GET["id"]); $call_recording_uuid = $_GET["id"];
$sql = "select * from v_call_recordings "; $sql = "select * from v_call_recordings ";
$sql .= "where call_recording_uuid = '$call_recording_uuid' "; $sql .= "where call_recording_uuid = :call_recording_uuid ";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = :domain_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['call_recording_uuid'] = $call_recording_uuid;
$prep_statement->execute(); //$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
foreach ($result as &$row) { $row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$call_recording_name = $row["call_recording_name"]; $call_recording_name = $row["call_recording_name"];
$call_recording_path = $row["call_recording_path"]; $call_recording_path = $row["call_recording_path"];
$call_recording_length = $row["call_recording_length"]; $call_recording_length = $row["call_recording_length"];
@@ -151,7 +152,7 @@
$call_recording_description = $row["call_recording_description"]; $call_recording_description = $row["call_recording_description"];
$call_recording_base64 = $row["call_recording_base64"]; $call_recording_base64 = $row["call_recording_base64"];
} }
unset ($prep_statement); unset($sql, $parameters, $row);
} }
//show the header //show the header
+11 -34
View File
@@ -86,32 +86,11 @@
require_once "resources/paging.php"; require_once "resources/paging.php";
//get variables used to control the order //get variables used to control the order
$order_by = check_str($_REQUEST["order_by"]); $order_by = $_REQUEST["order_by"] != '' ? $_REQUEST["order_by"] : 'call_recording_date';
$order = check_str($_REQUEST["order"]); $order = $_REQUEST["order"] != '' ? $_REQUEST["order"] : 'desc';
//validate order by //add the search term
if (strlen($order_by) > 0) { $search = strtolower($_REQUEST["search"]);
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', $order_by);
}
//validate the order
switch ($order) {
case 'asc':
break;
case 'desc':
break;
default:
$order = '';
}
//set the defaults
if (strlen($order_by) == 0) {
$order_by = 'call_recording_date';
$order = 'desc';
}
//add the search term
$search = strtolower(check_str($_REQUEST["search"]));
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql_search = "and ("; $sql_search = "and (";
$sql_search .= "lower(call_recording_name) like :search "; $sql_search .= "lower(call_recording_name) like :search ";
@@ -119,18 +98,17 @@
$sql_search .= "or lower(call_direction) like :search "; $sql_search .= "or lower(call_direction) like :search ";
$sql_search .= "or lower(call_recording_description) like :search "; $sql_search .= "or lower(call_recording_description) like :search ";
$sql_search .= ") "; $sql_search .= ") ";
$parameters['search'] = '%'.$search.'%';
} }
//prepare to page the results //prepare to page the results
$sql = "select count(call_recording_uuid) as num_rows from v_call_recordings "; $sql = "select count(call_recording_uuid) from v_call_recordings ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= $sql_search; $sql .= $sql_search;
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
if (strlen($search) > 0) {
$parameters['search'] = '%'.$search.'%';
}
$database = new database; $database = new database;
$num_rows = $database->select($sql, $parameters, 'column'); $num_rows = $database->select($sql, $parameters, 'column');
unset($sql);
//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;
@@ -144,12 +122,11 @@
$sql = "select * from v_call_recordings "; $sql = "select * from v_call_recordings ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= $sql_search; $sql .= $sql_search;
$sql .= "order by $order_by $order "; $sql .= order_by($order_by, $order);
$sql .= "limit :rows_per_page offset :offset "; $sql .= limit_offset($rows_per_page, $offset);
$database = new database; $database = new database;
$parameters['rows_per_page'] = $rows_per_page;
$parameters['offset'] = $offset;
$result = $database->select($sql, $parameters, 'all'); $result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//alternate the row style //alternate the row style
$c = 0; $c = 0;
@@ -280,7 +257,7 @@
$x++; $x++;
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($result);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";
+121 -106
View File
@@ -56,19 +56,20 @@
} }
//get the extension_uuid //get the extension_uuid
$extension_uuid = check_str($_REQUEST["id"]); $extension_uuid = $_REQUEST["id"];
//get the extension number //get the extension number
$sql = "select * from v_extensions "; $sql = "select * from v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and extension_uuid = '$extension_uuid' "; $sql .= "and extension_uuid = :extension_uuid ";
if (!(permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb'))) { if (!(permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb'))) {
if (count($_SESSION['user']['extension']) > 0) { if (count($_SESSION['user']['extension']) > 0) {
$sql .= "and ("; $sql .= "and (";
$x = 0; $x = 0;
foreach($_SESSION['user']['extension'] as $row) { foreach($_SESSION['user']['extension'] as $index => $row) {
if ($x > 0) { $sql .= "or "; } if ($x > 0) { $sql .= "or "; }
$sql .= "extension = '".$row['user']."' "; $sql .= "extension = :extension_".$index." ";
$parameters['extension_'.$index] = $row['user'];
$x++; $x++;
} }
$sql .= ")"; $sql .= ")";
@@ -78,70 +79,65 @@
$sql .= "and extension = 'disabled' "; $sql .= "and extension = 'disabled' ";
} }
} }
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['extension_uuid'] = $extension_uuid;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
if (count($result)== 0) { $row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$extension = $row["extension"];
$accountcode = $row["accountcode"];
$effective_caller_id_name = $row["effective_caller_id_name"];
$effective_caller_id_number = $row["effective_caller_id_number"];
$outbound_caller_id_name = $row["outbound_caller_id_name"];
$outbound_caller_id_number = $row["outbound_caller_id_number"];
$do_not_disturb = $row["do_not_disturb"] != '' ? $row["do_not_disturb"] : 'false';
$forward_all_destination = $row["forward_all_destination"];
$forward_all_enabled = $row["forward_all_enabled"];
$forward_busy_destination = $row["forward_busy_destination"];
$forward_busy_enabled = $row["forward_busy_enabled"];
$forward_no_answer_destination = $row["forward_no_answer_destination"];
$forward_no_answer_enabled = $row["forward_no_answer_enabled"];
$forward_user_not_registered_destination = $row["forward_user_not_registered_destination"];
$forward_user_not_registered_enabled = $row["forward_user_not_registered_enabled"];
$follow_me_uuid = $row["follow_me_uuid"];
$forward_caller_id_uuid = $row["forward_caller_id_uuid"];
}
else {
echo "access denied"; echo "access denied";
exit; exit;
} }
else { unset($sql, $parameters, $row);
foreach ($result as &$row) {
$extension = $row["extension"];
$accountcode = $row["accountcode"];
$effective_caller_id_name = $row["effective_caller_id_name"];
$effective_caller_id_number = $row["effective_caller_id_number"];
$outbound_caller_id_name = $row["outbound_caller_id_name"];
$outbound_caller_id_number = $row["outbound_caller_id_number"];
$do_not_disturb = $row["do_not_disturb"];
$forward_all_destination = $row["forward_all_destination"];
$forward_all_enabled = $row["forward_all_enabled"];
$forward_busy_destination = $row["forward_busy_destination"];
$forward_busy_enabled = $row["forward_busy_enabled"];
$forward_no_answer_destination = $row["forward_no_answer_destination"];
$forward_no_answer_enabled = $row["forward_no_answer_enabled"];
$forward_user_not_registered_destination = $row["forward_user_not_registered_destination"];
$forward_user_not_registered_enabled = $row["forward_user_not_registered_enabled"];
$follow_me_uuid = $row["follow_me_uuid"];
$forward_caller_id_uuid = $row["forward_caller_id_uuid"];
break; //limit to 1 row
}
if (strlen($do_not_disturb) == 0) {
$do_not_disturb = "false";
}
}
unset ($prep_statement);
//process post vars //process post vars
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (count($_POST) > 0) { if (count($_POST) > 0) {
$forward_all_enabled = check_str($_POST["forward_all_enabled"]); $forward_all_enabled = $_POST["forward_all_enabled"];
$forward_all_destination = check_str($_POST["forward_all_destination"]); $forward_all_destination = $_POST["forward_all_destination"];
$forward_busy_enabled = check_str($_POST["forward_busy_enabled"]); $forward_busy_enabled = $_POST["forward_busy_enabled"];
$forward_busy_destination = check_str($_POST["forward_busy_destination"]); $forward_busy_destination = $_POST["forward_busy_destination"];
$forward_no_answer_enabled = check_str($_POST["forward_no_answer_enabled"]); $forward_no_answer_enabled = $_POST["forward_no_answer_enabled"];
$forward_no_answer_destination = check_str($_POST["forward_no_answer_destination"]); $forward_no_answer_destination = $_POST["forward_no_answer_destination"];
$forward_user_not_registered_enabled = check_str($_POST["forward_user_not_registered_enabled"]); $forward_user_not_registered_enabled = $_POST["forward_user_not_registered_enabled"];
$forward_user_not_registered_destination = check_str($_POST["forward_user_not_registered_destination"]); $forward_user_not_registered_destination = $_POST["forward_user_not_registered_destination"];
$forward_caller_id_uuid = check_str($_POST["forward_caller_id_uuid"]); $forward_caller_id_uuid = $_POST["forward_caller_id_uuid"];
$cid_name_prefix = check_str($_POST["cid_name_prefix"]); $cid_name_prefix = $_POST["cid_name_prefix"];
$cid_number_prefix = check_str($_POST["cid_number_prefix"]); $cid_number_prefix = $_POST["cid_number_prefix"];
$follow_me_enabled = check_str($_POST["follow_me_enabled"]); $follow_me_enabled = $_POST["follow_me_enabled"];
$follow_me_caller_id_uuid = check_str($_POST["follow_me_caller_id_uuid"]); $follow_me_caller_id_uuid = $_POST["follow_me_caller_id_uuid"];
$follow_me_ignore_busy = check_str($_POST["follow_me_ignore_busy"]); $follow_me_ignore_busy = $_POST["follow_me_ignore_busy"];
$n = 0; $n = 0;
foreach ($_POST["destinations"] as $field) { foreach ($_POST["destinations"] as $field) {
$destinations[$n]['uuid'] = check_str($field['uuid']); $destinations[$n]['uuid'] = $field['uuid'];
$destinations[$n]['destination'] = check_str($field['destination']); $destinations[$n]['destination'] = $field['destination'];
$destinations[$n]['delay'] = check_str($field['delay']); $destinations[$n]['delay'] = $field['delay'];
$destinations[$n]['prompt'] = check_str($field['prompt']); $destinations[$n]['prompt'] = $field['prompt'];
$destinations[$n]['timeout'] = check_str($field['timeout']); $destinations[$n]['timeout'] = $field['timeout'];
$n++; $n++;
} }
$dnd_enabled = check_str($_POST["dnd_enabled"]); $dnd_enabled = $_POST["dnd_enabled"];
} }
//check for all required data //check for all required data
@@ -255,6 +251,7 @@
$database->app_name = 'call_routing'; $database->app_name = 'call_routing';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d'; $database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->save($array); $database->save($array);
unset($array);
//$message = $database->message; //$message = $database->message;
//remove the temporary permission //remove the temporary permission
@@ -262,8 +259,14 @@
//delete empty destination records //delete empty destination records
if (is_array($follow_me_delete_uuids) && sizeof($follow_me_delete_uuids) > 0) { if (is_array($follow_me_delete_uuids) && sizeof($follow_me_delete_uuids) > 0) {
$sql = "delete from v_follow_me_destinations where follow_me_destination_uuid in ('".implode("','", $follow_me_delete_uuids)."') "; foreach ($follow_me_delete_uuids as $follow_me_delete_uuid) {
$db->exec(check_sql($sql)); $array['follow_me_destinations'][]['follow_me_destination_uuid'] = $follow_me_delete_uuid;
}
$database = new database;
$database->app_name = 'call_routing';
$database->app_uuid = '19806921-e8ed-dcff-b325-dd3e5da4959d';
$database->delete($array);
$unset($array);
} }
//call forward config //call forward config
@@ -390,36 +393,39 @@
require_once "resources/header.php"; require_once "resources/header.php";
//pre-populate the form //pre-populate the form
if ($follow_me_uuid != '') { if (is_uuid($follow_me_uuid)) {
$sql = "select * from v_follow_me "; $sql = "select * from v_follow_me ";
$sql .= "where domain_uuid = '".$domain_uuid."' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and follow_me_uuid = '".$follow_me_uuid."' "; $sql .= "and follow_me_uuid = :follow_me_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $parameters['follow_me_uuid'] = $follow_me_uuid;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $database = new database;
foreach ($result as &$row) { $row = $database->select($sql, $parameters, 'row');
unset($sql, $parameters);
if (is_array($row) && sizeof($row) != 0) {
$cid_name_prefix = $row["cid_name_prefix"]; $cid_name_prefix = $row["cid_name_prefix"];
$cid_number_prefix = $row["cid_number_prefix"]; $cid_number_prefix = $row["cid_number_prefix"];
$follow_me_enabled = $row["follow_me_enabled"]; $follow_me_enabled = $row["follow_me_enabled"];
$follow_me_caller_id_uuid = $row["follow_me_caller_id_uuid"]; $follow_me_caller_id_uuid = $row["follow_me_caller_id_uuid"];
$follow_me_ignore_busy = $row["follow_me_ignore_busy"]; $follow_me_ignore_busy = $row["follow_me_ignore_busy"];
unset($row);
$sql = "select * from v_follow_me_destinations "; $sql = "select * from v_follow_me_destinations ";
$sql .= "where follow_me_uuid = '".$follow_me_uuid."' "; $sql .= "where follow_me_uuid = :follow_me_uuid ";
$sql .= "order by follow_me_order asc "; $sql .= "order by follow_me_order asc ";
$prep_statement_2 = $db->prepare(check_sql($sql)); $parameters['follow_me_uuid'] = $follow_me_uuid;
$prep_statement_2->execute(); $database = new database;
$result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); $result = $database->select($sql, $parameters, 'all');
foreach ($result2 as $x => &$row2) { foreach ($result as $x => &$row) {
$destinations[$x]['uuid'] = $row2["follow_me_destination_uuid"]; $destinations[$x]['uuid'] = $row["follow_me_destination_uuid"];
$destinations[$x]['destination'] = $row2["follow_me_destination"]; $destinations[$x]['destination'] = $row["follow_me_destination"];
$destinations[$x]['delay'] = $row2["follow_me_delay"]; $destinations[$x]['delay'] = $row["follow_me_delay"];
$destinations[$x]['prompt'] = $row2["follow_me_prompt"]; $destinations[$x]['prompt'] = $row["follow_me_prompt"];
$destinations[$x]['timeout'] = $row2["follow_me_timeout"]; $destinations[$x]['timeout'] = $row["follow_me_timeout"];
} }
unset ($prep_statement_2); unset($sql, $parameters, $result, $row);
} }
unset ($prep_statement);
} }
//set the default //set the default
@@ -436,11 +442,11 @@
echo " var extensions = [\n"; echo " var extensions = [\n";
$sql = "select * from v_extensions "; $sql = "select * from v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "order by extension, number_alias asc "; $sql .= "order by extension, number_alias asc ";
$prep_statement = $db->prepare(check_sql($sql)); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$prep_statement->execute(); $database = new database;
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $database->select($sql, $parameters, 'all');
foreach ($result as &$row) { foreach ($result as &$row) {
if (strlen($number_alias) == 0) { if (strlen($number_alias) == 0) {
echo " \"".escape($row["extension"])."\",\n"; echo " \"".escape($row["extension"])."\",\n";
@@ -455,6 +461,7 @@
echo " source: extensions\n"; echo " source: extensions\n";
echo " });\n"; echo " });\n";
} }
unset($sql, $parameters, $result, $row);
echo "});\n"; echo "});\n";
echo "</script>\n"; echo "</script>\n";
@@ -543,11 +550,15 @@
echo "</tr>\n"; echo "</tr>\n";
if (permission_exists('call_forward_caller_id')) { if (permission_exists('call_forward_caller_id')) {
$sql_forward = "select destination_uuid, destination_number, destination_description, destination_caller_id_number, destination_caller_id_name from v_destinations where domain_uuid = '".escape($domain_uuid)."' and destination_type = 'inbound' order by destination_number asc "; $sql = "select destination_uuid, destination_number, destination_description, destination_caller_id_number, destination_caller_id_name ";
$prep_statement_forward = $db->prepare(check_sql($sql_forward)); $sql .= "from v_destinations ";
$prep_statement_forward->execute(); $sql .= "where domain_uuid = :domain_uuid ";
$result_forward = $prep_statement_forward->fetchAll(PDO::FETCH_ASSOC); $sql .= "and destination_type = 'inbound' ";
if (count($result_forward) > 0) { $sql .= "order by destination_number asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$result = $database->select($sql, $parameters, 'all');
if (is_array($result) && sizeof($result) != 0) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>";
echo $text['label-cid-number']; echo $text['label-cid-number'];
@@ -555,24 +566,24 @@
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select name='forward_caller_id_uuid' id='forward_caller_id_uuid' class='formfld' >\n"; echo " <select name='forward_caller_id_uuid' id='forward_caller_id_uuid' class='formfld' >\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
foreach ($result_forward as &$row_forward) { foreach ($result as &$row) {
$selected = $row_forward["destination_uuid"] == $forward_caller_id_uuid ? "selected='selected' " : ''; $selected = $row["destination_uuid"] == $forward_caller_id_uuid ? "selected='selected' " : '';
$caller_id_number = $row_forward['destination_caller_id_number']; $caller_id_number = $row['destination_caller_id_number'];
if(strlen($caller_id_number) == 0){ if(strlen($caller_id_number) == 0){
$caller_id_number = $row_forward['destination_number']; $caller_id_number = $row['destination_number'];
} }
$caller_id_name = $row_forward['destination_caller_id_name']; $caller_id_name = $row['destination_caller_id_name'];
if(strlen($caller_id_name) == 0){ if(strlen($caller_id_name) == 0){
$caller_id_name = $row_forward['destination_description']; $caller_id_name = $row['destination_description'];
} }
echo " <option value='".escape($row_forward["destination_uuid"])."' ".escape($selected).">".escape(format_phone($caller_id_number))." : ".$caller_id_name."</option>\n"; echo " <option value='".escape($row["destination_uuid"])."' ".escape($selected).">".escape(format_phone($caller_id_number))." : ".escape($caller_id_name)."</option>\n";
} }
echo " </select><br />\n"; echo " </select><br />\n";
echo $text['description-cid-number']."\n"; echo $text['description-cid-number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
} }
unset ($sql_forward, $prep_statement_forward, $result_forward, $row_forward); unset($sql, $parameters, $result, $row);
} }
echo "<tr><td colspan='2'><br /></td></tr>\n"; echo "<tr><td colspan='2'><br /></td></tr>\n";
@@ -656,11 +667,15 @@
} }
if (permission_exists('follow_me_caller_id')) { if (permission_exists('follow_me_caller_id')) {
$sql_follow_me = "select destination_uuid, destination_number, destination_description, destination_caller_id_number, destination_caller_id_name from v_destinations where domain_uuid = '".escape($domain_uuid)."' and destination_type = 'inbound' order by destination_number asc "; $sql = "select destination_uuid, destination_number, destination_description, destination_caller_id_number, destination_caller_id_name ";
$prep_statement_follow_me = $db->prepare(check_sql($sql_follow_me)); $sql .= "from v_destinations ";
$prep_statement_follow_me->execute(); $sql .= "where domain_uuid = :domain_uuid ";
$result_follow_me = $prep_statement_follow_me->fetchAll(PDO::FETCH_ASSOC); $sql .= "and destination_type = 'inbound' ";
if (count($result_follow_me) > 0) { $sql .= "order by destination_number asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$result = $database->select($sql, $parameters, 'all');
if (is_array($result) && sizeof($result) != 0) {
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>";
echo $text['label-cid-number']; echo $text['label-cid-number'];
@@ -668,26 +683,26 @@
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select name='follow_me_caller_id_uuid' id='follow_me_caller_id_uuid' class='formfld' >\n"; echo " <select name='follow_me_caller_id_uuid' id='follow_me_caller_id_uuid' class='formfld' >\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
foreach ($result_follow_me as &$row_follow_me) { foreach ($result as &$row) {
$selected = $row_follow_me["destination_uuid"] == $follow_me_caller_id_uuid ? "selected='selected'" : ''; $selected = $row["destination_uuid"] == $follow_me_caller_id_uuid ? "selected='selected'" : null;
$caller_id_number = $row_follow_me['destination_caller_id_number']; $caller_id_number = $row['destination_caller_id_number'];
if(strlen($caller_id_number) == 0){ if(strlen($caller_id_number) == 0){
$caller_id_number = $row_follow_me['destination_number']; $caller_id_number = $row['destination_number'];
} }
$caller_id_name = $row_follow_me['destination_caller_id_name']; $caller_id_name = $row['destination_caller_id_name'];
if(strlen($caller_id_name) == 0){ if(strlen($caller_id_name) == 0){
$caller_id_name = $row_follow_me['destination_description']; $caller_id_name = $row['destination_description'];
} }
echo " <option value='".escape($row_follow_me["destination_uuid"])."' ".escape($selected).">".format_phone(escape($caller_id_number))." : ".escape($caller_id_name)."</option>\n"; echo " <option value='".escape($row["destination_uuid"])."' ".$selected.">".format_phone(escape($caller_id_number))." : ".escape($caller_id_name)."</option>\n";
} }
echo " </select><br />\n"; echo " </select><br />\n";
echo $text['description-cid-number']."\n"; echo $text['description-cid-number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
} }
unset ($sql_follow_me, $prep_statement_follow_me, $result_follow_me, $row_follow_me); unset($sql, $parameters, $result, $row);
} }
if (permission_exists('follow_me_cid_name_prefix')) { if (permission_exists('follow_me_cid_name_prefix')) {
+4 -5
View File
@@ -42,7 +42,7 @@
$domain_uuid = $_SESSION['domain_uuid']; $domain_uuid = $_SESSION['domain_uuid'];
//handle search term //handle search term
$search = check_str($_GET["search"]); $search = $_GET["search"];
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql_mod = "and ( "; $sql_mod = "and ( ";
$sql_mod .= "extension like :search "; $sql_mod .= "extension like :search ";
@@ -120,10 +120,8 @@
} }
$sql .= $sql_mod; //add search mod from above $sql .= $sql_mod; //add search mod from above
$sql .= "order by extension asc "; $sql .= "order by extension asc ";
$sql .= "limit :rows_per_page offset :offset "; $sql .= limit_offset($rows_per_page, $offset);
$database = new database; $database = new database;
$parameters['rows_per_page'] = $rows_per_page;
$parameters['offset'] = $offset;
$extensions = $database->select($sql, $parameters, 'all'); $extensions = $database->select($sql, $parameters, 'all');
unset($parameters); unset($parameters);
@@ -186,7 +184,8 @@
//get destination count if enabled //get destination count if enabled
$follow_me_destination_count = 0; $follow_me_destination_count = 0;
if ($row['follow_me_enabled'] == 'true') { if ($row['follow_me_enabled'] == 'true') {
$sql = "select count(follow_me_destination_uuid) as destination_count from v_follow_me_destinations "; $sql = "select count(follow_me_destination_uuid) as destination_count ";
$sql .= "from v_follow_me_destinations ";
$sql .= "where follow_me_uuid = :follow_me_uuid "; $sql .= "where follow_me_uuid = :follow_me_uuid ";
$sql .= "and domain_uuid = :domain_uuid "; $sql .= "and domain_uuid = :domain_uuid ";
$parameters['follow_me_uuid'] = $row['follow_me_uuid']; $parameters['follow_me_uuid'] = $row['follow_me_uuid'];