Update voicemail.php
Use is_array with foreach in the voicemail php class.
This commit is contained in:
parent
8750f50c19
commit
7e02426a80
|
|
@ -67,7 +67,7 @@
|
||||||
else {
|
else {
|
||||||
//ensure that the requested voicemail box is assigned to this user
|
//ensure that the requested voicemail box is assigned to this user
|
||||||
$found = false;
|
$found = false;
|
||||||
foreach($voicemail_uuids as $row) {
|
if (is_array($voicemail_uuids)) foreach($voicemail_uuids as $row) {
|
||||||
if ($voicemail_uuid == $row['voicemail_uuid']) {
|
if ($voicemail_uuid == $row['voicemail_uuid']) {
|
||||||
$sql .= "and voicemail_uuid = '".$row['voicemail_uuid']."' ";
|
$sql .= "and voicemail_uuid = '".$row['voicemail_uuid']."' ";
|
||||||
$found = true;
|
$found = true;
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
if (count($voicemail_ids) > 0) {
|
if (count($voicemail_ids) > 0) {
|
||||||
//show only the assigned voicemail ids
|
//show only the assigned voicemail ids
|
||||||
$sql .= "and (";
|
$sql .= "and (";
|
||||||
foreach($voicemail_ids as $row) {
|
if (is_array($voicemail_ids)) foreach($voicemail_ids as $row) {
|
||||||
if ($x == 0) {
|
if ($x == 0) {
|
||||||
$sql .= "voicemail_id = '".$row['voicemail_id']."' ";
|
$sql .= "voicemail_id = '".$row['voicemail_id']."' ";
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
$voicemails = $this->voicemails();
|
$voicemails = $this->voicemails();
|
||||||
|
|
||||||
//add the voicemail messages to the array
|
//add the voicemail messages to the array
|
||||||
foreach ($voicemails as &$row) {
|
if (is_array($voicemails)) foreach ($voicemails as &$row) {
|
||||||
//get the voicemail messages
|
//get the voicemail messages
|
||||||
$this->voicemail_uuid = $row['voicemail_uuid'];
|
$this->voicemail_uuid = $row['voicemail_uuid'];
|
||||||
$this->voicemail_id = $row['voicemail_id'];
|
$this->voicemail_id = $row['voicemail_id'];
|
||||||
|
|
@ -134,7 +134,7 @@
|
||||||
if (is_array($this->voicemail_id)) {
|
if (is_array($this->voicemail_id)) {
|
||||||
$sql .= "and (";
|
$sql .= "and (";
|
||||||
$x = 0;
|
$x = 0;
|
||||||
foreach($this->voicemail_id as $row) {
|
if (is_array($this->voicemail_id)) foreach($this->voicemail_id as $row) {
|
||||||
if ($x > 0) {
|
if ($x > 0) {
|
||||||
$sql .= "or ";
|
$sql .= "or ";
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +159,7 @@
|
||||||
$result_count = count($result);
|
$result_count = count($result);
|
||||||
unset ($prep_statement, $sql);
|
unset ($prep_statement, $sql);
|
||||||
if ($result_count > 0) {
|
if ($result_count > 0) {
|
||||||
foreach($result as &$row) {
|
if (is_array($result)) foreach($result as &$row) {
|
||||||
//set the greeting directory
|
//set the greeting directory
|
||||||
$path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id'];
|
$path = $_SESSION['switch']['voicemail']['dir'].'/default/'.$_SESSION['domain_name'].'/'.$row['voicemail_id'];
|
||||||
if (file_exists($path.'/msg_'.$row['voicemail_message_uuid'].'.wav')) {
|
if (file_exists($path.'/msg_'.$row['voicemail_message_uuid'].'.wav')) {
|
||||||
|
|
@ -192,7 +192,7 @@
|
||||||
|
|
||||||
//delete voicemail recordings folder (includes greetings)
|
//delete voicemail recordings folder (includes greetings)
|
||||||
$file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
|
$file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
|
||||||
foreach (glob($file_path."/*.*") as $file_name) {
|
if (isset(glob($file_path."/*.*"))) foreach (glob($file_path."/*.*") as $file_name) {
|
||||||
unlink($file_name);
|
unlink($file_name);
|
||||||
}
|
}
|
||||||
@rmdir($file_path);
|
@rmdir($file_path);
|
||||||
|
|
@ -266,7 +266,7 @@
|
||||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||||
foreach ($result as &$row) {
|
if (is_array($result)) foreach ($result as &$row) {
|
||||||
$this->voicemail_id = $row["voicemail_id"];
|
$this->voicemail_id = $row["voicemail_id"];
|
||||||
}
|
}
|
||||||
unset ($prep_statement);
|
unset ($prep_statement);
|
||||||
|
|
@ -275,13 +275,17 @@
|
||||||
//delete the recording
|
//delete the recording
|
||||||
$file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
|
$file_path = $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$this->voicemail_id;
|
||||||
if ($this->voicemail_message_uuid != '') {
|
if ($this->voicemail_message_uuid != '') {
|
||||||
foreach (
|
if (is_array(glob($file_path."/msg_".$this->voicemail_message_uuid.".*"))) {
|
||||||
glob($file_path."/msg_".$this->voicemail_message_uuid.".*") as $file_name) { unlink($file_name);
|
foreach (glob($file_path."/msg_".$this->voicemail_message_uuid.".*") as $file_name) {
|
||||||
|
unlink($file_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (
|
if (is_array(glob($file_path."/msg_*.*"))) {
|
||||||
glob($file_path."/msg_*.*") as $file_name) { unlink($file_name); //remove all recordings
|
foreach (glob($file_path."/msg_*.*") as $file_name) {
|
||||||
|
unlink($file_name); //remove all recordings
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,7 +313,7 @@
|
||||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||||
foreach ($result as &$row) {
|
if (is_array($result)) foreach ($result as &$row) {
|
||||||
$this->voicemail_id = $row["voicemail_id"];
|
$this->voicemail_id = $row["voicemail_id"];
|
||||||
}
|
}
|
||||||
unset ($prep_statement);
|
unset ($prep_statement);
|
||||||
|
|
@ -382,7 +386,7 @@
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
foreach($result as &$row) {
|
if (is_array($result)) foreach($result as &$row) {
|
||||||
if ($row['message_base64'] != '') {
|
if ($row['message_base64'] != '') {
|
||||||
$message_decoded = base64_decode($row['message_base64']);
|
$message_decoded = base64_decode($row['message_base64']);
|
||||||
file_put_contents($path.'/msg_'.$this->voicemail_message_uuid.'.ext', $message_decoded);
|
file_put_contents($path.'/msg_'.$this->voicemail_message_uuid.'.ext', $message_decoded);
|
||||||
|
|
@ -488,4 +492,4 @@ foreach ($_SESSION['user']['extension'] as $value) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue