diff --git a/app/voicemails/voicemail_delete.php b/app/voicemails/voicemail_delete.php
index 1ed1c745c3..3478ba9517 100644
--- a/app/voicemails/voicemail_delete.php
+++ b/app/voicemails/voicemail_delete.php
@@ -43,12 +43,10 @@
$text = $language->get();
//get the ids
- if (is_array($_REQUEST) && sizeof($_REQUEST) > 0) {
-
+ if (is_array($_REQUEST) && @sizeof($_REQUEST) > 0) {
$voicemail_uuids = $_REQUEST["id"];
foreach($voicemail_uuids as $voicemail_uuid) {
- $voicemail_uuid = check_str($voicemail_uuid);
- if ($voicemail_uuid != '') {
+ if (is_uuid($voicemail_uuid)) {
//delete voicemail messages
require_once "resources/classes/voicemail.php";
$voicemail = new voicemail;
@@ -66,4 +64,4 @@
header("Location: voicemails.php");
return;
-?>
+?>
\ No newline at end of file
diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php
index e2298d905a..4d8500e036 100644
--- a/app/voicemails/voicemail_edit.php
+++ b/app/voicemails/voicemail_edit.php
@@ -43,79 +43,83 @@
$text = $language->get();
//action add or update
- if (isset($_REQUEST["id"])) {
+ if (is_uuid($_REQUEST["id"])) {
$action = "update";
- $voicemail_uuid = check_str($_REQUEST["id"]);
+ $voicemail_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
//get http variables and set them to php variables
- $referer_path = check_str($_REQUEST["referer_path"]);
- $referer_query = check_str($_REQUEST["referer_query"]);
+ $referer_path = $_REQUEST["referer_path"];
+ $referer_query = $_REQUEST["referer_query"];
if (count($_POST)>0) {
//set the variables from the HTTP values
- $voicemail_id = check_str($_POST["voicemail_id"]);
- $voicemail_password = check_str($_POST["voicemail_password"]);
- $greeting_id = check_str($_POST["greeting_id"]);
+ $voicemail_id = $_POST["voicemail_id"];
+ $voicemail_password = $_POST["voicemail_password"];
+ $greeting_id = $_POST["greeting_id"];
$voicemail_options = $_POST["voicemail_options"];
- $voicemail_alternate_greet_id = check_str($_POST["voicemail_alternate_greet_id"]);
- $voicemail_mail_to = check_str($_POST["voicemail_mail_to"]);
- $voicemail_sms_to = check_str($_POST["voicemail_sms_to"]);
- $voicemail_transcription_enabled = check_str($_POST["voicemail_transcription_enabled"]);
- $voicemail_file = check_str($_POST["voicemail_file"]);
- $voicemail_local_after_email = check_str($_POST["voicemail_local_after_email"]);
- $voicemail_enabled = check_str($_POST["voicemail_enabled"]);
- $voicemail_description = check_str($_POST["voicemail_description"]);
- $voicemail_tutorial = check_str($_POST["voicemail_tutorial"]);
+ $voicemail_alternate_greet_id = $_POST["voicemail_alternate_greet_id"];
+ $voicemail_mail_to = $_POST["voicemail_mail_to"];
+ $voicemail_sms_to = $_POST["voicemail_sms_to"];
+ $voicemail_transcription_enabled = $_POST["voicemail_transcription_enabled"];
+ $voicemail_file = $_POST["voicemail_file"];
+ $voicemail_local_after_email = $_POST["voicemail_local_after_email"];
+ $voicemail_enabled = $_POST["voicemail_enabled"];
+ $voicemail_description = $_POST["voicemail_description"];
+ $voicemail_tutorial = $_POST["voicemail_tutorial"];
//remove the space
$voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to);
- //debug info
- //echo "
"; print_r($voicemail_options); echo "
";
}
//unassign the voicemail id copy from the voicemail id
- if ($_GET["a"] == "delete" && strlen($voicemail_uuid) > 0 && strlen($_REQUEST["voicemail_destination_uuid"]) > 0) {
+ if ($_GET["a"] == "delete" && is_uuid($voicemail_uuid) && is_uuid($_REQUEST["voicemail_destination_uuid"])) {
//set the variables
- $voicemail_destination_uuid = check_str($_REQUEST["voicemail_destination_uuid"]);
- //delete the voicemail from the destionations
- $sqld = "
- delete from
- v_voicemail_destinations
- where
- voicemail_destination_uuid = '".$voicemail_destination_uuid."' and
- voicemail_uuid = '".$voicemail_uuid."'";
- $db->exec(check_sql($sqld));
- //redirect the browser
+ $voicemail_destination_uuid = $_REQUEST["voicemail_destination_uuid"];
+ //build delete array
+ $array['voicemail_destinations'][0]['voicemail_destination_uuid'] = $voicemail_destination_uuid;
+ $array['voicemail_destinations'][0]['voicemail_uuid'] = $voicemail_uuid;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_destination_delete', 'temp');
+ //execute delete
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->delete($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('voicemail_destination_delete', 'temp');
+ //set message
message::add($text['message-delete']);
+ //redirect the browser
header("Location: voicemail_edit.php?id=".$voicemail_uuid);
- return;
+ exit;
}
//assign the voicemail id copy to the voicemail id
- if (strlen($voicemail_uuid) > 0 && strlen($_REQUEST["voicemail_uuid_copy"]) > 0) {
+ if (is_uuid($voicemail_uuid) && is_uuid($_REQUEST["voicemail_uuid_copy"])) {
//set the variables
- $voicemail_uuid_copy = check_str($_REQUEST["voicemail_uuid_copy"]);
- //assign the user to the extension
- $sqli = "
- insert into
- v_voicemail_destinations
- (
- domain_uuid,
- voicemail_destination_uuid,
- voicemail_uuid,
- voicemail_uuid_copy
- )
- values
- (
- '".$domain_uuid."',
- '".uuid()."',
- '".$voicemail_uuid."',
- '".$voicemail_uuid_copy."'
- )";
- $db->exec(check_sql($sqli));
- //redirect the browser
+ $voicemail_uuid_copy = $_REQUEST["voicemail_uuid_copy"];
+ //build insert array
+ $array['voicemail_destinations'][0]['domain_uuid'] = $domain_uuid;
+ $array['voicemail_destinations'][0]['voicemail_destination_uuid'] = uuid();
+ $array['voicemail_destinations'][0]['voicemail_uuid'] = $voicemail_uuid;
+ $array['voicemail_destinations'][0]['voicemail_uuid_copy'] = $voicemail_uuid_copy;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_destination_add', 'temp');
+ //execute insert
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p = new permissions;
+ $p->delete('voicemail_destination_add', 'temp');
+ //set message
message::add($text['message-add']);
}
@@ -123,7 +127,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
if ($action == "update") {
- $voicemail_uuid = check_str($_POST["voicemail_uuid"]);
+ $voicemail_uuid = $_POST["voicemail_uuid"];
}
//check for all required data
@@ -143,73 +147,44 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//add or update the database
if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('voicemail_add')) {
- $sql = "insert into v_voicemails ";
- $sql .= "(";
- $sql .= "domain_uuid, ";
- $sql .= "voicemail_uuid, ";
- $sql .= "voicemail_id, ";
- $sql .= "voicemail_password, ";
- $sql .= "greeting_id, ";
- $sql .= "voicemail_alternate_greet_id, ";
- $sql .= "voicemail_mail_to, ";
- $sql .= "voicemail_sms_to, ";
- $sql .= "voicemail_transcription_enabled, ";
- $sql .= "voicemail_tutorial, ";
- $sql .= "voicemail_file, ";
- if (permission_exists('voicemail_local_after_email')) {
- $sql .= "voicemail_local_after_email, ";
- }
- $sql .= "voicemail_enabled, ";
- $sql .= "voicemail_description ";
- $sql .= ")";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".$domain_uuid."', ";
- $sql .= "'".uuid()."', ";
- $sql .= "'".$voicemail_id."', ";
- $sql .= "'".$voicemail_password."', ";
- $sql .= (($greeting_id != '') ? "'".$greeting_id."'" : 'null').", ";
- $sql .= (($voicemail_alternate_greet_id != '') ? "'".$voicemail_alternate_greet_id."'" : 'null').", ";
- $sql .= "'".$voicemail_mail_to."', ";
- $sql .= "'".$voicemail_sms_to."', ";
- $sql .= "'".$voicemail_transcription_enabled."', ";
- $sql .= "'".$voicemail_tutorial."', ";
- $sql .= "'".$voicemail_file."', ";
- if (permission_exists('voicemail_local_after_email')) {
- $sql .= "'".$voicemail_local_after_email."', ";
- }
- $sql .= "'".$voicemail_enabled."', ";
- $sql .= "'".$voicemail_description."' ";
- $sql .= ")";
- $db->exec(check_sql($sql));
- unset($sql);
-
- message::add($text['message-add']);
- } //if ($action == "add")
+ //begin insert array
+ $voicemail_uuid = uuid();
+ $array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
+ //set message
+ message::add($text['message-add']);
+ }
if ($action == "update" && permission_exists('voicemail_edit')) {
- $sql = "update v_voicemails set ";
- $sql .= "voicemail_id = '".$voicemail_id."', ";
- $sql .= "voicemail_password = '".$voicemail_password."', ";
- $sql .= "greeting_id = ".(($greeting_id != '') ? "'".$greeting_id."'" : 'null').", ";
- $sql .= "voicemail_alternate_greet_id = ".(($voicemail_alternate_greet_id != '') ? "'".$voicemail_alternate_greet_id."'" : 'null').", ";
- $sql .= "voicemail_mail_to = '".$voicemail_mail_to."', ";
- $sql .= "voicemail_sms_to = '".$voicemail_sms_to."', ";
- $sql .= "voicemail_transcription_enabled = '".$voicemail_transcription_enabled."', ";
- $sql .= "voicemail_tutorial = '".$voicemail_tutorial."', ";
- $sql .= "voicemail_file = '".$voicemail_file."', ";
- if (permission_exists('voicemail_local_after_email')) {
- $sql .= "voicemail_local_after_email = '".$voicemail_local_after_email."', ";
- }
- $sql .= "voicemail_enabled = '".$voicemail_enabled."', ";
- $sql .= "voicemail_description = '".$voicemail_description."' ";
- $sql .= "where domain_uuid = '".$domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$voicemail_uuid."'";
- $db->exec(check_sql($sql));
- unset($sql);
+ //begin update array
+ $array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
+ //set message
+ message::add($text['message-update']);
+ }
- message::add($text['message-update']);
- } //if ($action == "update")
+ if (is_array($array) && @sizeof($array) != 0) {
+ //add common array fields
+ $array['voicemails'][0]['domain_uuid'] = $domain_uuid;
+ $array['voicemails'][0]['voicemail_id'] = $voicemail_id;
+ $array['voicemails'][0]['voicemail_password'] = $voicemail_password;
+ $array['voicemails'][0]['greeting_id'] = $greeting_id != '' ? $greeting_id : null;
+ $array['voicemails'][0]['voicemail_alternate_greet_id'] = $voicemail_alternate_greet_id != '' ? $voicemail_alternate_greet_id : null;
+ $array['voicemails'][0]['voicemail_mail_to'] = $voicemail_mail_to;
+ $array['voicemails'][0]['voicemail_sms_to'] = $voicemail_sms_to;
+ $array['voicemails'][0]['voicemail_transcription_enabled'] = $voicemail_transcription_enabled;
+ $array['voicemails'][0]['voicemail_tutorial'] = $voicemail_tutorial;
+ $array['voicemails'][0]['voicemail_file'] = $voicemail_file;
+ if (permission_exists('voicemail_local_after_email')) {
+ $array['voicemails'][0]['voicemail_local_after_email'] = $voicemail_local_after_email;
+ }
+ $array['voicemails'][0]['voicemail_enabled'] = $voicemail_enabled;
+ $array['voicemails'][0]['voicemail_description'] = $voicemail_description;
+ //execute insert/update
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->save($array);
+ unset($array);
+ }
// add voicemail options
@@ -217,25 +192,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
foreach ($voicemail_options as $index => $voicemail_option) {
if ($voicemail_option['voicemail_option_digits'] == '' || $voicemail_option['voicemail_option_param'] == '') { unset($voicemail_options[$index]); }
}
- }
- if (sizeof($voicemail_options) > 0) {
- $sql = "insert into v_voicemail_options ";
- $sql .= "( ";
- $sql .= "voicemail_option_uuid, ";
- $sql .= "voicemail_uuid, ";
- $sql .= "domain_uuid, ";
- $sql .= "voicemail_option_digits, ";
- $sql .= "voicemail_option_action, ";
- $sql .= "voicemail_option_param, ";
- $sql .= "voicemail_option_order, ";
- $sql .= "voicemail_option_description ";
- $sql .= ") ";
- $sql .= "values ";
foreach ($voicemail_options as $index => $voicemail_option) {
-
- //set the uuid
- $voicemail_option_uuid = uuid();
-
if (is_numeric($voicemail_option["voicemail_option_param"])) {
//if numeric then add tranfer $1 XML domain_name
$voicemail_option['voicemail_option_action'] = "menu-exec-app";
@@ -248,21 +205,30 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$voicemail_option['voicemail_option_param'] = join(':', $option_array);
}
- //continue building insert query
- $sql_record[$index] = "( ";
- $sql_record[$index] .= "'".$voicemail_option_uuid."', ";
- $sql_record[$index] .= "'".$voicemail_uuid."', ";
- $sql_record[$index] .= "'".$domain_uuid."', ";
- $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_digits'])."', ";
- $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_action'])."', ";
- $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_param'])."', ";
- $sql_record[$index] .= $voicemail_option['voicemail_option_order'].", ";
- $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_description'])."' ";
- $sql_record[$index] .= ") ";
+ //build insert array
+ $voicemail_option_uuid = uuid();
+ $array['voicemail_options'][$index]['voicemail_option_uuid'] = $voicemail_option_uuid;
+ $array['voicemail_options'][$index]['voicemail_uuid'] = $voicemail_uuid;
+ $array['voicemail_options'][$index]['domain_uuid'] = $domain_uuid;
+ $array['voicemail_options'][$index]['voicemail_option_digits'] = $voicemail_option['voicemail_option_digits'];
+ $array['voicemail_options'][$index]['voicemail_option_action'] = $voicemail_option['voicemail_option_action'];
+ $array['voicemail_options'][$index]['voicemail_option_param'] = $voicemail_option['voicemail_option_param'];
+ $array['voicemail_options'][$index]['voicemail_option_order'] = $voicemail_option['voicemail_option_order'];
+ $array['voicemail_options'][$index]['voicemail_option_description'] = $voicemail_option['voicemail_option_description'];
+ }
+ if (is_array($array) && @sizeof($array) != 0) {
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('voicemail_option_add', 'temp');
+ //execute inserts
+ $database = new database;
+ $database->app_name = 'voicemails';
+ $database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('voicemail_option_add', 'temp');
}
- $sql .= implode(",", $sql_record);
- $db->exec(check_sql($sql));
- unset($sql);
}
//redirect user
@@ -274,22 +240,23 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
}
exit;
- } //if ($_POST["persistformvar"] != "true")
-} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+ }
+}
//initialize the destinations object
$destination = new destinations;
//pre-populate the form
- if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
- $voicemail_uuid = check_str($_GET["id"]);
+ if (count($_GET)>0 && is_uuid($_GET["id"]) && $_POST["persistformvar"] != "true") {
+ $voicemail_uuid = $_GET["id"];
$sql = "select * from v_voicemails ";
- $sql .= "where domain_uuid = '".$domain_uuid."' ";
- $sql .= "and voicemail_uuid = '".$voicemail_uuid."' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- foreach ($result as &$row) {
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and voicemail_uuid = :voicemail_uuid ";
+ $parameters['domain_uuid'] = $domain_uuid;
+ $parameters['voicemail_uuid'] = $voicemail_uuid;
+ $database = new database;
+ $row = $database->select($sql, $parameters, 'row');
+ if (is_array($row) && @sizeof($row) != 0) {
$voicemail_id = $row["voicemail_id"];
$voicemail_password = $row["voicemail_password"];
$greeting_id = $row["greeting_id"];
@@ -302,9 +269,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$voicemail_local_after_email = $row["voicemail_local_after_email"];
$voicemail_enabled = $row["voicemail_enabled"];
$voicemail_description = $row["voicemail_description"];
- break; //limit to 1 row
}
- unset ($prep_statement);
+ unset($sql, $parameters, $row);
}
else {
$voicemail_file = $_SESSION['voicemail']['voicemail_file']['text'];
@@ -322,14 +288,14 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get the greetings list
$sql = "select * from v_voicemail_greetings ";
- $sql .= "where domain_uuid = '".$domain_uuid."' ";
- $sql .= "and voicemail_id = '".$voicemail_id."' ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and voicemail_id = :voicemail_id ";
$sql .= "order by greeting_name asc ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $greetings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- $greeting_count = count($greetings);
- unset ($prep_statement, $sql);
+ $parameters['domain_uuid'] = $domain_uuid;
+ $parameters['voicemail_id'] = $voicemail_id;
+ $database = new database;
+ $greetings = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters);
//show the header
require_once "resources/header.php";
@@ -431,7 +397,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo "\n";
echo " |