From 349185b8a72ce41a22777e0e5c5f9bad1e98c7f3 Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Fri, 20 Mar 2015 01:09:18 +0000 Subject: [PATCH] Voicemail: Added default settings to control default Voicemail File and Keep Local settings when creating new extensions and/or Voicemail boxes. --- app/extensions/extension_edit.php | 106 ++++++------------ app/voicemails/app_defaults.php | 42 +++++++ app/voicemails/voicemail_edit.php | 20 ++-- core/default_settings/app_languages.php | 19 +++- .../default_settings/default_setting_edit.php | 13 +++ 5 files changed, 115 insertions(+), 85 deletions(-) diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index fe69e1809c..77dbb4b888 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -707,7 +707,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $extension_uuid = check_str($_GET["id"]); $sql = "select * from v_extensions "; - $sql .= "where extension_uuid = '$extension_uuid' "; + $sql .= "where extension_uuid = '".$extension_uuid."' "; $sql .= "and domain_uuid = '".$domain_uuid."' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); @@ -746,41 +746,42 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $description = $row["description"]; } unset ($prep_statement); - } -//get the voicemail data - if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) { - //get the voicemails - $sql = "select * from v_voicemails "; - $sql .= "where domain_uuid = '".$domain_uuid."' "; - if (is_numeric($extension)) { - $sql .= "and voicemail_id = '$extension' "; - } - else { - $sql .= "and voicemail_id = '$number_alias' "; - } - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $voicemail_password = $row["voicemail_password"]; - //$greeting_id = $row["greeting_id"]; - $voicemail_mail_to = $row["voicemail_mail_to"]; + //get the voicemail data + if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/voicemails')) { + //get the voicemails + $sql = "select * from v_voicemails "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and voicemail_id = '".((is_numeric($extension)) ? $extension : $number_alias)."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $voicemail_password = $row["voicemail_password"]; + $voicemail_mail_to = $row["voicemail_mail_to"]; + $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); + $voicemail_file = $row["voicemail_file"]; + $voicemail_local_after_email = $row["voicemail_local_after_email"]; + $voicemail_enabled = $row["voicemail_enabled"]; + } + unset ($prep_statement); + //clean the variables + $voicemail_password = str_replace("#", "", $voicemail_password); $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); - $voicemail_file = $row["voicemail_file"]; - $voicemail_local_after_email = $row["voicemail_local_after_email"]; - $voicemail_enabled = $row["voicemail_enabled"]; - } - unset ($prep_statement); - //clean the variables - $voicemail_password = str_replace("#", "", $voicemail_password); - $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); + } + + } + else { + $voicemail_file = $_SESSION['voicemail']['voicemail_file']['text']; + $voicemail_local_after_email = $_SESSION['voicemail']['keep_local']['boolean']; } //set the defaults if (strlen($limit_max) == 0) { $limit_max = '5'; } if (strlen($call_timeout) == 0) { $call_timeout = '30'; } + + //begin the page content require_once "resources/header.php"; if ($action == "update") { @@ -1301,36 +1302,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " "; echo " \n"; echo " \n"; @@ -1487,7 +1461,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; @@ -1502,18 +1476,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_local_after_email']."\n"; diff --git a/app/voicemails/app_defaults.php b/app/voicemails/app_defaults.php index f5f230308e..d81acb5140 100644 --- a/app/voicemails/app_defaults.php +++ b/app/voicemails/app_defaults.php @@ -32,6 +32,48 @@ if ($domains_processed == 1) { $db->exec(check_sql($sql)); unset($sql); + //define array of settings + $x = 0; + $array[$x]['default_setting_category'] = 'voicemail'; + $array[$x]['default_setting_subcategory'] = 'voicemail_file'; + $array[$x]['default_setting_name'] = 'text'; + $array[$x]['default_setting_value'] = 'attach'; + $array[$x]['default_setting_enabled'] = 'true'; + $array[$x]['default_setting_description'] = 'Define whether to attach voicemail files to email notifications, or only include a link.'; + $x++; + $array[$x]['default_setting_category'] = 'voicemail'; + $array[$x]['default_setting_subcategory'] = 'keep_local'; + $array[$x]['default_setting_name'] = 'boolean'; + $array[$x]['default_setting_value'] = 'true'; + $array[$x]['default_setting_enabled'] = 'true'; + $array[$x]['default_setting_description'] = 'Define whether to keep voicemail files on the local system after sending attached via email.'; + $x++; + + //iterate and add each, if necessary + foreach ($array as $index => $default_settings) { + + //add the default setting + $sql = "select count(*) as num_rows from v_default_settings "; + $sql .= "where default_setting_category = '".$default_settings['default_setting_category']."' "; + $sql .= "and default_setting_subcategory = '".$default_settings['default_setting_subcategory']."' "; + $sql .= "and default_setting_name = '".$default_settings['default_setting_name']."' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + unset($prep_statement); + if ($row['num_rows'] == 0) { + $orm = new orm; + $orm->name('default_settings'); + $orm->save($array[$index]); + $message = $orm->message; + //print_r($message); + } + unset($row); + } + + } + } ?> \ No newline at end of file diff --git a/app/voicemails/voicemail_edit.php b/app/voicemails/voicemail_edit.php index 997f9b3300..24b4626ec4 100644 --- a/app/voicemails/voicemail_edit.php +++ b/app/voicemails/voicemail_edit.php @@ -271,6 +271,10 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } unset ($prep_statement); } + else { + $voicemail_file = $_SESSION['voicemail']['voicemail_file']['text']; + $voicemail_local_after_email = $_SESSION['voicemail']['keep_local']['boolean']; + } //remove the spaces $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); @@ -449,7 +453,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; @@ -464,18 +468,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_local_after_email']."\n"; diff --git a/core/default_settings/app_languages.php b/core/default_settings/app_languages.php index 0e54e645d6..c82b2c03a6 100644 --- a/core/default_settings/app_languages.php +++ b/core/default_settings/app_languages.php @@ -238,4 +238,21 @@ $text['message-required']['pt-pt'] = "Por favor indique: "; $text['message-required']['fr-fr'] = "Merci d'indiquer: "; -?> +//------ app specific ------ + + $text['option-voicemail_file_attach']['en-us'] = "Audio File Attachment"; + $text['option-voicemail_file_attach']['es-cl'] = "Archivo Adjunto Audio"; + $text['option-voicemail_file_attach']['pt-pt'] = "Anexo de arquivo de áudio"; + $text['option-voicemail_file_attach']['fr-fr'] = "Audio File Attachment"; + + $text['option-voicemail_file_link']['en-us'] = "Download Link (No Login Required)"; + $text['option-voicemail_file_link']['es-cl'] = "Enlace de descarga (No se requiere conexión)"; + $text['option-voicemail_file_link']['pt-pt'] = "Link para download (Não é necessário login)"; + $text['option-voicemail_file_link']['fr-fr'] = "Lien de téléchargement (Connexion non requise)"; + + $text['option-voicemail_file_listen']['en-us'] = "Listen Link (Login Required)"; + $text['option-voicemail_file_listen']['es-cl'] = "Escuchar Link (Se requiere entrar)"; + $text['option-voicemail_file_listen']['pt-pt'] = "Ouça Link (login requerido)"; + $text['option-voicemail_file_listen']['fr-fr'] = "Écouter Link (Connexion requise)"; + +?> \ No newline at end of file diff --git a/core/default_settings/default_setting_edit.php b/core/default_settings/default_setting_edit.php index 8c67168eb0..5ad378321a 100644 --- a/core/default_settings/default_setting_edit.php +++ b/core/default_settings/default_setting_edit.php @@ -460,6 +460,19 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " \n"; echo " \n"; } + elseif ($category == "voicemail" && $subcategory == "voicemail_file" && $name == "text" ) { + echo " \n"; + } + elseif ($category == "voicemail" && $subcategory == "keep_local" && $name == "boolean" ) { + echo " \n"; + } elseif (is_json($default_setting_value)) { echo " \n"; }