diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index 8ed1b8a675..88332f1674 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -89,6 +89,7 @@ //set the variables from the HTTP values $voicemail_id = $_POST["voicemail_id"]; + $voicemail_id_previous = $_POST["voicemail_id_previous"]; $voicemail_password = $_POST["voicemail_password"]; $greeting_id = $_POST["greeting_id"]; $voicemail_options = $_POST["voicemail_options"]; @@ -261,9 +262,21 @@ $p->delete('voicemail_option_add', 'temp'); $p->delete('voicemail_destination_add', 'temp'); - //make sure the voicemail directory exists + //create or rename voicemail directory as needed if (is_numeric($voicemail_id)) { - if (!file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id)) { + // old and new voicemail ids differ, old directory exists and new doesn't, rename directory + if ( + !empty($voicemail_id_previous) && is_numeric($voicemail_id_previous) && $voicemail_id_previous != $voicemail_id && + file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id_previous) && + !file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id) + ) { + rename( + $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id_previous, // previous + $_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id // new + ); + } + // new directory doesn't exist, create + else if (!file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id)) { mkdir($_SESSION['switch']['voicemail']['dir']."/default/".$_SESSION['domain_name']."/".$voicemail_id, 0770); } } @@ -561,6 +574,7 @@ echo "