diff --git a/app/extensions/extension_delete.php b/app/extensions/extension_delete.php index 70fa4f3a78..17421f383e 100644 --- a/app/extensions/extension_delete.php +++ b/app/extensions/extension_delete.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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; diff --git a/app/extensions/extensions.php b/app/extensions/extensions.php index 17f79ca5d7..bb036da90d 100644 --- a/app/extensions/extensions.php +++ b/app/extensions/extensions.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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 "
\n"; echo "\n"; echo "\n"; + if (permission_exists('extension_delete') && $num_rows > 0) { + echo ""; + } 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 "\n"; echo "\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 "\n"; + if (permission_exists('extension_delete')) { + echo " "; + $ext_ids[] = 'checkbox_'.$row['extension_uuid']; + } echo " \n"; echo "\n"; @@ -186,17 +199,22 @@ require_once "resources/paging.php"; unset($sql, $extensions, $row_count); } //end if results + echo " \n"; + echo " \n"; - echo " \n"; - echo " \n"; + echo "".$v_link_label_add.""; } } + if (permission_exists('extension_delete') && $num_rows > 0) { + echo "".$v_link_label_delete.""; + } + echo " \n"; + echo " \n"; + echo "
\n"; if (permission_exists('extension_add')) { if ($_SESSION['limit']['extensions']['numeric'] == '' || ($_SESSION['limit']['extensions']['numeric'] != '' && $total_extensions < $_SESSION['limit']['extensions']['numeric'])) { - echo " ".$v_link_label_add."\n"; + echo "".$v_link_label_add.""; } } + if (permission_exists('extension_delete') && $num_rows > 0) { + echo "".$v_link_label_delete.""; + } echo "
"; if (permission_exists('extension_edit')) { echo "".$row['extension'].""; @@ -177,7 +190,7 @@ require_once "resources/paging.php"; echo "$v_link_label_edit"; } if (permission_exists('extension_delete')) { - echo "$v_link_label_delete"; + echo "$v_link_label_delete"; } echo "
\n"; if (permission_exists('extension_add')) { if ($_SESSION['limit']['extensions']['numeric'] == '' || ($_SESSION['limit']['extensions']['numeric'] != '' && $total_extensions < $_SESSION['limit']['extensions']['numeric'])) { - echo "
\n"; - echo " ".$v_link_label_add."\n"; - echo "
"; + echo "
"; if (strlen($paging_controls) > 0) { echo "
".$paging_controls."
\n"; @@ -204,6 +222,17 @@ require_once "resources/paging.php"; echo "

\n"; + // check or uncheck all checkboxes + if (sizeof($ext_ids) > 0) { + echo "\n"; + } + //show the footer require_once "resources/footer.php"; ?> \ No newline at end of file diff --git a/app/voicemails/resources/classes/voicemail.php b/app/voicemails/resources/classes/voicemail.php index f16d187b1c..cd1cf99388 100644 --- a/app/voicemails/resources/classes/voicemail.php +++ b/app/voicemails/resources/classes/voicemail.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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() { diff --git a/app/voicemails/voicemail_delete.php b/app/voicemails/voicemail_delete.php index 96d0e61857..e6b61e2934 100644 --- a/app/voicemails/voicemail_delete.php +++ b/app/voicemails/voicemail_delete.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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']; diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index be0343e997..12c7126c3b 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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 "
\n"; echo "\n"; echo "\n"; + if (permission_exists('voicemail_delete') && $num_rows > 0) { + echo ""; + } 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 "\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 "\n"; echo "\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 "\n"; + if (permission_exists('voicemail_delete')) { + echo " "; + $vm_ids[] = 'checkbox_'.$row['voicemail_uuid']; + } echo " \n"; } @@ -204,22 +212,33 @@ else { unset($sql, $voicemails, $row_count); echo "\n"; - echo "\n"; + if (permission_exists('voicemail_delete') && $num_rows > 0) { + echo "".$v_link_label_delete.""; + } + echo " \n"; echo "\n"; echo "
".$text['label-tools'].""; - if (permission_exists('voicemail_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } + echo ""; + if (permission_exists('voicemail_add') || permission_exists('voicemail_edit')) { + echo "".$v_link_label_add.""; + } + if (permission_exists('voicemail_delete') && $num_rows > 0) { + echo "".$v_link_label_delete.""; } echo "
"; if (permission_exists('voicemail_edit')) { echo "".$row['voicemail_id'].""; @@ -191,10 +199,10 @@ else { if (permission_exists('voicemail_edit') || permission_exists('voicemail_delete')) { echo " "; if (permission_exists('voicemail_edit')) { - echo "$v_link_label_edit"; + echo "".$v_link_label_edit.""; } if (permission_exists('voicemail_delete')) { - echo "$v_link_label_delete"; + echo "".$v_link_label_delete.""; } echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; + echo " \n"; if (permission_exists('voicemail_add')) { - echo "$v_link_label_add"; + echo "".$v_link_label_add.""; } - echo "
\n"; - echo "
"; + echo "
"; + + if (strlen($paging_controls) > 0) { + echo "
".$paging_controls."
\n"; + } + + // check or uncheck all checkboxes + if (sizeof($vm_ids) > 0) { + echo "\n"; + } } else { diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php index 536a181880..05b7b6b675 100644 --- a/app/xml_cdr/xml_cdr.php +++ b/app/xml_cdr/xml_cdr.php @@ -341,7 +341,7 @@ else { echo "\n"; echo "\n"; if (permission_exists('xml_cdr_delete') && $result_count > 0) { - echo ""; + echo ""; $col_count++; } //column headings @@ -473,7 +473,7 @@ else { echo "\n"; if (permission_exists('xml_cdr_delete')) { echo " "; $xml_ids[] = 'checkbox_'.$row['uuid'];