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:
reliberate 2016-03-16 18:48:42 -06:00
parent 9cd30165d4
commit 39bfec7aa2
6 changed files with 200 additions and 94 deletions

View File

@ -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,39 +38,42 @@ else {
$language = new text;
$text = $language->get();
//check for the id
if (count($_GET) > 0) {
$id = check_str($_GET["id"]);
}
if (strlen($id) > 0) {
//check for the ids
if (is_array($_REQUEST) && sizeof($_REQUEST) > 0) {
//get the user_context
$sql = "select extension, user_context from v_extensions ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and extension_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$extension = $row["extension"];
$user_context = $row["user_context"];
$extension_uuids = $_REQUEST["id"];
foreach($extension_uuids as $extension_uuid) {
$extension_uuid = check_str($extension_uuid);
if ($extension_uuid != '') {
//get the user_context
$sql = "select extension, user_context from v_extensions ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and extension_uuid = '".$extension_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$extension = $row["extension"];
$user_context = $row["user_context"];
}
unset ($prep_statement);
//delete the extension
$sql = "delete from v_extensions ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and extension_uuid = '".$extension_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
$sql = "delete from v_extension_users ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and extension_uuid = '".$extension_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
}
unset ($prep_statement);
//delete the extension
$sql = "delete from v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and extension_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
$sql = "delete from v_extension_users ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and extension_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
}
//clear the cache
$cache = new cache;

View File

@ -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-2014
Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -138,8 +138,12 @@ require_once "resources/paging.php";
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<form name='frm' method='post' action='extension_delete.php'>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
if (permission_exists('extension_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('extension', $text['label-extension'], $order_by, $order);
echo th_order_by('call_group', $text['label-call_group'], $order_by, $order);
//echo th_order_by('voicemail_mail_to', $text['label-voicemail_mail_to'], $order_by, $order);
@ -149,9 +153,12 @@ require_once "resources/paging.php";
echo "<td class='list_control_icons'>\n";
if (permission_exists('extension_add')) {
if ($_SESSION['limit']['extensions']['numeric'] == '' || ($_SESSION['limit']['extensions']['numeric'] != '' && $total_extensions < $_SESSION['limit']['extensions']['numeric'])) {
echo " <a href='extension_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>\n";
echo "<a href='extension_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
if (permission_exists('extension_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";
@ -159,6 +166,12 @@ require_once "resources/paging.php";
foreach($extensions as $row) {
$tr_link = (permission_exists('extension_edit')) ? " href='extension_edit.php?id=".$row['extension_uuid']."'" : null;
echo "<tr ".$tr_link.">\n";
if (permission_exists('extension_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['extension_uuid']."' value='".$row['extension_uuid']."' onclick=\"if (!this.checked) { document.getElementById('chk_all').checked = false; }\">";
echo " </td>";
$ext_ids[] = 'checkbox_'.$row['extension_uuid'];
}
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('extension_edit')) {
echo "<a href='extension_edit.php?id=".$row['extension_uuid']."'>".$row['extension']."</a>";
@ -177,7 +190,7 @@ require_once "resources/paging.php";
echo "<a href='extension_edit.php?id=".$row['extension_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('extension_delete')) {
echo "<a href='extension_delete.php?id=".$row['extension_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
echo "<a href='extension_delete.php?id[]=".$row['extension_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
echo "</td>\n";
echo "</tr>\n";
@ -186,17 +199,22 @@ require_once "resources/paging.php";
unset($sql, $extensions, $row_count);
} //end if results
echo " <tr>\n";
echo " <td colspan='20' class='list_control_icons'>\n";
if (permission_exists('extension_add')) {
if ($_SESSION['limit']['extensions']['numeric'] == '' || ($_SESSION['limit']['extensions']['numeric'] != '' && $total_extensions < $_SESSION['limit']['extensions']['numeric'])) {
echo " <tr>\n";
echo " <td colspan='20' class='list_control_icons'>\n";
echo " <a href='extension_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>\n";
echo " </td>\n";
echo " </tr>\n";
echo "<a href='extension_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
if (permission_exists('extension_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";
@ -204,6 +222,17 @@ require_once "resources/paging.php";
echo "<br><br>\n";
// check or uncheck all checkboxes
if (sizeof($ext_ids) > 0) {
echo "<script>\n";
echo " function check(what) {\n";
foreach ($ext_ids as $ext_id) {
echo "document.getElementById('".$ext_id."').checked = (what == 'all') ? true : false;\n";
}
echo " }\n";
echo "</script>\n";
}
//show the footer
require_once "resources/footer.php";
?>

View File

@ -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() {

View File

@ -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'];

View File

@ -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 "&nbsp;";
}
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'>&nbsp;</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 {

View File

@ -341,7 +341,7 @@ else {
echo "<table class='tr_hover' width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
if (permission_exists('xml_cdr_delete') && $result_count > 0) {
echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' id='chk_all' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
$col_count++;
}
//column headings
@ -473,7 +473,7 @@ else {
echo "<tr ".$tr_link.">\n";
if (permission_exists('xml_cdr_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[".$index."]' id='checkbox_".$row['uuid']."' value='".$row['uuid']."' onclick=\"(this.checked) ? document.getElementById('recording_".$row['uuid']."').value='".base64_encode($recording_file_path)."' : document.getElementById('recording_".$row['uuid']."').value='';\">";
echo " <input type='checkbox' name='id[".$index."]' id='checkbox_".$row['uuid']."' value='".$row['uuid']."' onclick=\"if (this.checked) { document.getElementById('recording_".$row['uuid']."').value='".base64_encode($recording_file_path)."' } else { document.getElementById('recording_".$row['uuid']."').value=''; document.getElementById('chk_all').checked = false; }\">";
echo " <input type='hidden' name='rec[".$index."]' id='recording_".$row['uuid']."'>";
echo " </td>";
$xml_ids[] = 'checkbox_'.$row['uuid'];