mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Voicemail - Edit: Add bulk delete of Options and Destinations, dynamic Delete button action. Remove deprecated Option delete script.
This commit is contained in:
@@ -326,14 +326,14 @@
|
||||
$array[$this->table][$x]['voicemail_uuid'] = $voicemail_uuid;
|
||||
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['voicemail_options'][$x]['voicemail_uuid'] = $voicemail_uuid;
|
||||
$array['voicemail_options'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];;
|
||||
$array['voicemail_options'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['voicemail_messages'][$x]['voicemail_uuid'] = $voicemail_uuid;
|
||||
$array['voicemail_messages'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];;
|
||||
$array['voicemail_messages'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$array['voicemail_destinations'][$x]['voicemail_uuid'] = $voicemail_uuid;
|
||||
$array['voicemail_destinations'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];;
|
||||
$array['voicemail_destinations'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
if (is_numeric($voicemail_id)) {
|
||||
$array['voicemail_greetings'][$x]['voicemail_id'] = $voicemail_id;
|
||||
$array['voicemail_greetings'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];;
|
||||
$array['voicemail_greetings'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
$x++;
|
||||
}
|
||||
@@ -372,6 +372,108 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function voicemail_options_delete($records) {
|
||||
//assign private variables
|
||||
$this->permission_prefix = 'voicemail_option_';
|
||||
$this->list_page = 'voicemail_edit.php?id='.$this->voicemail_uuid;
|
||||
$this->table = 'voicemail_options';
|
||||
$this->uuid_prefix = 'voicemail_option_';
|
||||
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//filter out unchecked sip profiles
|
||||
foreach ($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
//build the delete array
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['voicemail_uuid'] = $this->voicemail_uuid;
|
||||
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function voicemail_destinations_delete($records) {
|
||||
//assign private variables
|
||||
$this->list_page = 'voicemail_edit.php?id='.$this->voicemail_uuid;
|
||||
$this->table = 'voicemail_destinations';
|
||||
$this->uuid_prefix = 'voicemail_destination_';
|
||||
|
||||
if (permission_exists('voicemail_forward')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//filter out unchecked sip profiles
|
||||
foreach ($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
//build the delete array
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['voicemail_uuid'] = $this->voicemail_uuid;
|
||||
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('voicemail_destination_delete', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('voicemail_destination_delete', 'temp');
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function voicemail_toggle($records) {
|
||||
if (permission_exists($this->permission_prefix.'edit')) {
|
||||
|
||||
|
||||
@@ -58,6 +58,25 @@
|
||||
$referer_path = $_REQUEST["referer_path"];
|
||||
$referer_query = $_REQUEST["referer_query"];
|
||||
if (count($_POST)>0) {
|
||||
|
||||
//process the http post data by submitted action
|
||||
if ($_POST['action'] != '' && is_uuid($_POST['voicemail_uuid'])) {
|
||||
$array[0]['checked'] = 'true';
|
||||
$array[0]['uuid'] = $_POST['voicemail_uuid'];
|
||||
|
||||
switch ($_POST['action']) {
|
||||
case 'delete':
|
||||
if (permission_exists('voicemail_delete')) {
|
||||
$obj = new voicemail;
|
||||
$obj->voicemail_delete($array);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
header('Location: voicemails.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
//set the variables from the HTTP values
|
||||
$voicemail_id = $_POST["voicemail_id"];
|
||||
$voicemail_password = $_POST["voicemail_password"];
|
||||
@@ -69,62 +88,16 @@
|
||||
$voicemail_transcription_enabled = $_POST["voicemail_transcription_enabled"];
|
||||
$voicemail_file = $_POST["voicemail_file"];
|
||||
$voicemail_local_after_email = $_POST["voicemail_local_after_email"];
|
||||
$voicemail_destination = $_POST["voicemail_destination"];
|
||||
$voicemail_enabled = $_POST["voicemail_enabled"];
|
||||
$voicemail_description = $_POST["voicemail_description"];
|
||||
$voicemail_tutorial = $_POST["voicemail_tutorial"];
|
||||
$voicemail_options_delete = $_POST["voicemail_options_delete"];
|
||||
$voicemail_destinations_delete = $_POST["voicemail_destinations_delete"];
|
||||
//remove the space
|
||||
$voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to);
|
||||
}
|
||||
|
||||
//unassign the voicemail id copy from the voicemail id
|
||||
if ($_GET["a"] == "delete" && is_uuid($voicemail_uuid) && is_uuid($_REQUEST["voicemail_destination_uuid"])) {
|
||||
//set the variables
|
||||
$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);
|
||||
exit;
|
||||
}
|
||||
|
||||
//assign the voicemail id copy to the voicemail id
|
||||
if (permission_exists('voicemail_forward') && is_uuid($voicemail_uuid) && is_uuid($_REQUEST["voicemail_uuid_copy"])) {
|
||||
//set the variables
|
||||
$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->delete('voicemail_destination_add', 'temp');
|
||||
//set message
|
||||
message::add($text['message-add']);
|
||||
}
|
||||
|
||||
//process the data
|
||||
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
|
||||
@@ -180,18 +153,16 @@
|
||||
}
|
||||
$array['voicemails'][0]['voicemail_enabled'] = $voicemail_enabled;
|
||||
$array['voicemails'][0]['voicemail_description'] = $voicemail_description;
|
||||
$database = new database;
|
||||
$database->app_name = 'voicemails';
|
||||
$database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//create permissions object
|
||||
$p = new permissions;
|
||||
|
||||
//add voicemail options
|
||||
if (permission_exists('voicemail_option_add') && 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 $x => $voicemail_option) {
|
||||
if ($voicemail_option['voicemail_option_digits'] == '' || $voicemail_option['voicemail_option_param'] == '') { unset($voicemail_options[$x]); }
|
||||
}
|
||||
foreach ($voicemail_options as $index => $voicemail_option) {
|
||||
foreach ($voicemail_options as $x => $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";
|
||||
@@ -205,33 +176,71 @@
|
||||
}
|
||||
|
||||
//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'][$x]['voicemail_option_uuid'] = uuid();
|
||||
$array['voicemail_options'][$x]['voicemail_uuid'] = $voicemail_uuid;
|
||||
$array['voicemail_options'][$x]['domain_uuid'] = $domain_uuid;
|
||||
$array['voicemail_options'][$x]['voicemail_option_digits'] = $voicemail_option['voicemail_option_digits'];
|
||||
$array['voicemail_options'][$x]['voicemail_option_action'] = $voicemail_option['voicemail_option_action'];
|
||||
if ($destination->valid(preg_replace('/\s/', ':', $voicemail_option['voicemail_option_param'], 1))) {
|
||||
$array['voicemail_options'][$index]['voicemail_option_param'] = $voicemail_option['voicemail_option_param'];
|
||||
$array['voicemail_options'][$x]['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'];
|
||||
$array['voicemail_options'][$x]['voicemail_option_order'] = $voicemail_option['voicemail_option_order'];
|
||||
$array['voicemail_options'][$x]['voicemail_option_description'] = $voicemail_option['voicemail_option_description'];
|
||||
}
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
if (is_array($array['voicemail_options']) && @sizeof($array['voicemail_options']) != 0) {
|
||||
//grant temporary permission
|
||||
$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');
|
||||
}
|
||||
}
|
||||
|
||||
//add voicemail destination
|
||||
if (permission_exists('voicemail_forward') && is_uuid($voicemail_destination)) {
|
||||
$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_destination;
|
||||
|
||||
if (is_array($array['voicemail_destinations']) && @sizeof($array['voicemail_destinations']) != 0) {
|
||||
//grant temporary permission
|
||||
$p->add('voicemail_destination_add', 'temp');
|
||||
}
|
||||
}
|
||||
|
||||
//execute insert/update
|
||||
$database = new database;
|
||||
$database->app_name = 'voicemails';
|
||||
$database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke any temporary permissions granted
|
||||
$p->delete('voicemail_option_add', 'temp');
|
||||
$p->delete('voicemail_destination_add', 'temp');
|
||||
|
||||
//remove checked voicemail options
|
||||
if (
|
||||
$action == 'update'
|
||||
&& permission_exists('voicemail_option_delete')
|
||||
&& is_array($voicemail_options_delete)
|
||||
&& @sizeof($voicemail_options_delete) != 0
|
||||
) {
|
||||
$obj = new voicemail;
|
||||
$obj->voicemail_uuid = $voicemail_uuid;
|
||||
$obj->voicemail_options_delete($voicemail_options_delete);
|
||||
}
|
||||
|
||||
//remove checked voicemail destinations
|
||||
if (
|
||||
$action == 'update'
|
||||
&& permission_exists('voicemail_forward')
|
||||
&& is_array($voicemail_destinations_delete)
|
||||
&& @sizeof($voicemail_destinations_delete) != 0
|
||||
) {
|
||||
$obj = new voicemail;
|
||||
$obj->voicemail_uuid = $voicemail_uuid;
|
||||
$obj->voicemail_destinations_delete($voicemail_destinations_delete);
|
||||
}
|
||||
|
||||
//set message
|
||||
if ($action == "add" && permission_exists('voicemail_add')) {
|
||||
message::add($text['message-add']);
|
||||
@@ -302,6 +311,81 @@
|
||||
$greetings = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//get the voicemail options
|
||||
if ($action == 'update' && 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;
|
||||
$voicemail_options = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
$show_option_delete = false;
|
||||
if (is_array($voicemail_options) && @sizeof($voicemail_options) != 0) {
|
||||
foreach ($voicemail_options as $x => $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));
|
||||
$voicemail_options[$x]['voicemail_option_param'] = $voicemail_option_param;
|
||||
unset($voicemail_option_param);
|
||||
}
|
||||
$show_option_delete = true;
|
||||
}
|
||||
}
|
||||
|
||||
//get the assigned voicemail destinations
|
||||
if ($action == 'update' && is_uuid($voicemail_uuid)) {
|
||||
$sql = "select v.voicemail_id, d.voicemail_destination_uuid, d.voicemail_uuid_copy ";
|
||||
$sql .= "from v_voicemails as v, v_voicemail_destinations as d ";
|
||||
$sql .= "where d.voicemail_uuid_copy = v.voicemail_uuid and ";
|
||||
$sql .= "v.domain_uuid = :domain_uuid and ";
|
||||
$sql .= "v.voicemail_enabled = 'true' and ";
|
||||
$sql .= "d.voicemail_uuid = :voicemail_uuid ";
|
||||
$sql .= "order by v.voicemail_id asc";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['voicemail_uuid'] = $voicemail_uuid;
|
||||
$database = new database;
|
||||
$voicemail_destinations_assigned = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($voicemail_destinations_assigned) && @sizeof($voicemail_destinations_assigned) != 0) {
|
||||
foreach ($voicemail_destinations_assigned as $field) {
|
||||
$voicemail_destinations[] = "'".$field['voicemail_uuid_copy']."'";
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
//get the available voicemail destinations
|
||||
$sql = "select v.voicemail_id, v.voicemail_uuid ";
|
||||
$sql .= "from v_voicemails as v ";
|
||||
$sql .= "where v.domain_uuid = :domain_uuid and ";
|
||||
$sql .= "v.voicemail_enabled = 'true' ";
|
||||
if (is_uuid($voicemail_uuid)) {
|
||||
$sql .= "and v.voicemail_uuid <> :voicemail_uuid ";
|
||||
}
|
||||
if (is_array($voicemail_destinations) && @sizeof($voicemail_destinations) != 0) {
|
||||
$sql .= "and v.voicemail_uuid not in (".implode(',', $voicemail_destinations).") ";
|
||||
}
|
||||
$sql .= "order by v.voicemail_id asc";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
if (is_uuid($voicemail_uuid)) {
|
||||
$parameters['voicemail_uuid'] = $voicemail_uuid;
|
||||
}
|
||||
$database = new database;
|
||||
$voicemail_destinations_available = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters, $voicemail_destinations);
|
||||
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
@@ -354,12 +438,16 @@
|
||||
|
||||
//show the content
|
||||
echo "<form method='post' name='frm' id='frm'>\n";
|
||||
echo "<input type='hidden' name='action' id='delete_action' value=''>\n";
|
||||
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-voicemail']."</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>$back_button_location]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'onclick'=>($password_complexity == "true" ? "if (check_password_strength(document.getElementById('password').value)) { submit_form(); }" : 'submit_form();')]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>$back_button_location]);
|
||||
if ($action == "update" && (permission_exists('voicemail_delete') || permission_exists('voicemail_option_delete'))) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','value'=>'delete','style'=>'margin-left: 15px;','onclick'=>"if (confirm('".$text['confirm-delete']."')) { document.getElementById('delete_action').value = this.value; submit_form(); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;','onclick'=>($password_complexity == "true" ? "if (check_password_strength(document.getElementById('password').value)) { submit_form(); } else { this.blur(); return false; }" : 'submit_form();')]);
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
@@ -371,7 +459,7 @@
|
||||
echo " ".$text['label-voicemail_id']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td width='70%' class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='voicemail_id' maxlength='255' value='".escape($voicemail_id)."'>\n";
|
||||
echo " <input class='formfld' type='text' name='voicemail_id' maxlength='255' autocomplete='new-password' value='".escape($voicemail_id)."'>\n";
|
||||
echo " <input type='text' style='display: none;' disabled='disabled'>\n"; //help defeat browser auto-fill
|
||||
echo "<br />\n";
|
||||
echo $text['description-voicemail_id']."\n";
|
||||
@@ -384,7 +472,7 @@
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input type='password' style='display: none;' disabled='disabled'>\n"; //help defeat browser auto-fill
|
||||
echo " <input class='formfld' type='password' name='voicemail_password' id='password' autocomplete='off' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" autocomplete='off' maxlength='50' value=\"".escape($voicemail_password)."\">\n";
|
||||
echo " <input class='formfld' type='password' name='voicemail_password' id='password' autocomplete='new-password' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" autocomplete='off' maxlength='50' value=\"".escape($voicemail_password)."\">\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-voicemail_password']."\n";
|
||||
echo "</td>\n";
|
||||
@@ -438,74 +526,51 @@
|
||||
echo " <tr>";
|
||||
echo " <td class='vncell' valign='top'>".$text['label-options']."</td>";
|
||||
echo " <td class='vtable' align='left'>";
|
||||
echo " <table width='60%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <table border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>".$text['label-option']."</td>\n";
|
||||
echo " <td class='vtable' style='text-align: center;'>".$text['label-option']."</td>\n";
|
||||
echo " <td class='vtable'>".$text['label-destination']."</td>\n";
|
||||
echo " <td class='vtable'>".$text['label-order']."</td>\n";
|
||||
echo " <td class='vtable' style='text-align: center;'>".$text['label-order']."</td>\n";
|
||||
echo " <td class='vtable'>".$text['label-description']."</td>\n";
|
||||
echo " <td></td>\n";
|
||||
if ($show_option_delete && permission_exists('voicemail_option_delete')) {
|
||||
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_options', 'delete_toggle_options');\" onmouseout=\"swap_display('delete_label_options', 'delete_toggle_options');\">\n";
|
||||
echo " <span id='delete_label_options'>".$text['label-delete']."</span>\n";
|
||||
echo " <span id='delete_toggle_options'><input type='checkbox' id='checkbox_all_options' name='checkbox_all' onclick=\"edit_all_toggle('options');\"></span>\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " </tr>\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'];
|
||||
if ($action == 'update' && is_array($voicemail_options) && @sizeof($voicemail_options) != 0) {
|
||||
foreach ($voicemail_options as $field) {
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable' style='text-align: center;'>".escape($field['voicemail_option_digits'])."</td>\n";
|
||||
echo " <td class='vtable'>".escape($field['voicemail_option_param'])."</td>\n";
|
||||
echo " <td class='vtable' style='text-align: center;'>".escape($field['voicemail_option_order'])."</td>\n";
|
||||
echo " <td class='vtable'>".escape($field['voicemail_option_description'])."</td>\n";
|
||||
if ($show_option_delete && permission_exists('voicemail_option_delete')) {
|
||||
echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'>";
|
||||
if (is_uuid($field['voicemail_option_uuid'])) {
|
||||
echo " <input type='checkbox' name='voicemail_options_delete[".$x."][checked]' value='true' class='chk_delete checkbox_options' onclick=\"edit_delete_action('options');\">\n";
|
||||
echo " <input type='hidden' name='voicemail_options_delete[".$x."][uuid]' value='".escape($field['voicemail_option_uuid'])."' />\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' style='text-align: left;'>";
|
||||
//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>";
|
||||
if (permission_exists('voicemail_option_delete')) {
|
||||
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";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " </tr>\n";
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $result, $field);
|
||||
unset($voicemail_options, $field);
|
||||
|
||||
for ($c = 0; $c < 1; $c++) {
|
||||
echo " <tr>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' style='width:70px' type='text' name='voicemail_options[".$c."][voicemail_option_digits]' maxlength='255' value='".$voicemail_option_digits."'>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left' nowrap='nowrap'>\n";
|
||||
echo $destination->select('ivr', 'voicemail_options['.$c.'][voicemail_option_param]', '');
|
||||
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 "<tr>\n";
|
||||
echo " <td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' style='width: 50px; text-align: center;' type='text' name='voicemail_options[".$c."][voicemail_option_digits]' maxlength='255' value='".$voicemail_option_digits."'>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable' align='left' nowrap='nowrap'>\n";
|
||||
echo $destination->select('ivr', 'voicemail_options['.$c.'][voicemail_option_param]', '');
|
||||
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";
|
||||
if (strlen(htmlspecialchars($voicemail_option_order))> 0) {
|
||||
echo " <option selected='yes' value='".htmlspecialchars($voicemail_option_order)."'>".htmlspecialchars($voicemail_option_order)."</option>\n";
|
||||
echo " <option selected='yes' value='".htmlspecialchars($voicemail_option_order)."'>".htmlspecialchars($voicemail_option_order)."</option>\n";
|
||||
}
|
||||
$i = 0;
|
||||
while ($i <= 999) {
|
||||
@@ -520,17 +585,16 @@
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' style='width:100px' type='text' name='voicemail_options[".$c."][voicemail_option_description]' maxlength='255' value=\"".$voicemail_option_description."\">\n";
|
||||
echo "</td>\n";
|
||||
echo " </select>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' style='width:100px' type='text' name='voicemail_options[".$c."][voicemail_option_description]' maxlength='255' value=\"".$voicemail_option_description."\">\n";
|
||||
echo " </td>\n";
|
||||
|
||||
echo " <td>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'onclick'=>'submit_form();']);
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <td></td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo " </table>\n";
|
||||
|
||||
echo " ".$text['description-options']."\n";
|
||||
@@ -611,90 +675,52 @@
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
if (permission_exists('voicemail_forward') && $action == "update") {
|
||||
if (permission_exists('voicemail_forward')) {
|
||||
echo " <tr>";
|
||||
echo " <td class='vncell' valign='top'>".$text['label-forward_destinations']."</td>";
|
||||
echo " <td class='vtable'>";
|
||||
echo " <table border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
|
||||
$sql = "
|
||||
select
|
||||
v.voicemail_id,
|
||||
d.voicemail_destination_uuid,
|
||||
d.voicemail_uuid_copy
|
||||
from
|
||||
v_voicemails as v,
|
||||
v_voicemail_destinations as d
|
||||
where
|
||||
d.voicemail_uuid_copy = v.voicemail_uuid and
|
||||
v.domain_uuid = :domain_uuid and
|
||||
v.voicemail_enabled = 'true' and
|
||||
d.voicemail_uuid = :voicemail_uuid
|
||||
order by
|
||||
v.voicemail_id 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) {
|
||||
echo " <table width='52%'>\n";
|
||||
foreach($result as $field) {
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>".escape($field['voicemail_id'])."</td>\n";
|
||||
echo " <td>\n";
|
||||
echo " <a href='voicemail_edit.php?id=".urlencode($voicemail_uuid)."&voicemail_destination_uuid=".urlencode($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_uuids_copied[] = $field['voicemail_uuid_copy'];
|
||||
if (is_array($voicemail_destinations_assigned) && @sizeof($voicemail_destinations_assigned) != 0) {
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>".$text['label-destination']."</td>\n";
|
||||
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_destinations', 'delete_toggle_destinations');\" onmouseout=\"swap_display('delete_label_destinations', 'delete_toggle_destinations');\">\n";
|
||||
echo " <span id='delete_label_destinations'>".$text['label-delete']."</span>\n";
|
||||
echo " <span id='delete_toggle_destinations'><input type='checkbox' id='checkbox_all_destinations' name='checkbox_all' onclick=\"edit_all_toggle('destinations');\"></span>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
foreach ($voicemail_destinations_assigned as $x => $field) {
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>".escape($field['voicemail_id'])."</td>\n";
|
||||
echo " <td class='vtable' style='text-align: center; padding-bottom: 3px;'>";
|
||||
echo " <input type='checkbox' name='voicemail_destinations_delete[".$x."][checked]' value='true' class='chk_delete checkbox_destinations' onclick=\"edit_delete_action('destinations');\">\n";
|
||||
echo " <input type='hidden' name='voicemail_destinations_delete[".$x."][uuid]' value='".escape($field['voicemail_destination_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
echo " </table>\n";
|
||||
echo " <br />\n";
|
||||
}
|
||||
unset($sql, $parameters, $result, $field);
|
||||
unset($voicemail_destinations_assigned, $field);
|
||||
|
||||
if (is_array($voicemail_uuids_copied) && @sizeof($voicemail_uuids_copied) != 0) {
|
||||
// modify sql to remove already copied voicemail uuids from the list
|
||||
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 = "
|
||||
select
|
||||
v.voicemail_id,
|
||||
v.voicemail_uuid
|
||||
from
|
||||
v_voicemails as v
|
||||
where
|
||||
v.domain_uuid = :domain_uuid and
|
||||
v.voicemail_enabled = 'true' and
|
||||
v.voicemail_uuid <> :voicemail_uuid
|
||||
".$sql_where."
|
||||
order by
|
||||
v.voicemail_id asc";
|
||||
$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";
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
foreach($result as $field) {
|
||||
if (is_array($voicemail_destinations_available) && @sizeof($voicemail_destinations_available) != 0) {
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable' colspan='2'>\n";
|
||||
echo " <select name='voicemail_destination' class='formfld'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
foreach ($voicemail_destinations_available as $field) {
|
||||
echo " <option value='".escape($field['voicemail_uuid'])."'>".escape($field['voicemail_id'])."</option>\n";
|
||||
}
|
||||
echo " </select>";
|
||||
if ($action == 'update') {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'collapse'=>'never','onclick'=>'submit_form();']);
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <tr>\n";
|
||||
}
|
||||
unset($sql, $parameters, $result, $field);
|
||||
echo " </select>";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'collapse'=>'never','onclick'=>'submit_form();']);
|
||||
echo " <br>\n";
|
||||
unset($voicemail_destinations_available, $field);
|
||||
|
||||
echo " </table>\n";
|
||||
|
||||
echo " ".$text['description-forward_destinations']."\n";
|
||||
echo " <br />\n";
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
}
|
||||
@@ -752,10 +778,9 @@
|
||||
echo " $(window).keypress(function(event){\n";
|
||||
echo " if (event.which == 13) { submit_form(); }\n";
|
||||
echo " });\n";
|
||||
//hide password fields, change to text, before submit
|
||||
//hide password fields before submit
|
||||
echo " function submit_form() {\n";
|
||||
echo " $('input:password').css('visibility','hidden');\n";
|
||||
echo " $('input:password').attr({type:'text'});\n";
|
||||
echo " hide_password_fields();\n";
|
||||
echo " $('form#frm').submit();\n";
|
||||
echo " }\n";
|
||||
echo "</script>\n";
|
||||
@@ -763,4 +788,4 @@
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -1,70 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2018
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
//includes
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
|
||||
//check permissions
|
||||
if (permission_exists('voicemail_option_delete')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//set the http values as variables
|
||||
$voicemail_option_uuid = $_GET["id"];
|
||||
$voicemail_uuid = $_GET["voicemail_uuid"];
|
||||
|
||||
//delete the voicemail option
|
||||
if (is_uuid($voicemail_option_uuid) && is_uuid($voicemail_uuid)) {
|
||||
//build delete array
|
||||
$array['voicemail_options'][0]['voicemail_option_uuid'] = $voicemail_option_uuid;
|
||||
$array['voicemail_options'][0]['domain_uuid'] = $domain_uuid;
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'voicemails';
|
||||
$database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
//redirect
|
||||
header('Location: voicemail_edit.php?id='.$voicemail_uuid);
|
||||
exit;
|
||||
}
|
||||
|
||||
//default redirect
|
||||
header('Location: voicemails.php');
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user