Merge remote-tracking branch 'remotes/fusionpbx/master' into Enhance_Install

Conflicts:
	core/install/resources/classes/install_fusionpbx.php
This commit is contained in:
Matthew Vale 2015-12-01 16:21:10 +00:00
commit f0e2e8d735
15 changed files with 223 additions and 59 deletions

View File

@ -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";

View File

@ -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'] = '';

View File

@ -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);
}
}

View File

@ -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;
}
}
}

View File

@ -347,14 +347,18 @@ include "root.php";
$schema->sql();
$schema->exec();
//get the contents of the sql file
if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql')){
$filename = "/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql";
}
else {
$filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/pgsql.sql';
}
$file_contents = file_get_contents($filename);
//if $this->db_create_username provided, attempt to create new PG role and database
if (strlen($this->db_create_username) > 0) {
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");
} else {
$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());
}
//replace \r\n with \n then explode on \n
$file_contents = str_replace("\r\n", "\n", $file_contents);

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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}", "<a href='https://"..domain_name.."/app/voicemails/voicemail_messages.php?action=download&type=vm&t=bin&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&src=email'>"..T'label-download'.."</a>");
body = body:gsub("${message}", "<a href='https://"..domain_name.."/app/voicemails/voicemail_messages.php?action=download&type=vm&t=bin&id="..id.."&voicemail_uuid="..db_voicemail_uuid.."&uuid="..uuid.."&src=email'>"..text['label-download'].."</a>");
else
body = body:gsub("${message}", "<a href='https://"..domain_name.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."'>"..T'label-listen'.."</a>");
body = body:gsub("${message}", "<a href='https://"..domain_name.."/app/voicemails/voicemail_messages.php?action=autoplay&id="..db_voicemail_uuid.."&uuid="..uuid.."'>"..text['label-listen'].."</a>");
end
body = body:gsub(" ", "&nbsp;");
body = body:gsub("%s+", "");

View File

@ -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;
}

View File

@ -3590,7 +3590,33 @@ Outgoing calls. 0 - No, 1 - Yes. Default is 0 -->
<!-- String -->
<P396>{$memory_key_value_18}</P396>
<!-- Extension Boards FOR GXP2110 and GXP2120 ONLY -->
<!-- Extension Board 1 Settings. -->
<!-- Extension Board 1 Settings. mode 23000, line 23001, label, 23002, value 23003 -->
{$start_id = 23000}
{foreach $keys as $row}
{if $row.device_key_category == "expansion"}
{$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"} <P{$type_id}>0</P{$type_id}>{/if}
{if $row.device_key_type == "blf"} <P{$type_id}>1</P{$type_id}>{/if}
{if $row.device_key_type == "presence watcher"} <P{$type_id}>2</P{$type_id}>{/if}
{if $row.device_key_type == "eventlist blf"} <P{$type_id}>3</P{$type_id}>{/if}
{if $row.device_key_type == "speed dial active"} <P{$type_id}>4</P{$type_id}>{/if}
{if $row.device_key_type == "dial dtmf"} <P{$type_id}>5</P{$type_id}>{/if}
{if $row.device_key_type == "voicemail"} <P{$type_id}>6</P{$type_id}>{/if}
{if $row.device_key_type == "call return"} <P{$type_id}>7</P{$type_id}>{/if}
{if $row.device_key_type == "transfer"} <P{$type_id}>8</P{$type_id}>{/if}
{if $row.device_key_type == "call park"} <P{$type_id}>9</P{$type_id}>{/if}
{if $row.device_key_type == "intercom"} <P{$type_id}>10</P{$type_id}>{/if}
{if $row.device_key_type == "ldap search"} <P{$type_id}>11</P{$type_id}>{/if}
<P{$line_id}>{$row.device_key_line}</P{$line_id}>
<P{$label_id}>{$row.device_key_label}</P{$label_id}>
<P{$value_id}>{$row.device_key_value}</P{$value_id}>
{/if}
{/foreach}
</config>
</gs_provision>

View File

@ -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);
}
}
}

View File

@ -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"]."', ";

View File

@ -1434,7 +1434,7 @@ if (strlen($_SESSION['message']) > 0) {
<?php
// check for background image
if (isset($_SESSION['theme']['enable_background_images']['boolean']) and $_SESSION['theme']['enable_background_images']['boolean'] == 'true') {
if (isset($_SESSION['theme']['background_image_enabled']['boolean']) and $_SESSION['theme']['background_image_enabled']['boolean'] == 'true') {
// background image is enabled
$image_extensions = array('jpg','jpeg','png','gif');