Recordings - Enable Default/Domain/User setting to control filename prefix and password.

This commit is contained in:
fusionate 2023-02-14 01:27:37 +00:00
parent 0f6ac8920c
commit 854802ea7f
No known key found for this signature in database
5 changed files with 111 additions and 51 deletions

View File

@ -86,7 +86,7 @@
$apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++; $y++;
$apps[$x]['permissions'][$y]['name'] = "recording_pin"; $apps[$x]['permissions'][$y]['name'] = "recording_password";
$apps[$x]['permissions'][$y]['groups'][] = "admin"; $apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin";
@ -123,6 +123,22 @@
$apps[$x]['default_settings'][$y]['default_setting_value'] = "3"; $apps[$x]['default_settings'][$y]['default_setting_value'] = "3";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Seconds of silence to end the recording for the voicemail message."; $apps[$x]['default_settings'][$y]['default_setting_description'] = "Seconds of silence to end the recording for the voicemail message.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "e4b509cc-1622-4867-b8b8-c48585c4d796";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "recordings";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "recording_prefix";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "text";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "recording_";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the prefix text for the recording name and filename (overrides recordings dialplan).";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "f74ab51f-e7c4-423e-b5b6-6f806ecf96b4";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "recordings";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "recording_password";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
$apps[$x]['default_settings'][$y]['default_setting_value'] = generate_password((is_numeric($_SESSION['voicemail']['password_length']['numeric']) ? $_SESSION['voicemail']['password_length']['numeric'] : 8), 1);
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the password required to create a recording (overrides recordings dialplan).";
//schema details //schema details
$y=0; $y=0;

View File

@ -442,25 +442,25 @@ $text['description']['ru-ru'] = "Наберите *732 для создания
$text['description']['sv-se'] = "För att göra en inspelning ring * 732 eller så kan du göra en 16bit 8kHz/16kHz Mono WAV-fil och kopiera den till följande katalog uppdatera sedan sidan för att spela upp den."; $text['description']['sv-se'] = "För att göra en inspelning ring * 732 eller så kan du göra en 16bit 8kHz/16kHz Mono WAV-fil och kopiera den till följande katalog uppdatera sedan sidan för att spela upp den.";
$text['description']['uk-ua'] = "Редагування інформації облікового запису"; $text['description']['uk-ua'] = "Редагування інформації облікового запису";
$text['description-with_pin']['en-us'] = "Dial *732 and enter the password ||PIN_NUMBER||, followed by a number for the recording to create. Or, for best results, upload a 16bit 8khz/16khz mono WAV file."; $text['description-with_password']['en-us'] = "Dial *732 and enter the password ||RECORDING_PASSWORD||, followed by a number for the recording to create. Or, for best results, upload a 16bit 8khz/16khz mono WAV file.";
$text['description-with_pin']['en-gb'] = "Dial *732 and enter the password ||PIN_NUMBER||, followed by a number for the recording to create. Or, for best results, upload a 16bit 8khz/16khz mono WAV file."; $text['description-with_password']['en-gb'] = "Dial *732 and enter the password ||RECORDING_PASSWORD||, followed by a number for the recording to create. Or, for best results, upload a 16bit 8khz/16khz mono WAV file.";
$text['description-with_pin']['ar-eg'] = ""; $text['description-with_password']['ar-eg'] = "";
$text['description-with_pin']['de-at'] = "Wählen Sie *732 um eine Aufnahme direkt vom Telefon zu starten oder laden Sie eine 16bit 8/16kHz mono WAV-Datei hoch."; //copied from de-de $text['description-with_password']['de-at'] = "Wählen Sie *732 um eine Aufnahme direkt vom Telefon zu starten oder laden Sie eine 16bit 8/16kHz mono WAV-Datei hoch."; //copied from de-de
$text['description-with_pin']['de-ch'] = "Wählen Sie *732 um eine Aufnahme direkt vom Telefon zu starten oder laden Sie eine 16bit 8/16kHz mono WAV-Datei hoch."; //copied from de-de $text['description-with_password']['de-ch'] = "Wählen Sie *732 um eine Aufnahme direkt vom Telefon zu starten oder laden Sie eine 16bit 8/16kHz mono WAV-Datei hoch."; //copied from de-de
$text['description-with_pin']['de-de'] = "Wählen Sie *732 um eine Aufnahme direkt vom Telefon zu starten oder laden Sie eine 16bit 8/16kHz mono WAV-Datei hoch."; $text['description-with_password']['de-de'] = "Wählen Sie *732 um eine Aufnahme direkt vom Telefon zu starten oder laden Sie eine 16bit 8/16kHz mono WAV-Datei hoch.";
$text['description-with_pin']['es-cl'] = "Para realizar una grabación marque *732 o puede crear un archivo en formato WAV a 16 bit 8khz/16khz Mono y luego copiarlo en el siguiente directorio y refrezcar la página para reproducirlo."; $text['description-with_password']['es-cl'] = "Para realizar una grabación marque *732 o puede crear un archivo en formato WAV a 16 bit 8khz/16khz Mono y luego copiarlo en el siguiente directorio y refrezcar la página para reproducirlo.";
$text['description-with_pin']['es-mx'] = "Para realizar una grabación marque *732 o puede crear un archivo en formato WAV a 16 bit 8khz/16khz Mono y luego copiarlo en el siguiente directorio y refrezcar la página para reproducirlo."; //copied from es-cl $text['description-with_password']['es-mx'] = "Para realizar una grabación marque *732 o puede crear un archivo en formato WAV a 16 bit 8khz/16khz Mono y luego copiarlo en el siguiente directorio y refrezcar la página para reproducirlo."; //copied from es-cl
$text['description-with_pin']['fr-ca'] = "Pour créer un guide vocal, composer le *732 ou créer un fichier audio WAV 16bit 8khz/16khz Mono et ensuite le copier dans le répertoire qui suit. Rafraîchir ensuite cette page pour le voir apparaitre."; //copied from fr-fr $text['description-with_password']['fr-ca'] = "Pour créer un guide vocal, composer le *732 ou créer un fichier audio WAV 16bit 8khz/16khz Mono et ensuite le copier dans le répertoire qui suit. Rafraîchir ensuite cette page pour le voir apparaitre."; //copied from fr-fr
$text['description-with_pin']['fr-fr'] = "Pour créer un guide vocal, composer le *732 ou créer un fichier audio WAV 16bit 8khz/16khz Mono et ensuite le copier dans le répertoire qui suit. Rafraîchir ensuite cette page pour le voir apparaitre."; $text['description-with_password']['fr-fr'] = "Pour créer un guide vocal, composer le *732 ou créer un fichier audio WAV 16bit 8khz/16khz Mono et ensuite le copier dans le répertoire qui suit. Rafraîchir ensuite cette page pour le voir apparaitre.";
$text['description-with_pin']['he-il'] = "חייג * 732 ליצירת הקלטה, או (לקבלת התוצאות הטובות ביותר) העלה קובץ WAV מונו בגודל 16bit 8khz / 16khz"; $text['description-with_password']['he-il'] = "חייג * 732 ליצירת הקלטה, או (לקבלת התוצאות הטובות ביותר) העלה קובץ WAV מונו בגודל 16bit 8khz / 16khz";
$text['description-with_pin']['it-it'] = "Chiamare *732 per creare una registrazione, o (per un risultato migliore) caricare file WAV a 16bit 8khz/16khz mono."; $text['description-with_password']['it-it'] = "Chiamare *732 per creare una registrazione, o (per un risultato migliore) caricare file WAV a 16bit 8khz/16khz mono.";
$text['description-with_pin']['nl-nl'] = "Kies *732 om een opname te make, of voor betere resultaten, stuur een 16bit 8kHz/16kHz mono WAV bestand. op"; $text['description-with_password']['nl-nl'] = "Kies *732 om een opname te make, of voor betere resultaten, stuur een 16bit 8kHz/16kHz mono WAV bestand. op";
$text['description-with_pin']['pl-pl'] = "Aby stworzyć własne nagranie wybierz *732 z klawiatury telefonu lub stwórz plik audio w formacie WAV o następujących parametrach: 16bit 8khz/16khz Mono, a następnie skopiuj go do odpowiedniego katalogu i odśwież, aby go odsłuchać."; $text['description-with_password']['pl-pl'] = "Aby stworzyć własne nagranie wybierz *732 z klawiatury telefonu lub stwórz plik audio w formacie WAV o następujących parametrach: 16bit 8khz/16khz Mono, a następnie skopiuj go do odpowiedniego katalogu i odśwież, aby go odsłuchać.";
$text['description-with_pin']['pt-br'] = "Editar informações da conta."; $text['description-with_password']['pt-br'] = "Editar informações da conta.";
$text['description-with_pin']['pt-pt'] = "Para fazer uma gravação marque *732 ou crie um ficheiro WAV de 16bit 8khz/16khz e copie-o para a seguinte directoria e actualize a página para o ouvir."; $text['description-with_password']['pt-pt'] = "Para fazer uma gravação marque *732 ou crie um ficheiro WAV de 16bit 8khz/16khz e copie-o para a seguinte directoria e actualize a página para o ouvir.";
$text['description-with_pin']['ro-ro'] = ""; $text['description-with_password']['ro-ro'] = "";
$text['description-with_pin']['ru-ru'] = "Наберите *732 для создания записи, или (для получения наилучших результатов) загрузите 16bit 8khz/16khz mono WAV файл."; $text['description-with_password']['ru-ru'] = "Наберите *732 для создания записи, или (для получения наилучших результатов) загрузите 16bit 8khz/16khz mono WAV файл.";
$text['description-with_pin']['sv-se'] = "För att göra en inspelning ring * 732 eller så kan du göra en 16bit 8kHz/16kHz Mono WAV-fil och kopiera den till följande katalog uppdatera sedan sidan för att spela upp den."; $text['description-with_password']['sv-se'] = "För att göra en inspelning ring * 732 eller så kan du göra en 16bit 8kHz/16kHz Mono WAV-fil och kopiera den till följande katalog uppdatera sedan sidan för att spela upp den.";
$text['description-with_pin']['uk-ua'] = "Редагування інформації облікового запису"; $text['description-with_password']['uk-ua'] = "Редагування інформації облікового запису";
?> ?>

View File

@ -335,28 +335,33 @@
$recordings = $database->select($sql, $parameters, 'all'); $recordings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters); unset($sql, $parameters);
//get current recordings pin number //get current recordings password
if (permission_exists('recording_pin')) { if (permission_exists('recording_password')) {
$sql = " if (is_numeric($_SESSION['recordings']['recording_password']['numeric'])) {
select $recording_password = $_SESSION['recordings']['recording_password']['numeric'];
split_part(dd.dialplan_detail_data,'=',2) }
from else {
v_dialplans as d, $sql = "
v_dialplan_details as dd select
where split_part(dd.dialplan_detail_data,'=',2)
d.dialplan_uuid = dd.dialplan_uuid and from
d.domain_uuid = :domain_uuid and v_dialplans as d,
d.app_uuid = '430737df-5385-42d1-b933-22600d3fb79e' and v_dialplan_details as dd
d.dialplan_name = 'recordings' and where
d.dialplan_enabled = 'true' and d.dialplan_uuid = dd.dialplan_uuid and
dd.dialplan_detail_tag = 'action' and d.domain_uuid = :domain_uuid and
dd.dialplan_detail_type = 'set' and d.app_uuid = '430737df-5385-42d1-b933-22600d3fb79e' and
dd.dialplan_detail_data like 'pin_number=%' and d.dialplan_name = 'recordings' and
dd.dialplan_detail_enabled = 'true' "; d.dialplan_enabled = 'true' and
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; dd.dialplan_detail_tag = 'action' and
$database = new database; dd.dialplan_detail_type = 'set' and
$pin_number = $database->select($sql, $parameters, 'column'); dd.dialplan_detail_data like 'pin_number=%' and
unset($sql, $parameters); dd.dialplan_detail_enabled = 'true' ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$recording_password = $database->select($sql, $parameters, 'column');
unset($sql, $parameters);
}
} }
//create token //create token
@ -422,8 +427,8 @@
echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]); echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
} }
if (permission_exists('recording_pin') && is_numeric($pin_number)) { if (permission_exists('recording_password') && is_numeric($recording_password)) {
echo str_replace('||PIN_NUMBER||', "<nobr style='font-weight: 600;'>".$pin_number."</nobr>", $text['description-with_pin']."\n"); echo str_replace('||RECORDING_PASSWORD||', "<nobr style='font-weight: 600;'>".$recording_password."</nobr>", $text['description-with_password']."\n");
} }
else { else {
echo $text['description']."\n"; echo $text['description']."\n";

View File

@ -39,6 +39,7 @@
--add functions --add functions
require "resources.functions.mkdir"; require "resources.functions.mkdir";
require "resources.functions.explode"; require "resources.functions.explode";
local cache = require "resources.functions.cache"
--setup the database connection --setup the database connection
local Database = require "resources.functions.database"; local Database = require "resources.functions.database";
@ -53,22 +54,29 @@
--get the domain_uuid --get the domain_uuid
if (session:ready()) then if (session:ready()) then
domain_uuid = session:getVariable("domain_uuid"); domain_uuid = session:getVariable("domain_uuid");
user_uuid = session:getVariable("user_uuid");
end end
--initialize the recordings --initialize the recordings
api = freeswitch.API(); api = freeswitch.API();
--clear cached prefix and password, refreshed from database settings
if cache.support() then
cache.del("setting::recordings.recording_prefix.text")
cache.del("setting::recordings.recording_password.numeric")
end
--load lazy settings library --load lazy settings library
local Settings = require "resources.functions.lazy_settings"; local Settings = require "resources.functions.lazy_settings";
--get the recordings settings --get the recordings settings
local settings = Settings.new(db, domain_name, domain_uuid); local settings = Settings.new(db, domain_name, domain_uuid, user_uuid);
--set the storage type and path --set the storage type and path
storage_type = settings:get('recordings', 'storage_type', 'text') or ''; storage_type = settings:get('recordings', 'storage_type', 'text') or '';
storage_path = settings:get('recordings', 'storage_path', 'text') or ''; storage_path = settings:get('recordings', 'storage_path', 'text') or '';
if (storage_path ~= '') then if (storage_path ~= '') then
storage_path = storage_path:gsub("${domain_name}", session:getVariable("domain_name")); storage_path = storage_path:gsub("${domain_name}", session:getVariable("domain_name"));
storage_path = storage_path:gsub("${domain_uuid}", domain_uuid); storage_path = storage_path:gsub("${domain_uuid}", domain_uuid);
end end
@ -98,7 +106,7 @@
if (not default_dialect) then default_dialect = 'us'; end if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end if (not default_voice) then default_voice = 'callie'; end
recording_id = session:getVariable("recording_id"); recording_id = session:getVariable("recording_id");
recording_prefix = session:getVariable("recording_prefix"); recording_prefix = settings:get('recordings', 'recording_prefix', 'text') or session:getVariable("recording_prefix");
recording_name = session:getVariable("recording_name"); recording_name = session:getVariable("recording_name");
record_ext = session:getVariable("record_ext"); record_ext = session:getVariable("record_ext");
domain_name = session:getVariable("domain_name"); domain_name = session:getVariable("domain_name");
@ -294,7 +302,7 @@ if (session:ready()) then
session:answer(); session:answer();
--get the dialplan variables and set them as local variables --get the dialplan variables and set them as local variables
pin_number = session:getVariable("pin_number"); pin_number = settings:get('recordings', 'recording_password', 'numeric') or session:getVariable("pin_number");
sounds_dir = session:getVariable("sounds_dir"); sounds_dir = session:getVariable("sounds_dir");
domain_name = session:getVariable("domain_name"); domain_name = session:getVariable("domain_name");
domain_uuid = session:getVariable("domain_uuid"); domain_uuid = session:getVariable("domain_uuid");

View File

@ -49,12 +49,13 @@ local function append_setting(array, category, subcategory, name, value)
end end
end end
function Settings.new(db, domain_name, domain_uuid) function Settings.new(db, domain_name, domain_uuid, user_uuid)
local self = setmetatable({}, Settings) local self = setmetatable({}, Settings)
self._array = {} self._array = {}
self._db = db self._db = db
self._domain_name = domain_name self._domain_name = domain_name
self._domain_uuid = domain_uuid self._domain_uuid = domain_uuid
self._user_uuid = user_uuid
self._use_cache = not cache.settings self._use_cache = not cache.settings
return self return self
@ -93,6 +94,7 @@ function Settings:get(category, subcategory, name)
end end
function Settings:_load(category, subcategory, name) function Settings:_load(category, subcategory, name)
local user_uuid = self._user_uuid
local domain_uuid = self._domain_uuid local domain_uuid = self._domain_uuid
local db = self._db local db = self._db
if type(self._db) == 'string' then if type(self._db) == 'string' then
@ -101,8 +103,37 @@ function Settings:_load(category, subcategory, name)
local found = false local found = false
--get the user settings
if user_uuid then
local sql = "SELECT user_setting_uuid,user_setting_category,user_setting_subcategory,user_setting_name,user_setting_value "
sql = sql .. "FROM v_user_settings ";
sql = sql .. "WHERE user_uuid = :user_uuid ";
sql = sql .. "AND user_setting_enabled = 'true' ";
sql = sql .. "AND user_setting_category = :category ";
sql = sql .. "AND user_setting_subcategory = :subcategory ";
sql = sql .. "AND user_setting_name = :name ";
sql = sql .. "AND user_setting_value is not null ";
sql = sql .. "ORDER BY user_setting_category, user_setting_subcategory ASC ";
local params = {
user_uuid = user_uuid,
category = category,
subcategory = subcategory,
name = name,
};
db:query(sql, params, function(row)
found = true;
self:set(
row.user_setting_category,
row.user_setting_subcategory,
row.user_setting_name,
row.user_setting_value
)
end)
end
--get the domain settings --get the domain settings
if domain_uuid then if not found and domain_uuid then
local sql = "SELECT domain_setting_uuid,domain_setting_category,domain_setting_subcategory,domain_setting_name,domain_setting_value " local sql = "SELECT domain_setting_uuid,domain_setting_category,domain_setting_subcategory,domain_setting_name,domain_setting_value "
sql = sql .. "FROM v_domain_settings "; sql = sql .. "FROM v_domain_settings ";
sql = sql .. "WHERE domain_uuid = :domain_uuid "; sql = sql .. "WHERE domain_uuid = :domain_uuid ";