Extensions: Added bulk delete.
Voicemail: Added bulk delete. On delete, remove recordings folder, and voicemail_options, _destinations, and _greetings database records.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2015
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2016
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -186,6 +186,50 @@
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function voicemail_delete() {
|
||||
//delete voicemail messages
|
||||
$this->message_delete();
|
||||
|
||||
//delete voicemail recordings folder (includes greetings)
|
||||
$file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
|
||||
foreach (glob($file_path."/*.*") as $file_name) {
|
||||
unlink($file_name);
|
||||
}
|
||||
@rmdir($file_path);
|
||||
|
||||
//delete voicemail destinations
|
||||
$sql = "delete from v_voicemail_destinations ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql, $prep_statement);
|
||||
|
||||
//delete voicemail greetings
|
||||
$sql = "delete from v_voicemail_greetings ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_id = '".$this->voicemail_id."' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql, $prep_statement);
|
||||
|
||||
//delete voicemail options
|
||||
$sql = "delete from v_voicemail_options ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql, $prep_statement);
|
||||
|
||||
//delete voicemail
|
||||
$sql = "delete from v_voicemails ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql, $prep_statement);
|
||||
}
|
||||
|
||||
public function message_count() {
|
||||
$sql = "select count(*) as num_rows from v_voicemail_messages ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
@@ -214,21 +258,11 @@
|
||||
}
|
||||
|
||||
public function message_delete() {
|
||||
|
||||
//delete voicemail_message
|
||||
$sql = "delete from v_voicemail_messages ";
|
||||
$sql .= "where domain_uuid = '$this->domain_uuid' ";
|
||||
$sql .= "and voicemail_uuid = '$this->voicemail_uuid' ";
|
||||
$sql .= "and voicemail_message_uuid = '$this->voicemail_message_uuid' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
|
||||
//get the voicemail_id
|
||||
if (!isset($this->voicemail_id)) {
|
||||
$sql = "select * from v_voicemails ";
|
||||
$sql = "select voicemail_id from v_voicemails ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and voicemail_uuid = '$this->voicemail_uuid' ";
|
||||
$sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
@@ -240,13 +274,30 @@
|
||||
|
||||
//delete the recording
|
||||
$file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
|
||||
foreach (glob($file_path."/msg_".$this->voicemail_message_uuid.".*") as $file_name) {
|
||||
unlink($file_name);
|
||||
if ($this->voicemail_message_uuid != '') {
|
||||
foreach (
|
||||
glob($file_path."/msg_".$this->voicemail_message_uuid.".*") as $file_name) { unlink($file_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach (
|
||||
glob($file_path."/msg_*.*") as $file_name) { unlink($file_name); //remove all recordings
|
||||
}
|
||||
}
|
||||
|
||||
//delete voicemail message(s)
|
||||
$sql = "delete from v_voicemail_messages ";
|
||||
$sql .= "where domain_uuid = '".$this->domain_uuid."' ";
|
||||
$sql .= "and voicemail_uuid = '".$this->voicemail_uuid."' ";
|
||||
if ($this->voicemail_message_uuid != '') {
|
||||
$sql .= "and voicemail_message_uuid = '".$this->voicemail_message_uuid."' ";
|
||||
}
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
|
||||
//check the message waiting status
|
||||
$this->message_waiting();
|
||||
|
||||
}
|
||||
|
||||
public function message_saved() {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2012
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2016
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -38,20 +38,24 @@ else {
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get the id
|
||||
if (count($_GET)>0) {
|
||||
$id = check_str($_GET["id"]);
|
||||
}
|
||||
//get the ids
|
||||
if (is_array($_REQUEST) && sizeof($_REQUEST) > 0) {
|
||||
|
||||
if (strlen($id)>0) {
|
||||
//delete voicemail
|
||||
$sql = "delete from v_voicemails ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and voicemail_uuid = '$id' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
}
|
||||
$voicemail_uuids = $_REQUEST["id"];
|
||||
foreach($voicemail_uuids as $voicemail_uuid) {
|
||||
$voicemail_uuid = check_str($voicemail_uuid);
|
||||
if ($voicemail_uuid != '') {
|
||||
//delete voicemail messages
|
||||
require_once "resources/classes/voicemail.php";
|
||||
$voicemail = new voicemail;
|
||||
$voicemail->db = $db;
|
||||
$voicemail->domain_uuid = $_SESSION['domain_uuid'];
|
||||
$voicemail->voicemail_uuid = $voicemail_uuid;
|
||||
$result = $voicemail->voicemail_delete();
|
||||
unset($voicemail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2015
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2016
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -143,8 +143,12 @@ else {
|
||||
|
||||
if ($num_rows > 0) {
|
||||
|
||||
echo "<form name='frm' method='post' action='voicemail_delete.php'>\n";
|
||||
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
if (permission_exists('voicemail_delete') && $num_rows > 0) {
|
||||
echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' id='chk_all' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
|
||||
}
|
||||
echo th_order_by('voicemail_id', $text['label-voicemail_id'], $order_by, $order);
|
||||
echo th_order_by('voicemail_mail_to', $text['label-voicemail_mail_to'], $order_by, $order);
|
||||
echo th_order_by('voicemail_file', $text['label-voicemail_file_attached'], $order_by, $order);
|
||||
@@ -152,14 +156,12 @@ else {
|
||||
echo "<th>".$text['label-tools']."</th>\n";
|
||||
echo th_order_by('voicemail_enabled', $text['label-voicemail_enabled'], $order_by, $order);
|
||||
echo th_order_by('voicemail_description', $text['label-voicemail_description'], $order_by, $order);
|
||||
if (permission_exists('voicemail_add') || permission_exists('voicemail_edit') || permission_exists('voicemail_delete')) {
|
||||
echo "<td class='list_control_icons' style='width: 25px;'>";
|
||||
if (permission_exists('voicemail_add')) {
|
||||
echo "<a href='voicemail_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
else {
|
||||
echo " ";
|
||||
}
|
||||
echo "<td class='list_control_icons' style='width: 25px;'>";
|
||||
if (permission_exists('voicemail_add') || permission_exists('voicemail_edit')) {
|
||||
echo "<a href='voicemail_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
|
||||
}
|
||||
if (permission_exists('voicemail_delete') && $num_rows > 0) {
|
||||
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
@@ -167,6 +169,12 @@ else {
|
||||
foreach($voicemails as $row) {
|
||||
$tr_link = (permission_exists('voicemail_edit')) ? "href='voicemail_edit.php?id=".$row['voicemail_uuid']."'" : null;
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
if (permission_exists('voicemail_delete')) {
|
||||
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center; vertical-align: middle; padding: 0px;'>";
|
||||
echo " <input type='checkbox' name='id[]' id='checkbox_".$row['voicemail_uuid']."' value='".$row['voicemail_uuid']."' onclick=\"if (!this.checked) { document.getElementById('chk_all').checked = false; }\">";
|
||||
echo " </td>";
|
||||
$vm_ids[] = 'checkbox_'.$row['voicemail_uuid'];
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>";
|
||||
if (permission_exists('voicemail_edit')) {
|
||||
echo "<a href='voicemail_edit.php?id=".$row['voicemail_uuid']."'>".$row['voicemail_id']."</a>";
|
||||
@@ -191,10 +199,10 @@ else {
|
||||
if (permission_exists('voicemail_edit') || permission_exists('voicemail_delete')) {
|
||||
echo " <td class='list_control_icons' style='width: 25px;'>";
|
||||
if (permission_exists('voicemail_edit')) {
|
||||
echo "<a href='voicemail_edit.php?id=".$row['voicemail_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
echo "<a href='voicemail_edit.php?id=".$row['voicemail_uuid']."' alt='".$text['button-edit']."'>".$v_link_label_edit."</a>";
|
||||
}
|
||||
if (permission_exists('voicemail_delete')) {
|
||||
echo "<a href='voicemail_delete.php?id=".$row['voicemail_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
||||
echo "<a href='voicemail_delete.php?id[]=".$row['voicemail_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
}
|
||||
@@ -204,22 +212,33 @@ else {
|
||||
unset($sql, $voicemails, $row_count);
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='11' align='left'>\n";
|
||||
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='33.3%' nowrap='nowrap'> </td>\n";
|
||||
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
echo " <td colspan='20' class='list_control_icons'>\n";
|
||||
if (permission_exists('voicemail_add')) {
|
||||
echo "<a href='voicemail_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
echo "<a href='voicemail_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>\n";
|
||||
echo "</td>\n";
|
||||
if (permission_exists('voicemail_delete') && $num_rows > 0) {
|
||||
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
if (strlen($paging_controls) > 0) {
|
||||
echo "<center>".$paging_controls."</center>\n";
|
||||
}
|
||||
|
||||
// check or uncheck all checkboxes
|
||||
if (sizeof($vm_ids) > 0) {
|
||||
echo "<script>\n";
|
||||
echo " function check(what) {\n";
|
||||
foreach ($vm_ids as $vm_id) {
|
||||
echo "document.getElementById('".$vm_id."').checked = (what == 'all') ? true : false;\n";
|
||||
}
|
||||
echo " }\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user