From fedd5ba9fc4e8a76b2b4e4226b0febde810810ee Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 30 Nov 2015 10:22:55 +0300 Subject: [PATCH 01/14] Add. Text class to manage translate texts. --- .../scripts/app/voicemail/app_languages.lua | 3 +- .../resources/functions/send_email.lua | 13 ++-- .../scripts/resources/functions/text.lua | 71 +++++++++++++++++++ 3 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 resources/install/scripts/resources/functions/text.lua diff --git a/resources/install/scripts/app/voicemail/app_languages.lua b/resources/install/scripts/app/voicemail/app_languages.lua index 0c2daed73b..57dc356a16 100644 --- a/resources/install/scripts/app/voicemail/app_languages.lua +++ b/resources/install/scripts/app/voicemail/app_languages.lua @@ -1,4 +1,4 @@ -text = {}; +text = text or {}; text['label-download'] = {}; text['label-download']['en-us'] = "Download"; @@ -24,3 +24,4 @@ text['label-attached']['fr-fr'] = "Attaché"; text['label-attached']['de-de'] = "im Anhang"; text['label-attached']['de-at'] = "im Anhang"; +return text \ No newline at end of file diff --git a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua index 0cb437c19e..0480f8c9dd 100644 --- a/resources/install/scripts/app/voicemail/resources/functions/send_email.lua +++ b/resources/install/scripts/app/voicemail/resources/functions/send_email.lua @@ -25,10 +25,6 @@ local send_mail = require 'resources.functions.send_mail' - local function T(str) - return text[str][default_language..'-'..default_dialect] or text[str]['en-us'] - end - --define a function to send email function send_email(id, uuid) --get voicemail message details @@ -58,7 +54,8 @@ --require the email address to send the email if (string.len(voicemail_mail_to) > 2) then --include languages file - require "app.voicemail.app_languages"; + local Text = require "resources.functions.text" + local text = Text.new("app.voicemail.app_languages") --get voicemail message details sql = [[SELECT * FROM v_voicemail_messages @@ -142,11 +139,11 @@ body = body:gsub("${sip_to_user}", id); body = body:gsub("${dialed_user}", id); if (voicemail_file == "attach") then - body = body:gsub("${message}", T'label-attached'); + body = body:gsub("${message}", text['label-attached']); elseif (voicemail_file == "link") then - body = body:gsub("${message}", ""..T'label-download'..""); + body = body:gsub("${message}", ""..text['label-download']..""); else - body = body:gsub("${message}", ""..T'label-listen'..""); + body = body:gsub("${message}", ""..text['label-listen']..""); end body = body:gsub(" ", " "); body = body:gsub("%s+", ""); diff --git a/resources/install/scripts/resources/functions/text.lua b/resources/install/scripts/resources/functions/text.lua new file mode 100644 index 0000000000..11bf0933a2 --- /dev/null +++ b/resources/install/scripts/resources/functions/text.lua @@ -0,0 +1,71 @@ +--- +-- @tparam table dict Dictionary +-- @tparam[opt='en'] string language default language +-- @tparam[opt='us'] string dialect default language +-- @return[1] nil if key is unknown +-- @return[2] empty string if language/dialect unknown or there no appropriate value for default language/dialect +-- @return[3] translated value accordint dictionary/language/dialect +-- +-- @usage +-- local dict = { +-- ['label-text'] = { +-- ['en-us'] = 'text'; +-- ['ru-ru'] = 'текст'; +-- } +-- } +-- local text = Text.new(dict) +-- -- use global `default_language` and `default_dialect` to resolve language +-- var = text['label-attached'] +-- -- use prefix form +-- var = text'label-attached' +-- -- Implicit specify language +-- var = text('label-attached', 'ru', 'ru') +-- -- set global variables(you can set them even after ctor call) +-- default_language, default_dialect = 'ru', 'ru' +-- var = text['label-attached'] +local function make_text(dict, language, dialect) + if not (language and dialect) then + language, dialect = 'en', 'us' + end + + if type(dict) == 'string' then + dict = require(dict) + end + + local default = (language .. '-' .. dialect):lower() + + local function index(_, k) + local t = dict[k] + if not t then return end + + local lang + if default_language and default_dialect then + lang = (default_language .. '-' .. default_dialect):lower() + end + if not lang then lang = default end + return t[lang] or t[default] or '' + end + + local function call(self, k, language, dialect) + if language and dialect then + local t = dict[k] + if not t then return end + local lang = (language .. '-' .. dialect):lower() + local v = t[lang] + if v then return v end + end + return self[k] + end + + return setmetatable({},{ + __newindex = function() + error('Can not add field to proxy') + end; + __index = index; + __call = call; + }) +end + +return { + new = make_text; +} \ No newline at end of file From 5339e39db839c496f425d14d2233f7d3da969336 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 30 Nov 2015 11:57:09 +0300 Subject: [PATCH 02/14] Add. Send reply message after fax task done. --- app/fax/app_config.php | 4 ++ app/fax/fax_send.php | 13 +++--- .../app/fax/resources/scripts/queue/retry.lua | 45 ++++++++++++++----- .../app/fax/resources/scripts/queue/tasks.lua | 1 + secure/fax_to_email.php | 13 +++--- 5 files changed, 53 insertions(+), 23 deletions(-) diff --git a/app/fax/app_config.php b/app/fax/app_config.php index fe63326d1d..83fe88019d 100644 --- a/app/fax/app_config.php +++ b/app/fax/app_config.php @@ -554,6 +554,10 @@ $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; $z++; + $apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_reply_address'; + $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; + $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; + $z++; $apps[$x]['db'][$y]['fields'][$z]['name'] = 'task_interrupted'; $apps[$x]['db'][$y]['fields'][$z]['type'] = 'text'; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ''; diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index 362dbaf46c..b5491287a0 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -131,7 +131,7 @@ if(!function_exists('gs_cmd')) { } if(!function_exists('fax_enqueue')) { - function fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string){ + function fax_enqueue($fax_uuid, $fax_file, $wav_file, $reply_address, $fax_uri, $fax_dtmf, $dial_string){ global $db, $db_type; $fax_task_uuid = uuid(); @@ -151,12 +151,12 @@ INSERT INTO v_fax_tasks( fax_task_uuid, fax_uuid, task_next_time, task_lock_time, task_fax_file, task_wav_file, task_uri, task_dial_string, task_dtmf, task_interrupted, task_status, task_no_answer_counter, task_no_answer_retry_counter, task_retry_counter, - task_description) + task_reply_address, task_description) VALUES (?, ?, $date_utc_now_sql, NULL, ?, ?, ?, ?, ?, 'false', 0, 0, 0, 0, - ?); + ?, ?); HERE; $stmt = $db->prepare($sql); $i = 0; @@ -167,6 +167,7 @@ HERE; $stmt->bindValue(++$i, $fax_uri); $stmt->bindValue(++$i, $dial_string); $stmt->bindValue(++$i, $fax_dtmf); + $stmt->bindValue(++$i, $reply_address); $stmt->bindValue(++$i, $description); if ($stmt->execute()) { $response = 'Enqueued'; @@ -694,8 +695,6 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ $common_dial_string .= "sip_h_X-accountcode='" . $fax_accountcode . "',"; $common_dial_string .= "domain_uuid=" . $_SESSION["domain_uuid"] . ","; $common_dial_string .= "domain_name=" . $_SESSION["domain_name"] . ","; - $common_dial_string .= "mailto_address='" . $mailto_address . "',"; - $common_dial_string .= "mailfrom_address='" . $mailfrom_address . "',"; $common_dial_string .= "origination_caller_id_name='" . $fax_caller_id_name . "',"; $common_dial_string .= "origination_caller_id_number='" . $fax_caller_id_number . "',"; $common_dial_string .= "fax_ident='" . $fax_caller_id_number . "',"; @@ -722,6 +721,8 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ if ($fax_send_mode != 'queue') { $dial_string .= $t38; + $dial_string .= "mailto_address='" . $mailto_address . "',"; + $dial_string .= "mailfrom_address='" . $mailfrom_address . "',"; $dial_string .= "fax_uri=" . $fax_uri . ","; $dial_string .= "fax_retry_attempts=1" . ","; $dial_string .= "fax_retry_limit=20" . ","; @@ -744,7 +745,7 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ } else{ // enqueue $wav_file = ''; //! @todo add custom message - $response = fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string); + $response = fax_enqueue($fax_uuid, $fax_file, $wav_file, $mailto_address, $fax_uri, $fax_dtmf, $dial_string); } } diff --git a/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua index feb8f6ef4f..32ef3fac07 100644 --- a/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua +++ b/resources/install/scripts/app/fax/resources/scripts/queue/retry.lua @@ -4,10 +4,11 @@ require "resources.functions.split"; require "resources.functions.count"; - local log = require "resources.functions.log".fax_retry - local Database = require "resources.functions.database" - local Settings = require "resources.functions.lazy_settings" - local Tasks = require "app.fax.resources.scripts.queue.tasks" + local log = require "resources.functions.log".fax_retry + local Database = require "resources.functions.database" + local Settings = require "resources.functions.lazy_settings" + local Tasks = require "app.fax.resources.scripts.queue.tasks" + local send_mail = require "resources.functions.send_mail" local fax_task_uuid = env:getHeader('fax_task_uuid') local task = Tasks.select_task(fax_task_uuid) @@ -69,11 +70,7 @@ local fax_uuid = task.fax_uuid -- Email variables - local email_address = env:getHeader("mailto_address") - local from_address = env:getHeader("mailfrom_address") or email_address local number_dialed = fax_uri:match("/([^/]-)%s*$") - local email_message_fail = "We are sorry the fax failed to go through. It has been attached. Please check the number "..number_dialed..", and if it was correct you might consider emailing it instead." - local email_message_success = "We are happy to report the fax was sent successfully. It has been attached for your records." log.noticef([[<<< CALL RESULT >>> uuid: = '%s' @@ -86,7 +83,6 @@ accountcode: = '%s' origination_caller_id_name: = '%s' origination_caller_id_number: = '%s' - mailfrom_address: = '%s' mailto_address: = '%s' hangup_cause_q850: = '%s' fax_options = '%s' @@ -101,8 +97,7 @@ tostring(accountcode) , tostring(origination_caller_id_name) , tostring(origination_caller_id_number) , - tostring(from_address) , - tostring(email_address) , + tostring(task.reply_address) , tostring(hangup_cause_q850) , fax_options ) @@ -249,6 +244,14 @@ dbh:query(sql); end +--prepare the headers + local mail_x_headers = { + ["X-FusionPBX-Domain-UUID"] = domain_uuid; + ["X-FusionPBX-Domain-Name"] = domain_name; + ["X-FusionPBX-Call-UUID"] = uuid; + ["X-FusionPBX-Email-Type"] = 'email2fax'; + } + -- add the fax files if fax_success == "1" then @@ -328,6 +331,16 @@ end Tasks.remove_task(task) + + if task.reply_address and #task.reply_address > 0 then + send_mail(mail_x_headers, task.reply_address, { + "Fax to: " .. number_dialed .. " SENT", + table.concat{ + "We are happy to report the fax was sent successfully.", + "It has been attached for your records.", + } + }) + end end if fax_success ~= "1" then @@ -349,6 +362,16 @@ Tasks.wait_task(task, answered, hangup_cause_q850) if task.status ~= 0 then Tasks.remove_task(task) + if task.reply_address and #task.reply_address > 0 then + send_mail(mail_x_headers, task.reply_address, { + "Fax to: " .. number_dialed .. " FAILED", + table.concat{ + "We are sorry the fax failed to go through. ", + "It has been attached. Please check the number "..number_dialed..", ", + "and if it was correct you might consider emailing it instead.", + } + }) + end end end end diff --git a/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua b/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua index 96f6d612bf..dd049fd8ef 100644 --- a/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua +++ b/resources/install/scripts/app/fax/resources/scripts/queue/tasks.lua @@ -43,6 +43,7 @@ select t1.task_dtmf as dtmf, t1.task_fax_file as fax_file, t1.task_wav_file as wav_file, + t1.task_reply_address as reply_address, t1.task_no_answer_counter as no_answer_counter, t1.task_no_answer_retry_counter as no_answer_retry_counter, t1.task_retry_counter as retry_counter, diff --git a/secure/fax_to_email.php b/secure/fax_to_email.php index a0576756c0..3005595d6b 100644 --- a/secure/fax_to_email.php +++ b/secure/fax_to_email.php @@ -236,7 +236,7 @@ if(!function_exists('tiff2pdf')) { } if(!function_exists('fax_enqueue')) { - function fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string){ + function fax_enqueue($fax_uuid, $fax_file, $wav_file, $reply_address, $fax_uri, $fax_dtmf, $dial_string){ global $db, $db_type; $fax_task_uuid = uuid(); @@ -256,12 +256,12 @@ INSERT INTO v_fax_tasks( fax_task_uuid, fax_uuid, task_next_time, task_lock_time, task_fax_file, task_wav_file, task_uri, task_dial_string, task_dtmf, task_interrupted, task_status, task_no_answer_counter, task_no_answer_retry_counter, task_retry_counter, - task_description) + task_reply_address, task_description) VALUES (?, ?, $date_utc_now_sql, NULL, ?, ?, ?, ?, ?, 'false', 0, 0, 0, 0, - ?); + ?, ?); HERE; $stmt = $db->prepare($sql); $i = 0; @@ -272,6 +272,7 @@ HERE; $stmt->bindValue(++$i, $fax_uri); $stmt->bindValue(++$i, $dial_string); $stmt->bindValue(++$i, $fax_dtmf); + $stmt->bindValue(++$i, $reply_address); $stmt->bindValue(++$i, $description); if ($stmt->execute()) { $response = 'Enqueued'; @@ -479,8 +480,6 @@ if(!function_exists('fax_split_dtmf')) { $common_dial_string .= "sip_h_X-accountcode='" . $fax_accountcode . "',"; $common_dial_string .= "domain_uuid=" . $_SESSION["domain_uuid"] . ","; $common_dial_string .= "domain_name=" . $_SESSION["domain_name"] . ","; - $common_dial_string .= "mailto_address='" . $mailto_address . "',"; - $common_dial_string .= "mailfrom_address='" . $mailfrom_address . "',"; $common_dial_string .= "origination_caller_id_name='" . $fax_caller_id_name . "',"; $common_dial_string .= "origination_caller_id_number='" . $fax_caller_id_number . "',"; $common_dial_string .= "fax_ident='" . $fax_caller_id_number . "',"; @@ -489,6 +488,8 @@ if(!function_exists('fax_split_dtmf')) { if ($fax_send_mode != 'queue') { $dial_string .= $t38; + $dial_string .= "mailto_address='" . $mailto_address . "',"; + $dial_string .= "mailfrom_address='" . $mailfrom_address . "',"; $dial_string .= "fax_uri=" . $fax_uri . ","; $dial_string .= "fax_retry_attempts=1" . ","; $dial_string .= "fax_retry_limit=20" . ","; @@ -533,7 +534,7 @@ if(!function_exists('fax_split_dtmf')) { } else{ $wav_file = ''; - $response = fax_enqueue($fax_uuid, $fax_file, $wav_file, $fax_uri, $fax_dtmf, $dial_string); + $response = fax_enqueue($fax_uuid, $fax_file, $wav_file, $mailto_address, $fax_uri, $fax_dtmf, $dial_string); } } } From 6cfc24f8eb60a9326ea717d9e1b55c6e57a30d34 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 30 Nov 2015 12:08:26 +0300 Subject: [PATCH 03/14] Fix. Send mail when fail create outbound channel. --- .../app/fax/resources/scripts/queue/next.lua | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/resources/install/scripts/app/fax/resources/scripts/queue/next.lua b/resources/install/scripts/app/fax/resources/scripts/queue/next.lua index bb5607f5ca..fb0df5c1cd 100644 --- a/resources/install/scripts/app/fax/resources/scripts/queue/next.lua +++ b/resources/install/scripts/app/fax/resources/scripts/queue/next.lua @@ -4,6 +4,7 @@ require "resources.functions.sleep" local log = require "resources.functions.log".next_fax_task local Tasks = require "app.fax.resources.scripts.queue.tasks" local Esl = require "resources.functions.esl" +local send_mail = require "resources.functions.send_mail" local FAX_OPTIONS = { "fax_use_ecm=false,fax_enable_t38=true,fax_enable_t38_request=true,fax_disable_v17=default"; @@ -13,6 +14,25 @@ local FAX_OPTIONS = { "fax_use_ecm=false,fax_enable_t38=false,fax_enable_t38_request=false,fax_disable_v17=false"; } +local function task_send_mail(task) + local mail_x_headers = { + ["X-FusionPBX-Domain-UUID"] = task.domain_uuid; + ["X-FusionPBX-Domain-Name"] = task.domain_name; + ["X-FusionPBX-Email-Type"] = 'email2fax'; + } + local number_dialed = task.uri:match("/([^/]-)%s*$") + if task.reply_address and #task.reply_address > 0 then + send_mail(mail_x_headers, task.reply_address, { + "Fax to: " .. number_dialed .. " FAILED", + table.concat{ + "We are sorry the fax failed to go through. ", + "It has been attached. Please check the number "..number_dialed..", ", + "and if it was correct you might consider emailing it instead.", + } + }) + end +end + local function next_task() local task, err = Tasks.next_task() @@ -43,6 +63,7 @@ local function next_task() Tasks.wait_task(task, false, info) if task.status ~= 0 then Tasks.remove_task(task) + task_send_mail(task) end log.noticef('Can not originate to `%s` cause: %s: %s ', task.uri, tostring(status), tostring(info)) else From 0c828deba60c9b1bb35a9db8b832b525902a12e0 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 30 Nov 2015 13:55:02 +0300 Subject: [PATCH 04/14] Fix. Create DB during web install. --- core/install/resources/classes/install_fusionpbx.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index f0e4ca1597..c891f96daa 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -275,9 +275,9 @@ include "root.php"; try { if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } if (strlen($this->db_host) > 0) { - $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} user={".$this->db_create_username."} password={".$this->db_create_password."} dbname=template1"); + $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); } else { - $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={".$this->db_create_username."} password={".$this->db_create_password."} dbname=template1"); + $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); } } catch (PDOException $error) { throw new Exception("error connecting to database: " . $error->getMessage()); From a4b126785ad6a324aba7c8ac50b7d781b8a981db Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 30 Nov 2015 14:54:39 +0300 Subject: [PATCH 05/14] Add. Translate to email2fax type message. --- app/emails/app_languages.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/emails/app_languages.php b/app/emails/app_languages.php index 5c08ca3825..c373cd8ce5 100644 --- a/app/emails/app_languages.php +++ b/app/emails/app_languages.php @@ -72,6 +72,15 @@ $text['label-type_voicemail']['pl'] = "Poczta głosowa"; $text['label-type_voicemail']['sv-se'] = "Röstbrevlåda"; $text['label-type_voicemail']['de-at'] = "Mailbox"; +$text['label-type_email2fax']['en-us'] = "Email to fax report"; +$text['label-type_email2fax']['es-cl'] = ""; +$text['label-type_email2fax']['pt-pt'] = ""; +$text['label-type_email2fax']['fr-fr'] = ""; +$text['label-type_email2fax']['pt-br'] = ""; +$text['label-type_email2fax']['pl'] = ""; +$text['label-type_email2fax']['sv-se'] = ""; +$text['label-type_email2fax']['de-at'] = ""; + $text['label-type']['en-us'] = "Type"; $text['label-type']['es-cl'] = "Tipo"; $text['label-type']['pt-pt'] = "Tipo"; From 29c4421592df6599221a02000bfcbb32bd884d2e Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 30 Nov 2015 15:36:11 +0300 Subject: [PATCH 06/14] Fix. Make channel uuid optional in email. This needs for example if fax server could not create outgoing channel. --- secure/v_mailto.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/secure/v_mailto.php b/secure/v_mailto.php index e81de0c6b1..5a7566a081 100644 --- a/secure/v_mailto.php +++ b/secure/v_mailto.php @@ -292,11 +292,14 @@ $mailer_error = $mail->ErrorInfo; echo "Mailer Error: ".$mailer_error."\n\n"; + $call_uuid = $headers["X-FusionPBX-Call-UUID"]; // log/store message in database for review $email_uuid = uuid(); $sql = "insert into v_emails ( "; $sql .= "email_uuid, "; - $sql .= "call_uuid, "; + if ($call_uuid) { + $sql .= "call_uuid, "; + } $sql .= "domain_uuid, "; $sql .= "sent_date, "; $sql .= "type, "; @@ -304,7 +307,9 @@ $sql .= "email "; $sql .= ") values ( "; $sql .= "'".$email_uuid."', "; - $sql .= "'".$headers["X-FusionPBX-Call-UUID"]."', "; + if ($call_uuid) { + $sql .= "'".$call_uuid."', "; + } $sql .= "'".$headers["X-FusionPBX-Domain-UUID"]."', "; $sql .= "now(),"; $sql .= "'".$headers["X-FusionPBX-Email-Type"]."', "; From b944a4dca73d5f831dbdae38866a6c8132c86e61 Mon Sep 17 00:00:00 2001 From: Alexey Melnichuk Date: Mon, 30 Nov 2015 16:04:13 +0300 Subject: [PATCH 07/14] Fix. Use incorrect option name. --- themes/enhanced/template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/enhanced/template.php b/themes/enhanced/template.php index fd0c9da8ad..23aadd820a 100644 --- a/themes/enhanced/template.php +++ b/themes/enhanced/template.php @@ -1434,7 +1434,7 @@ if (strlen($_SESSION['message']) > 0) { Date: Mon, 30 Nov 2015 12:33:27 -0700 Subject: [PATCH 08/14] Add expansion aka side car support to the Grandstream gxp21xx template. --- .../provision/grandstream/gxp21xx/{$mac}.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml index 2b0445ef10..78611d3c37 100644 --- a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml +++ b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml @@ -3591,6 +3591,17 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 --> {$memory_key_value_18} +{$start_label_id = 23002} +{$start_value_id = 23003} +{foreach $keys as $row} +{if $row.device_key_category == "expansion"} + {$key_id = $row.device_key_id - 1} + {$label_id = $start_label_id + ($key_id * 5)} + {$value_id = $start_value_id + ($key_id * 5)} + {$row.device_key_label} + {$row.device_key_value} +{/if} +{/foreach} \ No newline at end of file From 675544a655ea6239eedd4d3dc3dbbb8179335b4a Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 30 Nov 2015 12:50:41 -0700 Subject: [PATCH 09/14] Add a few more keys parameters to the Grandstream gxp21xx template. --- .../templates/provision/grandstream/gxp21xx/{$mac}.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml index 78611d3c37..63be439319 100644 --- a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml +++ b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml @@ -3591,13 +3591,19 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 --> {$memory_key_value_18} +{$start_type_id = 23000} +{$start_line_id = 23001} {$start_label_id = 23002} {$start_value_id = 23003} {foreach $keys as $row} {if $row.device_key_category == "expansion"} {$key_id = $row.device_key_id - 1} + {$line_id = $start_line_id + ($key_id * 5)} + {$type_id = $start_type_id + ($key_id * 5)} {$label_id = $start_label_id + ($key_id * 5)} {$value_id = $start_value_id + ($key_id * 5)} + {$row.device_key_type} + {$row.device_key_line} {$row.device_key_label} {$row.device_key_value} {/if} From 8b3e6e7a967f3bd3cdcd4b51412e87f192cabee8 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 30 Nov 2015 13:09:02 -0700 Subject: [PATCH 10/14] Fix the mode definition for the Grandstream expansion keys. --- app/provision/resources/classes/provision.php | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 62a8118182..60a7cdb141 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -664,21 +664,21 @@ include "root.php"; case "ldap search": $device_key_type = "21"; break; } } - if ($device_key_category == "memory") { - switch ($device_key_type) { - case "speed dial": $device_key_type = "0"; break; - case "blf": $device_key_type = "1"; break; - case "presence watcher": $device_key_type = "2"; break; - case "eventlist blf": $device_key_type = "3"; break; - case "speed dial active": $device_key_type = "4"; break; - case "dial dtmf": $device_key_type = "5"; break; - case "voicemail": $device_key_type = "6"; break; - case "call return": $device_key_type = "7"; break; - case "transfer": $device_key_type = "8"; break; - case "call park": $device_key_type = "9"; break; - case "intercom": $device_key_type = "10"; break; - case "ldap search": $device_key_type = "11"; break; - } + if ($device_key_category == "memory" || $device_key_category == "expansion") { + switch ($device_key_type) { + case "speed dial": $device_key_type = "0"; break; + case "blf": $device_key_type = "1"; break; + case "presence watcher": $device_key_type = "2"; break; + case "eventlist blf": $device_key_type = "3"; break; + case "speed dial active": $device_key_type = "4"; break; + case "dial dtmf": $device_key_type = "5"; break; + case "voicemail": $device_key_type = "6"; break; + case "call return": $device_key_type = "7"; break; + case "transfer": $device_key_type = "8"; break; + case "call park": $device_key_type = "9"; break; + case "intercom": $device_key_type = "10"; break; + case "ldap search": $device_key_type = "11"; break; + } } } From 1f7923908fb8274b3bbd27832e3ca65ee7245f87 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 30 Nov 2015 13:33:46 -0700 Subject: [PATCH 11/14] Adjust the type / mode in the Grandstream gxp21xx template. --- .../provision/grandstream/gxp21xx/{$mac}.xml | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml index 63be439319..a76deb0480 100644 --- a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml +++ b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml @@ -3590,18 +3590,27 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 --> {$memory_key_value_18} - -{$start_type_id = 23000} -{$start_line_id = 23001} -{$start_label_id = 23002} -{$start_value_id = 23003} + +{$start_id = 23000} {foreach $keys as $row} {if $row.device_key_category == "expansion"} - {$key_id = $row.device_key_id - 1} - {$line_id = $start_line_id + ($key_id * 5)} - {$type_id = $start_type_id + ($key_id * 5)} - {$label_id = $start_label_id + ($key_id * 5)} - {$value_id = $start_value_id + ($key_id * 5)} +{$key_id = $row.device_key_id - 1} +{$type_id = $start_id + ($key_id * 5)} +{$line_id = ($start_id + 1) + ($key_id * 5)} +{$label_id = ($start_id + 2) ($key_id * 5)} +{$value_id = ($start_id + 3) + ($key_id * 5)} +{if $row.device_key_type == "speed dial"}0{/if} +{if $row.device_key_type == "blf"}1{/if} +{if $row.device_key_type == "presence watcher"}2{/if} +{if $row.device_key_type == "eventlist blf"}3{/if} +{if $row.device_key_type == "speed dial active"}4{/if} +{if $row.device_key_type == "dial dtmf"}5{/if} +{if $row.device_key_type == "voicemail"}6{/if} +{if $row.device_key_type == "call return"}7{/if} +{if $row.device_key_type == "transfer"}8{/if} +{if $row.device_key_type == "call park"}9{/if} +{if $row.device_key_type == "intercom"}10{/if} +{if $row.device_key_type == "ldap search"}11{/if} {$row.device_key_type} {$row.device_key_line} {$row.device_key_label} From ea16b7ea8cbd36fd3a05527b12e3499767e4c91d Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 30 Nov 2015 13:35:31 -0700 Subject: [PATCH 12/14] Add a missing plus in the template. --- resources/templates/provision/grandstream/gxp21xx/{$mac}.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml index a76deb0480..0255c67ee7 100644 --- a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml +++ b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml @@ -3597,7 +3597,7 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 --> {$key_id = $row.device_key_id - 1} {$type_id = $start_id + ($key_id * 5)} {$line_id = ($start_id + 1) + ($key_id * 5)} -{$label_id = ($start_id + 2) ($key_id * 5)} +{$label_id = ($start_id + 2) + ($key_id * 5)} {$value_id = ($start_id + 3) + ($key_id * 5)} {if $row.device_key_type == "speed dial"}0{/if} {if $row.device_key_type == "blf"}1{/if} From d4303df93ab7643e53ee6d2c75fa8cbc5de704e0 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 30 Nov 2015 13:39:17 -0700 Subject: [PATCH 13/14] Adjust the spaces and remove the extra device key type. --- .../provision/grandstream/gxp21xx/{$mac}.xml | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml index 0255c67ee7..c8913f3c4e 100644 --- a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml +++ b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml @@ -3599,19 +3599,18 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 --> {$line_id = ($start_id + 1) + ($key_id * 5)} {$label_id = ($start_id + 2) + ($key_id * 5)} {$value_id = ($start_id + 3) + ($key_id * 5)} -{if $row.device_key_type == "speed dial"}0{/if} -{if $row.device_key_type == "blf"}1{/if} -{if $row.device_key_type == "presence watcher"}2{/if} -{if $row.device_key_type == "eventlist blf"}3{/if} -{if $row.device_key_type == "speed dial active"}4{/if} -{if $row.device_key_type == "dial dtmf"}5{/if} -{if $row.device_key_type == "voicemail"}6{/if} -{if $row.device_key_type == "call return"}7{/if} -{if $row.device_key_type == "transfer"}8{/if} -{if $row.device_key_type == "call park"}9{/if} -{if $row.device_key_type == "intercom"}10{/if} -{if $row.device_key_type == "ldap search"}11{/if} - {$row.device_key_type} +{if $row.device_key_type == "speed dial"} 0{/if} +{if $row.device_key_type == "blf"} 1{/if} +{if $row.device_key_type == "presence watcher"} 2{/if} +{if $row.device_key_type == "eventlist blf"} 3{/if} +{if $row.device_key_type == "speed dial active"} 4{/if} +{if $row.device_key_type == "dial dtmf"} 5{/if} +{if $row.device_key_type == "voicemail"} 6{/if} +{if $row.device_key_type == "call return"} 7{/if} +{if $row.device_key_type == "transfer"} 8{/if} +{if $row.device_key_type == "call park"} 9{/if} +{if $row.device_key_type == "intercom"} 10{/if} +{if $row.device_key_type == "ldap search"} 11{/if} {$row.device_key_line} {$row.device_key_label} {$row.device_key_value} From e7ee8fb0f83c4021d2ef5334abb05f7fe630f3b5 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 30 Nov 2015 13:42:06 -0700 Subject: [PATCH 14/14] Add an additional line feed to the grandstream/gxp21xx template. --- resources/templates/provision/grandstream/gxp21xx/{$mac}.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml index c8913f3c4e..d534b1bd28 100644 --- a/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml +++ b/resources/templates/provision/grandstream/gxp21xx/{$mac}.xml @@ -3611,6 +3611,7 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 --> {if $row.device_key_type == "call park"} 9{/if} {if $row.device_key_type == "intercom"} 10{/if} {if $row.device_key_type == "ldap search"} 11{/if} + {$row.device_key_line} {$row.device_key_label} {$row.device_key_value}