diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php
index c578a17c12..b26e93ad1c 100644
--- a/app/voicemails/voicemail_edit.php
+++ b/app/voicemails/voicemail_edit.php
@@ -99,7 +99,7 @@
}
//assign the voicemail id copy to the voicemail id
- if (is_uuid($voicemail_uuid) && is_uuid($_REQUEST["voicemail_uuid_copy"])) {
+ if (permission_exists('voicemail_forward_destinations') && is_uuid($voicemail_uuid) && is_uuid($_REQUEST["voicemail_uuid_copy"])) {
//set the variables
$voicemail_uuid_copy = $_REQUEST["voicemail_uuid_copy"];
//build insert array
@@ -122,55 +122,47 @@
message::add($text['message-add']);
}
-if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+//process the data
+ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
- $msg = '';
- if ($action == "update") {
- $voicemail_uuid = $_POST["voicemail_uuid"];
- }
-
- //validate the token
- $token = new token;
- if (!$token->validate($_SERVER['PHP_SELF'])) {
- message::add($text['message-invalid_token'],'negative');
- header('Location: voicemails.php');
- exit;
+ $msg = '';
+ if ($action == "update") {
+ $voicemail_uuid = $_POST["voicemail_uuid"];
}
- //check for all required data
- if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
- require_once "resources/header.php";
- require_once "resources/persist_form_var.php";
- echo "
\n";
- echo "
\n";
- echo $msg." ";
- echo " |
\n";
- persistformvar($_POST);
- echo "
\n";
- require_once "resources/footer.php";
- return;
- }
-
- //add or update the database
- if ($_POST["persistformvar"] != "true") {
- if ($action == "add" && permission_exists('voicemail_add')) {
- //begin insert array
- $voicemail_uuid = uuid();
- $array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
- //set message
- message::add($text['message-add']);
+ //validate the token
+ $token = new token;
+ if (!$token->validate($_SERVER['PHP_SELF'])) {
+ message::add($text['message-invalid_token'],'negative');
+ header('Location: voicemails.php');
+ exit;
}
- if ($action == "update" && permission_exists('voicemail_edit')) {
- //begin update array
- $array['voicemails'][0]['voicemail_uuid'] = $voicemail_uuid;
- //set message
- message::add($text['message-update']);
+ //check for all required data
+ if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
+ require_once "resources/header.php";
+ require_once "resources/persist_form_var.php";
+ echo "\n";
+ echo "
\n";
+ echo $msg." ";
+ echo " |
\n";
+ persistformvar($_POST);
+ echo "
\n";
+ require_once "resources/footer.php";
+ return;
}
- if (is_array($array) && @sizeof($array) != 0) {
+ //add or update the database
+ if ($_POST["persistformvar"] != "true") {
+
+ //get a new voicemail_uuid
+ if ($action == "add" && permission_exists('voicemail_add')) {
+ $voicemail_uuid = uuid();
+ }
+
//add common array fields
$array['voicemails'][0]['domain_uuid'] = $domain_uuid;
+ $array['voicemails'][0]['voicemail_uuid'] = $voicemail_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;
@@ -185,70 +177,74 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
}
$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
+ if (permission_exists('voicemail_options') && sizeof($voicemail_options) > 0) {
+ foreach ($voicemail_options as $index => $voicemail_option) {
+ if ($voicemail_option['voicemail_option_digits'] == '' || $voicemail_option['voicemail_option_param'] == '') { unset($voicemail_options[$index]); }
+ }
+ foreach ($voicemail_options as $index => $voicemail_option) {
+ 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";
+ $voicemail_option['voicemail_option_param'] = "transfer ".$voicemail_option["voicemail_option_param"]." XML ".$_SESSION['domain_name'];
+ }
+ else {
+ //seperate the action and the param
+ $option_array = explode(":", $voicemail_option["voicemail_option_param"]);
+ $voicemail_option['voicemail_option_action'] = array_shift($option_array);
+ $voicemail_option['voicemail_option_param'] = join(':', $option_array);
+ }
+
+ //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');
+ }
+ }
+
+ //set message
+ if ($action == "add" && permission_exists('voicemail_add')) {
+ message::add($text['message-add']);
+ }
+ if ($action == "update" && permission_exists('voicemail_edit')) {
+ message::add($text['message-update']);
+ }
+
+ //redirect user
+ if ($action == 'add') {
+ header("Location: voicemails.php");
+ }
+ else if ($action == "update") {
+ header("Location: voicemail_edit.php?id=".$voicemail_uuid);
+ }
+ exit;
}
-
-
- // add voicemail options
- if (sizeof($voicemail_options) > 0) {
- foreach ($voicemail_options as $index => $voicemail_option) {
- if ($voicemail_option['voicemail_option_digits'] == '' || $voicemail_option['voicemail_option_param'] == '') { unset($voicemail_options[$index]); }
- }
- foreach ($voicemail_options as $index => $voicemail_option) {
- 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";
- $voicemail_option['voicemail_option_param'] = "transfer ".$voicemail_option["voicemail_option_param"]." XML ".$_SESSION['domain_name'];
- }
- else {
- //seperate the action and the param
- $option_array = explode(":", $voicemail_option["voicemail_option_param"]);
- $voicemail_option['voicemail_option_action'] = array_shift($option_array);
- $voicemail_option['voicemail_option_param'] = join(':', $option_array);
- }
-
- //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');
- }
- }
-
- //redirect user
- if ($action == 'add') {
- header("Location: voicemails.php");
- }
- else if ($action == "update") {
- header("Location: voicemail_edit.php?id=".$voicemail_uuid);
- }
- exit;
-
- }
-}
+ }
//initialize the destinations object
$destination = new destinations;
@@ -431,106 +427,108 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo "\n";
echo "\n";
- echo " ";
- echo " | ".$text['label-options']." | ";
- echo " ";
- echo " \n";
- echo " \n";
- echo " | ".$text['label-option']." | \n";
- echo " ".$text['label-destination']." | \n";
- echo " ".$text['label-order']." | \n";
- echo " ".$text['label-description']." | \n";
- echo " | \n";
- echo " \n";
- if (is_uuid($voicemail_uuid)) {
- $sql = "select * from v_voicemail_options ";
- $sql .= "where domain_uuid = :domain_uuid ";
- $sql .= "and voicemail_uuid = :voicemail_uuid ";
- $sql .= "order by voicemail_option_digits, voicemail_option_order asc ";
- $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 " \n";
- echo " | \n";
- echo " ".escape($field['voicemail_option_digits']);
- echo " | \n";
- echo " \n";
- echo " ".escape($voicemail_option_param)." \n";
- echo " | \n";
- echo " \n";
- echo " ".escape($field['voicemail_option_order'])." \n";
- echo " | \n";
- echo " \n";
- echo " ".escape($field['voicemail_option_description'])." \n";
- echo " | \n";
- echo " ";
- echo "".$v_link_label_edit."";
- echo "".$v_link_label_delete."";
- echo " | \n";
- echo " \n";
- }
- }
- }
- unset($sql, $parameters, $result, $field);
-
- for ($c = 0; $c < 1; $c++) {
+ if (permission_exists('voicemail_options')) {
+ echo " ";
+ echo " | ".$text['label-options']." | ";
+ echo " ";
+ echo " \n";
+ if (is_uuid($voicemail_uuid)) {
+ $sql = "select * from v_voicemail_options ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and voicemail_uuid = :voicemail_uuid ";
+ $sql .= "order by voicemail_option_digits, voicemail_option_order asc ";
+ $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 " | \n";
+ echo " | \n";
+ echo " ".escape($field['voicemail_option_digits']);
+ echo " | \n";
+ echo " \n";
+ echo " ".escape($voicemail_option_param)." \n";
+ echo " | \n";
+ echo " \n";
+ echo " ".escape($field['voicemail_option_order'])." \n";
+ echo " | \n";
+ echo " \n";
+ echo " ".escape($field['voicemail_option_description'])." \n";
+ echo " | \n";
+ echo " ";
+ echo "".$v_link_label_edit."";
+ echo "".$v_link_label_delete."";
+ echo " | \n";
+ echo " \n";
+ }
+ }
+ }
+ unset($sql, $parameters, $result, $field);
- echo " ".$text['description-options']."\n";
- echo " \n";
- echo " ";
- echo " ";
+ for ($c = 0; $c < 1; $c++) {
+ echo " \n";
+ echo "| \n";
+ echo " \n";
+ echo " | \n";
+ echo "\n";
+ echo $destination->select('ivr', 'voicemail_options['.$c.'][voicemail_option_param]', '');
+ echo " | \n";
+ echo "\n";
+ echo " \n";
+ echo " | \n";
+ echo "\n";
+ echo " \n";
+ echo " | \n";
+
+ echo " \n";
+ echo " \n";
+ echo " | \n";
+ echo " \n";
+ }
+ echo " \n";
+
+ echo " ".$text['description-options']."\n";
+ echo " \n";
+ echo " | ";
+ echo "
";
+ }
echo "\n";
echo "| \n";
@@ -542,7 +540,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo $text['description-voicemail_mail_to']."\n";
echo " | \n";
echo "
\n";
- if(permission_exists('sms_edit')) {
+
+ if (permission_exists('sms_edit')) {
echo "\n";
echo "| \n";
echo " ".$text['label-voicemail_sms_to']."\n";
@@ -554,7 +553,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " | \n";
echo "
\n";
}
- if(permission_exists('voicemail_transcription_edit') && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == "true") {
+
+ if (permission_exists('voicemail_transcription_edit') && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == "true") {
echo "\n";
echo "| \n";
echo " ".$text['label-voicemail_transcription_enabled']."\n";
@@ -601,7 +601,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " |
\n";
}
- if ($action == "update") {
+ if (permission_exists('voicemail_forward_destinations') && $action == "update") {
echo " ";
echo " | ".$text['label-forward_destinations']." | ";
echo " ";
@@ -631,7 +631,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
echo " |
\n";
echo " | ".escape($field['voicemail_id'])." | \n";
echo " \n";
- echo " ".$v_link_label_delete."\n";
+ echo " ".$v_link_label_delete."\n";
echo " | \n";
echo "
\n";
$voicemail_uuids_copied[] = $field['voicemail_uuid_copy'];