Voicemails: Database class integration.
This commit is contained in:
+210
-230
@@ -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 "<pre>"; print_r($voicemail_options); echo "</pre>";
|
||||
}
|
||||
|
||||
//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 "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' name='greeting_id'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($greeting_count > 0) {
|
||||
if (is_array($greetings) && @sizeof($greetings) != 0) {
|
||||
foreach ($greetings as $greeting) {
|
||||
$selected = ($greeting['greeting_id'] == $greeting_id) ? 'selected' : null;
|
||||
echo "<option value='".escape($greeting['greeting_id'])."' ".escape($selected).">".escape($greeting['greeting_name'])."</option>\n";
|
||||
@@ -465,49 +431,51 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo " <td class='vtable'>".$text['label-description']."</td>\n";
|
||||
echo " <td></td>\n";
|
||||
echo " </tr>\n";
|
||||
if (strlen($voicemail_uuid) > 0) {
|
||||
if (is_uuid($voicemail_uuid)) {
|
||||
$sql = "select * from v_voicemail_options ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_uuid = '".$voicemail_uuid."' ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and voicemail_uuid = :voicemail_uuid ";
|
||||
$sql .= "order by voicemail_option_digits, voicemail_option_order asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
foreach($result as $field) {
|
||||
$voicemail_option_param = $field['voicemail_option_param'];
|
||||
if (strlen(trim($voicemail_option_param)) == 0) {
|
||||
$voicemail_option_param = $field['voicemail_option_action'];
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['voicemail_uuid'] = $voicemail_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach($result as $field) {
|
||||
$voicemail_option_param = $field['voicemail_option_param'];
|
||||
if (strlen(trim($voicemail_option_param)) == 0) {
|
||||
$voicemail_option_param = $field['voicemail_option_action'];
|
||||
}
|
||||
$voicemail_option_param = str_replace("menu-", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("XML", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("transfer", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("bridge", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace($_SESSION['domain_name'], "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("\${domain_name}", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("\${domain}", "", $voicemail_option_param);
|
||||
$voicemail_option_param = ucfirst(trim($voicemail_option_param));
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($field['voicemail_option_digits']);
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($voicemail_option_param)." \n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($field['voicemail_option_order'])." \n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($field['voicemail_option_description'])." \n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
echo "<a href='voicemail_option_edit.php?id=".escape($field['voicemail_option_uuid'])."&voicemail_uuid=".escape($field['voicemail_uuid'])."' alt='".$text['button-edit']."'>".$v_link_label_edit."</a>";
|
||||
echo "<a href='voicemail_option_delete.php?id=".escape($field['voicemail_option_uuid'])."&voicemail_uuid=".escape($field['voicemail_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
$voicemail_option_param = str_replace("menu-", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("XML", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("transfer", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("bridge", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace($_SESSION['domain_name'], "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("\${domain_name}", "", $voicemail_option_param);
|
||||
$voicemail_option_param = str_replace("\${domain}", "", $voicemail_option_param);
|
||||
$voicemail_option_param = ucfirst(trim($voicemail_option_param));
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($field['voicemail_option_digits']);
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($voicemail_option_param)." \n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($field['voicemail_option_order'])." \n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable'>\n";
|
||||
echo " ".escape($field['voicemail_option_description'])." \n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
echo "<a href='voicemail_option_edit.php?id=".escape($field['voicemail_option_uuid'])."&voicemail_uuid=".escape($field['voicemail_uuid'])."' alt='".$text['button-edit']."'>".$v_link_label_edit."</a>";
|
||||
echo "<a href='voicemail_option_delete.php?id=".escape($field['voicemail_option_uuid'])."&voicemail_uuid=".escape($field['voicemail_uuid'])."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
}
|
||||
unset($sql, $result);
|
||||
unset($sql, $parameters, $result, $field);
|
||||
|
||||
for ($c = 0; $c < 1; $c++) {
|
||||
echo " <tr>\n";
|
||||
@@ -519,12 +487,11 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select name='voicemail_options[".$c."][voicemail_option_order]' class='formfld' style='width:55px'>\n";
|
||||
//echo " <option></option>\n";
|
||||
if (strlen(htmlspecialchars($voicemail_option_order))> 0) {
|
||||
echo " <option selected='yes' value='".htmlspecialchars($voicemail_option_order)."'>".htmlspecialchars($voicemail_option_order)."</option>\n";
|
||||
}
|
||||
$i=0;
|
||||
while($i<=999) {
|
||||
$i = 0;
|
||||
while ($i <= 999) {
|
||||
if (strlen($i) == 1) {
|
||||
echo " <option value='00$i'>00$i</option>\n";
|
||||
}
|
||||
@@ -638,16 +605,16 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
v_voicemail_destinations as d
|
||||
where
|
||||
d.voicemail_uuid_copy = v.voicemail_uuid and
|
||||
v.domain_uuid = '".$_SESSION['domain_uuid']."' and
|
||||
v.domain_uuid = :domain_uuid and
|
||||
v.voicemail_enabled = 'true' and
|
||||
d.voicemail_uuid = '".$voicemail_uuid."'
|
||||
d.voicemail_uuid = :voicemail_uuid
|
||||
order by
|
||||
v.voicemail_id asc";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
if ($result_count > 0) {
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['voicemail_uuid'] = $voicemail_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
echo " <table width='52%'>\n";
|
||||
foreach($result as $field) {
|
||||
echo " <tr>\n";
|
||||
@@ -656,15 +623,25 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo " <a href='voicemail_edit.php?id=".escape($voicemail_uuid)."&voicemail_destination_uuid=".escape($field['voicemail_destination_uuid'])."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
$voicemail_uuid_copied[] = $field['voicemail_uuid_copy'];
|
||||
$voicemail_uuids_copied[] = $field['voicemail_uuid_copy'];
|
||||
}
|
||||
echo " </table>\n";
|
||||
echo " <br />\n";
|
||||
}
|
||||
unset($sql, $parameters, $result, $field);
|
||||
|
||||
if (sizeof($voicemail_uuid_copied) > 0) {
|
||||
if (is_array($voicemail_uuids_copied) && @sizeof($voicemail_uuids_copied) != 0) {
|
||||
// modify sql to remove already copied voicemail uuids from the list
|
||||
$sql_mod = " and v.voicemail_uuid not in ('".implode("','", $voicemail_uuid_copied)."') ";
|
||||
foreach ($voicemail_uuids_copied as $x => $voicemail_uuid_copied) {
|
||||
if (is_uuid($voicemail_uuid_copied)) {
|
||||
$sql_where_and[] = 'v.voicemail_uuid <> :voicemail_uuid_'.$x;
|
||||
$parameters['voicemail_uuid_'.$x] = $voicemail_uuid_copied;
|
||||
}
|
||||
}
|
||||
if (is_array($sql_where_and) && @sizeof($sql_where_and) != 0) {
|
||||
$sql_where = ' and '.implode(' and ', $sql_where_and);
|
||||
}
|
||||
unset($voicemail_uuids_copied, $x, $voicemail_uuid_copied, $sql_where_and);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
@@ -674,23 +651,26 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
from
|
||||
v_voicemails as v
|
||||
where
|
||||
v.domain_uuid = '".$_SESSION['domain_uuid']."' and
|
||||
v.domain_uuid = :domain_uuid and
|
||||
v.voicemail_enabled = 'true' and
|
||||
v.voicemail_uuid <> '".$voicemail_uuid."'
|
||||
".$sql_mod."
|
||||
v.voicemail_uuid <> :voicemail_uuid
|
||||
".$sql_where."
|
||||
order by
|
||||
v.voicemail_id asc";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['voicemail_uuid'] = $voicemail_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
echo " <select name=\"voicemail_uuid_copy\" class='formfld' style='width: auto;'>\n";
|
||||
echo " <option value=\"\"></option>\n";
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach($result as $field) {
|
||||
echo " <option value='".escape($field['voicemail_uuid'])."'>".escape($field['voicemail_id'])."</option>\n";
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach($result as $field) {
|
||||
echo " <option value='".escape($field['voicemail_uuid'])."'>".escape($field['voicemail_id'])."</option>\n";
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $result, $field);
|
||||
echo " </select>";
|
||||
echo " <input type='button' class='btn' value=\"".$text['button-add']."\" onclick='submit_form();'>\n";
|
||||
unset($sql, $result);
|
||||
echo " <br>\n";
|
||||
echo " ".$text['description-forward_destinations']."\n";
|
||||
echo " <br />\n";
|
||||
@@ -757,7 +737,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo " $(window).keypress(function(event){\n";
|
||||
echo " if (event.which == 13) { submit_form(); }\n";
|
||||
echo " });\n";
|
||||
// convert password fields to
|
||||
//hide password fields, change to text, before submit
|
||||
echo " function submit_form() {\n";
|
||||
echo " $('input:password').css('visibility','hidden');\n";
|
||||
echo " $('input:password').attr({type:'text'});\n";
|
||||
@@ -768,4 +748,4 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user